各砂站运输量统计表查询修改
parent
1be46cdd34
commit
5f3b5a4f42
|
|
@ -13,20 +13,14 @@ import com.jfinal.kit.StrKit;
|
|||
import com.jfinal.log.Log;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
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 java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static com.cowr.common.utils.DateTimeUtil.*;
|
||||
import static com.cowr.common.utils.DateTimeUtil.ETM_SUFFIX;
|
||||
|
||||
public class OrderStatService {
|
||||
private static Log log = Log.getLog(OrderStatService.class);
|
||||
|
|
@ -2282,110 +2276,111 @@ 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.supermarket_id = 4\n" +
|
||||
" and (t.create_time < '2021-09-08 00:00:00'\n" +
|
||||
" or t.create_time > '2021-10-15 23:59:59')\n" +
|
||||
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' )" +
|
||||
// " 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" +
|
||||
" group by t.customer_id\n";
|
||||
|
||||
union_99 = " union select\n" +
|
||||
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
" 99 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_99 += "and t.invoice_type = " + invoice_type + " \n";
|
||||
}
|
||||
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
union_99 += " and t.sale_type = " + sale_type + " \n";
|
||||
}else{
|
||||
union_99 += " and t.sale_type = 0 \n";
|
||||
}
|
||||
|
||||
union_99 += " and t.supermarket_id = 4\n" +
|
||||
" and ((t.create_time >= '2021-09-08 00:00:00' and t.create_time <= '2021-10-15 23:59:59') \n" +
|
||||
" or (t.create_time >= '2021-10-20 00:00:00' and t.create_time <= '2021-10-20 23:59:59'))\n" +
|
||||
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
|
||||
// " and t.create_time >= ? \n" +
|
||||
// " and t.create_time <= ?\n" +
|
||||
" group by t.customer_id\n";
|
||||
|
||||
today = " 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) {
|
||||
today += "and t.invoice_type = " + invoice_type + " \n";
|
||||
}
|
||||
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
today += " and t.sale_type = " + sale_type + " \n";
|
||||
}else{
|
||||
today += " and t.sale_type = 0 \n";
|
||||
}
|
||||
|
||||
today += " and t.supermarket_id != 4\n" +
|
||||
" AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
|
||||
// " and t.create_time>= ? \n" +
|
||||
// " and t.create_time<= ?\n" +
|
||||
// paramsSql +
|
||||
" group by t.customer_id, t.supermarket_id \n " +
|
||||
" union \n ";
|
||||
}
|
||||
// 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.supermarket_id = 4\n" +
|
||||
// " and (t.create_time < '2021-09-08 00:00:00'\n" +
|
||||
// " or t.create_time > '2021-10-15 23:59:59')\n" +
|
||||
// " AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' )" +
|
||||
//// " 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" +
|
||||
// " group by t.customer_id\n";
|
||||
//
|
||||
// union_99 = " union select\n" +
|
||||
// " ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
// " 99 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_99 += "and t.invoice_type = " + invoice_type + " \n";
|
||||
// }
|
||||
//
|
||||
// if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
// union_99 += " and t.sale_type = " + sale_type + " \n";
|
||||
// }else{
|
||||
// union_99 += " and t.sale_type = 0 \n";
|
||||
// }
|
||||
//
|
||||
// union_99 += " and t.supermarket_id = 4\n" +
|
||||
// " and ((t.create_time >= '2021-09-08 00:00:00' and t.create_time <= '2021-10-15 23:59:59') \n" +
|
||||
// " or (t.create_time >= '2021-10-20 00:00:00' and t.create_time <= '2021-10-20 23:59:59'))\n" +
|
||||
// " AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
|
||||
//// " and t.create_time >= ? \n" +
|
||||
//// " and t.create_time <= ?\n" +
|
||||
// " group by t.customer_id\n";
|
||||
//
|
||||
// today = " 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) {
|
||||
// today += "and t.invoice_type = " + invoice_type + " \n";
|
||||
// }
|
||||
//
|
||||
// if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
// today += " and t.sale_type = " + sale_type + " \n";
|
||||
// }else{
|
||||
// today += " and t.sale_type = 0 \n";
|
||||
// }
|
||||
//
|
||||
// today += " and t.supermarket_id != 4\n" +
|
||||
// " AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' ) \n" +
|
||||
//// " and t.create_time>= ? \n" +
|
||||
//// " and t.create_time<= ?\n" +
|
||||
//// paramsSql +
|
||||
// " group by t.customer_id, t.supermarket_id \n " +
|
||||
// " union \n ";
|
||||
// }
|
||||
|
||||
|
||||
union_4 += " UNION\n" +
|
||||
" 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_end t \n" +
|
||||
" WHERE\n" +
|
||||
" t.supermarket_id != 4 \n" +
|
||||
" AND t.date >= ? \n" +
|
||||
" AND t.date <= ? \n" +
|
||||
" and (t.date < '2021-09-08'\n" +
|
||||
" or t.date > '2021-10-15')\n" +
|
||||
" and (t.date < '2021-10-20' or t.date > '2021-10-20')\n" +
|
||||
saleParam +
|
||||
" GROUP BY\n" +
|
||||
" t.customer_id,\n" +
|
||||
" t.supermarket_id";
|
||||
// union_4 += " UNION\n" +
|
||||
// " 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 >= ? \n" +
|
||||
// " AND t.create_time <= ? \n" +
|
||||
// " and (t.create_time < '2021-09-08'\n" +
|
||||
// " or t.create_time > '2021-10-15')\n" +
|
||||
// " and (t.create_time < '2021-10-20' or t.date > '2021-10-20')\n" +
|
||||
// saleParam +
|
||||
// " GROUP BY\n" +
|
||||
// " t.customer_id,\n" +
|
||||
// " t.supermarket_id";
|
||||
|
||||
|
||||
union_99 += " union SELECT\n" +
|
||||
|
|
@ -2394,13 +2389,14 @@ public class OrderStatService {
|
|||
" ifnull( sum( t.weight ), 0 ) weight,\n" +
|
||||
" ifnull( sum( t.total_price ), 0 ) total_price \n" +
|
||||
" FROM\n" +
|
||||
" order_end t \n" +
|
||||
" order_temp t \n" +
|
||||
" WHERE\n" +
|
||||
" t.supermarket_id = 4 \n" +
|
||||
" AND ( t.date < '2021-09-08 00:00:00' OR t.date > '2021-10-15 23:59:59' ) \n" +
|
||||
" AND t.date >= ? \n" +
|
||||
" AND t.date <= ? \n" +
|
||||
" AND ( t.date < '2021-10-20 00:00:00' OR t.date > '2021-10-20 23:59:59' ) \n" +
|
||||
" AND t.state = 5 \n" +
|
||||
" AND ( t.create_time < '2021-09-08 00:00:00' OR t.date > '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.date > '2021-10-20 23:59:59' ) \n" +
|
||||
saleParam +
|
||||
" GROUP BY\n" +
|
||||
" t.customer_id ";
|
||||
|
|
@ -2436,11 +2432,11 @@ 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_end t\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.supermarket_id != 4\n" +
|
||||
// " and t.product_id != 4\n" +
|
||||
" and t.date>= ? \n" +
|
||||
" and t.date<= ?\n" +
|
||||
" and t.create_time>= ? \n" +
|
||||
" and t.create_time<= ?\n" +
|
||||
saleParam +
|
||||
" group by t.customer_id, t.supermarket_id\n" +
|
||||
union_4 + union_99 +
|
||||
|
|
@ -2451,16 +2447,18 @@ public class OrderStatService {
|
|||
|
||||
if (invoice_type != null) {
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
customer_sale_list = Db.find(sql, stm, etm, sale_type, stm, etm, sale_type, stm, etm, sale_type);
|
||||
// customer_sale_list = Db.find(sql, stm, etm, sale_type, stm, etm, sale_type, stm, etm, sale_type);
|
||||
customer_sale_list = Db.find(sql, stm, etm, sale_type, stm, etm, sale_type);
|
||||
} else {
|
||||
// customer_sale_list = Db.find(sql, stm, etm, invoice_type, stm, etm, invoice_type, stm, etm, invoice_type);
|
||||
customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm);
|
||||
customer_sale_list = Db.find(sql, stm, etm, stm, etm);
|
||||
}
|
||||
} else {
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
customer_sale_list = Db.find(sql,stm, etm, sale_type, stm, etm, sale_type, stm, etm, sale_type);
|
||||
// customer_sale_list = Db.find(sql,stm, etm, sale_type, stm, etm, sale_type, stm, etm, sale_type);
|
||||
customer_sale_list = Db.find(sql,stm, etm, sale_type, stm, etm, sale_type);
|
||||
} else {
|
||||
customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm);
|
||||
customer_sale_list = Db.find(sql, stm, etm, stm, etm);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2475,33 +2473,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)) {
|
||||
tempSql += "UNION select t.customer_id, sum(t.total_price) total_price\n" +
|
||||
// if (LocalDate.now().toString().equals(tm)) {
|
||||
String 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" +
|
||||
" 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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue