From 5c4e460cacaabd3b3fbb9b70f06a7b3caeedb6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Tue, 15 Sep 2026 14:52:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=A3=E7=A7=9F=E8=BF=87=E6=BB=A4=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialInventoryApplicationService.java | 2 ++ .../repository/po/MaterialInventoryPO.java | 3 +++ .../mapper/materialInventory/MaterialInventoryMapper.xml | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java index f8c74da3e..99fefa42b 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java @@ -1021,6 +1021,8 @@ public class MaterialInventoryApplicationService { //未查询到库存记录 if (materialInventoryPOS==null || materialInventoryPOS.size()==0) return; for (MaterialInventoryPO materialInventoryPO : materialInventoryPOS) { + String businessChargeType = materialInventoryPO.getBusinessChargeType(); + if (!"散租".equals(businessChargeType)) continue; Date createTime = materialInventoryPO.getCreateTime(); Long materialBaseInfoId = materialInventoryPO.getMaterialBaseInfoId(); String lotNumber = materialInventoryPO.getLotNumber(); diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/po/MaterialInventoryPO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/po/MaterialInventoryPO.java index 0a1007541..d5157b036 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/po/MaterialInventoryPO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/po/MaterialInventoryPO.java @@ -277,4 +277,7 @@ public class MaterialInventoryPO extends MaterialBasePO { @ApiModelProperty("半月仓租单位") @Excel(name = "半月仓租单位") private String halfMonthWarehouseRentUnit; + + @ApiModelProperty("业务计价类型") + private String businessChargeType; } \ No newline at end of file diff --git a/mhd_wms/src/main/resources/mapper/materialInventory/MaterialInventoryMapper.xml b/mhd_wms/src/main/resources/mapper/materialInventory/MaterialInventoryMapper.xml index 3f5e19f8d..384540582 100644 --- a/mhd_wms/src/main/resources/mapper/materialInventory/MaterialInventoryMapper.xml +++ b/mhd_wms/src/main/resources/mapper/materialInventory/MaterialInventoryMapper.xml @@ -75,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -1822,8 +1823,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" From ae4e0e129b464d81a0801241fdf3e9899a08f53e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Tue, 15 Sep 2026 16:21:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialInventoryApplicationService.java | 14 ++++++++++---- .../facade/IMaterialInventoryService.java | 2 ++ .../repository/mapper/MaterialInventoryMapper.java | 2 ++ .../persistence/MaterialInventoryImpl.java | 5 +++++ .../service/MaterialInventoryDomainService.java | 4 ++++ .../materialInventory/MaterialInventoryMapper.xml | 10 ++++++++++ 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java index 99fefa42b..11acc0e39 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java @@ -904,7 +904,9 @@ public class MaterialInventoryApplicationService { String inOrderNumber = materialInventoryPO.getInOrderNumber(); Long warehouseId = materialInventoryPO.getWarehouseId(); Date lastBillingTime = materialInventoryPO.getLastBillingTime(); - if (warehouseId==19) {//干仓计费 + String warehouseCode = materialInventoryMapper.queryWarehouseCode(warehouseId); + if (warehouseCode == null) return; + if ("CMD".equals(warehouseCode)) {//干仓计费 Map shipperParameters = materialInventoryDomainService.queryShipperParameters(shipperId,"干仓计费配置"); //客户未配置干仓计费配置 if (shipperParameters == null || shipperParameters.size()==0) return; @@ -962,7 +964,7 @@ public class MaterialInventoryApplicationService { buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"冻仓"); buildBusinessDocument(fireInsureFee, materialInventoryPO,"0D08","火险保费",contractManageId,"冻仓"); } - } else if (warehouseId==20) {//冻仓计费 + } else if ("CMC".equals(warehouseCode)) {//冻仓计费 Map shipperParameters = materialInventoryDomainService.queryShipperParameters(Long.valueOf(shipperId),"冻仓计费配置"); if (shipperParameters == null || shipperParameters.size()==0) return; Long contractManageId = (Long) shipperParameters.get("contractManageId"); @@ -1022,6 +1024,7 @@ public class MaterialInventoryApplicationService { if (materialInventoryPOS==null || materialInventoryPOS.size()==0) return; for (MaterialInventoryPO materialInventoryPO : materialInventoryPOS) { String businessChargeType = materialInventoryPO.getBusinessChargeType(); + //非散租 if (!"散租".equals(businessChargeType)) continue; Date createTime = materialInventoryPO.getCreateTime(); Long materialBaseInfoId = materialInventoryPO.getMaterialBaseInfoId(); @@ -1029,7 +1032,10 @@ public class MaterialInventoryApplicationService { String inOrderNumber = materialInventoryPO.getInOrderNumber(); Long warehouseId = materialInventoryPO.getWarehouseId(); Date lastBillingTime = materialInventoryPO.getLastBillingTime(); - if (warehouseId==19) {//干仓计费 + String warehouseCode = materialInventoryDomainService.queryWarehouseCode(warehouseId); + //仓库代码为空 + if (warehouseCode==null) continue; + if ("CMD".equals(warehouseCode)) {//干仓计费 Map shipperParameters = materialInventoryDomainService.queryShipperParameters(Long.valueOf(shipperId),"干仓计费配置"); //客户未配置干仓计费配置 if (shipperParameters == null || shipperParameters.size()==0) continue; @@ -1087,7 +1093,7 @@ public class MaterialInventoryApplicationService { buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"干仓"); buildBusinessDocument(fireInsureFee, materialInventoryPO,"0D08","火险保费",contractManageId,"干仓"); } - } else if (warehouseId==20) {//冻仓计费 + } else if ("CMC".equals(warehouseCode)) {//冻仓计费 Map shipperParameters = materialInventoryDomainService.queryShipperParameters(Long.valueOf(shipperId),"冻仓计费配置"); if (shipperParameters == null || shipperParameters.size()==0) continue; Long contractManageId = (Long) shipperParameters.get("contractManageId"); diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/facade/IMaterialInventoryService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/facade/IMaterialInventoryService.java index 7168ca15b..9b768df7e 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/facade/IMaterialInventoryService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/facade/IMaterialInventoryService.java @@ -136,4 +136,6 @@ public interface IMaterialInventoryService extends IService public Map queryShipperParameters(Long shipperId,String parametersName); Map queryMaterialClassify(Long id); + + String queryWarehouseCode(Long id); } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/mapper/MaterialInventoryMapper.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/mapper/MaterialInventoryMapper.java index 7e0ed1acc..b5865656b 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/mapper/MaterialInventoryMapper.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/mapper/MaterialInventoryMapper.java @@ -140,4 +140,6 @@ public interface MaterialInventoryMapper extends BaseMapper public Map queryShipperParameters(@Param("shipperId") Long shipperId,@Param("parametersName") String parametersName); public Map queryMaterialClassify(@Param("id") Long id); + + public String queryWarehouseCode(@Param("id") Long id); } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java index 10f3c5202..5b6dfe0ac 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java @@ -1286,4 +1286,9 @@ public class MaterialInventoryImpl extends ServiceImpl queryMaterialClassify(Long id) { return materialInventoryMapper.queryMaterialClassify(id); } + + @Override + public String queryWarehouseCode(Long id) { + return materialInventoryMapper.queryWarehouseCode(id); + } } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/service/MaterialInventoryDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/service/MaterialInventoryDomainService.java index 95a0b8718..00787f65a 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/service/MaterialInventoryDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/service/MaterialInventoryDomainService.java @@ -149,4 +149,8 @@ public class MaterialInventoryDomainService { public Map queryMaterialClassify(Long id) { return materialInventoryService.queryMaterialClassify(id); } + + public String queryWarehouseCode(Long id) { + return materialInventoryService.queryWarehouseCode(id); + } } \ No newline at end of file diff --git a/mhd_wms/src/main/resources/mapper/materialInventory/MaterialInventoryMapper.xml b/mhd_wms/src/main/resources/mapper/materialInventory/MaterialInventoryMapper.xml index 384540582..97b34c7a8 100644 --- a/mhd_wms/src/main/resources/mapper/materialInventory/MaterialInventoryMapper.xml +++ b/mhd_wms/src/main/resources/mapper/materialInventory/MaterialInventoryMapper.xml @@ -1896,4 +1896,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 1 = 1 AND MATERIAL_CLASSIFY_ID = #{id} AND DEL_FLAG = 1 + + \ No newline at end of file From 5892efccaf0f0052e811ebd61bbb674d5b441679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Tue, 15 Sep 2026 16:42:02 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20260915_wms_push_billing_record_log.sql | 46 ++ mhd_wms/sql/__write_test.sql | 2 + .../MaterialInventoryApplicationService.java | 401 ++++++++++++------ .../entity/PushBillingRecordLog.java | 66 +++ .../mapper/PushBillingRecordLogMapper.java | 13 + ...le_dm_szwl_wms_push_billing_record_log.sql | 46 ++ sql/20260915_wms_billing_job_log.sql | 46 ++ 7 files changed, 493 insertions(+), 127 deletions(-) create mode 100644 mhd_wms/sql/20260915_wms_push_billing_record_log.sql create mode 100644 mhd_wms/sql/__write_test.sql create mode 100644 mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/entity/PushBillingRecordLog.java create mode 100644 mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/mapper/PushBillingRecordLogMapper.java create mode 100644 sql/20260915_create_table_dm_szwl_wms_push_billing_record_log.sql create mode 100644 sql/20260915_wms_billing_job_log.sql diff --git a/mhd_wms/sql/20260915_wms_push_billing_record_log.sql b/mhd_wms/sql/20260915_wms_push_billing_record_log.sql new file mode 100644 index 000000000..b393cda67 --- /dev/null +++ b/mhd_wms/sql/20260915_wms_push_billing_record_log.sql @@ -0,0 +1,46 @@ +-- ---------------------------- +-- 入库业务单推送bms计费流水定时任务(XXL-Job: pushBillingRecord)执行日志表 -- 达梦(DM)数据库版 +-- 适用:mhd-wms-service 连接的达梦库(生产/测试按环境选择,在WMS服务连接的用户/模式下执行) +-- 用途:记录任务执行过程中的例外情况(执行异常报错、业务continue跳过、生成业务单据失败), +-- 本次执行全程无任何例外时保留一条成功记录(LOG_TYPE=SUCCESS) +-- @date 2026-09-15 +-- ---------------------------- + +CREATE TABLE WMS_PUSH_BILLING_RECORD_LOG ( + ID BIGINT IDENTITY(1,1) NOT NULL, + JOB_NAME VARCHAR(100) DEFAULT NULL, + SHIPPER_ID VARCHAR(50) DEFAULT NULL, + MATERIAL_INVENTORY_ID BIGINT DEFAULT NULL, + IN_ORDER_NUMBER VARCHAR(100) DEFAULT NULL, + MATERIAL_BASE_INFO_ID BIGINT DEFAULT NULL, + LOT_NUMBER VARCHAR(100) DEFAULT NULL, + WAREHOUSE_CODE VARCHAR(50) DEFAULT NULL, + LOG_TYPE VARCHAR(20) DEFAULT NULL, + LOG_MESSAGE VARCHAR(2000) DEFAULT NULL, + EXECUTION_TIME DATETIME DEFAULT NULL, + DEL_FLAG INT DEFAULT 1, + CONSTRAINT PK_WMS_PUSH_BILLING_RECORD_LOG PRIMARY KEY (ID) +); + +COMMENT ON TABLE WMS_PUSH_BILLING_RECORD_LOG IS '入库业务单推送bms计费流水任务执行日志表'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.ID IS '主键ID'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.JOB_NAME IS '任务名称(XXL-Job任务标识,如pushBillingRecord)'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.SHIPPER_ID IS '货主ID(任务参数)'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.MATERIAL_INVENTORY_ID IS '物料库存ID'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.IN_ORDER_NUMBER IS '入库单号'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.MATERIAL_BASE_INFO_ID IS '物料基础信息ID'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.LOT_NUMBER IS 'LOT编号'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.WAREHOUSE_CODE IS '仓库编码'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.LOG_TYPE IS '日志类型:SUCCESS-全部执行成功 SKIP-业务跳过(continue) ERROR-执行异常'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.LOG_MESSAGE IS '日志信息(成功说明/跳过原因/异常信息)'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.EXECUTION_TIME IS '执行时间'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.DEL_FLAG IS '删除标记:0-无状态,1-正常,2-已删除'; + +CREATE INDEX IDX_WPBR_JOB_NAME ON WMS_PUSH_BILLING_RECORD_LOG (JOB_NAME); +CREATE INDEX IDX_WPBR_SHIPPER_ID ON WMS_PUSH_BILLING_RECORD_LOG (SHIPPER_ID); +CREATE INDEX IDX_WPBR_EXECUTION_TIME ON WMS_PUSH_BILLING_RECORD_LOG (EXECUTION_TIME); + +-- ---------------------------- +-- 回滚脚本 +-- DROP TABLE WMS_PUSH_BILLING_RECORD_LOG; +-- ---------------------------- diff --git a/mhd_wms/sql/__write_test.sql b/mhd_wms/sql/__write_test.sql new file mode 100644 index 000000000..e05719756 --- /dev/null +++ b/mhd_wms/sql/__write_test.sql @@ -0,0 +1,2 @@ +-- test write permission +SELECT 1; diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java index 11acc0e39..30ae45c48 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/materialInventory/MaterialInventoryApplicationService.java @@ -20,7 +20,9 @@ import com.mhd.system.api.model.LoginUser; import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo; import com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper; import com.mhd.wms.domain.materialInventory.entity.MaterialInventory; +import com.mhd.wms.domain.materialInventory.entity.PushBillingRecordLog; import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper; +import com.mhd.wms.domain.materialInventory.repository.mapper.PushBillingRecordLogMapper; import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO; import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO; import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO; @@ -75,6 +77,11 @@ public class MaterialInventoryApplicationService { private OutMaterialDetailMapper outMaterialDetailMapper; @Autowired private MaterialBaseInfoMapper materialBaseInfoMapper; + @Autowired + private PushBillingRecordLogMapper pushBillingRecordLogMapper; + + /** XXL-Job任务标识:入库业务单推送bms计费流水 */ + private static final String JOB_NAME_PUSH_BILLING_RECORD = "pushBillingRecord"; /** @@ -1019,140 +1026,270 @@ public class MaterialInventoryApplicationService { public void pushBillingRecord(String shipperId) { - List materialInventoryPOS = materialInventoryDomainService.queryPushBms(shipperId); - //未查询到库存记录 - if (materialInventoryPOS==null || materialInventoryPOS.size()==0) return; - for (MaterialInventoryPO materialInventoryPO : materialInventoryPOS) { - String businessChargeType = materialInventoryPO.getBusinessChargeType(); - //非散租 - if (!"散租".equals(businessChargeType)) continue; - Date createTime = materialInventoryPO.getCreateTime(); - Long materialBaseInfoId = materialInventoryPO.getMaterialBaseInfoId(); - String lotNumber = materialInventoryPO.getLotNumber(); - String inOrderNumber = materialInventoryPO.getInOrderNumber(); - Long warehouseId = materialInventoryPO.getWarehouseId(); - Date lastBillingTime = materialInventoryPO.getLastBillingTime(); - String warehouseCode = materialInventoryDomainService.queryWarehouseCode(warehouseId); - //仓库代码为空 - if (warehouseCode==null) continue; - if ("CMD".equals(warehouseCode)) {//干仓计费 - Map shipperParameters = materialInventoryDomainService.queryShipperParameters(Long.valueOf(shipperId),"干仓计费配置"); - //客户未配置干仓计费配置 - if (shipperParameters == null || shipperParameters.size()==0) continue; - Long contractManageId = (Long) shipperParameters.get("contractManageId"); - Long settlementCustomersId = (Long) shipperParameters.get("settlementCustomersId"); - String contractNumber = (String) shipperParameters.get("contractNumber"); - String content = (String) shipperParameters.get("content"); - Map contentMap = content != null ? JSON.parseObject(content, Map.class) : new HashMap<>(); - Integer sfzdcz = (Integer) contentMap.get("sfzdcz"); - //客户未配置或是否自动推送设置为否 - if (sfzdcz==null) continue; - if (sfzdcz!=1) continue; - //计算费用 - List> monthFee = materialInventoryDomainService.getMonthFee(inOrderNumber, materialBaseInfoId,lotNumber); - //入库业务单未设置每月仓租 - if (monthFee == null || monthFee.size()==0) continue; - Map feeMap = monthFee.get(0); - //半月仓租 - BigDecimal halfMonthWhFee = (BigDecimal) feeMap.get("halfMonthWhFee"); - //整月仓租 - BigDecimal monthlyWarehouseFee = (BigDecimal) feeMap.get("monthlyWarehouseFee"); - // 判断是否为昨天 - boolean isYesterday = false; - if (createTime != null) { - LocalDate yesterday = LocalDate.now().minusDays(1); - LocalDate createDate = createTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - isYesterday = yesterday.isEqual(createDate); - } - if (isYesterday) { - //首次计费 需要夫力费 - //库存数量 - BigDecimal inventoryQuantity = materialInventoryPO.getInventoryQuantity(); - //仓租 - BigDecimal totalWarehouseRent = inventoryQuantity.multiply(monthlyWarehouseFee); - //夫力费 - BigDecimal manpowerFee = totalWarehouseRent.multiply(new BigDecimal("0.2")); - MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId); - BigDecimal unitPrice = materialBaseInfo.getUnitPrice(); - //火险保费 - BigDecimal fireInsureFee = unitPrice.multiply(inventoryQuantity).multiply(new BigDecimal("0.0003")); - buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"干仓"); - buildBusinessDocument(manpowerFee, materialInventoryPO,"0D082","夫力费",contractManageId,"干仓"); - buildBusinessDocument(fireInsureFee, materialInventoryPO,"0D08","火险保费",contractManageId,"干仓"); - - } else { - //期间付费 不需要夫力费 - //库存数量 - BigDecimal inventoryQuantity = materialInventoryPO.getInventoryQuantity(); - //仓租 - BigDecimal totalWarehouseRent = inventoryQuantity.multiply(monthlyWarehouseFee); - MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId); - BigDecimal unitPrice = materialBaseInfo.getUnitPrice(); - //火险保费 - BigDecimal fireInsureFee = unitPrice.multiply(inventoryQuantity).multiply(new BigDecimal("0.0003")); - buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"干仓"); - buildBusinessDocument(fireInsureFee, materialInventoryPO,"0D08","火险保费",contractManageId,"干仓"); - } - } else if ("CMC".equals(warehouseCode)) {//冻仓计费 - Map shipperParameters = materialInventoryDomainService.queryShipperParameters(Long.valueOf(shipperId),"冻仓计费配置"); - if (shipperParameters == null || shipperParameters.size()==0) continue; - Long contractManageId = (Long) shipperParameters.get("contractManageId"); - Long settlementCustomersId = (Long) shipperParameters.get("settlementCustomersId"); - String contractNumber = (String) shipperParameters.get("contractNumber"); - String content = (String) shipperParameters.get("content"); - Map contentMap = content != null ? JSON.parseObject(content, Map.class) : new HashMap<>(); - Integer sfzdcz = (Integer) contentMap.get("sfzdcz"); - //客户未配置或是否自动推送设置为否 - if (sfzdcz==null) continue; - if (sfzdcz!=1) continue; - //计算费用 - MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId); - BigDecimal unitPrice = materialBaseInfo.getUnitPrice(); - String materialClassifyId = materialBaseInfo.getMaterialClassifyId(); - BigDecimal weightLimit = materialBaseInfo.getWeightLimit(); - Map materialClassify = materialInventoryDomainService.queryMaterialClassify(Long.valueOf(materialClassifyId)); - //物料分类不存在 - if (materialClassify == null || materialClassify.size()==0) continue; - BigDecimal monthlyWarehouseRent = (BigDecimal) materialClassify.get("monthlyWarehouseRent"); - BigDecimal halfMonthWarehouseRent = (BigDecimal) materialClassify.get("halfMonthWarehouseRent"); - String monthlyWarehouseRentUnit = (String) materialClassify.get("monthlyWarehouseRentUnit"); - String halfMonthWarehouseRentUnit = (String) materialClassify.get("halfMonthWarehouseRentUnit"); - //半月仓租 - BigDecimal halfMonthWhFee = halfMonthWarehouseRent; - //整月仓租 - BigDecimal monthlyWarehouseFee = monthlyWarehouseRent; - long daysDiff = 0; - if (lastBillingTime != null) { - LocalDate lastBillingDate = lastBillingTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - daysDiff = ChronoUnit.DAYS.between(lastBillingDate, LocalDate.now()); - } else { - daysDiff = -1; - } - BigDecimal inventoryQuantity = materialInventoryPO.getInventoryQuantity(); - if (daysDiff < 15) { - // 不足半月: 收半月仓租 - BigDecimal totalWarehouseRent = inventoryQuantity.multiply(halfMonthWhFee).multiply(weightLimit); - buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"冻仓"); - } else { - // 大于等于半月: 收整月仓租 - BigDecimal totalWarehouseRent = inventoryQuantity.multiply(monthlyWarehouseFee).multiply(weightLimit); - buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"冻仓"); - } - //更新最后计费时间 - Long materialInventoryId = materialInventoryPO.getMaterialInventoryId(); - MaterialInventory materialInventory = materialInventoryMapper.selectById(materialInventoryId); - materialInventory.setLastBillingTime(new Date()); - materialInventoryMapper.updateById(materialInventory); + // 例外情况计数(业务跳过continue、执行异常、生成业务单据失败),为0时说明本次执行全程无例外,保留成功记录 + int exceptionCount = 0; + try { + List materialInventoryPOS = materialInventoryDomainService.queryPushBms(shipperId); + //未查询到库存记录 + if (materialInventoryPOS==null || materialInventoryPOS.size()==0) { + savePushBillingRecordLog(shipperId, null, null, PushBillingRecordLog.LOG_TYPE_SUCCESS, + "未查询到待推送的库存记录,任务正常结束"); + return; } + for (MaterialInventoryPO materialInventoryPO : materialInventoryPOS) { + try { + String businessChargeType = materialInventoryPO.getBusinessChargeType(); + //非散租 + if (!"散租".equals(businessChargeType)) { + savePushBillingRecordLog(shipperId, materialInventoryPO, null, PushBillingRecordLog.LOG_TYPE_SKIP, + "业务计价类型[" + businessChargeType + "]非散租,跳过推送"); + exceptionCount++; + continue; + } + Date createTime = materialInventoryPO.getCreateTime(); + Long materialBaseInfoId = materialInventoryPO.getMaterialBaseInfoId(); + String lotNumber = materialInventoryPO.getLotNumber(); + String inOrderNumber = materialInventoryPO.getInOrderNumber(); + Long warehouseId = materialInventoryPO.getWarehouseId(); + Date lastBillingTime = materialInventoryPO.getLastBillingTime(); + String warehouseCode = materialInventoryDomainService.queryWarehouseCode(warehouseId); + //仓库代码为空 + if (warehouseCode==null) { + savePushBillingRecordLog(shipperId, materialInventoryPO, null, PushBillingRecordLog.LOG_TYPE_SKIP, + "仓库ID[" + warehouseId + "]未查询到仓库编码,跳过推送"); + exceptionCount++; + continue; + } + if ("CMD".equals(warehouseCode)) {//干仓计费 + Map shipperParameters = materialInventoryDomainService.queryShipperParameters(Long.valueOf(shipperId),"干仓计费配置"); + //客户未配置干仓计费配置 + if (shipperParameters == null || shipperParameters.size()==0) { + savePushBillingRecordLog(shipperId, materialInventoryPO, warehouseCode, PushBillingRecordLog.LOG_TYPE_SKIP, + "货主未配置[干仓计费配置],跳过推送"); + exceptionCount++; + continue; + } + Long contractManageId = (Long) shipperParameters.get("contractManageId"); + Long settlementCustomersId = (Long) shipperParameters.get("settlementCustomersId"); + String contractNumber = (String) shipperParameters.get("contractNumber"); + String content = (String) shipperParameters.get("content"); + Map contentMap = content != null ? JSON.parseObject(content, Map.class) : new HashMap<>(); + Integer sfzdcz = (Integer) contentMap.get("sfzdcz"); + //客户未配置或是否自动推送设置为否 + if (sfzdcz==null) { + savePushBillingRecordLog(shipperId, materialInventoryPO, warehouseCode, PushBillingRecordLog.LOG_TYPE_SKIP, + "干仓计费配置未设置[是否自动推送],跳过推送"); + exceptionCount++; + continue; + } + if (sfzdcz!=1) { + savePushBillingRecordLog(shipperId, materialInventoryPO, warehouseCode, PushBillingRecordLog.LOG_TYPE_SKIP, + "干仓计费配置[是否自动推送]为否,跳过推送"); + exceptionCount++; + continue; + } + //计算费用 + List> monthFee = materialInventoryDomainService.getMonthFee(inOrderNumber, materialBaseInfoId,lotNumber); + //入库业务单未设置每月仓租 + if (monthFee == null || monthFee.size()==0) { + savePushBillingRecordLog(shipperId, materialInventoryPO, warehouseCode, PushBillingRecordLog.LOG_TYPE_SKIP, + "入库业务单未设置每月仓租,跳过推送"); + exceptionCount++; + continue; + } + Map feeMap = monthFee.get(0); + //半月仓租 + BigDecimal halfMonthWhFee = (BigDecimal) feeMap.get("halfMonthWhFee"); + //整月仓租 + BigDecimal monthlyWarehouseFee = (BigDecimal) feeMap.get("monthlyWarehouseFee"); + // 判断是否为昨天 + boolean isYesterday = false; + if (createTime != null) { + LocalDate yesterday = LocalDate.now().minusDays(1); + LocalDate createDate = createTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + isYesterday = yesterday.isEqual(createDate); + } + if (isYesterday) { + //首次计费 需要夫力费 + //库存数量 + BigDecimal inventoryQuantity = materialInventoryPO.getInventoryQuantity(); + //仓租 + BigDecimal totalWarehouseRent = inventoryQuantity.multiply(monthlyWarehouseFee); + //夫力费 + BigDecimal manpowerFee = totalWarehouseRent.multiply(new BigDecimal("0.2")); + MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId); + BigDecimal unitPrice = materialBaseInfo.getUnitPrice(); + //火险保费 + BigDecimal fireInsureFee = unitPrice.multiply(inventoryQuantity).multiply(new BigDecimal("0.0003")); + if (!buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"干仓")) { + exceptionCount++; + } + if (!buildBusinessDocument(manpowerFee, materialInventoryPO,"0D082","夫力费",contractManageId,"干仓")) { + exceptionCount++; + } + if (!buildBusinessDocument(fireInsureFee, materialInventoryPO,"0D08","火险保费",contractManageId,"干仓")) { + exceptionCount++; + } + + } else { + //期间付费 不需要夫力费 + //库存数量 + BigDecimal inventoryQuantity = materialInventoryPO.getInventoryQuantity(); + //仓租 + BigDecimal totalWarehouseRent = inventoryQuantity.multiply(monthlyWarehouseFee); + MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId); + BigDecimal unitPrice = materialBaseInfo.getUnitPrice(); + //火险保费 + BigDecimal fireInsureFee = unitPrice.multiply(inventoryQuantity).multiply(new BigDecimal("0.0003")); + if (!buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"干仓")) { + exceptionCount++; + } + if (!buildBusinessDocument(fireInsureFee, materialInventoryPO,"0D08","火险保费",contractManageId,"干仓")) { + exceptionCount++; + } + } + } else if ("CMC".equals(warehouseCode)) {//冻仓计费 + Map shipperParameters = materialInventoryDomainService.queryShipperParameters(Long.valueOf(shipperId),"冻仓计费配置"); + if (shipperParameters == null || shipperParameters.size()==0) { + savePushBillingRecordLog(shipperId, materialInventoryPO, warehouseCode, PushBillingRecordLog.LOG_TYPE_SKIP, + "货主未配置[冻仓计费配置],跳过推送"); + exceptionCount++; + continue; + } + Long contractManageId = (Long) shipperParameters.get("contractManageId"); + Long settlementCustomersId = (Long) shipperParameters.get("settlementCustomersId"); + String contractNumber = (String) shipperParameters.get("contractNumber"); + String content = (String) shipperParameters.get("content"); + Map contentMap = content != null ? JSON.parseObject(content, Map.class) : new HashMap<>(); + Integer sfzdcz = (Integer) contentMap.get("sfzdcz"); + //客户未配置或是否自动推送设置为否 + if (sfzdcz==null) { + savePushBillingRecordLog(shipperId, materialInventoryPO, warehouseCode, PushBillingRecordLog.LOG_TYPE_SKIP, + "冻仓计费配置未设置[是否自动推送],跳过推送"); + exceptionCount++; + continue; + } + if (sfzdcz!=1) { + savePushBillingRecordLog(shipperId, materialInventoryPO, warehouseCode, PushBillingRecordLog.LOG_TYPE_SKIP, + "冻仓计费配置[是否自动推送]为否,跳过推送"); + exceptionCount++; + continue; + } + //计算费用 + MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId); + BigDecimal unitPrice = materialBaseInfo.getUnitPrice(); + String materialClassifyId = materialBaseInfo.getMaterialClassifyId(); + BigDecimal weightLimit = materialBaseInfo.getWeightLimit(); + Map materialClassify = materialInventoryDomainService.queryMaterialClassify(Long.valueOf(materialClassifyId)); + //物料分类不存在 + if (materialClassify == null || materialClassify.size()==0) { + savePushBillingRecordLog(shipperId, materialInventoryPO, warehouseCode, PushBillingRecordLog.LOG_TYPE_SKIP, + "物料分类[" + materialClassifyId + "]不存在,跳过推送"); + exceptionCount++; + continue; + } + BigDecimal monthlyWarehouseRent = (BigDecimal) materialClassify.get("monthlyWarehouseRent"); + BigDecimal halfMonthWarehouseRent = (BigDecimal) materialClassify.get("halfMonthWarehouseRent"); + String monthlyWarehouseRentUnit = (String) materialClassify.get("monthlyWarehouseRentUnit"); + String halfMonthWarehouseRentUnit = (String) materialClassify.get("halfMonthWarehouseRentUnit"); + //半月仓租 + BigDecimal halfMonthWhFee = halfMonthWarehouseRent; + //整月仓租 + BigDecimal monthlyWarehouseFee = monthlyWarehouseRent; + long daysDiff = 0; + if (lastBillingTime != null) { + LocalDate lastBillingDate = lastBillingTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + daysDiff = ChronoUnit.DAYS.between(lastBillingDate, LocalDate.now()); + } else { + daysDiff = -1; + } + BigDecimal inventoryQuantity = materialInventoryPO.getInventoryQuantity(); + if (daysDiff < 15) { + // 不足半月: 收半月仓租 + BigDecimal totalWarehouseRent = inventoryQuantity.multiply(halfMonthWhFee).multiply(weightLimit); + if (!buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"冻仓")) { + exceptionCount++; + } + } else { + // 大于等于半月: 收整月仓租 + BigDecimal totalWarehouseRent = inventoryQuantity.multiply(monthlyWarehouseFee).multiply(weightLimit); + if (!buildBusinessDocument(totalWarehouseRent, materialInventoryPO,"0D01","租金(固定租)",contractManageId,"冻仓")) { + exceptionCount++; + } + } + //更新最后计费时间 + Long materialInventoryId = materialInventoryPO.getMaterialInventoryId(); + MaterialInventory materialInventory = materialInventoryMapper.selectById(materialInventoryId); + materialInventory.setLastBillingTime(new Date()); + materialInventoryMapper.updateById(materialInventory); + } + } catch (Exception e) { + savePushBillingRecordLog(shipperId, materialInventoryPO, null, PushBillingRecordLog.LOG_TYPE_ERROR, + "处理物料库存时发生异常:" + e); + throw e; + } + } + } catch (Exception e) { + savePushBillingRecordLog(shipperId, null, null, PushBillingRecordLog.LOG_TYPE_ERROR, + "任务执行异常中断:" + e); + throw e; + } + // 本次执行无任何例外(无跳过、无异常),保留成功记录 + if (exceptionCount == 0) { + savePushBillingRecordLog(shipperId, null, null, PushBillingRecordLog.LOG_TYPE_SUCCESS, + "入库业务单推送bms计费流水全部执行成功"); + } + } + + /** + * 保存入库业务单推送bms计费流水执行日志(日志写入失败仅打印错误,不影响任务主流程) + * + * @param shipperId 货主ID(任务参数),为空时从物料库存取 + * @param materialInventoryPO 物料库存(为空表示任务级日志) + * @param warehouseCode 仓库编码 + * @param logType 日志类型:SUCCESS-全部执行成功 SKIP-业务跳过 ERROR-执行异常 + * @param logMessage 日志信息(成功说明/跳过原因/异常信息) + */ + private void savePushBillingRecordLog(String shipperId, MaterialInventoryPO materialInventoryPO, String warehouseCode, + String logType, String logMessage) { + try { + PushBillingRecordLog logRecord = new PushBillingRecordLog(); + logRecord.setJobName(JOB_NAME_PUSH_BILLING_RECORD); + if (StringUtils.isNotBlank(shipperId)) { + logRecord.setShipperId(shipperId); + } else if (materialInventoryPO != null && materialInventoryPO.getShipperId() != null) { + logRecord.setShipperId(String.valueOf(materialInventoryPO.getShipperId())); + } + if (materialInventoryPO != null) { + logRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId()); + logRecord.setInOrderNumber(materialInventoryPO.getInOrderNumber()); + logRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); + logRecord.setLotNumber(materialInventoryPO.getLotNumber()); + } + logRecord.setWarehouseCode(warehouseCode); + logRecord.setLogType(logType); + // 日志信息截断,防止超长导致入库失败 + if (logMessage != null && logMessage.length() > 2000) { + logMessage = logMessage.substring(0, 2000); + } + logRecord.setLogMessage(logMessage); + logRecord.setExecutionTime(new Date()); + logRecord.setDelFlag(1); + pushBillingRecordLogMapper.insert(logRecord); + } catch (Exception e) { + log.error("保存入库业务单推送bms计费流水执行日志失败: {}", e.getMessage(), e); } } - private void buildBusinessDocument(BigDecimal fee, MaterialInventoryPO materialInventoryPO,String code,String name,Long contractManageId,String warehouseType) { + private boolean buildBusinessDocument(BigDecimal fee, MaterialInventoryPO materialInventoryPO,String code,String name,Long contractManageId,String warehouseType) { Long shipperId = materialInventoryPO.getShipperId(); Map shipper = materialInventoryMapper.querySetlleByShipperId(shipperId); if (shipper == null) { - return; + savePushBillingRecordLog(null, materialInventoryPO, materialInventoryPO.getWarehouseCode(), + PushBillingRecordLog.LOG_TYPE_SKIP, + "货主[" + shipperId + "]未查询到结算客户信息,未生成业务单据"); + return false; } Long settlementCustomersId = (Long) shipper.get("settlementCustomersId"); Long settlementEntityId = (Long) shipper.get("settlementEntityId"); @@ -1182,7 +1319,12 @@ public class MaterialInventoryApplicationService { businessDocumentFeign.setWarehouseType(warehouseType); businessDocumentFeign.setOriginalBusinessNum(materialInventoryPO.getInOrderNumber()); Map contract = materialInventoryDomainService.queryContract(contractManageId); - if (contract == null) {return;} + if (contract == null) { + savePushBillingRecordLog(null, materialInventoryPO, materialInventoryPO.getWarehouseCode(), + PushBillingRecordLog.LOG_TYPE_SKIP, + "合同[" + contractManageId + "]未查询到合同信息,未生成业务单据"); + return false; + } String contractName = (String) contract.get("contractName"); String contractNumber = (String) contract.get("contractNumber"); businessDocumentFeign.setContractName(contractName); @@ -1193,6 +1335,11 @@ public class MaterialInventoryApplicationService { AjaxResult ajaxResult = bmsServiceFeign.feignSaveBusinessDocument(businessDocumentFeign); if (ajaxResult == null || !"200".equals(String.valueOf(ajaxResult.get("code")))) { log.error("保存业务单据失败: {}", ajaxResult != null ? ajaxResult.get("msg") : "feign调用异常"); + savePushBillingRecordLog(null, materialInventoryPO, materialInventoryPO.getWarehouseCode(), + PushBillingRecordLog.LOG_TYPE_ERROR, + "保存业务单据失败:" + (ajaxResult != null ? ajaxResult.get("msg") : "feign调用异常")); + return false; } + return true; } } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/entity/PushBillingRecordLog.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/entity/PushBillingRecordLog.java new file mode 100644 index 000000000..8dca13fd7 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/entity/PushBillingRecordLog.java @@ -0,0 +1,66 @@ +package com.mhd.wms.domain.materialInventory.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 入库业务单推送bms计费流水任务(XXL-Job:pushBillingRecord)执行日志对象 wms_push_billing_record_log + * + * @author mhd + * @date 2026-09-15 + */ +@Data +@TableName("WMS_PUSH_BILLING_RECORD_LOG") +public class PushBillingRecordLog implements Serializable { + private static final long serialVersionUID = 1L; + + /** 日志类型:全部执行成功 */ + public static final String LOG_TYPE_SUCCESS = "SUCCESS"; + /** 日志类型:业务跳过(continue跳出) */ + public static final String LOG_TYPE_SKIP = "SKIP"; + /** 日志类型:执行异常(报错) */ + public static final String LOG_TYPE_ERROR = "ERROR"; + + @ApiModelProperty("主键ID") + @TableId(type = IdType.AUTO) + private Long id; + + @ApiModelProperty("任务名称(XXL-Job任务标识)") + private String jobName; + + @ApiModelProperty("货主ID(任务参数)") + private String shipperId; + + @ApiModelProperty("物料库存ID") + private Long materialInventoryId; + + @ApiModelProperty("入库单号") + private String inOrderNumber; + + @ApiModelProperty("物料基础信息ID") + private Long materialBaseInfoId; + + @ApiModelProperty("LOT编号") + private String lotNumber; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("日志类型:SUCCESS-全部执行成功 SKIP-业务跳过 ERROR-执行异常") + private String logType; + + @ApiModelProperty("日志信息(成功说明/跳过原因/异常信息)") + private String logMessage; + + @ApiModelProperty("执行时间") + private Date executionTime; + + @ApiModelProperty("删除标记:0-无状态,1-正常,2-已删除") + private Integer delFlag; +} diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/mapper/PushBillingRecordLogMapper.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/mapper/PushBillingRecordLogMapper.java new file mode 100644 index 000000000..59034a062 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/mapper/PushBillingRecordLogMapper.java @@ -0,0 +1,13 @@ +package com.mhd.wms.domain.materialInventory.repository.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mhd.wms.domain.materialInventory.entity.PushBillingRecordLog; + +/** + * 入库业务单推送bms计费流水任务执行日志Mapper接口 + * + * @author mhd + * @date 2026-09-15 + */ +public interface PushBillingRecordLogMapper extends BaseMapper { +} diff --git a/sql/20260915_create_table_dm_szwl_wms_push_billing_record_log.sql b/sql/20260915_create_table_dm_szwl_wms_push_billing_record_log.sql new file mode 100644 index 000000000..b393cda67 --- /dev/null +++ b/sql/20260915_create_table_dm_szwl_wms_push_billing_record_log.sql @@ -0,0 +1,46 @@ +-- ---------------------------- +-- 入库业务单推送bms计费流水定时任务(XXL-Job: pushBillingRecord)执行日志表 -- 达梦(DM)数据库版 +-- 适用:mhd-wms-service 连接的达梦库(生产/测试按环境选择,在WMS服务连接的用户/模式下执行) +-- 用途:记录任务执行过程中的例外情况(执行异常报错、业务continue跳过、生成业务单据失败), +-- 本次执行全程无任何例外时保留一条成功记录(LOG_TYPE=SUCCESS) +-- @date 2026-09-15 +-- ---------------------------- + +CREATE TABLE WMS_PUSH_BILLING_RECORD_LOG ( + ID BIGINT IDENTITY(1,1) NOT NULL, + JOB_NAME VARCHAR(100) DEFAULT NULL, + SHIPPER_ID VARCHAR(50) DEFAULT NULL, + MATERIAL_INVENTORY_ID BIGINT DEFAULT NULL, + IN_ORDER_NUMBER VARCHAR(100) DEFAULT NULL, + MATERIAL_BASE_INFO_ID BIGINT DEFAULT NULL, + LOT_NUMBER VARCHAR(100) DEFAULT NULL, + WAREHOUSE_CODE VARCHAR(50) DEFAULT NULL, + LOG_TYPE VARCHAR(20) DEFAULT NULL, + LOG_MESSAGE VARCHAR(2000) DEFAULT NULL, + EXECUTION_TIME DATETIME DEFAULT NULL, + DEL_FLAG INT DEFAULT 1, + CONSTRAINT PK_WMS_PUSH_BILLING_RECORD_LOG PRIMARY KEY (ID) +); + +COMMENT ON TABLE WMS_PUSH_BILLING_RECORD_LOG IS '入库业务单推送bms计费流水任务执行日志表'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.ID IS '主键ID'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.JOB_NAME IS '任务名称(XXL-Job任务标识,如pushBillingRecord)'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.SHIPPER_ID IS '货主ID(任务参数)'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.MATERIAL_INVENTORY_ID IS '物料库存ID'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.IN_ORDER_NUMBER IS '入库单号'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.MATERIAL_BASE_INFO_ID IS '物料基础信息ID'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.LOT_NUMBER IS 'LOT编号'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.WAREHOUSE_CODE IS '仓库编码'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.LOG_TYPE IS '日志类型:SUCCESS-全部执行成功 SKIP-业务跳过(continue) ERROR-执行异常'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.LOG_MESSAGE IS '日志信息(成功说明/跳过原因/异常信息)'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.EXECUTION_TIME IS '执行时间'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.DEL_FLAG IS '删除标记:0-无状态,1-正常,2-已删除'; + +CREATE INDEX IDX_WPBR_JOB_NAME ON WMS_PUSH_BILLING_RECORD_LOG (JOB_NAME); +CREATE INDEX IDX_WPBR_SHIPPER_ID ON WMS_PUSH_BILLING_RECORD_LOG (SHIPPER_ID); +CREATE INDEX IDX_WPBR_EXECUTION_TIME ON WMS_PUSH_BILLING_RECORD_LOG (EXECUTION_TIME); + +-- ---------------------------- +-- 回滚脚本 +-- DROP TABLE WMS_PUSH_BILLING_RECORD_LOG; +-- ---------------------------- diff --git a/sql/20260915_wms_billing_job_log.sql b/sql/20260915_wms_billing_job_log.sql new file mode 100644 index 000000000..b393cda67 --- /dev/null +++ b/sql/20260915_wms_billing_job_log.sql @@ -0,0 +1,46 @@ +-- ---------------------------- +-- 入库业务单推送bms计费流水定时任务(XXL-Job: pushBillingRecord)执行日志表 -- 达梦(DM)数据库版 +-- 适用:mhd-wms-service 连接的达梦库(生产/测试按环境选择,在WMS服务连接的用户/模式下执行) +-- 用途:记录任务执行过程中的例外情况(执行异常报错、业务continue跳过、生成业务单据失败), +-- 本次执行全程无任何例外时保留一条成功记录(LOG_TYPE=SUCCESS) +-- @date 2026-09-15 +-- ---------------------------- + +CREATE TABLE WMS_PUSH_BILLING_RECORD_LOG ( + ID BIGINT IDENTITY(1,1) NOT NULL, + JOB_NAME VARCHAR(100) DEFAULT NULL, + SHIPPER_ID VARCHAR(50) DEFAULT NULL, + MATERIAL_INVENTORY_ID BIGINT DEFAULT NULL, + IN_ORDER_NUMBER VARCHAR(100) DEFAULT NULL, + MATERIAL_BASE_INFO_ID BIGINT DEFAULT NULL, + LOT_NUMBER VARCHAR(100) DEFAULT NULL, + WAREHOUSE_CODE VARCHAR(50) DEFAULT NULL, + LOG_TYPE VARCHAR(20) DEFAULT NULL, + LOG_MESSAGE VARCHAR(2000) DEFAULT NULL, + EXECUTION_TIME DATETIME DEFAULT NULL, + DEL_FLAG INT DEFAULT 1, + CONSTRAINT PK_WMS_PUSH_BILLING_RECORD_LOG PRIMARY KEY (ID) +); + +COMMENT ON TABLE WMS_PUSH_BILLING_RECORD_LOG IS '入库业务单推送bms计费流水任务执行日志表'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.ID IS '主键ID'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.JOB_NAME IS '任务名称(XXL-Job任务标识,如pushBillingRecord)'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.SHIPPER_ID IS '货主ID(任务参数)'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.MATERIAL_INVENTORY_ID IS '物料库存ID'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.IN_ORDER_NUMBER IS '入库单号'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.MATERIAL_BASE_INFO_ID IS '物料基础信息ID'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.LOT_NUMBER IS 'LOT编号'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.WAREHOUSE_CODE IS '仓库编码'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.LOG_TYPE IS '日志类型:SUCCESS-全部执行成功 SKIP-业务跳过(continue) ERROR-执行异常'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.LOG_MESSAGE IS '日志信息(成功说明/跳过原因/异常信息)'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.EXECUTION_TIME IS '执行时间'; +COMMENT ON COLUMN WMS_PUSH_BILLING_RECORD_LOG.DEL_FLAG IS '删除标记:0-无状态,1-正常,2-已删除'; + +CREATE INDEX IDX_WPBR_JOB_NAME ON WMS_PUSH_BILLING_RECORD_LOG (JOB_NAME); +CREATE INDEX IDX_WPBR_SHIPPER_ID ON WMS_PUSH_BILLING_RECORD_LOG (SHIPPER_ID); +CREATE INDEX IDX_WPBR_EXECUTION_TIME ON WMS_PUSH_BILLING_RECORD_LOG (EXECUTION_TIME); + +-- ---------------------------- +-- 回滚脚本 +-- DROP TABLE WMS_PUSH_BILLING_RECORD_LOG; +-- ----------------------------