修复统计问题

dev
lisai17@sina.com 2021-09-17 09:40:03 +08:00
parent 46ea632571
commit 258669997a
2 changed files with 40 additions and 34 deletions

View File

@ -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" +

View File

@ -1966,36 +1966,7 @@ public class OrderStatService {
*
*/
public Record trafficStatisticsOfEachSandStation(String stm, String etm, String tm, Integer invoice_type) {
List<Record> 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<Record>() {
@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<Supermarket> sups = Supermarket.dao.find("select * from supermarket where id <= 6");
String paramsSql = "";
if (invoice_type != null) {
@ -2041,6 +2012,43 @@ public class OrderStatService {
customer_sale_list = Db.find(sql, stm, etm);
}
List<String> ids = new ArrayList<>();
for (Record r : customer_sale_list) {
ids.add(r.getStr("customer_id"));
}
List<Record> 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<Record>() {
@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<Integer, Record> salemap = new HashMap<>();
Map<Integer, List<Record>> typemap = new HashMap<>();
@ -2129,8 +2137,6 @@ public class OrderStatService {
}
}
List<Supermarket> sups = Supermarket.dao.find("select * from supermarket where id <= 6");
typelist.sort(new Comparator<Record>() {
@Override
public int compare(Record o1, Record o2) {