From 5c67cb66187711376d43459246ed93ba164b1b1c Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Sat, 31 Oct 2020 13:48:22 +0800 Subject: [PATCH 01/10] . --- .../model/SupermarketCustomerDistance.java | 2 +- .../base/BaseCustomerSupermarketProduct.java | 8 +- .../model/base/BaseInvoiceInvalidVerify.java | 4 +- .../cowr/model/base/BaseInvoiceReceive.java | 4 +- .../model/base/BaseOrderInvalidVerify.java | 4 +- .../com/cowr/model/base/BaseOrderTemp.java | 4 +- .../base/BaseSupermarketCustomerDistance.java | 6 +- .../com/cowr/model/base/BaseSyncTask.java | 4 +- .../receive/InvoiceReceiveService.java | 2 +- .../ordercluster/OrderclusterService.java | 5 +- .../truck/OrderclusterTruckService.java | 2 +- .../stat/invoice/InvoiceUseController.java | 32 ++ .../stat/invoice/InvoiceUseService.java | 293 ++++++++++++++++++ ...upermarketCustomerDistancePKValidator.java | 2 +- .../SupermarketCustomerDistanceService.java | 2 +- .../SupermarketCustomerDistanceValidator.java | 2 +- .../devicectrl/common/DeviceThread.java | 2 +- .../invoice/log/InvoiceLogController.java | 16 + .../invoice/log/InvoiceLogSyncService.java | 110 +++++++ .../com/cowr/local/ssjygl/main/Config.java | 6 +- .../java/com/cowr/local/ssjygl/main/Main.java | 4 +- .../order/ordertemp/OrderTempSyncService.java | 2 +- .../invoice/log/InvoiceLogSyncService.java | 14 +- .../jobs/CheckUndonOrderclusterJob.java | 2 +- .../com/cowr/service/ssjygl/main/Config.java | 2 + .../ordercluster/OrderclusterSyncService.java | 13 +- 26 files changed, 503 insertions(+), 44 deletions(-) create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseController.java create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/SupermarketCustomerDistance.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/SupermarketCustomerDistance.java index 4851f36..475e805 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/SupermarketCustomerDistance.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/SupermarketCustomerDistance.java @@ -5,7 +5,7 @@ import com.cowr.model.base.BaseSupermarketCustomerDistance; /** * Generated by COWR Tue Aug 25 17:27:08 CST 2020 * TableName: supermarket_customer_distance - * Remarks: 基础配置 - 超市到客户的距离 + * Remarks: 基础配置 - 砂站到客户的距离 * PrimaryKey: supermarket_id,customer_id */ @SuppressWarnings("serial") diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerSupermarketProduct.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerSupermarketProduct.java index 5ac6a9b..968fb6a 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerSupermarketProduct.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerSupermarketProduct.java @@ -48,7 +48,7 @@ public abstract class BaseCustomerSupermarketProduct> extend * isPrimaryKey: NO * defaultValue: * - * @param supermarketId 领取超市id + * @param supermarketId 领取砂站id */ @JSONField(name = "supermarket_id") public void setSupermarketId(Integer supermarketId) { @@ -243,7 +243,7 @@ public abstract class BaseInvoiceReceive> extend /** - * @return supermarket_id 领取超市id + * @return supermarket_id 领取砂站id */ @JSONField(name = "supermarket_id") public Integer getSupermarketId() { diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderInvalidVerify.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderInvalidVerify.java index ea1ea08..3692f49 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderInvalidVerify.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderInvalidVerify.java @@ -252,7 +252,7 @@ public abstract class BaseOrderInvalidVerify * isNullable: YES * isPrimaryKey: NO * defaultValue: - * @param supermarketId 超市id + * @param supermarketId 砂站id */ @JSONField(name="supermarket_id") public void setSupermarketId(Integer supermarketId) { @@ -261,7 +261,7 @@ public abstract class BaseOrderInvalidVerify /** - * @return supermarket_id 超市id + * @return supermarket_id 砂站id */ @JSONField(name="supermarket_id") public Integer getSupermarketId() { diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderTemp.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderTemp.java index 89e44c6..1864346 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderTemp.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderTemp.java @@ -96,7 +96,7 @@ public abstract class BaseOrderTemp> extends BaseMode * isPrimaryKey: NO * defaultValue: * - * @param supermarketId 超市id + * @param supermarketId 砂站id */ @JSONField(name = "supermarket_id") public void setSupermarketId(Integer supermarketId) { @@ -105,7 +105,7 @@ public abstract class BaseOrderTemp> extends BaseMode /** - * @return supermarket_id 超市id + * @return supermarket_id 砂站id */ @JSONField(name = "supermarket_id") public Integer getSupermarketId() { diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseSupermarketCustomerDistance.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseSupermarketCustomerDistance.java index 2920487..618747c 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseSupermarketCustomerDistance.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseSupermarketCustomerDistance.java @@ -7,7 +7,7 @@ import com.alibaba.fastjson.annotation.JSONField; /** * Generated by COWR Tue Aug 25 17:27:08 CST 2020 * TableName: supermarket_customer_distance - * Remarks: 基础配置 - 超市到客户的距离 + * Remarks: 基础配置 - 砂站到客户的距离 * PrimaryKey: supermarket_id,customer_id */ @SuppressWarnings("serial") @@ -27,7 +27,7 @@ public abstract class BaseSupermarketCustomerDistance> extends BaseModel< * isPrimaryKey: NO * defaultValue: * - * @param supermarketId 超市id + * @param supermarketId 砂站id */ @JSONField(name = "supermarket_id") public void setSupermarketId(Integer supermarketId) { @@ -105,7 +105,7 @@ public abstract class BaseSyncTask> extends BaseModel< /** - * @return supermarket_id 超市id + * @return supermarket_id 砂站id */ @JSONField(name = "supermarket_id") public Integer getSupermarketId() { diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveService.java index 53099f6..be3c6e1 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveService.java @@ -132,7 +132,7 @@ public class InvoiceReceiveService extends BaseService { } /** - * 获取指定超市下一个可用的发票号码 + * 获取指定砂站下一个可用的发票号码 * TODO:要区分专票和普票 * * @param supermarket_id diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java index c150296..0186407 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java @@ -338,12 +338,13 @@ public class OrderclusterService extends BaseService { return Db.find(sql, paraList.toArray()); } - public List undonlist(int supermarket_id, String customer_name) { + public List undonlist(int supermarket_id, String customer_name, String cutoff_time) { String sql = "select * from ordercluster t \n" + " where t.state < ? \n" + + " and t.cutoff_time like ? \n" + " and t.supermarket_id = ? \n" + " and t.customer_name = ? "; - return Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), supermarket_id, customer_name); + return Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), cutoff_time + "%", supermarket_id, customer_name); } /** diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java index 7bf64e9..33ac5bd 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java @@ -88,7 +88,7 @@ public class OrderclusterTruckService extends BaseService { } /** - * 用超市id、车牌号查询当天关联的集团订单信息 + * 用砂站id、车牌号查询当天关联的集团订单信息 * * @param supermarket_id * @param truck_license diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseController.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseController.java new file mode 100644 index 0000000..1579e5f --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseController.java @@ -0,0 +1,32 @@ +package com.cowr.ssjygl.stat.invoice; + +import com.cowr.common.validator.DayValidator; +import com.cowr.common.view.ExcelRender; +import com.cowr.common.view.Result; +import com.cowr.ssjygl.stat.sale.OrderStatService; +import com.jfinal.aop.Before; +import com.jfinal.core.Controller; +import org.apache.poi.ss.usermodel.Workbook; + +public class InvoiceUseController extends Controller { + @Before(DayValidator.class) + public void statuse() { + String tm = get("tm"); + Integer supermarket_id = getInt("supermarket_id"); + Integer invoice_type = getInt("invoice_type"); + String invoice_number = get("invoice_number"); + String invoice_code = get("invoice_code"); + Integer invoice_state = getInt("invoice_state"); + String order_sn = get("order_sn"); + String truck_license = get("truck_license"); + Integer order_state = getInt("order_state"); + + int export = getInt("export", 0); + if (export == 0) { + renderJson(Result.success(InvoiceUseService.me.statuse(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, order_sn, truck_license, order_state))); + }else{ + Workbook wb = InvoiceUseService.me.statuseExport(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, order_sn, truck_license, order_state); + render(new ExcelRender(tm + "_票据使用记录_" + System.currentTimeMillis() + ".xlsx", wb)); + } + } +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java new file mode 100644 index 0000000..f07c6e2 --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java @@ -0,0 +1,293 @@ +package com.cowr.ssjygl.stat.invoice; + +import com.cowr.common.utils.DataUtil; +import com.cowr.common.utils.DateTimeUtil; +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.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.ArrayList; +import java.util.List; + +public class InvoiceUseService { + private static Log log = Log.getLog(InvoiceUseService.class); + public static InvoiceUseService me = new InvoiceUseService(); + + /** + * 票据使用情况统计 + */ + public Record statuse( + String tm, + Integer supermarket_id, + Integer invoice_type, + String invoice_number, + String invoice_code, + Integer invoice_state, + String order_sn, + String truck_license, + Integer order_state + ) { + String logsql = "select \n" + + " t.id rowkey, t.invoice_number, t.`code` invoice_code, t.state invoice_state, t.settlement_user_name, t.settlement_time, t.create_time, t.invalid_time, t.invalid_memo, t.invoice_type, t.invalid_user_name\n" + + " , r.receive_user_name, r.create_time receive_time, r.supermarket_id\n" + + " , o.sn order_sn, o.weight, o.total_price, o.unit_price, o.truck_license, o.customer_id, o.customer_texpayer_name, o.customer_texpayer_num, o.isprepaid, o.state order_state\n" + + " , s.name supermarket_name " + + " from invoice_log t\n" + + " left join invoice_receive r on t.invoice_receive_id = r.id\n" + + " left join order_temp o on o.sn = t.order_sn \n" + + " left join supermarket s on s.id = r.supermarket_id \n" + + " where 1 = 1 \n"; + + String ordsql = "select\n" + + " t.uuid rowkey, t.invoice_number, t.invoice_code, null invoice_state, t.settlement_user_name, null settlement_time, t.create_time, null invalid_time, null invalid_memo, t.invoice_type, null invalid_user_name\n" + + " , null receive_user_name, null receive_time, t.supermarket_id \n" + + " , t.sn order_sn, t.weight, t.total_price, t.unit_price, t.truck_license, t.customer_id, t.customer_texpayer_name, t.customer_texpayer_num, t.isprepaid, t.state order_state \n" + + " , s.name supermarket_name " + + " from order_temp t \n" + + " left join invoice_log l on l.order_sn = t.sn \n" + + " left join supermarket s on s.id = t.supermarket_id \n" + + " where t.invoice_type = 2 \n" + + " and l.id is null\n"; + + List paramlog = new ArrayList<>(); + List paramord = new ArrayList<>(); + + logsql += " and t.create_time like ? \n"; + ordsql += " and t.create_time like ? \n"; + + paramlog.add(tm + "%"); + paramord.add(tm + "%"); + + if (supermarket_id != null) { + logsql += " and r.supermarket_id <= ? \n"; // 这里用领用记录的 supermarket_id + ordsql += " and t.supermarket_id <= ? \n"; + + paramlog.add(supermarket_id); + paramord.add(supermarket_id); + } + + if (StrKit.notBlank(invoice_number)) { + logsql += " and t.invoice_number like ? \n"; + ordsql += " and t.invoice_number like ? \n"; + + paramlog.add("%" + invoice_number.trim() + "%"); + paramord.add("%" + invoice_number.trim() + "%"); + } + + if (StrKit.notBlank(invoice_code)) { + logsql += " and t.invoice_code like ? \n"; + ordsql += " and t.invoice_code like ? \n"; + + paramlog.add("%" + invoice_code.trim() + "%"); + paramord.add("%" + invoice_code.trim() + "%"); + } + + if (StrKit.notBlank(order_sn)) { + logsql += " and t.order_sn like ? \n"; + ordsql += " and t.sn like ? \n"; + + paramlog.add("%" + order_sn.trim() + "%"); + paramord.add("%" + order_sn.trim() + "%"); + } + + if (StrKit.notBlank(truck_license)) { + logsql += " and o.truck_license like ? \n"; // 订单表里面才有车牌号 + ordsql += " and t.truck_license like ? \n"; + + paramlog.add("%" + truck_license.trim() + "%"); + paramord.add("%" + truck_license.trim() + "%"); + } + + if (invoice_state != null) { + logsql += " and t.state = ? \n"; + paramlog.add(invoice_state); + } + + if (order_state != null) { + logsql += " and o.state <= ? \n"; + ordsql += " and t.state <= ? \n"; + + paramlog.add(order_state); + paramord.add(order_state); + } + + List list = new ArrayList<>(); + + if (invoice_type != null && invoice_type == 1) { + list = Db.find(logsql + " order by t.create_time", paramlog.toArray()); + } else { + paramlog.addAll(paramord); + + list = Db.find("select * from (" + logsql + "\n union \n " + ordsql + ") a order by a.create_time ", paramlog.toArray()); + } + + Record out = new Record(); + out.set("list", list); + out.set("cnt", list.size()); + out.set("total_weight", 0.0); + out.set("total_price", 0.0); + out.set("invoice_type_1_cnt", 0); + out.set("invoice_type_2_cnt", 0); + + for (Record record : list) { + if (record.get("weight") != null) { + out.set("total_weight", out.getBigDecimal("total_weight").add(record.getBigDecimal("weight"))); + } + if (record.get("total_price") != null) { + out.set("total_price", out.getBigDecimal("total_price").add(record.getBigDecimal("total_price"))); + } + + if (record.getInt("invoice_type") == 1) { + out.set("invoice_type_1_cnt", out.getInt("invoice_type_1_cnt") + 1); + } else if (record.getInt("invoice_type") == 2) { + out.set("invoice_type_2_cnt", out.getInt("invoice_type_2_cnt") + 1); + } else { + log.debug("错误数据: %s", record.toJson()); + } + } + + return out; + } + + public Workbook statuseExport( + String tm, + Integer supermarket_id, + Integer invoice_type, + String invoice_number, + String invoice_code, + Integer invoice_state, + String order_sn, + String truck_license, + Integer order_state + ) { + Record ret = statuse(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, order_sn, truck_license, order_state); + + List list = ret.get("list"); + + Workbook wb = new XSSFWorkbook(); + Sheet sheet = wb.createSheet("票据使用记录"); + + // 表头 start + Row row = sheet.createRow(0); + int a = 0; + row.createCell(a++).setCellValue("序号"); + row.createCell(a++).setCellValue("订单号"); + row.createCell(a++).setCellValue("新建时间"); + row.createCell(a++).setCellValue("砂站"); + row.createCell(a++).setCellValue("开票名称"); + row.createCell(a++).setCellValue("开票税号"); + row.createCell(a++).setCellValue("数量(吨)"); + row.createCell(a++).setCellValue("总价"); + row.createCell(a++).setCellValue("车牌号"); + row.createCell(a++).setCellValue("订单状态"); + row.createCell(a++).setCellValue("发票代码"); + row.createCell(a++).setCellValue("发票编号"); + row.createCell(a++).setCellValue("发票类型"); + row.createCell(a++).setCellValue("发票状态"); + row.createCell(a++).setCellValue("开票人"); + row.createCell(a++).setCellValue("开票时间"); + row.createCell(a++).setCellValue("作废人"); + row.createCell(a++).setCellValue("作废时间"); + row.createCell(a++).setCellValue("备注"); + // 表头 end + + int end_col = 19; + int datalen = list.size(); + for (int i = 0; i < datalen; i++) { + Record order = list.get(i); + + row = sheet.createRow(i + 1); + a = 0; + row.createCell(a++).setCellValue(i + 1); + row.createCell(a++).setCellValue(order.getStr("order_sn")); + row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("create_time"))); + row.createCell(a++).setCellValue(order.getStr("supermarket_name")); + row.createCell(a++).setCellValue(order.getStr("customer_texpayer_name")); + row.createCell(a++).setCellValue(order.getStr("customer_texpayer_num")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "weight")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price")); + row.createCell(a++).setCellValue(order.getStr("truck_license")); + if (order.get("order_state") != null) { + switch (order.getInt("order_state")) { + case 1: + row.createCell(a++).setCellValue("新建"); + break; + case 4: + row.createCell(a++).setCellValue("待付款"); + break; + case 5: + row.createCell(a++).setCellValue("已完成"); + break; + case 9: + row.createCell(a++).setCellValue("已取消"); + break; + default: + row.createCell(a++).setCellValue(""); + } + } else { + row.createCell(a++).setCellValue(""); + } + row.createCell(a++).setCellValue(order.getStr("invoice_number")); + row.createCell(a++).setCellValue(order.getStr("invoice_code")); + row.createCell(a++).setCellValue(order.getInt("invoice_type") == 2 ? "专票" : "普票"); + if (order.get("invoice_state") != null) { + switch (order.getInt("invoice_state")) { + case 5: + row.createCell(a++).setCellValue("已使用"); + break; + case 9: + row.createCell(a++).setCellValue("已作废"); + break; + default: + row.createCell(a++).setCellValue(""); + } + } else { + row.createCell(a++).setCellValue(""); + } + row.createCell(a++).setCellValue(order.getStr("settlement_user_name")); + if (order.get("settlement_time") != null) { + row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("settlement_time"))); + } else { + row.createCell(a++).setCellValue(""); + } + row.createCell(a++).setCellValue(order.getStr("invalid_user_name")); + if (order.get("invalid_time") != null) { + row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("invalid_time"))); + } else { + row.createCell(a++).setCellValue(""); + } + row.createCell(a++).setCellValue(order.getStr("invalid_memo")); + } + + // 通用单元格格式 + Font font = wb.createFont(); + CellStyle cellStyle = wb.createCellStyle(); + font.setFontHeight((short) (10 * 20)); + font.setFontName("宋体"); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + cellStyle.setFont(font); + + // 设置通用单元格格式 + for (int r = 0; r < datalen + 1; r++) { + row = sheet.getRow(r); + if (row == null) { + row = sheet.createRow(r); + } + + for (int c = 0; c < end_col + 1; c++) { + Cell cell = row.getCell(c); + + if (cell == null) { + cell = row.createCell(c); + } + cell.setCellStyle(cellStyle); + } + } + + return wb; + } +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistancePKValidator.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistancePKValidator.java index 7ed4ed8..f74280c 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistancePKValidator.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistancePKValidator.java @@ -8,7 +8,7 @@ import com.jfinal.core.Controller; /** * Generated by COWR Tue Aug 25 17:27:14 CST 2020 * TableName: supermarket_customer_distance - * Remarks: 基础配置 - 超市到客户的距离 + * Remarks: 基础配置 - 砂站到客户的距离 * PrimaryKey: supermarket_id,customer_id */ public class SupermarketCustomerDistancePKValidator extends CrudParamValidator { diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistanceService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistanceService.java index 5e33bd7..dd9f713 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistanceService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistanceService.java @@ -17,7 +17,7 @@ import java.util.List; /** * Generated by COWR Tue Aug 25 17:27:14 CST 2020 * TableName: supermarket_customer_distance - * Remarks: 基础配置 - 超市到客户的距离 + * Remarks: 基础配置 - 砂站到客户的距离 * PrimaryKey: supermarket_id,customer_id */ public class SupermarketCustomerDistanceService extends BaseService { diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistanceValidator.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistanceValidator.java index 8c87edd..a2f79da 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistanceValidator.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/supermarket/customerdistance/SupermarketCustomerDistanceValidator.java @@ -8,7 +8,7 @@ import com.cowr.model.SupermarketCustomerDistance; /** * Generated by COWR Tue Aug 25 17:27:14 CST 2020 * TableName: supermarket_customer_distance - * Remarks: 基础配置 - 超市到客户的距离 + * Remarks: 基础配置 - 砂站到客户的距离 * PrimaryKey: supermarket_id,customer_id */ public class SupermarketCustomerDistanceValidator extends CrudParamValidator { diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/common/DeviceThread.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/common/DeviceThread.java index c84e1df..71ba3b9 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/common/DeviceThread.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/common/DeviceThread.java @@ -169,7 +169,7 @@ public class DeviceThread extends Thread { LEDThread led = new LEDThread(which + "_led", ledconf.getString("ip"), ledconf.getIntValue("port")); AbsScale scale; - // 根据超市id,兼容不同的表头 + // 根据砂站id,兼容不同的表头 if (supermarket_id == 3) { // 城隍用了耀华的表头 scale = new YaoHuaScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port")); } else if (supermarket_id == 4) { // 石畈用了两个不一样的表头 diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java index 9d27b20..abb3e57 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java @@ -82,4 +82,20 @@ public class InvoiceLogController extends Controller { InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段 renderJson(InvoiceLogService.me.findByPk(model)); } + + public void invalid() { + Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); + + if (tokenuser == null) { + renderJson(Result.noauth()); + return; + } + + Integer supermarket_id = getInt("supermarket_id", 0); + String invoice_number = get("invoice_number"); + String code = get("code"); + String invalid_memo = get("invalid_memo"); + + renderJson(InvoiceLogSyncService.me.invalid(supermarket_id, invoice_number, code, invalid_memo, tokenuser)); + } } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogSyncService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogSyncService.java index d13c5f1..24ebf0e 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogSyncService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogSyncService.java @@ -1,10 +1,120 @@ package com.cowr.local.ssjygl.invoice.log; +import com.cowr.common.enums.Enums; +import com.cowr.common.enums.OrderStateEnum; +import com.cowr.common.view.Result; import com.cowr.local.ssjygl.base.BaseSyncService; +import com.cowr.local.ssjygl.main.CliCacheData; +import com.cowr.local.ssjygl.synctask.SyncTaskService; +import com.cowr.model.*; +import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService; +import com.cowr.ssjygl.modifylog.ModifyLogService; +import com.jfinal.kit.StrKit; import com.jfinal.log.Log; +import com.jfinal.plugin.activerecord.Db; +import com.jfinal.plugin.activerecord.IAtom; + +import java.util.Date; public class InvoiceLogSyncService extends BaseSyncService { private static Log log = Log.getLog(InvoiceLogSyncService.class); public static InvoiceLogSyncService me = new InvoiceLogSyncService(); + /** + * 作废发票,未关联订单的(损毁等,不是正常开票使用的发票) + * + * @return + */ + public Result invalid(int supermarket_id, String invoice_number, String code, String invalid_memo, Sysuser sysuser) { + if (supermarket_id != CliCacheData.SUP.getId()) { + return Result.failed("砂站信息错误"); + } + + // 先判断这张发票有没有被领用 + InvoiceReceive receive = InvoiceReceiveService.me.checkSurplusReceive(supermarket_id, invoice_number, code); + if (receive == null) { + return Result.failed("没有有效的发票领用记录,或者发票已经被使用"); + } + + InvoiceLog invoiceLog = InvoiceLog.dao.findFirst("select * from invoice_log t \n" + + " where t.invoice_number = ? and t.code = ? limit 1 ", invoice_number, code); + + if (invoiceLog != null) { + // 再判断这张发票是不是已经被取消了 + if (invoiceLog.getState() == OrderStateEnum.INVALID.getStateid()) { + return Result.failed("发票已作废"); + } else { + // 还要判断这张发票已经在订单上使用了 + return Result.failed("发票已使用,请使用“取消发票”功能"); + } + } + + // 然后就可以开始取消了 + + invoiceLog = new InvoiceLog(); + invoiceLog.setId(StrKit.getRandomUUID()); + invoiceLog.setInvalidUserId(sysuser.getId()); + invoiceLog.setInvalidUserName(sysuser.getName()); + invoiceLog.setInvalidTime(new Date()); + invoiceLog.setInvalidMemo(invalid_memo); + invoiceLog.setState(OrderStateEnum.INVALID.getStateid()); + invoiceLog.setInvoiceReceiveId(receive.getId()); + invoiceLog.setCode(code); + invoiceLog.setInvoiceNumber(invoice_number); + + receive.setSurplus(receive.getSurplus() - 1); + receive.setInvalidCount(receive.getInvalidCount() + 1); + + if (receive.getSurplus() == 0) { + // 作废最后一张发票,当前发票停再最后一个发票号码上 + receive.setCurrentCode(receive.getEndCode()); + } else { + if (code.equals(receive.getStartCode())) { // 作废第一张发票 + receive.setCurrentCode(String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode()) + 1)); + } else if (code.equals(receive.getCurrentCode())) { // 作废顺延的下一张发票 + receive.setCurrentCode(String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getCurrentCode()) + 1)); + } else { + // 其他情况下不更新 current_code + } + } + + SyncTask synctask = new SyncTask(); + + InvoiceLog finalInvoiceLog = invoiceLog; + boolean ret = Db.tx(new IAtom() { + @Override + public boolean run() { + try { + boolean ret = finalInvoiceLog.save(); + + if (!ret) { + return false; + } + + synctask.addSaveData(finalInvoiceLog); + + ret = receive.update(); + + if (!ret) { + return false; + } + + synctask.addUpdateData(receive); + + return SyncTaskService.me.save(synctask) + && ModifyLogService.me.save(finalInvoiceLog, null, Enums.DataOpType.SAVE.getId(), sysuser); + } catch (Exception e) { + log.error(e.getMessage(), e); + return false; + } + } + }); + + // 普票作废理解同步到砂站 + if (ret) { + SyncTaskService.me.send(synctask); + } + + return ret ? Result.success(invoiceLog) : Result.failed(false, "处理失败"); + } } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java index de1ba25..4e64263 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java @@ -56,6 +56,7 @@ import com.cowr.ssjygl.cctv.CctvController; import com.cowr.local.ssjygl.prepay.PrepayController; import com.cowr.local.ssjygl.overall.OverallController; import com.cowr.ssjygl.modifylog.ModifyLogController; +import com.cowr.ssjygl.stat.invoice.InvoiceUseController; import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController; import com.cowr.local.ssjygl.stat.sale.OrderStatController; import com.cowr.ssjygl.stat.transfer.OrderTransferStatController; @@ -225,6 +226,7 @@ public class Config extends JFinalConfig { me.add("/stat/sale", OrderStatController.class); me.add("/stat/transfer", OrderTransferStatController.class); me.add("/stat/purchase", OrderPurchaseStatController.class); + me.add("/stat/invoiceuse", InvoiceUseController.class); // -- 发票管理 me.add("/invoice/log", InvoiceLogController.class); @@ -354,9 +356,9 @@ public class Config extends JFinalConfig { System.exit(0); } else { log.info("===================================================="); - log.info("============= 启动 %s %s 服务 ================", CliCacheData.SUP.getId(), CliCacheData.SUP.getName()); + log.info("============= 启动 %s %s 服务 ================", CliCacheData.SUP.getId(), CliCacheData.SUP.getName()); log.info("===================================================="); - log.info("============= 最大限重 %s 吨 =================", configprop.getInt("weigh.max")); + log.info("============= 最大限重 %s 吨 =================", configprop.getInt("weigh.max")); log.info("===================================================="); } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Main.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Main.java index 143ae21..5d24493 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Main.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Main.java @@ -22,8 +22,8 @@ public class Main { */ log.info("===================================================="); - log.info("========= 启动本地服务 =============="); - log.info("========= PID: %s ===============", pid); + log.info("========= 启动本地服务 =============="); + log.info("========= PID: %s ==============", pid); boolean isprod = Config.isProd(); String path = PathKit.getWebRootPath(); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java index 36da5c1..2b9f272 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java @@ -632,7 +632,7 @@ public class OrderTempSyncService { InvoiceReceive receive = null; // 2020-09-29 需要开具专票的,先开具结算单,不打发票 - // 2020-10-12 所有超市都可以开结算单 + // 2020-10-12 所有砂站都可以开结算单 if (customer.getInvoiceType() == 2) { order.setInvoiceType(2); // 需要专票的,在结算开了专票之后,再修改 invoice_site 字段 diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java index 47e990d..a727944 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java @@ -110,7 +110,7 @@ public class InvoiceLogSyncService extends BaseSyncService { } - // 将订单同步到不同的超市 + // 将订单同步到不同的砂站 for (Map.Entry entry : map.entrySet()) { if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) { return false; @@ -137,11 +137,11 @@ public class InvoiceLogSyncService extends BaseSyncService { Supermarket supermarket = Supermarket.dao.findById(supermarket_id); if (supermarket == null) { - return Result.failed("未找到超市信息"); + return Result.failed("未找到砂站信息"); } // 先判断这张发票有没有被领用 - InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(supermarket_id, invoice_number, code); + InvoiceReceive receive = InvoiceReceiveService.me.checkSurplusReceive(supermarket_id, invoice_number, code); if (receive == null) { return Result.failed("没有有效的发票领用记录,或者发票已经被使用"); } @@ -175,10 +175,12 @@ public class InvoiceLogSyncService extends BaseSyncService { receive.setSurplus(receive.getSurplus() - 1); receive.setInvalidCount(receive.getInvalidCount() + 1); - if (receive.getSurplus() == 0) { + if (receive.getSurplus() < 0) { + return Result.failed("作废失败,减少剩余量时发生错误"); + } else if (receive.getSurplus() == 0) { // 作废最后一张发票,当前发票停再最后一个发票号码上 receive.setCurrentCode(receive.getEndCode()); - } else { + } else{ if (code.equals(receive.getStartCode())) { // 作废第一张发票 receive.setCurrentCode(String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode()) + 1)); } else if (code.equals(receive.getCurrentCode())) { // 作废顺延的下一张发票 @@ -435,7 +437,7 @@ public class InvoiceLogSyncService extends BaseSyncService { } } - // 将订单同步到不同的超市 + // 将订单同步到不同的砂站 for (Map.Entry entry : map.entrySet()) { if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) { return false; diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/CheckUndonOrderclusterJob.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/CheckUndonOrderclusterJob.java index 17b4686..08f94dc 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/CheckUndonOrderclusterJob.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/CheckUndonOrderclusterJob.java @@ -65,7 +65,7 @@ public class CheckUndonOrderclusterJob implements Job { } } - // 各个超市分开同步 + // 各个砂站分开同步 for (Map.Entry entry : syncmap.entrySet()) { if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) { return false; diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java index 9ef947c..58291c5 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java @@ -50,6 +50,7 @@ import com.cowr.ssjygl.cctv.CctvController; import com.cowr.service.ssjygl.prepay.PrepayController; import com.cowr.service.ssjygl.overall.OverallController; import com.cowr.ssjygl.modifylog.ModifyLogController; +import com.cowr.ssjygl.stat.invoice.InvoiceUseController; import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController; import com.cowr.service.ssjygl.stat.sale.OrderStatController; import com.cowr.ssjygl.stat.transfer.OrderTransferStatController; @@ -192,6 +193,7 @@ public class Config extends JFinalConfig { me.add("/stat/sale", OrderStatController.class); me.add("/stat/transfer", OrderTransferStatController.class); me.add("/stat/purchase", OrderPurchaseStatController.class); + me.add("/stat/invoiceuse", InvoiceUseController.class); // -- 发票管理 me.add("/invoice/log", InvoiceLogController.class); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java index fa0984c..c96e9b0 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java @@ -96,7 +96,7 @@ public class OrderclusterSyncService extends BaseSyncService { } if (chksup.contains(supermarket_id)) { - return Result.failed("同一个客户不能重复给超市分配配额"); + return Result.failed("同一个客户不能重复给砂站分配配额"); } else { chksup.add(supermarket_id); @@ -112,7 +112,7 @@ public class OrderclusterSyncService extends BaseSyncService { } if (total_weight == 0) { - log.debug("重量为 0 的超市(id:%s)跳过", supermarket_id); + log.debug("重量为 0 的砂站(id:%s)跳过", supermarket_id); continue; } @@ -209,7 +209,7 @@ public class OrderclusterSyncService extends BaseSyncService { syncmap.get(model.getSupermarketId()).addSaveData(model); } - // 将订单同步到不同的超市 + // 将订单同步到不同的砂站 for (Map.Entry entry : syncmap.entrySet()) { if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) { return false; @@ -245,6 +245,7 @@ public class OrderclusterSyncService extends BaseSyncService { String trucks, Sysuser sysuser ) { + String query_cutoff_time = DateTimeUtil.sdf.get().format(cutoff_time); Supermarket supermarket = SvrCacheData.SUP_CACHE.get(supermarket_id); if (supermarket == null) { return Result.failed("砂站信息无效"); @@ -254,10 +255,10 @@ public class OrderclusterSyncService extends BaseSyncService { return Result.failedstr("[%s]砂站还未部署", supermarket.getName()); } - List undonlist = OrderclusterService.me.undonlist(supermarket_id, customer_name); + List undonlist = OrderclusterService.me.undonlist(supermarket_id, customer_name, query_cutoff_time); if (undonlist != null && !undonlist.isEmpty()) { - return Result.failedstr("客户[%s]在砂站[%s]还有未完成的配额", customer_name, SvrCacheData.SUP_CACHE.get(supermarket_id).getName()); + return Result.failedstr("客户[%s][%s]在砂站[%s]还有未完成的配额", customer_name, query_cutoff_time, SvrCacheData.SUP_CACHE.get(supermarket_id).getName()); } Product product = Product.dao.findById(Const.DEFAULT_PRODUCT_ID); @@ -305,7 +306,7 @@ public class OrderclusterSyncService extends BaseSyncService { return Result.failed(StrKit.join(ts, ",") + " 车牌号在黑名单中"); } - ts.add(0, DateTimeUtil.sdf.get().format(cutoff_time) + "%"); + ts.add(0, query_cutoff_time + "%"); List chkduk = Db.find( "select * from ordercluster_truck t \n" + " left join ordercluster c on c.id = t.ordercluster_id\n" + From 4b565e841f34f32c619b5996982a71ba543dfa0d Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Sat, 31 Oct 2020 13:50:25 +0800 Subject: [PATCH 02/10] . --- .../src/main/java/com/cowr/common/plugin/NettyServerPlugin.java | 2 +- .../src/main/java/com/cowr/local/ssjygl/netty/NettyClient.java | 2 +- .../main/java/com/cowr/service/ssjygl/netty/NettyServer.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/common/plugin/NettyServerPlugin.java b/ssjygl-xsx-common/src/main/java/com/cowr/common/plugin/NettyServerPlugin.java index 0076932..9761d60 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/common/plugin/NettyServerPlugin.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/common/plugin/NettyServerPlugin.java @@ -42,7 +42,7 @@ public class NettyServerPlugin implements IPlugin { ch.pipeline().addLast( new IdleStateHandler(5, 5, 5), new StringEncoder(CharsetUtil.UTF_8), - new LineBasedFrameDecoder(4096), + new LineBasedFrameDecoder(1024 * 4096), new StringDecoder(CharsetUtil.UTF_8), new MsgHandler() ); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/netty/NettyClient.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/netty/NettyClient.java index 272aa30..b4248a1 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/netty/NettyClient.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/netty/NettyClient.java @@ -78,7 +78,7 @@ public class NettyClient { new ReadTimeoutHandler(15), new IdleStateHandler(5, 5, 5), // 处理心跳包 new StringEncoder(CharsetUtil.UTF_8), - new LineBasedFrameDecoder(20 * 4096), // 处理粘包问题 // 数据内容超过这里设置的值,会导致数据发送失败 + new LineBasedFrameDecoder(1024 * 4096), // 处理粘包问题 // 数据内容超过这里设置的值,会导致数据发送失败 new StringDecoder(CharsetUtil.UTF_8), new MsgHandler(supermarket_id) ); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/netty/NettyServer.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/netty/NettyServer.java index 4410698..5ecf119 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/netty/NettyServer.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/netty/NettyServer.java @@ -79,7 +79,7 @@ public class NettyServer { ch.pipeline().addLast( new IdleStateHandler(5, 5, 5), // 处理心跳包 new StringEncoder(CharsetUtil.UTF_8), - new LineBasedFrameDecoder(20 * 4096), // 处理粘包问题 // 数据内容超过这里设置的值,会导致数据发送失败 + new LineBasedFrameDecoder(1024 * 4096), // 处理粘包问题 // 数据内容超过这里设置的值,会导致数据发送失败 new StringDecoder(CharsetUtil.UTF_8), new MsgHandler() ); From 051be87f3cc4d436fe628a3817fed3415af7dffc Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Mon, 2 Nov 2020 10:02:58 +0800 Subject: [PATCH 03/10] . --- .../cowr/common/view/ReportExcelStyle.java | 35 +++ .../truck/OrderclusterTruckService.java | 33 ++- .../cowr/ssjygl/overall/OverallService.java | 1 + .../ssjygl/stat/sale/OrderStatService.java | 193 +++++++++++++++- .../truck/OrderclusterTruckController.java | 8 +- .../ssjygl/stat/sale/OrderStatController.java | 23 ++ .../ssjygl/synctask/SyncTaskService.java | 14 ++ .../service/ssjygl/netty/NettyServer.java | 2 + .../EditTempClusterValidator.java | 21 ++ .../ordercluster/OrderclusterController.java | 15 ++ .../ordercluster/OrderclusterSyncService.java | 216 +++++++++++++++++- .../truck/OrderclusterTruckController.java | 8 +- .../truck/OrderclusterTruckSyncService.java | 38 ++- .../ssjygl/stat/sale/OrderStatController.java | 17 ++ .../ssjygl/synctask/SyncTaskService.java | 22 ++ 15 files changed, 626 insertions(+), 20 deletions(-) create mode 100644 ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/EditTempClusterValidator.java diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/common/view/ReportExcelStyle.java b/ssjygl-xsx-common/src/main/java/com/cowr/common/view/ReportExcelStyle.java index 671c4ba..4907f4b 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/common/view/ReportExcelStyle.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/common/view/ReportExcelStyle.java @@ -129,4 +129,39 @@ public class ReportExcelStyle { sheet.getLastRowNum() //end row ); } + + public static void setCommonCellStyle( + Workbook wb, + Sheet sheet, + int datalen, + int end_col + ){ + // 通用单元格格式 + Font font = wb.createFont(); + CellStyle cellStyle = wb.createCellStyle(); + font.setFontHeight((short) (10 * 20)); + font.setFontName("宋体"); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + cellStyle.setFont(font); + + Row row; + + // 设置通用单元格格式 + for (int r = 0; r < datalen + 1; r++) { + row = sheet.getRow(r); + if (row == null) { + row = sheet.createRow(r); + } + + for (int c = 0; c < end_col + 1; c++) { + Cell cell = row.getCell(c); + + if (cell == null) { + cell = row.createCell(c); + } + cell.setCellStyle(cellStyle); + } + } + } } diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java index 33ac5bd..33634d4 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java @@ -26,10 +26,32 @@ import java.util.List; public class OrderclusterTruckService extends BaseService { public static final OrderclusterTruckService me = new OrderclusterTruckService(); - public Page find(PageParam pp) { - String selectsql = "select * "; - String fromsql = "from ordercluster_truck t where 1=1 "; - List paraList = new ArrayList<>(); + public Page find(PageParam pp, String stm, String etm, String customer_name, String truck_license) { + String selectsql = "select * "; + String fromsql = "from ordercluster_truck t \n" + + " left join ordercluster c on c.id = t.ordercluster_id \n" + + " where 1=1 "; + List paraList = new ArrayList<>(); + + if (StrKit.notBlank(stm)) { + fromsql += " and c.cutoff_time >= ? \n"; + paraList.add(stm); + } + + if (StrKit.notBlank(etm)) { + fromsql += " and c.cutoff_time <= ? \n"; + paraList.add(etm); + } + + if (StrKit.notBlank(customer_name)) { + fromsql += " and c.customer_name like ? \n"; + paraList.add("%" + customer_name.trim() + "%"); + } + + if (StrKit.notBlank(truck_license)) { + fromsql += " and t.truck_license like ? \n"; + paraList.add("%" + truck_license.trim() + "%"); + } String totalRowSql = "select count(*) " + fromsql; String findSql = selectsql + fromsql; @@ -43,6 +65,8 @@ public class OrderclusterTruckService extends BaseService { } else { findSql += " " + Const.ORDER_BY_DESC; } + } else { + findSql += " order by c.cutoff_time desc"; } return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray()); @@ -54,6 +78,7 @@ public class OrderclusterTruckService extends BaseService { /** * 验证车牌号是不是再当天有运输任务 + * * @param supermarket_id * @param truck_license * @return diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java index 6b79f16..56c53bd 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java @@ -5,6 +5,7 @@ import com.cowr.common.utils.DateTimeUtil; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Record; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java index 13d9669..57404b9 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java @@ -12,8 +12,10 @@ import com.jfinal.log.Log; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Record; 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.util.*; public class OrderStatService { @@ -285,8 +287,6 @@ public class OrderStatService { double sum_weight = 0.0; double sum_price = 0.0; - double sum_distance = 0.0; - double sum_trans_price = 0.0; double isprepaid_sum_price = 0.0; int datalen = list.size(); int end_col = sup_name == null ? 11 : 10; @@ -296,8 +296,6 @@ public class OrderStatService { sum_weight += DataUtil.getDefaultByRecord(order, "weight"); sum_price += DataUtil.getDefaultByRecord(order, "total_price"); - sum_distance += DataUtil.getDefaultByRecord(order, "trans_distance"); - sum_trans_price += DataUtil.getDefaultByRecord(order, "trans_price"); if (order.getInt("isprepaid") == 1) { isprepaid_sum_price += DataUtil.getDefaultByRecord(order, "total_price"); @@ -306,6 +304,11 @@ public class OrderStatService { row = sheet.createRow(i + 3); a = 0; row.createCell(a++).setCellValue(i + 1); + + if (order.get("in_time") == null) { + log.error("有 transport 未同步成功 %s", order.toJson()); + } + row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("in_time"))); row.createCell(a++).setCellValue(order.getStr("sn")); row.createCell(a++).setCellValue(order.getStr("product_name")); @@ -1441,4 +1444,186 @@ public class OrderStatService { return wb; } + + public List yearStatBySup(String year) { + List list; + if (StrKit.notBlank(year)) { + list = Db.find("select s.name, a.* from supermarket s\n" + + "left join (\n" + + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + + " where t.state = 5\n" + + " and t.create_time like ? \n" + + " group by t.supermarket_id\n" + + ") a on s.id = a.id", year + "%"); + } else { + list = Db.find("select s.name, a.* from supermarket s\n" + + "left join (\n" + + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + + " where t.state = 5\n" + + " group by t.supermarket_id\n" + + ") a on s.id = a.id"); + } + + Record hj = new Record(); + hj.set("id", 0); + hj.set("name", "合计"); + hj.set("cnt", 0); + hj.set("total_price", new BigDecimal(0)); + hj.set("total_weight", new BigDecimal(0)); + + for (Record record : list) { + hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt")); + hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price"))); + hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight"))); + } + + list.add(hj); + + return list; + } + + public Workbook yearStatBySupExport(String year) { + List list = yearStatBySup(year); + Workbook wb = new XSSFWorkbook(); + Sheet sheet; + + if (StrKit.notBlank(year)) { + sheet = wb.createSheet(year + "年销售汇总"); + } else { + sheet = wb.createSheet("销售汇总"); + } + + + // 表头 start + Row row = sheet.createRow(0); + int a = 0; + row.createCell(a++).setCellValue("名称"); + row.createCell(a++).setCellValue("订单量"); + row.createCell(a++).setCellValue("总销售吨数"); + row.createCell(a++).setCellValue("总销售额"); + + int end_col = 4; + int datalen = list.size(); + for (int i = 0; i < datalen; i++) { + Record order = list.get(i); + + row = sheet.createRow(i + 1); + a = 0; + row.createCell(a++).setCellValue(order.getStr("name")); + row.createCell(a++).setCellValue(order.getInt("cnt")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price")); + } + + ReportExcelStyle.setCommonCellStyle(wb, sheet, datalen, end_col); + + return wb; + } + + public List yearStatByCustomer(String year) { + List list; + if (StrKit.notBlank(year)) { + list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + + " where t.state = 5\n" + + " and t.create_time like ? \n" + + " group by t.customer_id\n" + + " ) a\n" + + " left join customer c on c.id = a.id\n" + + " left join prepay_customer p on p.customer_id = a.id", year + "%"); + } else { + list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + + " where t.state = 5\n" + + " group by t.customer_id\n" + + " ) a\n" + + " left join customer c on c.id = a.id\n" + + " left join prepay_customer p on p.customer_id = a.id"); + } + + Record hj = new Record(); + hj.set("id", 0); + hj.set("name", "合计"); + hj.set("cnt", 0); + hj.set("total_price", new BigDecimal(0)); + hj.set("total_weight", new BigDecimal(0)); + hj.set("total_weight", new BigDecimal(0)); + hj.set("total_surplus", new BigDecimal(0)); + + for (Record record : list) { + hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt")); + hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price"))); + hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight"))); + + if (record.get("total_surplus") != null) { + hj.set("total_surplus", hj.getBigDecimal("total_surplus").add(record.getBigDecimal("total_surplus"))); + } + } + + hj.set("total_account_surplus", hj.getBigDecimal("total_surplus").add(hj.getBigDecimal("total_price"))); + + list.add(hj); + + return list; + } + + + public Workbook yearStatByCustomerExport(String year) { + List list = yearStatByCustomer(year); + Workbook wb = new XSSFWorkbook(); + Sheet sheet; + + if (StrKit.notBlank(year)) { + sheet = wb.createSheet(year + "年销售汇总"); + } else { + sheet = wb.createSheet("销售汇总"); + } + + + // 表头 start + Row row = sheet.createRow(0); + int a = 0; + row.createCell(a++).setCellValue("名称"); + row.createCell(a++).setCellValue("订单量"); + row.createCell(a++).setCellValue("总销售吨数"); + row.createCell(a++).setCellValue("总销售额"); + row.createCell(a++).setCellValue("客户总余额"); + + int end_col = 5; + int datalen = list.size(); + Record hj = null; + + for (int i = 0; i < datalen; i++) { + Record order = list.get(i); + + row = sheet.createRow(i + 1); + a = 0; + + if (order.getInt("id") == 0) { + hj = order; + } + + row.createCell(a++).setCellValue(order.getStr("name")); + row.createCell(a++).setCellValue(order.getInt("cnt")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_surplus")); + } + + if (hj != null) { + row = sheet.createRow(datalen + 1); + a = 0; + + row.createCell(a++).setCellValue("账户总余额"); + row.createCell(a++).setCellValue(""); + row.createCell(a++).setCellValue(""); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(hj, "total_account_surplus")); + row.createCell(a++).setCellValue(""); + } + + sheet.addMergedRegion(new CellRangeAddress(datalen + 1, datalen + 1, 3, 4));// 下标从0开始 起始行号,终止行号, 起始列号,终止列号 + ReportExcelStyle.setCommonCellStyle(wb, sheet, datalen + 1, end_col); + + return wb; + } } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java index 096edaf..f29b3f7 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java @@ -33,8 +33,12 @@ public class OrderclusterTruckController extends Controller { * 分页查找 ordercluster_truck 订单相关 - 订单派车 */ public void find() { - PageParam pp = getBean(PageParam.class, "", true); - renderJson(Result.object(OrderclusterTruckService.me.find(pp))); + PageParam pp = getBean(PageParam.class, "", true); + String stm = get("stm"); + String etm = get("etm"); + String customer_name = get("customer_name"); + String truck_license = get("truck_license"); + renderJson(Result.object(OrderclusterTruckService.me.find(pp, stm, etm, customer_name, truck_license))); } /** diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java index 03b0e75..1f6b69a 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java @@ -4,6 +4,7 @@ import com.cowr.common.base.BaseController; import com.cowr.common.validator.DayValidator; import com.cowr.common.validator.MonthValidator; import com.cowr.common.validator.StartAndEndIntervalValidator; +import com.cowr.common.validator.YearValidator; import com.cowr.common.view.ExcelRender; import com.cowr.common.view.Result; import com.cowr.ssjygl.stat.sale.OrderStatService; @@ -279,4 +280,26 @@ public class OrderStatController extends BaseController { render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } + + public void statYearCustomer() { + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + if (export == 0) { + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm))); + } else { + Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm); + render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); + } + } + + public void statYearBySup() { + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + if (export == 0) { + renderJson(Result.object(OrderStatService.me.yearStatBySup(tm))); + } else { + Workbook wb = OrderStatService.me.yearStatBySupExport(tm); + render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); + } + } } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/synctask/SyncTaskService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/synctask/SyncTaskService.java index b7855db..f719598 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/synctask/SyncTaskService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/synctask/SyncTaskService.java @@ -174,6 +174,13 @@ public class SyncTaskService { if (ret.length != list.size()) { return false; } + + for (int i : ret) { + // 必须是每条 sql 修改一条记录 + if (i != 1) { + return false; + } + } } } @@ -196,6 +203,13 @@ public class SyncTaskService { if (ret.length != list.size()) { return false; } + + for (int i : ret) { + // 必须是每条 sql 修改一条记录 + if (i != 1) { + return false; + } + } } } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/netty/NettyServer.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/netty/NettyServer.java index 5ecf119..b97f9fc 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/netty/NettyServer.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/netty/NettyServer.java @@ -221,6 +221,8 @@ public class NettyServer { .fluentPut("target", Enums.MsgTarget.SYNCRECV) .fluentPut("id", data.get("id")) .toJSONString()); + } else { + log.debug("数据接收后,入库失败:", msg); } } else if (Enums.MsgTarget.SYNCRECV.name().equals(target)) { SyncTaskService.me.syncComplete(json.getString("id")); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/EditTempClusterValidator.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/EditTempClusterValidator.java new file mode 100644 index 0000000..117affd --- /dev/null +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/EditTempClusterValidator.java @@ -0,0 +1,21 @@ +package com.cowr.service.ssjygl.order.ordercluster; + +import com.cowr.common.validator.CrudParamValidator; +import com.cowr.common.view.Result; +import com.jfinal.core.Controller; +import com.jfinal.kit.StrKit; + +public class EditTempClusterValidator extends CrudParamValidator { + @Override + protected void validate(Controller c) { + validateRequired("id", "id", "id 必填"); + validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647"); + validateBigDecimal("total_weight", new java.math.BigDecimal("0.01"), new java.math.BigDecimal(9.9999999999E10), "total_weight", "total_weight 范围 0.01~9.9999999999E10"); + validateString("trucks", 1, 2000, "trucks", "trucks 长度 1~2000"); + } + + @Override + protected void handleError(Controller c) { + c.renderJson(Result.failed(getErrmsg())); + } +} diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java index 036f968..204ff78 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java @@ -94,6 +94,21 @@ public class OrderclusterController extends BaseController { renderJson(OrderclusterSyncService.me.update(model, tokenuser)); } + @Before(EditTempClusterValidator.class) + public void editTemp() { + Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); + + if (tokenuser == null) { + renderJson(Result.noauth()); + return; + } + + Ordercluster model = getModel(Ordercluster.class, "", true); // 忽略不在model中的字段 + String trucks = get("trucks"); + + renderJson(OrderclusterSyncService.me.updateTemp(model, trucks, tokenuser)); + } + /** * 分页查找 ordercluster 订单簇 - 集团客户订单 */ diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java index c96e9b0..35b1e62 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java @@ -245,8 +245,8 @@ public class OrderclusterSyncService extends BaseSyncService { String trucks, Sysuser sysuser ) { - String query_cutoff_time = DateTimeUtil.sdf.get().format(cutoff_time); - Supermarket supermarket = SvrCacheData.SUP_CACHE.get(supermarket_id); + String query_cutoff_time = DateTimeUtil.sdf.get().format(cutoff_time); + Supermarket supermarket = SvrCacheData.SUP_CACHE.get(supermarket_id); if (supermarket == null) { return Result.failed("砂站信息无效"); } @@ -315,16 +315,20 @@ public class OrderclusterSyncService extends BaseSyncService { " and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray()); if (chkduk != null && !chkduk.isEmpty()) { - ts = new ArrayList<>(); + List outerr = new ArrayList<>(); for (Record bl : chkduk) { - ts.add(bl.get("truck_license")); + outerr.add(String.format( + "[%s]已经在[%s]分配给了[%s]", + bl.get("truck_license"), + DateTimeUtil.sdfymd.get().format(bl.get("cutoff_time")), + bl.get("customer_name") + )); } - return Result.failed(StrKit.join(ts, ",") + " 车牌号已经分配给其他客户"); + return Result.failed(StrKit.join(outerr, "。")); } - SyncTask synctask = new SyncTask(); Ordercluster model = new Ordercluster(); model.setCustomerName(customer_name); @@ -511,6 +515,202 @@ public class OrderclusterSyncService extends BaseSyncService { } } + + public Result updateTemp(Ordercluster model, String trucks, Sysuser sysuser) { + Ordercluster oldobj = model.findByPk(); + + if (oldobj == null) { + return Result.failed(false, "按主键未找到对应记录"); + } + + if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) { + return Result.failed(false, "订单已完成,不能修改"); + } + + BigDecimal overweight = OrderclusterService.me.getOverWeight(model.getId()); // 集团订单已完成量 + + if (model.getTotalWeight().compareTo(overweight) < 0) { + return Result.failedstr("总量不能低于已运输量(%.2f)", overweight); + } else { + oldobj.setTotalWeight(model.getTotalWeight()); + } + + String query_cutoff_time = DateTimeUtil.sdf.get().format(oldobj.getCutoffTime()); + List chk = new ArrayList<>(); + String[] truckarr = trucks.split(","); + List ts = new ArrayList<>(); + List tsql = new ArrayList<>(); + + // 检查提交上来的车辆字符串是否用重复的 + for (String truck_license : truckarr) { + if (chk.contains(truck_license)) { + return Result.failedstr("车牌号 %s 重复", truck_license); + } + + chk.add(truck_license); + + ts.add(truck_license); + tsql.add("?"); + } + + // 检查是否还在黑名单中,未被移除 + List list = Blacklist.dao.find( + "select * from blacklist \n" + + " where remove_user_id is null \n" + + " and truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray()); + + if (list != null && !list.isEmpty()) { + List retts = new ArrayList<>(); + + for (Blacklist bl : list) { + retts.add(bl.getTruckLicense()); + } + + return Result.failed(StrKit.join(retts, ",") + " 车牌号在黑名单中"); + } + + ts.add(0, query_cutoff_time + "%"); + List chkduk = Db.find( + "select * from ordercluster_truck t \n" + + " left join ordercluster c on c.id = t.ordercluster_id\n" + + " where c.state < 5 \n" + // OrderStateEnum.RECEIVED.getStateid() + " and t.ordercluster_id <> " + oldobj.getId() + + " and c.cutoff_time like ? \n" + + " and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray()); + + if (chkduk != null && !chkduk.isEmpty()) { + List outerr = new ArrayList<>(); + + for (Record bl : chkduk) { + outerr.add(String.format( + "[%s]已经在[%s]分配给了[%s]", + bl.get("truck_license"), + DateTimeUtil.sdfymd.get().format(bl.get("cutoff_time")), + bl.get("customer_name") + )); + } + + return Result.failed(StrKit.join(outerr, "。")); + } + + // 查询已有的集团订单分配的车辆 + List otlist = OrderclusterTruck.dao.find( + "select * from ordercluster_truck \n" + + " where ordercluster_id = ? \n", oldobj.getId()); + + List dellist = new ArrayList<>(); + List chktpsql = new ArrayList<>(); + List chkold = new ArrayList<>(); + SyncTask synctask = new SyncTask(); + + // 数据库中,提交上的数据中没有的,要删掉 + for (OrderclusterTruck ot : otlist) { + if (!chk.contains(ot.getTruckLicense())) { + dellist.add(ot.getTruckLicense()); + chktpsql.add("?"); + synctask.addDeleteData(ot); + } else { + chkold.add(ot.getTruckLicense()); + } + } + + // 要删除的车辆没有结算,不能删除 + if (!dellist.isEmpty()) { + List querydel = new ArrayList<>(); + querydel.add(oldobj.getSupermarketId().toString()); + querydel.add(DateTimeUtil.sdf.get().format(oldobj.getCutoffTime()) + "%"); + querydel.addAll(dellist); + + List chktp = Transport.dao.find("select * from transport t \n" + + " where t.state < 5 \n" + + " and t.supermarket_id = ? \n" + + " and t.in_time like ? \n" + + " and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray()); + + if (!chktp.isEmpty()) { + List outerr = new ArrayList<>(); + + for (Transport tp : chktp) { + outerr.add(String.format("[%s]已进入[%s]砂站,删除后不能结算", tp.getTruckLicense(), SvrCacheData.SUP_CACHE.get(tp.getSupermarketId()).getName())); + } + + return Result.failed(StrKit.join(outerr, "\r\n")); + } + } + + List savelist = new ArrayList<>(); + + for (String truck_license : truckarr) { + // 已经在数据库中的,不再重复添加 + if (chkold.contains(truck_license)) { + continue; + } + + OrderclusterTruck oct = new OrderclusterTruck(); + oct.setId(StrKit.getRandomUUID()); + oct.setOrderclusterId(oldobj.getId()); + oct.setTruckLicense(truck_license); + + synctask.addSaveData(oct); + savelist.add(oct); + } + + try { + boolean ret = Db.tx(new IAtom() { + @Override + public boolean run() throws SQLException { + try { + if (!dellist.isEmpty()) { + int delret = Db.delete("delete from ordercluster_truck where ordercluster_id = " + oldobj.getId() + + " and truck_license in ('" + StrKit.join(dellist, "','") + "')"); + + log.debug("删除 ordercluster_truck %d", delret); + + if(delret != dellist.size()){ + return false; + } + } + + if (!savelist.isEmpty()) { + int[] ret = Db.batchSave(savelist, savelist.size()); + + for (int i : ret) { + // 必须是每条 sql 修改一条记录 + if (i != 1) { + return false; + } + } + } + + boolean ret = oldobj.update(); + + if (!ret) { + return false; + } + + synctask.addUpdateData(oldobj); + + return SyncTaskService.me.save(synctask, oldobj.getSupermarketId()) + && ModifyLogService.me.save(model, null, Enums.DataOpType.UPDATE.getId(), sysuser); + } catch (Exception e) { + log.error(e.getMessage(), e); + + return false; + } + } + }); + + if (ret) { + SyncTaskService.me.send(synctask); + } + + return ret ? Result.success(oldobj) : Result.failed("修改失败"); + } catch (Exception e) { + log.error(e.getMessage(), e); + return Result.failed("修改失败"); + } + } + public Result update(Ordercluster model, Sysuser sysuser) { Ordercluster oldobj = model.findByPk(); @@ -593,6 +793,10 @@ public class OrderclusterSyncService extends BaseSyncService { } }); + if (ret) { + SyncTaskService.me.send(synctask); + } + return ret ? Result.success(oldobj) : Result.failed("修改失败"); } catch (Exception e) { log.error(e.getMessage(), e); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java index 84e1e9a..2a32a55 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java @@ -70,8 +70,12 @@ public class OrderclusterTruckController extends Controller { * 分页查找 ordercluster_truck 订单相关 - 订单派车 */ public void find() { - PageParam pp = getBean(PageParam.class, "", true); - renderJson(Result.object(OrderclusterTruckService.me.find(pp))); + PageParam pp = getBean(PageParam.class, "", true); + String stm = get("stm"); + String etm = get("etm"); + String customer_name = get("customer_name"); + String truck_license = get("truck_license"); + renderJson(Result.object(OrderclusterTruckService.me.find(pp, stm, etm, customer_name, truck_license))); } /** diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckSyncService.java index c2d9be7..e5bbb6f 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckSyncService.java @@ -6,6 +6,7 @@ import com.cowr.common.utils.DateTimeUtil; import com.cowr.common.view.Result; import com.cowr.model.*; import com.cowr.service.ssjygl.base.BaseSyncService; +import com.cowr.service.ssjygl.main.SvrCacheData; import com.cowr.service.ssjygl.synctask.SyncTaskService; import com.cowr.ssjygl.modifylog.ModifyLogService; import com.jfinal.kit.StrKit; @@ -91,15 +92,20 @@ public class OrderclusterTruckSyncService extends BaseSyncService { retts.add(bl.get("truck_license")); } - return Result.failedstr("%s 已在[%s]分配", StrKit.join(retts, ","), DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime())); + return Result.failedstr( + "%s 已在[%s]分配", + StrKit.join(retts, ","), + DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()) + ); } - // 查询已有的集团订单 + // 查询已有的集团订单分配的车辆 List otlist = OrderclusterTruck.dao.find( "select * from ordercluster_truck \n" + " where ordercluster_id = ? \n", ordercluster_id); List dellist = new ArrayList<>(); + List chktpsql = new ArrayList<>(); List chkold = new ArrayList<>(); SyncTask synctask = new SyncTask(); @@ -107,12 +113,36 @@ public class OrderclusterTruckSyncService extends BaseSyncService { for (OrderclusterTruck ot : otlist) { if (!chk.contains(ot.getTruckLicense())) { dellist.add(ot.getTruckLicense()); + chktpsql.add("?"); synctask.addDeleteData(ot); } else { chkold.add(ot.getTruckLicense()); } } + // 要删除的车辆没有结算,不能删除 + if(!dellist.isEmpty()){ + List querydel = new ArrayList<>(); + querydel.add(ordercluster.getSupermarketId().toString()); + querydel.add(DateTimeUtil.sdf.get().format(ordercluster.getCutoffTime()) + "%"); + querydel.addAll(dellist); + List chktp = Transport.dao.find("select * from transport t \n" + + " where t.state < 5 \n" + + " and t.supermarket_id = ? \n" + + " and t.in_time like ? \n" + + " and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray()); + + if(!chktp.isEmpty()){ + List outerr = new ArrayList<>(); + + for(Transport tp : chktp){ + outerr.add(String.format("[%s]已进入[%s]砂站,删除后不能结算", tp.getTruckLicense(), SvrCacheData.SUP_CACHE.get(tp.getSupermarketId()).getName())); + } + + return Result.failed(StrKit.join(outerr, "\r\n")); + } + } + List savelist = new ArrayList<>(); for (String truck_license : truckarr) { @@ -151,6 +181,10 @@ public class OrderclusterTruckSyncService extends BaseSyncService { " and truck_license in ('" + StrKit.join(dellist, "','") + "')"); log.debug("删除 ordercluster_truck %d", delret); + + if(delret != dellist.size()){ + return false; + } } if (!savelist.isEmpty()) { diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java index e9fe5ee..2992912 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java @@ -5,6 +5,7 @@ import com.cowr.common.enums.UserTypeEnum; import com.cowr.common.validator.DayValidator; import com.cowr.common.validator.MonthValidator; import com.cowr.common.validator.StartAndEndIntervalValidator; +import com.cowr.common.validator.YearValidator; import com.cowr.common.view.ExcelRender; import com.cowr.common.view.Result; import com.cowr.model.Sysuser; @@ -340,4 +341,20 @@ public class OrderStatController extends BaseController { render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } + + public void statYearCustomer() { + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + if (export == 0) { + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm))); + } + } + + public void statYearBySup() { + String tm = get("tm"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + if (export == 0) { + renderJson(Result.object(OrderStatService.me.yearStatBySup(tm))); + } + } } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/synctask/SyncTaskService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/synctask/SyncTaskService.java index 99803de..53dbd57 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/synctask/SyncTaskService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/synctask/SyncTaskService.java @@ -161,6 +161,7 @@ public class SyncTaskService { /** * 按砂站ID去找未完成的,避免一个砂站有过多的未完成堆积,导致其他的不能下发 + * * @param supermarket_id */ public void task(int supermarket_id) { @@ -246,6 +247,13 @@ public class SyncTaskService { if (ret.length != list.size()) { return false; } + + for (int i : ret) { + // 必须是每条 sql 修改一条记录 + if (i != 1) { + return false; + } + } } } @@ -267,6 +275,13 @@ public class SyncTaskService { if (ret.length != list.size()) { return false; } + + for (int i : ret) { + // 必须是每条 sql 修改一条记录 + if (i != 1) { + return false; + } + } } } @@ -368,6 +383,13 @@ public class SyncTaskService { if (ret.length != sts.size()) { return false; } + + for (int i : ret) { + // 必须是每条 sql 修改一条记录 + if (i != 1) { + return false; + } + } } } From 4d59db756867f67dd7e2cd4b9f1478c7509f4c57 Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Mon, 2 Nov 2020 16:22:00 +0800 Subject: [PATCH 04/10] . --- .../stat/invoice/InvoiceUseService.java | 10 + .../ordercluster/ForwardClusterValidator.java | 26 ++ .../ordercluster/ForwardTempValidator.java | 28 ++ .../ordercluster/OrderclusterController.java | 40 +- .../ordercluster/OrderclusterSyncService.java | 414 +++++++++++++++++- 5 files changed, 514 insertions(+), 4 deletions(-) create mode 100644 ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/ForwardClusterValidator.java create mode 100644 ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/ForwardTempValidator.java diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java index f07c6e2..cc6a152 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java @@ -18,6 +18,16 @@ public class InvoiceUseService { /** * 票据使用情况统计 + * @param tm 日期 yyyy-DD-dd + * @param supermarket_id 砂站id + * @param invoice_type 发票类型 1 普票、2 专票 + * @param invoice_number 发票代码 + * @param invoice_code 发票号码 + * @param invoice_state 发票状态 5 已使用 9 已取消 + * @param order_sn 订单号 + * @param truck_license 车牌号 + * @param order_state 订单状态 5 已出货 9 已取消 + * @return */ public Record statuse( String tm, diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/ForwardClusterValidator.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/ForwardClusterValidator.java new file mode 100644 index 0000000..f1843d1 --- /dev/null +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/ForwardClusterValidator.java @@ -0,0 +1,26 @@ +package com.cowr.service.ssjygl.order.ordercluster; + +import com.cowr.common.utils.DateTimeUtil; +import com.cowr.common.validator.CrudParamValidator; +import com.cowr.common.view.Result; +import com.jfinal.core.Controller; +import com.jfinal.kit.StrKit; + +public class ForwardClusterValidator extends CrudParamValidator { + @Override + protected void validate(Controller c) { + validateRequired("id", "id", "id 必填"); + validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647"); + validateBigDecimal("total_weight", new java.math.BigDecimal("0.01"), new java.math.BigDecimal(9.9999999999E10), "total_weight", "total_weight 范围 0.01~9.9999999999E10"); + validateDate("cutoff_time", "yyyy-MM-dd HH:mm:ss", false, "cutoff_time", "cutoff_time 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整 + + if (StrKit.notBlank(c.get("cutoff_time")) && DateTimeUtil.isEarlyToday(c.get("cutoff_time"))) { + addError("cutoff_time", "截止时间不能早于今天"); + } + } + + @Override + protected void handleError(Controller c) { + c.renderJson(Result.failed(getErrmsg())); + } +} diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/ForwardTempValidator.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/ForwardTempValidator.java new file mode 100644 index 0000000..971d685 --- /dev/null +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/ForwardTempValidator.java @@ -0,0 +1,28 @@ +package com.cowr.service.ssjygl.order.ordercluster; + +import com.cowr.common.utils.DateTimeUtil; +import com.cowr.common.validator.CrudParamValidator; +import com.cowr.common.view.Result; +import com.jfinal.core.Controller; +import com.jfinal.kit.StrKit; + +public class ForwardTempValidator extends CrudParamValidator { + @Override + protected void validate(Controller c) { + validateRequired("id", "id", "id 必填"); + validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647"); + validateBigDecimal("total_weight", new java.math.BigDecimal("0.01"), new java.math.BigDecimal(9.9999999999E10), "total_weight", "total_weight 范围 0.01~9.9999999999E10"); + validateDate("cutoff_time", "yyyy-MM-dd HH:mm:ss", false, "cutoff_time", "cutoff_time 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整 + + if (StrKit.notBlank(c.get("cutoff_time")) && DateTimeUtil.isEarlyToday(c.get("cutoff_time"))) { + addError("cutoff_time", "截止时间不能早于今天"); + } + + validateString("trucks", 1, 2000, "trucks", "trucks 长度 1~2000"); + } + + @Override + protected void handleError(Controller c) { + c.renderJson(Result.failed(getErrmsg())); + } +} diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java index 204ff78..7b64f36 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java @@ -14,6 +14,7 @@ import com.cowr.ssjygl.order.ordercluster.OrderclusterValidator; import com.jfinal.aop.Before; import com.jfinal.log.Log; +import java.math.BigDecimal; import java.util.Date; public class OrderclusterController extends BaseController { @@ -91,7 +92,7 @@ public class OrderclusterController extends BaseController { } Ordercluster model = getModel(Ordercluster.class, "", true); // 忽略不在model中的字段 - renderJson(OrderclusterSyncService.me.update(model, tokenuser)); + renderJson(OrderclusterSyncService.me.updateCluster(model, tokenuser)); } @Before(EditTempClusterValidator.class) @@ -241,4 +242,41 @@ public class OrderclusterController extends BaseController { renderJson(Result.object(OrderclusterSyncService.me.complete(ordercluster_id, tokenuser))); } + + + /** + * 修改 ordercluster 订单簇 - 集团客户订单 + */ + @Before(ForwardClusterValidator.class) + public void forwardCluster() { + Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); + + if (tokenuser == null) { + renderJson(Result.noauth()); + return; + } + + int ordercluster_id = getInt("id"); + double total_weight = getParaToDouble("total_weight"); + Date cutoff_time = getDate("cutoff_time"); + + renderJson(OrderclusterSyncService.me.forwardCluster(ordercluster_id, new BigDecimal(total_weight), cutoff_time, tokenuser)); + } + + @Before(ForwardTempValidator.class) + public void forwardTemp() { + Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); + + if (tokenuser == null) { + renderJson(Result.noauth()); + return; + } + + int ordercluster_id = getInt("id"); + double total_weight = getParaToDouble("total_weight"); + Date cutoff_time = getDate("cutoff_time"); + String trucks = get("trucks"); + + renderJson(OrderclusterSyncService.me.forwardTemp(ordercluster_id, new BigDecimal(total_weight), cutoff_time, trucks, tokenuser)); + } } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java index 35b1e62..85fc7b6 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java @@ -666,7 +666,7 @@ public class OrderclusterSyncService extends BaseSyncService { log.debug("删除 ordercluster_truck %d", delret); - if(delret != dellist.size()){ + if (delret != dellist.size()) { return false; } } @@ -711,7 +711,7 @@ public class OrderclusterSyncService extends BaseSyncService { } } - public Result update(Ordercluster model, Sysuser sysuser) { + public Result updateCluster(Ordercluster model, Sysuser sysuser) { Ordercluster oldobj = model.findByPk(); if (oldobj == null) { @@ -747,7 +747,7 @@ public class OrderclusterSyncService extends BaseSyncService { BigDecimal overweight = OrderclusterService.me.getOverWeightByCustomer(oldobj.getCustomerId()); // 按客户找集团订单已完成量 if (plan_total_weight.subtract(overweight).multiply(oldobj.getUnitPrice()).compareTo(prepayCustomer.getSurplus()) > 0) { - return Result.failedstr("剩余总配额 %.2f,客户余额(%.2f)不足", plan_total_weight.subtract(overweight), prepayCustomer.getSurplus()); + return Result.failedstr("计划总配额 %.2f,超过了客户余额(%.2f)", plan_total_weight.subtract(overweight), prepayCustomer.getSurplus()); } } } @@ -851,6 +851,41 @@ public class OrderclusterSyncService extends BaseSyncService { if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) { return Result.failed("已经完结或者取消的,不能再修改"); } +/* + List otlist = OrderclusterTruck.dao.find( + "select * from ordercluster_truck \n" + + " where ordercluster_id = ? \n", oldobj.getId()); + + if (!otlist.isEmpty()) { + List trlist = new ArrayList<>(); + List chktpsql = new ArrayList<>(); + + // 数据库中,提交上的数据中没有的,要删掉 + for (OrderclusterTruck ot : otlist) { + trlist.add(ot.getTruckLicense()); + chktpsql.add("?"); + } + + List querydel = new ArrayList<>(); + querydel.add(oldobj.getSupermarketId().toString()); + querydel.add(DateTimeUtil.sdf.get().format(oldobj.getCutoffTime()) + "%"); + querydel.addAll(trlist); + + List chktp = Transport.dao.find("select * from transport t \n" + + " where t.state < 5 \n" + + " and t.supermarket_id = ? \n" + + " and t.in_time like ? \n" + + " and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray()); + + if (!chktp.isEmpty()) { + List errarr = new ArrayList<>(); + for (Transport t : chktp) { + errarr.add(t.getTruckLicense()); + } + + return Result.failedstr("配额中的车辆[%s]还未结算出场,或者砂站数据还未同步至结算中心,不能结束", StrKit.join(errarr, ",")); + } + }*/ oldobj.setState(OrderStateEnum.RECEIVED.getStateid()); // 将订单状态置为 5 oldobj.setCompleteTime(new Date()); @@ -878,4 +913,377 @@ public class OrderclusterSyncService extends BaseSyncService { return Result.failed("修改失败"); } } + + /** + * 固定购砂结转 + * + * @param ordercluster_id + * @param total_weight + * @param cutoff_time + * @param sysuser + * @return + */ + public Result forwardCluster(int ordercluster_id, BigDecimal total_weight, Date cutoff_time, Sysuser sysuser) { + Ordercluster oldobj = Ordercluster.dao.findById(ordercluster_id); + + if (oldobj == null) { + return Result.failed(false, "按主键未找到对应记录"); + } + + if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) { + return Result.failed("已经完结或者取消的,不能再修改"); + } + + if (oldobj.getCustomerId() == null) { + return Result.failed("固定供砂配额信息错误"); + } + + PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(oldobj.getCustomerId()); + if (prepayCustomer == null) { + return Result.failed("不是预付费用户"); + } + + // 按客户查询未完成的订单量 + List undonlist = OrderclusterService.me.undonlist(oldobj.getCustomerId()); + + if (undonlist != null && !undonlist.isEmpty()) { + BigDecimal plan_total_weight = total_weight; + + for (Record record : undonlist) { + if (oldobj.getId().equals(record.getInt("id"))) { + continue; // 当前修改的记录已经做为初始值了,不再累计 + } + + // 累加总量 + plan_total_weight = plan_total_weight.add(record.getBigDecimal("total_weight")); + } + + // 按客户统计已完成量 + BigDecimal overweight = OrderclusterService.me.getOverWeightByCustomer(oldobj.getCustomerId()); // 按客户找集团订单已完成量 + + if (plan_total_weight.subtract(overweight).multiply(oldobj.getUnitPrice()).compareTo(prepayCustomer.getSurplus()) > 0) { + return Result.failedstr("计划总配额 %.2f,超过了客户余额(%.2f)", plan_total_weight.subtract(overweight), prepayCustomer.getSurplus()); + } + } + + // 按客户统计已完成量 + BigDecimal over_weight = OrderclusterService.me.getOverWeight(oldobj.getId()); // 按客户找集团订单已完成量 + BigDecimal surplus_weight = oldobj.getTotalWeight().subtract(over_weight); // 剩余未完成量 + + /* + 1. total_weight >= surplus_weight 将旧的剩余量清 0 + 2. total_weight < surplus_weight 将旧的剩余量调整到 surplus_weight - total_weight + */ + + if (total_weight.compareTo(surplus_weight) >= 0) { + oldobj.setTotalWeight(over_weight); // 将总量设置成和已完成量一样,就是将余量设置为 0 了 + } else { + oldobj.setTotalWeight(surplus_weight.subtract(total_weight)); // 结转不完的,要留下 + } + + List octs = OrderclusterTruck.dao.find("select * from ordercluster_truck t where t.ordercluster_id = ?", ordercluster_id); + + if (!octs.isEmpty()) { + // 已有车辆的,在结转前,需要将已经分配其他集团订单的车辆去掉 + List ts = new ArrayList<>(); + List tsql = new ArrayList<>(); + Map delmap = new HashMap<>(); + + // 检查提交上来的车辆字符串是否用重复的 + for (int i = 0; i < octs.size(); i++) { + OrderclusterTruck oct = octs.get(i); + ts.add(oct.getTruckLicense()); + tsql.add("?"); + + delmap.put(oct.getTruckLicense(), i); + } + + ts.add(0, cutoff_time); // 加到查询参数里面 + ts.add(0, ordercluster_id); // 加到查询参数里面 + List chkduk = Db.find( + "select * from ordercluster_truck t\n" + + " left join ordercluster o on o.id = t.ordercluster_id\n" + + " where t.ordercluster_id <> ? \n" + + " and o.state < 5 \n" + + " and o.cutoff_time = ? \n" + + " and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray()); + + if (chkduk != null && !chkduk.isEmpty()) { + for (Record record : chkduk) { + if (delmap.containsKey(record.getStr("truck_license"))) { + octs.remove(delmap.get(record.getStr("truck_license")).intValue()); + } + } + } + } + + SyncTask synctask = new SyncTask(); + Date now = new Date(); + + boolean ret = Db.tx(new IAtom() { + @Override + public boolean run() throws SQLException { + try { + boolean ret = false; + + if (oldobj.getState() < OrderStateEnum.RECEIVED.getStateid()) { // 没有完结的进行完结,已经完结的就不动了 + oldobj.setState(OrderStateEnum.RECEIVED.getStateid()); // 将订单状态置为 5 + oldobj.setCompleteTime(now); + + ret = oldobj.update(); + + if (!ret) { + return false; + } + + synctask.addUpdateData(oldobj); + } + + Ordercluster forwardoldobj = Ordercluster.dao.findFirst( + "select * from ordercluster t \n" + + " where t.customer_id = ? \n" + + " and t.cutoff_time = ? \n" + + " and t.state < 5 limit 1", oldobj.getCustomerId(), cutoff_time); + + if (forwardoldobj == null) { + // 新建一个 + forwardoldobj = oldobj.clone(); + forwardoldobj.setId(null); // 等待数据库自增长 + forwardoldobj.setUuid(StrKit.getRandomUUID()); + forwardoldobj.setTotalWeight(total_weight); + forwardoldobj.setCutoffTime(cutoff_time); + forwardoldobj.setCreateTime(now); // 当前系统时间 + forwardoldobj.setCreateUserId(sysuser.getId()); // 当前用户id + forwardoldobj.setCreateUserName(sysuser.getName()); + forwardoldobj.setState(OrderStateEnum.INITIAL.getStateid()); // 新增固定为 1 + + ret = forwardoldobj.save(); + synctask.addSaveData(forwardoldobj); + } else { + // 已有的,直接更新重量 + forwardoldobj.setTotalWeight(total_weight); + + ret = forwardoldobj.update(); + synctask.addUpdateData(forwardoldobj); + } + + if (!ret) { + return false; + } + + if (!octs.isEmpty()) { + List savelist = new ArrayList<>(); + + for (int i = 0; i < octs.size(); i++) { + OrderclusterTruck oldoct = octs.get(i); + + OrderclusterTruck oct = new OrderclusterTruck(); + oct.setId(StrKit.getRandomUUID()); + oct.setOrderclusterId(forwardoldobj.getId()); + oct.setTruckLicense(oldoct.getTruckLicense()); + + synctask.addSaveData(oct); + savelist.add(oct); + } + + if (!savelist.isEmpty()) { + int[] retarr = Db.batchSave(savelist, savelist.size()); + + for (int i : retarr) { + // 必须是每条 sql 修改一条记录 + if (i != 1) { + return false; + } + } + } + } + + return SyncTaskService.me.save(synctask, forwardoldobj.getSupermarketId()); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + return false; + } + }); + + if (ret) { + SyncTaskService.me.send(synctask); + } + + return ret ? Result.success() : Result.failed("操作失败"); + } + + /** + * 临时购砂结转 + * + * @param ordercluster_id + * @param total_weight + * @param trucks + * @param cutoff_time + * @param sysuser + * @return + */ + public Result forwardTemp(int ordercluster_id, BigDecimal total_weight, Date cutoff_time, String trucks, Sysuser sysuser) { + Ordercluster oldobj = Ordercluster.dao.findById(ordercluster_id); + + if (oldobj == null) { + return Result.failed(false, "按主键未找到对应记录"); + } + + if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) { + return Result.failed("已经完结或者取消的,不能再修改"); + } + + // 按客户统计已完成量 + BigDecimal over_weight = OrderclusterService.me.getOverWeight(oldobj.getId()); // 按客户找集团订单已完成量 + BigDecimal surplus_weight = oldobj.getTotalWeight().subtract(over_weight); // 剩余未完成量 + + /* + 1. total_weight >= surplus_weight 将旧的剩余量清 0 + 2. total_weight < surplus_weight 将旧的剩余量调整到 surplus_weight - total_weight + */ + + if (total_weight.compareTo(surplus_weight) >= 0) { + oldobj.setTotalWeight(over_weight); // 将总量设置成和已完成量一样,就是将余量设置为 0 了 + } else { + oldobj.setTotalWeight(surplus_weight.subtract(total_weight)); // 结转不完的,要留下 + } + + String[] truckarr = trucks.split(","); + + // 已有车辆的,在结转前,需要将已经分配其他集团订单的车辆去掉 + List ts = new ArrayList<>(); + List tsql = new ArrayList<>(); + Map delmap = new HashMap<>(); + + // 检查提交上来的车辆字符串是否用重复的 + for (int i = 0; i < truckarr.length; i++) { + String truck_license = truckarr[i]; + ts.add(truck_license); + tsql.add("?"); + + delmap.put(truck_license, i); + } + + ts.add(0, cutoff_time); // 加到查询参数里面 + ts.add(0, ordercluster_id); // 加到查询参数里面 + List chkduk = Db.find( + "select * from ordercluster_truck t\n" + + " left join ordercluster o on o.id = t.ordercluster_id\n" + + " where t.ordercluster_id <> ? \n" + + " and o.state < 5 \n" + + " and o.cutoff_time = ? \n" + + " and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray()); + + if (chkduk != null && !chkduk.isEmpty()) { + for (Record record : chkduk) { + if (delmap.containsKey(record.getStr("truck_license"))) { + delmap.remove(record.getStr("truck_license")); + } + } + + String[] newarr = new String[delmap.keySet().size()]; + delmap.keySet().toArray(newarr); + truckarr = newarr; + } + + SyncTask synctask = new SyncTask(); + Date now = new Date(); + String[] finalTruckarr = truckarr; + + boolean ret = Db.tx(new IAtom() { + @Override + public boolean run() throws SQLException { + try { + boolean ret = false; + + if (oldobj.getState() < OrderStateEnum.RECEIVED.getStateid()) { // 没有完结的进行完结,已经完结的就不动了 + oldobj.setState(OrderStateEnum.RECEIVED.getStateid()); // 将订单状态置为 5 + oldobj.setCompleteTime(now); + + ret = oldobj.update(); + + if (!ret) { + return false; + } + + synctask.addUpdateData(oldobj); + } + + + Ordercluster forwardoldobj = Ordercluster.dao.findFirst( + "select * from ordercluster t \n" + + " where t.customer_name = ? \n" + + " and t.cutoff_time = ? \n" + + " and t.state < 5 limit 1", oldobj.getCustomerName(), cutoff_time); + + if (forwardoldobj == null) { + // 新建一个 + forwardoldobj = oldobj.clone(); + forwardoldobj.setId(null); // 等待数据库自增长 + forwardoldobj.setUuid(StrKit.getRandomUUID()); + forwardoldobj.setTotalWeight(total_weight); + forwardoldobj.setCutoffTime(cutoff_time); + forwardoldobj.setCreateTime(now); // 当前系统时间 + forwardoldobj.setCreateUserId(sysuser.getId()); // 当前用户id + forwardoldobj.setCreateUserName(sysuser.getName()); + forwardoldobj.setState(OrderStateEnum.INITIAL.getStateid()); // 新增固定为 1 + + ret = forwardoldobj.save(); + synctask.addSaveData(forwardoldobj); + } else { + // 已有的,直接更新重量 + forwardoldobj.setTotalWeight(total_weight); + + ret = forwardoldobj.update(); + synctask.addUpdateData(forwardoldobj); + } + + if (!ret) { + return false; + } + + if (finalTruckarr.length > 0) { + List savelist = new ArrayList<>(); + + for (int i = 0; i < finalTruckarr.length; i++) { + String truck_license = finalTruckarr[i]; + + OrderclusterTruck oct = new OrderclusterTruck(); + oct.setId(StrKit.getRandomUUID()); + oct.setOrderclusterId(forwardoldobj.getId()); + oct.setTruckLicense(truck_license); + + synctask.addSaveData(oct); + savelist.add(oct); + } + + if (!savelist.isEmpty()) { + int[] retarr = Db.batchSave(savelist, savelist.size()); + + for (int i : retarr) { + // 必须是每条 sql 修改一条记录 + if (i != 1) { + return false; + } + } + } + } + + return SyncTaskService.me.save(synctask, forwardoldobj.getSupermarketId()); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + return false; + } + }); + + if (ret) { + SyncTaskService.me.send(synctask); + } + + return ret ? Result.success() : Result.failed("操作失败"); + } } From 03b7478252632def240cb6ae624439c369703d95 Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Mon, 2 Nov 2020 16:30:40 +0800 Subject: [PATCH 05/10] . --- .../ordercluster/OrderclusterSyncService.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java index 85fc7b6..cbad68d 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java @@ -916,10 +916,11 @@ public class OrderclusterSyncService extends BaseSyncService { /** * 固定购砂结转 + * /order/ordercluster/forwardCluster * - * @param ordercluster_id - * @param total_weight - * @param cutoff_time + * @param ordercluster_id ordercluster 的 id + * @param total_weight 结转的重量,默认哦那个剩余重量填充 + * @param cutoff_time 结转目的日期 * @param sysuser * @return */ @@ -1115,12 +1116,13 @@ public class OrderclusterSyncService extends BaseSyncService { } /** - * 临时购砂结转 + * 零散购砂结转 + * /order/ordercluster/forwardTemp * - * @param ordercluster_id - * @param total_weight - * @param trucks - * @param cutoff_time + * @param ordercluster_id ordercluster 的 id + * @param total_weight 结转的重量,默认哦那个剩余重量填充 + * @param cutoff_time 结转目的日期 + * @param trucks 默认用当前配额的车辆填充 * @param sysuser * @return */ From 36cb174ae3466eab54037480b434849bbcdf6f84 Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Mon, 2 Nov 2020 18:10:16 +0800 Subject: [PATCH 06/10] . --- .../truck/OrderclusterTruckService.java | 13 +++++++- .../stat/invoice/InvoiceUseService.java | 33 ++++++++++++------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java index 33634d4..76ab35d 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java @@ -27,9 +27,20 @@ public class OrderclusterTruckService extends BaseService { public static final OrderclusterTruckService me = new OrderclusterTruckService(); public Page find(PageParam pp, String stm, String etm, String customer_name, String truck_license) { - String selectsql = "select * "; + String selectsql = "select t.id, t.truck_license" + + ", c.uuid, c.total_weight, c.avg_weight, c.create_time, c.cutoff_time, c.complete_time" + + ", c.unit_price, c.state, c.supermarket_id, c.trans_distance, c.pay_type, c.create_user_id" + + ", c.create_user_name, c.req_receipt, c.change_time, c.product_id, c.product_name, c.customer_id" + + ", c.customer_name, c.customer_texpayer_name, c.customer_texpayer_num, c.customer_address" + + ", c.customer_phone, c.customer_bank_name, c.customer_bank_account, c.customer_receiver_name" + + ", c.customer_receiver_phone, c.customer_receiver_address, c.customer_receiver_lgtd" + + ", c.customer_receiver_lttd, c.trans_co_id, c.trans_co_name, c.trans_co_texpayer_name" + + ", c.trans_co_texpayer_num, c.trans_co_address, c.trans_co_phone, c.trans_co_bank_name" + + ", c.trans_co_bank_account, c.time_interval, c.mini_truck" + + ", s.name supermarket_name "; String fromsql = "from ordercluster_truck t \n" + " left join ordercluster c on c.id = t.ordercluster_id \n" + + " left join supermarket s on s.id = c.supermarket_id \n" + " where 1=1 "; List paraList = new ArrayList<>(); diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java index cc6a152..00baa61 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java @@ -18,15 +18,16 @@ public class InvoiceUseService { /** * 票据使用情况统计 - * @param tm 日期 yyyy-DD-dd + * + * @param tm 日期 yyyy-DD-dd * @param supermarket_id 砂站id - * @param invoice_type 发票类型 1 普票、2 专票 + * @param invoice_type 发票类型 1 普票、2 专票 * @param invoice_number 发票代码 - * @param invoice_code 发票号码 - * @param invoice_state 发票状态 5 已使用 9 已取消 - * @param order_sn 订单号 - * @param truck_license 车牌号 - * @param order_state 订单状态 5 已出货 9 已取消 + * @param invoice_code 发票号码 + * @param invoice_state 发票状态 5 已使用 9 已取消 + * @param order_sn 订单号 + * @param truck_license 车牌号 + * @param order_state 订单状态 5 已出货 9 已取消 * @return */ public Record statuse( @@ -72,8 +73,8 @@ public class InvoiceUseService { paramord.add(tm + "%"); if (supermarket_id != null) { - logsql += " and r.supermarket_id <= ? \n"; // 这里用领用记录的 supermarket_id - ordsql += " and t.supermarket_id <= ? \n"; + logsql += " and r.supermarket_id = ? \n"; // 这里用领用记录的 supermarket_id + ordsql += " and t.supermarket_id = ? \n"; paramlog.add(supermarket_id); paramord.add(supermarket_id); @@ -88,7 +89,7 @@ public class InvoiceUseService { } if (StrKit.notBlank(invoice_code)) { - logsql += " and t.invoice_code like ? \n"; + logsql += " and t.code like ? \n"; ordsql += " and t.invoice_code like ? \n"; paramlog.add("%" + invoice_code.trim() + "%"); @@ -117,8 +118,8 @@ public class InvoiceUseService { } if (order_state != null) { - logsql += " and o.state <= ? \n"; - ordsql += " and t.state <= ? \n"; + logsql += " and o.state = ? \n"; + ordsql += " and t.state = ? \n"; paramlog.add(order_state); paramord.add(order_state); @@ -131,6 +132,14 @@ public class InvoiceUseService { } else { paramlog.addAll(paramord); + if (invoice_type != null && invoice_type == 2) { + logsql += " and t.invoice_type = ? \n"; + ordsql += " and t.invoice_type = ? \n"; + + paramlog.add(invoice_type); + paramord.add(invoice_type); + } + list = Db.find("select * from (" + logsql + "\n union \n " + ordsql + ") a order by a.create_time ", paramlog.toArray()); } From a9bb7003a295c0a72e317ba5ad12e4504ba4f230 Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Mon, 2 Nov 2020 22:24:50 +0800 Subject: [PATCH 07/10] . --- .../order/ordercluster/truck/OrderclusterTruckService.java | 7 ++++++- .../ordercluster/truck/OrderclusterTruckController.java | 3 ++- .../ordercluster/truck/OrderclusterTruckController.java | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java index 76ab35d..5af8c15 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java @@ -26,7 +26,7 @@ import java.util.List; public class OrderclusterTruckService extends BaseService { public static final OrderclusterTruckService me = new OrderclusterTruckService(); - public Page find(PageParam pp, String stm, String etm, String customer_name, String truck_license) { + public Page find(PageParam pp, String stm, String etm, String customer_name, String truck_license, Integer state) { String selectsql = "select t.id, t.truck_license" + ", c.uuid, c.total_weight, c.avg_weight, c.create_time, c.cutoff_time, c.complete_time" + ", c.unit_price, c.state, c.supermarket_id, c.trans_distance, c.pay_type, c.create_user_id" + @@ -64,6 +64,11 @@ public class OrderclusterTruckService extends BaseService { paraList.add("%" + truck_license.trim() + "%"); } + if (state != null) { + fromsql += " and c.state = ? \n"; + paraList.add(state); + } + String totalRowSql = "select count(*) " + fromsql; String findSql = selectsql + fromsql; diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java index f29b3f7..75ddcb7 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java @@ -38,7 +38,8 @@ public class OrderclusterTruckController extends Controller { String etm = get("etm"); String customer_name = get("customer_name"); String truck_license = get("truck_license"); - renderJson(Result.object(OrderclusterTruckService.me.find(pp, stm, etm, customer_name, truck_license))); + Integer state = getInt("state"); + renderJson(Result.object(OrderclusterTruckService.me.find(pp, stm, etm, customer_name, truck_license, state))); } /** diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java index 2a32a55..e73c6ee 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java @@ -75,7 +75,8 @@ public class OrderclusterTruckController extends Controller { String etm = get("etm"); String customer_name = get("customer_name"); String truck_license = get("truck_license"); - renderJson(Result.object(OrderclusterTruckService.me.find(pp, stm, etm, customer_name, truck_license))); + Integer state = getInt("state"); + renderJson(Result.object(OrderclusterTruckService.me.find(pp, stm, etm, customer_name, truck_license, state))); } /** From 68a4bb317532562660047660f99fe048c793e4cd Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Tue, 3 Nov 2020 09:23:02 +0800 Subject: [PATCH 08/10] . --- .../order/ordercluster/truck/OrderclusterTruckService.java | 2 +- .../java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java index 5af8c15..d099a50 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/truck/OrderclusterTruckService.java @@ -82,7 +82,7 @@ public class OrderclusterTruckService extends BaseService { findSql += " " + Const.ORDER_BY_DESC; } } else { - findSql += " order by c.cutoff_time desc"; + findSql += " order by c.cutoff_time desc, t.id"; } return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray()); diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java index 00baa61..77ef4d3 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java @@ -130,8 +130,6 @@ public class InvoiceUseService { if (invoice_type != null && invoice_type == 1) { list = Db.find(logsql + " order by t.create_time", paramlog.toArray()); } else { - paramlog.addAll(paramord); - if (invoice_type != null && invoice_type == 2) { logsql += " and t.invoice_type = ? \n"; ordsql += " and t.invoice_type = ? \n"; @@ -140,6 +138,8 @@ public class InvoiceUseService { paramord.add(invoice_type); } + paramlog.addAll(paramord); + list = Db.find("select * from (" + logsql + "\n union \n " + ordsql + ") a order by a.create_time ", paramlog.toArray()); } From 9a0783899015bafe15f4e3bd03aad2a9704c6d9e Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Tue, 3 Nov 2020 09:49:49 +0800 Subject: [PATCH 09/10] . --- .../ssjygl/order/ordercluster/OrderclusterSyncService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java index cbad68d..b9bce7d 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterSyncService.java @@ -1062,7 +1062,7 @@ public class OrderclusterSyncService extends BaseSyncService { synctask.addSaveData(forwardoldobj); } else { // 已有的,直接更新重量 - forwardoldobj.setTotalWeight(total_weight); + forwardoldobj.setTotalWeight(forwardoldobj.getTotalWeight().add(total_weight)); ret = forwardoldobj.update(); synctask.addUpdateData(forwardoldobj); @@ -1236,7 +1236,7 @@ public class OrderclusterSyncService extends BaseSyncService { synctask.addSaveData(forwardoldobj); } else { // 已有的,直接更新重量 - forwardoldobj.setTotalWeight(total_weight); + forwardoldobj.setTotalWeight(forwardoldobj.getTotalWeight().add(total_weight)); ret = forwardoldobj.update(); synctask.addUpdateData(forwardoldobj); From 4d5f82109a70d540b6c67bc0f91b054204794d49 Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Tue, 3 Nov 2020 10:13:30 +0800 Subject: [PATCH 10/10] . --- .../src/main/java/com/cowr/local/ssjygl/main/Config.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java index 4e64263..4f745d2 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java @@ -95,7 +95,7 @@ public class Config extends JFinalConfig { public static DeviceThread deviceThread = new DeviceThread(); public static SocketIOService socketio = null; private static boolean client_run = true; - public static final String CLINET_VERSION = "20201030"; + public static final String CLINET_VERSION = "20201103"; public static String getRootPath() { return PathKit.getWebRootPath()