bug修改

dev
wany 2025-03-26 14:39:29 +08:00
parent ca995fd7de
commit 602b5fb05f
6 changed files with 110 additions and 71 deletions

View File

@ -625,42 +625,55 @@ public class OrderStatService {
List<Record> sups = Db.find("select t.* from supermarket t \n" +
" where t.type = 0");
if(sups == null || sups.isEmpty()){
return null;
}
String dynamicSql = "";
for (int s = 0; s < sups.size(); s++) {
Integer id = sups.get(s).getInt("id");
dynamicSql += "IFNULL( SUM( CASE WHEN t.supermarket_id = " + id+ " THEN t.source_weight END ), 0 ) AS xse_"+ id +",\n" +
" IFNULL( SUM( CASE WHEN t.supermarket_id = " + id+ " THEN t.weight END ), 0 ) AS xss_"+ id +",\n" +
" IFNULL( SUM( CASE WHEN t.supermarket_id = " + id+ " THEN t.count END ), 0 ) AS xsl_"+ id +",\n";
}
// 查询取土场站订单信息
List<Record> sale_list = Db.find("SELECT\n" +
" s.id AS sandfarm_id,\n" +
" s.NAME AS sandfarm_name,\n" +
// " IFNULL( SUM( CASE WHEN t.supermarket_id = 1 THEN t.count END ), 0 ) AS xsl_1,\n" +
" 0 AS xsl_1,\n" +
" IFNULL( SUM( CASE WHEN t.supermarket_id = 1 THEN t.source_weight END ), 0 ) AS xse_1,\n" +
" IFNULL( SUM( CASE WHEN t.supermarket_id = 1 THEN t.weight END ), 0 ) AS xss_1,\n" +
// " 0 AS xsl_1,\n"
dynamicSql +
// " IFNULL( SUM( CASE WHEN t.supermarket_id = 1 THEN t.source_weight END ), 0 ) AS xse_1,\n" +
// " IFNULL( SUM( CASE WHEN t.supermarket_id = 1 THEN t.weight END ), 0 ) AS xss_1,\n" +
" IFNULL( SUM( t.weight ), 0 ) AS weight \n" +
"FROM\n" +
" supermarket s\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" t.supermarket_id sandfarm_id,\n" +
" t.customer_id supermarket_id,\n" +
" COUNT( t.sn ) AS count,\n" +
" SUM( t.weight ) AS source_weight,\n" +
" 0 weight \n" +
" FROM\n" +
" supermarket s\n" +
" LEFT JOIN order_temp t ON t.supermarket_id = s.id \n" +
" WHERE\n" +
" s.del = 0 \n" +
" AND t.state = 5 \n" +
" AND s.type = 1 \n" +
" AND t.create_time >= ? \n" +
" AND t.create_time <= ? \n" +
" GROUP BY\n" +
" t.supermarket_id,\n" +
" t.customer_id UNION\n" +
// " SELECT\n" +
// " t.supermarket_id sandfarm_id,\n" +
// " t.customer_id supermarket_id,\n" +
// " COUNT( t.sn ) AS count,\n" +
// " SUM( t.weight ) AS source_weight,\n" +
// " 0 weight \n" +
// " FROM\n" +
// " supermarket s\n" +
// " LEFT JOIN order_temp t ON t.supermarket_id = s.id \n" +
// " WHERE\n" +
// " s.del = 0 \n" +
// " AND t.state = 5 \n" +
// " AND s.type = 1 \n" +
// " AND t.create_time >= ? \n" +
// " AND t.create_time <= ? \n" +
// " GROUP BY\n" +
// " t.supermarket_id,\n" +
// " t.customer_id UNION\n" +
" SELECT\n" +
" t.sandfarm_id,\n" +
" t.supermarket_id,\n" +
" COUNT( t.sn ) AS count,\n" +
" 0 source_weight,\n" +
" SUM( t.source_weight) AS source_weight,\n" +
" SUM( t.weight ) AS weight \n" +
" FROM\n" +
" order_transfer t \n" +
@ -677,30 +690,20 @@ public class OrderStatService {
"GROUP BY\n" +
" s.id \n" +
"ORDER BY\n" +
" s.id;", stm,etm, stm,etm);
double all_xsl_1 = 0.0;
double all_xse_1 = 0.0;
double all_xss_1 = 0.0;
double all_weight = 0.0;
for (Record record : sale_list) {
all_xsl_1 += DataUtil.getDefaultByRecord(record, "xsl_1");
all_xse_1 += DataUtil.getDefaultByRecord(record, "xse_1");
all_xss_1 += DataUtil.getDefaultByRecord(record, "xss_1");
all_weight += DataUtil.getDefaultByRecord(record, "weight");
}
" s.id;", stm,etm);
Record record = new Record();
record.set("sandfarm_name", "合计");
record.set("xsl_1", all_xsl_1);
record.set("xse_1", all_xse_1);
record.set("xss_1", all_xss_1);
record.set("weight", all_weight);
for (Record sup : sups) {
Integer id = sup.getInt("id");
record.set("xsl_"+id, sale_list.stream().map(o->o.getBigDecimal("xsl_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("xse_"+id, sale_list.stream().map(o->o.getBigDecimal("xse_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("xss_"+id, sale_list.stream().map(o->o.getBigDecimal("xss_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
}
record.set("weight", sale_list.stream().map(o->o.getBigDecimal("weight")).reduce(BigDecimal.ZERO, BigDecimal::add));
sale_list.add(record);
@ -3238,7 +3241,7 @@ public class OrderStatService {
" where t.type = 1"); //取土场
if(sups == null || sups.isEmpty()){
return null;
return new Record();
}
String dynamicSql = "";
@ -3267,12 +3270,11 @@ public class OrderStatService {
" ot.sandfarm_id,\n" +
" ot.truck_license license,\n" +
" ifnull( count( ot.sn ), 0 ) count,\n" +
" ifnull( sum( t.weight ), 0 ) weight,\n" +
" ifnull( sum( ot.weight ), 0 ) source_weight,\n" +
" ifnull( sum( ot.weight ), 0 ) weight,\n" +
" ifnull( sum( ot.source_weight ), 0 ) source_weight,\n" +
" ifnull( sum( ot.trans_price ), 0 ) trans_price \n" +
" FROM\n" +
" order_transfer ot \n" +
" LEFT JOIN order_temp t ON ot.old_sn = t.sn " +
" WHERE\n" +
" ot.create_time >= ? \n" +
" AND ot.create_time <= ? \n" +
@ -3289,6 +3291,10 @@ public class OrderStatService {
List<Record> customer_sale_list = Db.find(sql, stm, etm);
if(customer_sale_list.isEmpty() || customer_sale_list == null){
return new Record().set("data", new ArrayList<>()).set("supermarket", sups);
}
List<String> ids = new ArrayList<>();
String cidsql = "";
@ -3370,15 +3376,15 @@ public class OrderStatService {
record.set("trans_co_id", -1);
record.set("trans_name", "合计");
record.set("count", trans_co_list.stream().map(o->o.getBigDecimal("count")).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("source_weight", trans_co_list.stream().map(o->o.getBigDecimal("source_weight")).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("trans_price", trans_co_list.stream().map(o->o.getBigDecimal("trans_price")).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("count", customer_sale_list.stream().map(o->o.getBigDecimal("count")).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("source_weight", customer_sale_list.stream().map(o->o.getBigDecimal("source_weight")).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("trans_price", customer_sale_list.stream().map(o->o.getBigDecimal("trans_price")).reduce(BigDecimal.ZERO, BigDecimal::add));
for (Record sup : sups) {
Integer id = sup.getInt("id");
record.set("xsc_"+id, trans_co_list.stream().map(o->o.getBigDecimal("xsc_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("xst_"+id, trans_co_list.stream().map(o->o.getBigDecimal("xst_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("xss_"+id, trans_co_list.stream().map(o->o.getBigDecimal("xss_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("xsw_"+id, trans_co_list.stream().map(o->o.getBigDecimal("xsw_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("xsc_"+id, customer_sale_list.stream().map(o->o.getBigDecimal("xsc_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("xst_"+id, customer_sale_list.stream().map(o->o.getBigDecimal("xst_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("xss_"+id, customer_sale_list.stream().map(o->o.getBigDecimal("xss_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
record.set("xsw_"+id, customer_sale_list.stream().map(o->o.getBigDecimal("xsw_"+id)).reduce(BigDecimal.ZERO, BigDecimal::add));
}

View File

@ -42,17 +42,32 @@ public class TicketLogService extends BaseService {
}
public Page<Record> find(PageParam pp, Integer supermarket_id,Integer supermarket_type, Integer state, String order_sn, String stm, String etm, String ticket_code) {
String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
String selectsql = "";
String fromsql = "";
if(supermarket_type == 0){
selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
" case when t.type = 3 then p.weight end weight, \n" +
" case when t.type = 3 then p.total_price end total_price, \n" +
" case when t.type = 3 then p.create_time end create_time, \n" +
" case when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" +
" case when t.type = 3 then p.customer_name end customer_name \n";
String fromsql = "from ticket_log t \n" +
fromsql = "from ticket_log t \n" +
" left join ticket_receive r on r.id = t.ticket_receive_id \n" +
" left join supermarket s on s.id = r.supermarket_id \n" +
" left join order_temp p on p.sn = t.order_sn \n" +
" where 1=1 ";
" where t.type = 3 ";
} else{
selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
" case when t.type = 2 then p.weight end weight, \n" +
" case when t.type = 2 then p.create_time end create_time, \n" +
" case when t.type = 2 then p.settlement_user_name end settlement_user_name\n";
fromsql = "from ticket_log t \n" +
" left join ticket_receive r on r.id = t.ticket_receive_id \n" +
" left join supermarket s on s.id = r.supermarket_id \n" +
" left join order_transfer p on p.sn = t.order_sn \n" +
" where t.type = 2 ";
}
List<Object> paraList = new ArrayList<>();
if (supermarket_id != null) {
@ -60,10 +75,10 @@ public class TicketLogService extends BaseService {
paraList.add(supermarket_id);
}
if (supermarket_type != null) {
fromsql += " and s.type = ? \n";
paraList.add(supermarket_type);
}
// if (supermarket_type != null) {
// fromsql += " and s.type = ? \n";
// paraList.add(supermarket_type);
// }
if (state != null) {
fromsql += " and t.state = ? \n";

View File

@ -259,7 +259,7 @@ public class OrderTransferSyncService {
ticketLog.setSettlementUserId(order.getSettlementUserId());
ticketLog.setSettlementUserName(order.getSettlementUserName());
ticketLog.setOrderSn(order.getSn());
ticketLog.setType(OrderTypeEnum.TEMP.getTypeid());
ticketLog.setType(OrderTypeEnum.TRANSFER.getTypeid());
ret = ticketLog.save();

View File

@ -10,6 +10,7 @@ import com.cowr.local.ssjygl.main.AuthInterceptor;
import com.cowr.ssjygl.stat.sale.OrderStatService;
import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.plugin.activerecord.Record;
import org.apache.poi.ss.usermodel.Workbook;
public class OrderStatController extends BaseController {
@ -377,6 +378,22 @@ public class OrderStatController extends BaseController {
}
}
/**
* ()
*/
@Clear(AuthInterceptor.class)
public void statYearBySup1() {
String tm = get("tm");
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Boolean stat_product = getBoolean("stat_product", false);
if (export == 0) {
renderJson(Result.object(OrderStatService.me.statYearBySup1(tm)));
} else {
Workbook wb = OrderStatService.me.yearsalestatExportBySup(tm);
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
}
}
@Before(StartAndEndIntervalValidator.class)
public void statRangeAllCustomer() {
String stm = get("stm");

View File

@ -19,7 +19,7 @@ public class TicketInvalidVerifySyncService {
public static TicketInvalidVerifySyncService me = new TicketInvalidVerifySyncService();
public Result save(String order_sn, String invalid_memo, Sysuser sysuser) {
OrderTemp order = OrderTemp.dao.findById(order_sn);
OrderTransfer order = OrderTransfer.dao.findById(order_sn);
if (order == null) {
return Result.failedstr("按 %s 没有找到订单信息", order_sn);

View File

@ -14,6 +14,7 @@ import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.ssjygl.stat.sale.OrderStatService;
import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.plugin.activerecord.Record;
import org.apache.poi.ss.usermodel.Workbook;
import java.util.Date;