各砂站运输量统计表查询修改

dev
徐杰盟 2024-03-18 13:49:42 +08:00
parent db3a1f34ed
commit 795155db39
1 changed files with 68 additions and 36 deletions

View File

@ -18,9 +18,11 @@ import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import static com.cowr.common.utils.DateTimeUtil.ETM_SUFFIX;
import static com.cowr.common.utils.DateTimeUtil.STM_SUFFIX;
public class OrderStatService {
private static Log log = Log.getLog(OrderStatService.class);
@ -2276,6 +2278,34 @@ public class OrderStatService {
String union_4 = "";
String union_99 = "";
String today = "";
String endDay = etm.split(" ")[0];
if (LocalDate.now().toString().equals(endDay)) {
union_4 = "union select\n" +
" ifnull(t.customer_id, 0) customer_id,\n" +
" t.supermarket_id,\n" +
" ifnull(sum(t.weight), 0) weight,\n" +
" ifnull(sum(t.total_price), 0) total_price\n" +
" from order_temp t\n" +
" where t.state = 5\n";
// " and t.product_id != 4\n" +
if (invoice_type != null) {
union_4 += "and t.invoice_type = " + invoice_type + " \n";
}
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
union_4 += " and t.sale_type = " + sale_type + " \n";
}else{
union_4 += " and t.sale_type = 0 \n";
}
union_4 += " AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' )" +
" group by t.customer_id\n";
}
// String endDay = etm.split(" ")[0];
// if (LocalDate.now().toString().equals(endDay)) {
//
@ -2383,23 +2413,23 @@ public class OrderStatService {
// " t.supermarket_id";
union_99 += " union SELECT\n" +
" ifnull( t.customer_id, 0 ) customer_id,\n" +
" t.supermarket_id,\n" +
" ifnull( sum( t.weight ), 0 ) weight,\n" +
" ifnull( sum( t.total_price ), 0 ) total_price \n" +
" FROM\n" +
" order_temp t \n" +
" WHERE\n" +
" t.supermarket_id = 4 \n" +
" AND t.state = 5 \n" +
// " AND ( t.create_time < '2021-09-08 00:00:00' OR t.create_time > '2021-10-15 23:59:59' ) \n" +
" AND t.create_time >= ? \n" +
" AND t.create_time <= ? \n" +
// " AND ( t.create_time < '2021-10-20 00:00:00' OR t.create_time > '2021-10-20 23:59:59' ) \n" +
saleParam +
" GROUP BY\n" +
" t.customer_id ";
// union_99 += " union SELECT\n" +
// " ifnull( t.customer_id, 0 ) customer_id,\n" +
// " t.supermarket_id,\n" +
// " ifnull( sum( t.weight ), 0 ) weight,\n" +
// " ifnull( sum( t.total_price ), 0 ) total_price \n" +
// " FROM\n" +
// " order_temp t \n" +
// " WHERE\n" +
// " t.supermarket_id = 4 \n" +
// " AND t.state = 5 \n" +
//// " AND ( t.create_time < '2021-09-08 00:00:00' OR t.create_time > '2021-10-15 23:59:59' ) \n" +
// " AND t.create_time >= ? \n" +
// " AND t.create_time <= ? \n" +
//// " AND ( t.create_time < '2021-10-20 00:00:00' OR t.create_time > '2021-10-20 23:59:59' ) \n" +
// saleParam +
// " GROUP BY\n" +
// " t.customer_id ";
String order_sql = "";
@ -2432,11 +2462,13 @@ public class OrderStatService {
" t.supermarket_id,\n" +
" ifnull(sum(t.weight), 0) weight,\n" +
" ifnull(sum(t.total_price), 0) total_price\n" +
" from order_temp t\n" +
" where t.supermarket_id != 4\n" +
" from order_end t\n" +
" where " +
// "t.supermarket_id != 4\n" +
// " and t.product_id != 4\n" +
" and t.create_time>= ? \n" +
" and t.create_time<= ?\n" +
// " and " +
" t.date >= ? \n" +
" and t.date <= ?\n" +
saleParam +
" group by t.customer_id, t.supermarket_id\n" +
union_4 + union_99 +
@ -2473,33 +2505,33 @@ public class OrderStatService {
}
List<Object> customer_pre_list_params = new ArrayList<>();
// customer_pre_list_params.add(tm);
customer_pre_list_params.add(tm);
// String tempSql =
// " select t.customer_id, sum(t.total_price) total_price\n" +
// " from order_end t\n" +
// " where t.customer_id > -1\n" +
//// "and t.product_id != 4\n" +
// " and t.date <= ?\n" +
// " and t.sale_type = 0\n" +
// " group by t.customer_id\n";
String tempSql =
" select t.customer_id, sum(t.total_price) total_price\n" +
" from order_end t\n" +
" where t.customer_id > -1\n" +
// "and t.product_id != 4\n" +
" and t.date <= ?\n" +
" and t.sale_type = 0\n" +
" group by t.customer_id\n";
// 如果是当天的就加上销售订单数据
// if (LocalDate.now().toString().equals(tm)) {
String tempSql = " select t.customer_id, sum(t.total_price) total_price\n" +
if (LocalDate.now().toString().equals(tm)) {
tempSql += " select t.customer_id, sum(t.total_price) total_price\n" +
" from order_temp t\n" +
" where t.customer_id is not null\n" +
// "and t.product_id != 4\n" +
// " and t.create_time >= ?\n" +
" and t.create_time >= ?\n" +
" and t.create_time <= ?\n" +
" and t.state = 5\n" +
" and t.sale_type = 0\n" +
// " and t.sale_type = 0\n" +
" group by t.customer_id\n";
// customer_pre_list_params.add(tm + STM_SUFFIX);
customer_pre_list_params.add(tm + STM_SUFFIX);
customer_pre_list_params.add(tm + ETM_SUFFIX);
// }
}
// customer_pre_list_params.add(tm);
customer_pre_list_params.add(tm);