Merge branch 'master' into ls-dev

# Conflicts:
#	ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java
dev
lisai17@sina.com 2021-04-16 10:22:09 +08:00
commit 1c5a1123b5
4 changed files with 84 additions and 22 deletions

View File

@ -165,7 +165,7 @@ public class PrepayService {
* @param etm * @param etm
* @return * @return
*/ */
public List<Record> consumption(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license) { public List<Record> consumption(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license,Integer invoice_type) {
String sale_sql = " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time \n" + String sale_sql = " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time \n" +
" from order_sale t \n" + " from order_sale t \n" +
" left join customer c on c.id = t.customer_id \n" + " left join customer c on c.id = t.customer_id \n" +
@ -201,6 +201,13 @@ public class PrepayService {
tempList.add(supermarket_id); tempList.add(supermarket_id);
} }
if (invoice_type!=null) {
sale_sql += " and t.invoice_type = ?";
saleList.add(invoice_type);
temp_sql += " and t.invoice_type = ?";
tempList.add(invoice_type);
}
if (customer_id != null && customer_id > 0) { if (customer_id != null && customer_id > 0) {
sale_sql += " and t.customer_id = ?"; sale_sql += " and t.customer_id = ?";
saleList.add(customer_id); saleList.add(customer_id);
@ -244,7 +251,7 @@ public class PrepayService {
return Db.find(sql, paraList.toArray()); return Db.find(sql, paraList.toArray());
} }
public Workbook consumptionExport(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license) { public Workbook consumptionExport(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license,Integer invoice_type) {
Customer customer = Customer.dao.findById(customer_id); Customer customer = Customer.dao.findById(customer_id);
String cname = ""; String cname = "";
@ -252,7 +259,7 @@ public class PrepayService {
cname = customer.getName(); cname = customer.getName();
} }
List<Record> list = consumption(customer_id, supermarket_id, stm, etm, truck_license); List<Record> list = consumption(customer_id, supermarket_id, stm, etm, truck_license,invoice_type);
list.sort(new Comparator<Record>() { list.sort(new Comparator<Record>() {
public int compare(Record o1, Record o2) { public int compare(Record o1, Record o2) {

View File

@ -1839,8 +1839,8 @@ public class OrderStatService {
return wb; return wb;
} }
public Workbook trafficStatisticsOfEachSandStationExport(String stm, String etm){ public Workbook trafficStatisticsOfEachSandStationExport(String stm, String etm,Integer invoice_type){
List<Record> list=trafficStatisticsOfEachSandStation(stm, etm); List<Record> list=trafficStatisticsOfEachSandStation(stm, etm,invoice_type);
Workbook wb = new XSSFWorkbook(); Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + etm.substring(0, 10) + "各砂站运输量统计表"); Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + etm.substring(0, 10) + "各砂站运输量统计表");
@ -1953,22 +1953,22 @@ public class OrderStatService {
/** /**
* *
*/ */
public List<Record> trafficStatisticsOfEachSandStation( String stm, String etm){ public List<Record> trafficStatisticsOfEachSandStation( String stm, String etm,Integer invoice_type){
List<Record> dataList = new ArrayList<>(); List<Record> dataList = new ArrayList<>();
//零散用户统计 //零散用户统计
Record scattered=scatteredUsersAreNotClassified(stm,etm); Record scattered=scatteredUsersAreNotClassified(stm,etm,invoice_type);
if(scattered.getBigDecimal("weight").compareTo(new BigDecimal("0"))>0||scattered.getBigDecimal("total_price").compareTo(new BigDecimal("0"))>0){ if(scattered.getBigDecimal("weight").compareTo(new BigDecimal("0"))>0||scattered.getBigDecimal("total_price").compareTo(new BigDecimal("0"))>0){
Record scatteredSandStation=scatteredUsersClassificationStatistics(stm,etm); Record scatteredSandStation=scatteredUsersClassificationStatistics(stm,etm,invoice_type);
scattered.setColumns(scatteredSandStation); scattered.setColumns(scatteredSandStation);
dataList.add(scattered); dataList.add(scattered);
} }
//固定用户统计 //固定用户统计
List<Record> recordList = fixedUserUnclassified(stm,etm); List<Record> recordList = fixedUserUnclassified(stm,etm,invoice_type);
if(recordList!=null&&!recordList.isEmpty()){ if(recordList!=null&&!recordList.isEmpty()){
for (Record record : recordList) { for (Record record : recordList) {
if(record.getBigDecimal("weight").compareTo(new BigDecimal("0"))>0||record.getBigDecimal("total_price").compareTo(new BigDecimal("0"))>0){ if(record.getBigDecimal("weight").compareTo(new BigDecimal("0"))>0||record.getBigDecimal("total_price").compareTo(new BigDecimal("0"))>0){
Integer customer_id=record.getInt("customer_id"); Integer customer_id=record.getInt("customer_id");
Record sandStation=fixedUserClassificationStatistics(stm, etm,customer_id); Record sandStation=fixedUserClassificationStatistics(stm, etm,customer_id,invoice_type);
record.setColumns(sandStation); record.setColumns(sandStation);
} }
} }
@ -1982,7 +1982,11 @@ public class OrderStatService {
/** /**
* *
*/ */
public List<Record> fixedUserUnclassified(String stm, String etm){ public List<Record> fixedUserUnclassified(String stm, String etm,Integer invoice_type){
String paramsSql="";
if(invoice_type!=null){
paramsSql="and t.invoice_type=?\n";
}
String sql="SELECT\n" + String sql="SELECT\n" +
"a.customer_name,\n" + "a.customer_name,\n" +
" a.customer_id,\n" + " a.customer_id,\n" +
@ -2003,6 +2007,7 @@ public class OrderStatService {
"t.state = 5 \n" + "t.state = 5 \n" +
"AND t.create_time >=? \n" + "AND t.create_time >=? \n" +
"AND t.create_time <=? \n" + "AND t.create_time <=? \n" +
paramsSql+
"AND t.isprepaid = 1 UNION\n" + "AND t.isprepaid = 1 UNION\n" +
"SELECT\n" + "SELECT\n" +
"t.sn,t.customer_id,\n" + "t.sn,t.customer_id,\n" +
@ -2017,12 +2022,20 @@ public class OrderStatService {
"t.state = 5 \n" + "t.state = 5 \n" +
"AND t.create_time >=? \n" + "AND t.create_time >=? \n" +
"AND t.create_time <=? \n" + "AND t.create_time <=? \n" +
paramsSql+
"AND t.isprepaid = 1 \n" + "AND t.isprepaid = 1 \n" +
") a\n" + ") a\n" +
" JOIN customer c ON c.id = a.customer_id \n" + " JOIN customer c ON c.id = a.customer_id \n" +
"GROUP BY\n" + "GROUP BY\n" +
"a.customer_id,a.customer_name"; "a.customer_id,a.customer_name";
List<Record> recordList = Db.find(sql, stm, etm, stm, etm);
List<Record> recordList;
if(invoice_type!=null){
recordList = Db.find(sql, stm, etm,invoice_type, stm, etm,invoice_type);
}else {
recordList = Db.find(sql, stm, etm, stm, etm);
}
return recordList; return recordList;
} }
@ -2030,7 +2043,11 @@ public class OrderStatService {
* *
* @return * @return
*/ */
public Record fixedUserClassificationStatistics(String stm, String etm,Integer customer_id){ public Record fixedUserClassificationStatistics(String stm, String etm,Integer customer_id,Integer invoice_type){
String paramsSql="";
if(invoice_type!=null){
paramsSql="and t.invoice_type=?\n";
}
String sql="SELECT\n" + String sql="SELECT\n" +
"ifnull( sum( CASE g.id WHEN 1 THEN g.weight END ), 0.00 ) zw_xsl,\n" + "ifnull( sum( CASE g.id WHEN 1 THEN g.weight END ), 0.00 ) zw_xsl,\n" +
"ifnull( sum( CASE g.id WHEN 1 THEN g.total_price END ), 0.00 ) zw_xse,\n" + "ifnull( sum( CASE g.id WHEN 1 THEN g.total_price END ), 0.00 ) zw_xse,\n" +
@ -2081,6 +2098,7 @@ public class OrderStatService {
"t.state = 5 \n" + "t.state = 5 \n" +
"AND t.create_time >=? \n" + "AND t.create_time >=? \n" +
"AND t.create_time <=? \n" + "AND t.create_time <=? \n" +
paramsSql+
"AND t.isprepaid = 1 UNION\n" + "AND t.isprepaid = 1 UNION\n" +
"SELECT\n" + "SELECT\n" +
"t.sn,t.supermarket_id AS id,\n" + "t.sn,t.supermarket_id AS id,\n" +
@ -2096,6 +2114,7 @@ public class OrderStatService {
"t.state = 5 \n" + "t.state = 5 \n" +
"AND t.create_time >=? \n" + "AND t.create_time >=? \n" +
"AND t.create_time <=? \n" + "AND t.create_time <=? \n" +
paramsSql+
"AND t.isprepaid = 1 \n" + "AND t.isprepaid = 1 \n" +
") a\n" + ") a\n" +
"JOIN customer c ON c.id = a.customer_id \n" + "JOIN customer c ON c.id = a.customer_id \n" +
@ -2107,13 +2126,22 @@ public class OrderStatService {
") g \n" + ") g \n" +
"GROUP BY\n" + "GROUP BY\n" +
"g.customer_id"; "g.customer_id";
Record record = Db.findFirst(sql, stm,etm, stm,etm, customer_id); Record record;
if(invoice_type!=null){
record = Db.findFirst(sql, stm,etm,invoice_type, stm,etm,invoice_type, customer_id);
}else {
record = Db.findFirst(sql, stm,etm, stm,etm, customer_id);
}
return total(record); return total(record);
} }
/** /**
* *
*/ */
public Record scatteredUsersAreNotClassified(String stm, String etm){ public Record scatteredUsersAreNotClassified(String stm, String etm,Integer invoice_type){
String paramsSql="";
if(invoice_type!=null){
paramsSql="and t.invoice_type=?\n";
}
String sql="SELECT '零散用户' customer_name, 0 customer_id,\n" + String sql="SELECT '零散用户' customer_name, 0 customer_id,\n" +
"ifnull(sum( a.weight ),0) weight,\n" + "ifnull(sum( a.weight ),0) weight,\n" +
"ifnull(sum( a.total_price ),0) total_price\n" + "ifnull(sum( a.total_price ),0) total_price\n" +
@ -2129,6 +2157,7 @@ public class OrderStatService {
"t.state = 5 \n" + "t.state = 5 \n" +
"AND t.create_time >=?\n" + "AND t.create_time >=?\n" +
"AND t.create_time <=?\n" + "AND t.create_time <=?\n" +
paramsSql+
"AND t.isprepaid = 0 UNION\n" + "AND t.isprepaid = 0 UNION\n" +
"SELECT\n" + "SELECT\n" +
"t.sn,t.weight,\n" + "t.sn,t.weight,\n" +
@ -2140,9 +2169,16 @@ public class OrderStatService {
"t.state = 5 \n" + "t.state = 5 \n" +
"AND t.create_time >=?\n" + "AND t.create_time >=?\n" +
"AND t.create_time <=?\n" + "AND t.create_time <=?\n" +
paramsSql+
"AND t.isprepaid = 0 \n" + "AND t.isprepaid = 0 \n" +
") a"; ") a";
Record record = Db.findFirst(sql, stm, etm, stm, etm); Record record;
if(invoice_type!=null){
record = Db.findFirst(sql, stm, etm,invoice_type, stm, etm,invoice_type);
}else {
record = Db.findFirst(sql, stm, etm, stm, etm);
}
return record; return record;
} }
@ -2152,7 +2188,11 @@ public class OrderStatService {
* @param etm * @param etm
* @return * @return
*/ */
public Record scatteredUsersClassificationStatistics(String stm, String etm){ public Record scatteredUsersClassificationStatistics(String stm, String etm,Integer invoice_type){
String paramsSql="";
if(invoice_type!=null){
paramsSql="and t.invoice_type=?\n";
}
String sql="select \n" + String sql="select \n" +
"ifnull( sum( CASE g.id WHEN 1 THEN IFNULL( g.weight, 0 ) END ), 0 ) zw_xsl,\n" + "ifnull( sum( CASE g.id WHEN 1 THEN IFNULL( g.weight, 0 ) END ), 0 ) zw_xsl,\n" +
"ifnull( sum( CASE g.id WHEN 1 THEN IFNULL( g.total_price, 0 ) END ), 0 ) zw_xse,\n" + "ifnull( sum( CASE g.id WHEN 1 THEN IFNULL( g.total_price, 0 ) END ), 0 ) zw_xse,\n" +
@ -2185,6 +2225,7 @@ public class OrderStatService {
"t.state = 5 \n" + "t.state = 5 \n" +
"AND t.create_time >=? \n" + "AND t.create_time >=? \n" +
"AND t.create_time <=? \n" + "AND t.create_time <=? \n" +
paramsSql+
"AND t.isprepaid = 0 UNION\n" + "AND t.isprepaid = 0 UNION\n" +
"SELECT\n" + "SELECT\n" +
"t.sn,t.supermarket_id AS id,\n" + "t.sn,t.supermarket_id AS id,\n" +
@ -2196,9 +2237,16 @@ public class OrderStatService {
"t.state = 5 \n" + "t.state = 5 \n" +
"AND t.create_time >=? \n" + "AND t.create_time >=? \n" +
"AND t.create_time <=? \n" + "AND t.create_time <=? \n" +
paramsSql+
"AND t.isprepaid = 0 ) n on m.id=n.id\n" + "AND t.isprepaid = 0 ) n on m.id=n.id\n" +
") g"; ") g";
Record record = Db.findFirst(sql, stm,etm, stm,etm);
Record record;
if(invoice_type!=null) {
record = Db.findFirst(sql, stm,etm,invoice_type, stm,etm,invoice_type);
}else {
record = Db.findFirst(sql, stm,etm, stm,etm);
}
return total(record); return total(record);
} }

View File

@ -202,6 +202,13 @@ public class DeviceThread extends Thread {
} else { } else {
scale = new XiShuiScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port")); scale = new XiShuiScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
} }
} else if (supermarket_id == 5) {
// 2021-04-15 融嘉入口磅换了
if (which.startsWith(Enums.CtrlFlowEnum.R.name())) {
scale = new DingsongScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
} else {
scale = new XiShuiScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
}
} else if (supermarket_id == 7) { } else if (supermarket_id == 7) {
scale = new KeLiScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port")); scale = new KeLiScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
} else if (supermarket_id == 8 || supermarket_id == 9) { } else if (supermarket_id == 8 || supermarket_id == 9) {

View File

@ -30,11 +30,11 @@ public class PrepayController extends BaseController {
String stm = get("stm"); String stm = get("stm");
String etm = get("etm"); String etm = get("etm");
String truck_license = get("truck_license"); String truck_license = get("truck_license");
Integer invoice_type = getInt("invoice_type");
if (export == 0) { if (export == 0) {
renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm, truck_license))); renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm, truck_license,invoice_type)));
} else { } else {
Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm, truck_license); Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm, truck_license,invoice_type);
render(new ExcelRender("消费记录_" + System.currentTimeMillis() + ".xlsx", wb)); render(new ExcelRender("消费记录_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }