Compare commits

..

2 Commits

Author SHA1 Message Date
wany 4c3952e6a4 取土场结算时sale_type为3;按客户年统计不统计原材料运输的 2025-03-11 14:46:26 +08:00
wany 5f7aa01ab2 bug修改 2025-03-11 13:32:56 +08:00
3 changed files with 31 additions and 8 deletions

View File

@ -140,7 +140,7 @@ public class OrderTempService extends BaseService {
} }
if (supermarket_id != null) { if (supermarket_id != null) {
fromsql += " and t.supermarket_id = ? \n"; fromsql += " and s.supermarket_id = ? \n";
paraList.add(supermarket_id); paraList.add(supermarket_id);
} }

View File

@ -547,13 +547,36 @@ public class OrderStatService {
params.add(type); params.add(type);
} }
params.addAll(params);
//2025-03-06更改解决砂站商品删除后月统计数据查询不到问题
String selectSql = "select s.id, s.name, s.name2, p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as orderCount, ifnull(a.totalPrice, 0) as totalPrice, ifnull(a.weight, 0) as weight\n" +
" from supermarket_product t\n";
String commonSql = "select t.id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
" from (\n" +
" select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" +
" from order_temp t\n" +
" where t.state = 5 \n" +
" and t.create_time between ? and ? \n" +
saleParams +
" ) t\n" +
" group by t.id, t.product_id\n";
String sql = "select m.* from (" + selectSql + "left join (\n" + commonSql + " ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" +
" left join supermarket s on s.id = t.supermarket_id\n" +
" left join product p on p.id = t.product_id\n" +
"union\n" +
selectSql + "right join (\n" + commonSql + " ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" +
" left join supermarket s on s.id = a.id\n" +
" left join product p on p.id = a.product_id ) m order by m.id,m.product_id";
/**
String sql = "select s.id, s.name, s.name2, p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as orderCount, ifnull(a.totalPrice, 0) as totalPrice, ifnull(a.weight, 0) as weight\n" + String sql = "select s.id, s.name, s.name2, p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as orderCount, ifnull(a.totalPrice, 0) as totalPrice, ifnull(a.weight, 0) as weight\n" +
" from supermarket_product t\n" + " from supermarket_product t\n" +
" left join (\n" + " left join (\n" +
" select t.id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" + " select t.id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
" from (\n" + " from (\n" +
" select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" + " select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" +
" from order_temp t LEFT JOIN supermarket s on t.supermarket_id = s.id AND s.type = 0\n" + " from order_temp t LEFT JOIN supermarket s on t.supermarket_id = s.id \n" +
" where t.state = 5 \n" + " where t.state = 5 \n" +
// " and t.create_time like ? \n" + // " and t.create_time like ? \n" +
" and t.create_time between ? and ? \n" + " and t.create_time between ? and ? \n" +
@ -562,8 +585,7 @@ public class OrderStatService {
" group by t.id, t.product_id\n" + " group by t.id, t.product_id\n" +
" ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" + " ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" +
" left join supermarket s on s.id = t.supermarket_id\n" + " left join supermarket s on s.id = t.supermarket_id\n" +
" left join product p on p.id = t.product_id AND p.del = 0" + " left join product p on p.id = t.product_id AND p.del = 0";*/
" where s.type = 0";
List<Record> dblist = Db.find(sql, params.toArray()); List<Record> dblist = Db.find(sql, params.toArray());
@ -2029,7 +2051,7 @@ public class OrderStatService {
" LEFT JOIN product p ON p.id = t.product_id " + " LEFT JOIN product p ON p.id = t.product_id " +
" left join customer c on c.id = t.customer_id\n" + " left join customer c on c.id = t.customer_id\n" +
// " where t.state = 5\n" + // " where t.state = 5\n" +
" where 1 = 1\n" + " where 1 = 1 and t.sale_type != 3 \n" +
saleParams + saleParams +
// " and t.create_time like ? \n"; // " and t.create_time like ? \n";
// " and t.create_time between ? and ? \n"; // " and t.create_time between ? and ? \n";
@ -2066,7 +2088,7 @@ public class OrderStatService {
" from order_end t\n" + " from order_end t\n" +
" left join customer c on c.id = t.customer_id\n" + " left join customer c on c.id = t.customer_id\n" +
// " where t.state = 5\n" + // " where t.state = 5\n" +
" where 1 = 1\n" + " where 1 = 1 and t.sale_type != 3 \n" +
saleParams + saleParams +
// " and t.create_time like ? \n"; // " and t.create_time like ? \n";
// " and t.create_time between ? and ? \n"; // " and t.create_time between ? and ? \n";
@ -2107,7 +2129,7 @@ public class OrderStatService {
" LEFT JOIN product p ON p.id = t.product_id " + " LEFT JOIN product p ON p.id = t.product_id " +
" left join customer c on c.id = t.customer_id\n" + " left join customer c on c.id = t.customer_id\n" +
// " where t.state = 5\n" + // " where t.state = 5\n" +
" where 1 = 1\n" + saleParams; " where 1 = 1 and t.sale_type != 3 \n" + saleParams;
if (customer_id != null) { if (customer_id != null) {
sql += " and c.id = ? \n"; sql += " and c.id = ? \n";
@ -2138,7 +2160,7 @@ public class OrderStatService {
" from order_end t\n" + " from order_end t\n" +
" left join customer c on c.id = t.customer_id\n" + " left join customer c on c.id = t.customer_id\n" +
// " where t.state = 5\n" + // " where t.state = 5\n" +
" where 1 = 1\n" + saleParams; " where 1 = 1 and t.sale_type != 3 \n" + saleParams;
if (customer_id != null) { if (customer_id != null) {
sql += " and c.id = ? \n"; sql += " and c.id = ? \n";

View File

@ -493,6 +493,7 @@ public class OrderTempSyncService {
order.setSettlementUserId(sysuser.getId()); order.setSettlementUserId(sysuser.getId());
order.setSettlementUserName(sysuser.getName()); order.setSettlementUserName(sysuser.getName());
order.setSaleType(ordercluster.getSaleType());
order.setState(OrderStateEnum.RECEIVED.getStateid()); // 直接完成,没有前面的过程 order.setState(OrderStateEnum.RECEIVED.getStateid()); // 直接完成,没有前面的过程
order.setCreateTime(now); order.setCreateTime(now);
order.setMemo(memo); // 备注 order.setMemo(memo); // 备注