diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java index 97092cb..32e1ee7 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java @@ -139,10 +139,10 @@ group by date Date day = c.getTime(); // 当日 - c.add(Calendar.DAY_OF_MONTH, 1); + c.set(Calendar.DAY_OF_MONTH, 1); Date month = c.getTime(); // 当月 - c.add(Calendar.MONTH, 1); + c.set(Calendar.MONTH, 1); Date year = c.getTime(); // 当年 String sql_ordercluster = "select\n" + diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java index 9cba8bc..375666f 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java @@ -1959,36 +1959,7 @@ public class OrderStatService { * 各砂站运输量统计表 */ public Record trafficStatisticsOfEachSandStation(String stm, String etm, String tm, Integer invoice_type) { - List customer_pre_list = Db.find("select\n" + - " a.customer_id,\n" + - " tp.id customer_type_id,\n" + - " tp.name customer_type_name,\n" + - " c.name customer_name,\n" + - " c.name,\n" + - " a.total_amount prepay_total_amount,\n" + - " p.surplus prepay_surplus\n" + - " from (\n" + - " select t.customer_id, sum(t.amount) total_amount from prepay_detail t\n" + - " where t.state = 2\n" + - " and t.verify_time > ?\n" + - " group by t.customer_id\n" + - " ) a\n" + - " left join customer c on c.id = a.customer_id\n" + - " left join customer_type tp on tp.id = c.customer_type_id\n" + - " left join prepay_customer p on p.customer_id = c.id\n" + - " union\n" + - " select 0 customer_id, 99 customer_type_id, '零散' customer_type_name, '零散客户' customer_name, '零散客户' name, null prepay_total_amount, null prepay_surplus", tm); - - customer_pre_list.sort(new Comparator() { - @Override - public int compare(Record o1, Record o2) { - if (o1.getInt("customer_type_id") == 0 || o2.getInt("customer_type_id") == 0) { - return -1; - } else { - return o1.getInt("customer_type_id") - o2.getInt("customer_type_id"); - } - } - }); + List sups = Supermarket.dao.find("select * from supermarket where id <= 6"); String paramsSql = ""; if (invoice_type != null) { @@ -2034,6 +2005,43 @@ public class OrderStatService { customer_sale_list = Db.find(sql, stm, etm); } + List ids = new ArrayList<>(); + for (Record r : customer_sale_list) { + ids.add(r.getStr("customer_id")); + } + + List customer_pre_list = Db.find("select\n" + + " a.customer_id,\n" + + " tp.id customer_type_id,\n" + + " tp.name customer_type_name,\n" + + " c.name customer_name,\n" + + " c.name,\n" + + " a.total_amount prepay_total_amount,\n" + + " p.surplus prepay_surplus\n" + + " from customer c \n" + + " left join ( \n" + + " select t.customer_id, sum(t.amount) total_amount from prepay_detail t \n" + + " where t.state = 2 \n" + + " and t.verify_time > ? \n" + + " group by t.customer_id \n" + + " ) a on c.id = a.customer_id \n" + + " left join customer_type tp on tp.id = c.customer_type_id\n" + + " left join prepay_customer p on p.customer_id = c.id\n" + + " where c.id in(" + StrKit.join(ids, ",") + ") or a.customer_id is not null \n" + // 查询时间段内有购砂、起始时间年内有充值的 + " union\n" + + " select 0 customer_id, 99 customer_type_id, '零散' customer_type_name, '零散客户' customer_name, '零散客户' name, null prepay_total_amount, null prepay_surplus", tm); + + customer_pre_list.sort(new Comparator() { + @Override + public int compare(Record o1, Record o2) { + if (o1.getInt("customer_type_id") == 0 || o2.getInt("customer_type_id") == 0) { + return -1; + } else { + return o1.getInt("customer_type_id") - o2.getInt("customer_type_id"); + } + } + }); + Map salemap = new HashMap<>(); Map> typemap = new HashMap<>(); @@ -2122,8 +2130,6 @@ public class OrderStatService { } } - List sups = Supermarket.dao.find("select * from supermarket where id <= 6"); - typelist.sort(new Comparator() { @Override public int compare(Record o1, Record o2) {