From 2732a45220a719322055d1bf1b8d8d62c061570b Mon Sep 17 00:00:00 2001 From: guojunyun Date: Tue, 21 Oct 2025 09:19:57 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AD=97=E5=85=B8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contractorder/enums/contract/DictEnum.java | 17 ++++------------- .../service/contract/ContractServiceImpl.java | 16 ++++++++-------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/zt-module-contract-order/zt-module-contract-order-api/src/main/java/com/zt/plat/module/contractorder/enums/contract/DictEnum.java b/zt-module-contract-order/zt-module-contract-order-api/src/main/java/com/zt/plat/module/contractorder/enums/contract/DictEnum.java index 7887456..c5ad9e4 100644 --- a/zt-module-contract-order/zt-module-contract-order-api/src/main/java/com/zt/plat/module/contractorder/enums/contract/DictEnum.java +++ b/zt-module-contract-order/zt-module-contract-order-api/src/main/java/com/zt/plat/module/contractorder/enums/contract/DictEnum.java @@ -1,8 +1,11 @@ package com.zt.plat.module.contractorder.enums.contract; +import lombok.Getter; + /** * 字典枚举 */ +@Getter public enum DictEnum { /** ERP请求状态 */ @@ -60,19 +63,7 @@ public enum DictEnum { */ private final String remark; - public String getLabel() { - return label; - } - - public String getCode() { - return code; - } - - public String getRemark() { - return remark; - } - - public static DictEnum getByCode(String code, String dictType) { + public static DictEnum getByCodeAndType(String code, String dictType) { return DictEnum.valueOf(dictType + "_" +code); } } diff --git a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractServiceImpl.java b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractServiceImpl.java index 786e181..abb54c2 100644 --- a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractServiceImpl.java +++ b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractServiceImpl.java @@ -706,7 +706,7 @@ public class ContractServiceImpl implements ContractService { || DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(oldContractMainDO.getStatus()))) { throw exception(CONTRACT_STATUS_NOT_UPDATE, - DictEnum.getByCode(oldContractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); + DictEnum.getByCodeAndType(oldContractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); } // 校验合同名称是否重复 @@ -952,7 +952,7 @@ public class ContractServiceImpl implements ContractService { String msg = id.toString() + ":" + CONTRACT_STATUS_NOT_DELETE.getMsg() - .replace("{}", DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); + .replace("{}", DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); result.add(new JSONObject().putOnce("deleted", false).putOnce("msg", msg)); } @@ -1032,7 +1032,7 @@ public class ContractServiceImpl implements ContractService { || DictEnum.BSE_CTRT_STS_WAIT_AUDIT.getCode().equals(contractMainDO.getStatus()))) { throw exception(CONTRACT_STATUS_NOT_SUBMIT_APPROVAL, - DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); + DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); } // 合同内容校验 @@ -1119,7 +1119,7 @@ public class ContractServiceImpl implements ContractService { if (!DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode().equals(contractMainDO.getStatus())) { throw exception(CONTRACT_STATUS_NOT_APPROVAL, - DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); + DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); } // 获取当前流程正在审批的任务节点 @@ -1305,7 +1305,7 @@ public class ContractServiceImpl implements ContractService { || DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus()))) { throw exception(CONTRACT_STATUS_NOT_SUBMIT_ERP, - DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); + DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); } // 生成ERP合同映射表 @@ -1439,7 +1439,7 @@ public class ContractServiceImpl implements ContractService { // 合同状态校验 if (!DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus())) { throw exception(CONTRACT_STATUS_NOT_ARCHIVE, - DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); + DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); } // 设置归档状态 @@ -1467,7 +1467,7 @@ public class ContractServiceImpl implements ContractService { // 合同状态校验 if (!DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())) { throw exception(CONTRACT_STATUS_NOT_ARCHIVE, - DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); + DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); } // 设置作废状态 @@ -1498,7 +1498,7 @@ public class ContractServiceImpl implements ContractService { // 合同状态校验 if (!DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())) { throw exception(CONTRACT_STATUS_NOT_ARCHIVE, - DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); + DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel()); } // 设置完结状态 From a2e2c479518b9e07f2278ed5ef3818e977e48056 Mon Sep 17 00:00:00 2001 From: liss <1780094091@qq.com> Date: Tue, 21 Oct 2025 09:52:15 +0800 Subject: [PATCH 2/6] =?UTF-8?q?erp=E6=8F=90=E4=BA=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zt/plat/module/erp/api/dto/ErpSubmitReqDTO.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zt-module-erp/zt-module-erp-api/src/main/java/com/zt/plat/module/erp/api/dto/ErpSubmitReqDTO.java b/zt-module-erp/zt-module-erp-api/src/main/java/com/zt/plat/module/erp/api/dto/ErpSubmitReqDTO.java index 2519329..39ca91f 100644 --- a/zt-module-erp/zt-module-erp-api/src/main/java/com/zt/plat/module/erp/api/dto/ErpSubmitReqDTO.java +++ b/zt-module-erp/zt-module-erp-api/src/main/java/com/zt/plat/module/erp/api/dto/ErpSubmitReqDTO.java @@ -22,11 +22,17 @@ public class ErpSubmitReqDTO { * "sign": 签名,uuid+srcsys+密码,MD5 32位小写签名,密码另行约定 * "req": {具体参数,参见RFC功能列表} */ + @Schema(description = "接口编号,必须,参见RFC功能列表,可调用接口编号范围051-900") private String funcnr; + @Schema(description = "调用系统业务单据编号,必须,在外部系统唯一,用于关联") private String bskey; + @Schema(description = "SAP系统ID, 必须") private String usrid; + @Schema(description = "源调用系统ID,必须") private String usrnm; - private String sign; +// @Schema(description = "签名,uuid+srcsys+密码,MD5 32位小写签名,密码另行约定") +// private String sign; + @Schema(description = "具体参数,参见RFC功能列表") private Map req; } From 06e1a7787326b60268091e0bf189e1e80699008b Mon Sep 17 00:00:00 2001 From: liss <1780094091@qq.com> Date: Tue, 21 Oct 2025 14:43:09 +0800 Subject: [PATCH 3/6] =?UTF-8?q?erp=E7=94=9F=E4=BA=A7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=B7=A5=E5=8E=82=EF=BC=8C=E7=89=A9=E6=96=99=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=8F=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/service/erp/ErpProductiveVersionServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpProductiveVersionServiceImpl.java b/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpProductiveVersionServiceImpl.java index 11771d4..c552f2b 100644 --- a/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpProductiveVersionServiceImpl.java +++ b/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpProductiveVersionServiceImpl.java @@ -159,8 +159,8 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ JSONObject dataJson = dataArray.getJSONObject(i); if (dataJson != null) { ErpProductiveVersionDO DO = new ErpProductiveVersionDO(); - DO.setFactoryNumber(dataJson.getString("MATNR") != null ? dataJson.getString("MATNR").trim() : null); - DO.setMaterialNumber(dataJson.getString("WERKS") != null ? dataJson.getString("WERKS").trim() : null); + DO.setFactoryNumber(dataJson.getString("WERKS") != null ? dataJson.getString("WERKS").trim() : null); + DO.setMaterialNumber(dataJson.getString("MATNR") != null ? dataJson.getString("MATNR").trim() : null); DO.setProductiveVersionNumber(dataJson.getString("VERID") != null ? dataJson.getString("VERID").trim() : null); DO.setProductiveVersionName(dataJson.getString("TEXT1")); DO.setBomNumber(dataJson.getString("STLAL")); From 5679aade47714ffa0ad5abd76e22e3005f34a9b1 Mon Sep 17 00:00:00 2001 From: liss <1780094091@qq.com> Date: Tue, 21 Oct 2025 15:10:15 +0800 Subject: [PATCH 4/6] =?UTF-8?q?erp=E6=B5=8B=E8=AF=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/zt/plat/module/erp/utils/ErpConfig.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/utils/ErpConfig.java b/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/utils/ErpConfig.java index e00d9e6..cdcf879 100644 --- a/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/utils/ErpConfig.java +++ b/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/utils/ErpConfig.java @@ -107,9 +107,6 @@ public class ErpConfig { requestBody.put("bskey", reqDTO.getBskey()); requestBody.put("usrid", reqDTO.getUsrid()); requestBody.put("usrnm", reqDTO.getUsrnm()); - if (reqDTO.getSign() != null) { - requestBody.put("sign", reqDTO.getSign()); - } if (reqDTO.getReq() != null) { requestBody.put("req", reqDTO.getReq()); } From 6fc56823742eb76005a0746d094fbd3b03ef86be Mon Sep 17 00:00:00 2001 From: liss <1780094091@qq.com> Date: Tue, 21 Oct 2025 15:23:47 +0800 Subject: [PATCH 5/6] =?UTF-8?q?erp=E7=94=9F=E4=BA=A7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E5=B7=A5=E8=89=BA=E8=B7=AF=E7=BA=BF=EF=BC=8C=E7=BB=84?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E5=99=A8=EF=BC=8C=E5=8F=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/service/erp/ErpProductiveVersionServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpProductiveVersionServiceImpl.java b/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpProductiveVersionServiceImpl.java index c552f2b..4e6e622 100644 --- a/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpProductiveVersionServiceImpl.java +++ b/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpProductiveVersionServiceImpl.java @@ -164,8 +164,8 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ DO.setProductiveVersionNumber(dataJson.getString("VERID") != null ? dataJson.getString("VERID").trim() : null); DO.setProductiveVersionName(dataJson.getString("TEXT1")); DO.setBomNumber(dataJson.getString("STLAL")); - DO.setBlineGroup(dataJson.getString("PLNNR")); - String alnalValue = dataJson.getString("ALNAL"); + DO.setBlineGroup(dataJson.getString("ALNAL")); + String alnalValue = dataJson.getString("PLNNR"); // 修复:增加对空字符串的判断 DO.setGroupCount(alnalValue != null && !alnalValue.trim().isEmpty() ? Long.valueOf(alnalValue.trim()) : null); String number = dataJson.getString("MATNR").trim() + "-" + dataJson.getString("WERKS").trim() + "-" + dataJson.getString("VERID").trim(); From a4b997ec49f851a95f497068e4b58792b663ea45 Mon Sep 17 00:00:00 2001 From: guojunyun Date: Tue, 21 Oct 2025 16:23:24 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=8F=90=E4=BA=A4erp=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=81=E4=BF=AE=E6=94=B9=E5=90=88=E5=90=8C?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/contract/ContractController.java | 2 +- .../service/contract/ContractService.java | 2 +- .../service/contract/ContractServiceImpl.java | 58 ++++++++++++++++--- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/controller/admin/contract/ContractController.java b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/controller/admin/contract/ContractController.java index f862935..fef3ebe 100644 --- a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/controller/admin/contract/ContractController.java +++ b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/controller/admin/contract/ContractController.java @@ -145,7 +145,7 @@ public class ContractController implements BusinessControllerMarker { @PostMapping("/submit/erp") @Operation(summary = "提交ERP") @PreAuthorize("@ss.hasPermission('base:contract:erp')") - public CommonResult submitErp(@RequestBody List ids) { + public CommonResult> submitErp(@RequestBody List ids) { return success(contractService.submitErp(ids)); } diff --git a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractService.java b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractService.java index 8adf1f8..e758493 100644 --- a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractService.java +++ b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractService.java @@ -105,7 +105,7 @@ public interface ContractService { * @param ids 合同ID集合 * @return */ - Boolean submitErp(List ids); + List submitErp(List ids); /** * 删除合同 diff --git a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractServiceImpl.java b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractServiceImpl.java index abb54c2..91f33c9 100644 --- a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractServiceImpl.java +++ b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/service/contract/ContractServiceImpl.java @@ -730,6 +730,29 @@ public class ContractServiceImpl implements ContractService { // 请求更新的合同信息 ContractMainDO newContractMainDO = BeanUtils.toBean(reqVO, ContractMainDO.class); + // 校验ERP的公司 + if (StringUtils.isNotEmpty(reqVO.getPurchaseCompanyNumber()) + || StringUtils.isNotEmpty(reqVO.getSalesCompanyNumber())) { + if (StringUtils.isNotEmpty(reqVO.getPurchaseCompanyNumber())) { + ErpCompanyDO erpCompany = erpCompanyService.getErpCompanyByNumber(reqVO.getPurchaseCompanyNumber()); + if (erpCompany == null) { + throw exception(CONTRACT_ERP_COMPANY_PLEASE_BIND, ApiConstants.PURCHASE); + } else { + newContractMainDO.setErpPurchaseCompanyNumber(erpCompany.getNumber()); + newContractMainDO.setErpPurchaseCompanyName(erpCompany.getName()); + } + } + if (StringUtils.isNotEmpty(reqVO.getSalesCompanyNumber())) { + ErpCompanyDO erpCompany = erpCompanyService.getErpCompanyByNumber(reqVO.getSalesCompanyNumber()); + if (erpCompany == null) { + throw exception(CONTRACT_ERP_COMPANY_PLEASE_BIND, ApiConstants.SALES); + } else { + newContractMainDO.setErpSalesCompanyNumber(erpCompany.getNumber()); + newContractMainDO.setErpSalesCompanyName(erpCompany.getName()); + } + } + } + // 删除关联信息 // 查询合同明细 List detailDOS = contractDetailMapper @@ -1289,7 +1312,9 @@ public class ContractServiceImpl implements ContractService { } @Override - public Boolean submitErp(List ids) { + public List submitErp(List ids) { + + List results = new ArrayList<>(); // 遍历合同ID集合 ids.forEach(id -> { @@ -1312,23 +1337,40 @@ public class ContractServiceImpl implements ContractService { ErpContractSaveReqVO erpContractVO = getErpContract(contractMainDO); // 调用ERP模块 - Map erpResult = sendToErp(erpContractVO); + JSONObject erpResult = sendToErp(erpContractVO); log.info("合同提交ERP结果:{}", erpResult); + String result = id + +"-"+erpResult.getBool("success") + +(erpResult.getBool("success") ? "" : "-" + erpResult.getStr("errMsg")); + results.add(result); + + // 更新合同状态 + if (erpResult.getBool("success")) { + contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode()); + contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_FIND.getCode()); + contractMainMapper.updateById(contractMainDO); + } else { + contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_PUSH_ERROR.getCode()); + contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_RLBK.getCode()); + // contractMainDO.setCause(erpResult.getStr("errMsg")); + contractMainMapper.updateById(contractMainDO); + } } else { - throw exception(CONTRACT_NOT_EXISTS); + results.add(id+"-"+"false"+"-"+CONTRACT_NOT_EXISTS); } }); - return true; + return results; } - private Map sendToErp(ErpContractSaveReqVO erpContractVO) { - Map erpResult = new HashMap<>(); + private JSONObject sendToErp(ErpContractSaveReqVO erpContractVO) { + JSONObject erpResult = new JSONObject(); try { String result = erpContractService.submitErp(erpContractVO); - erpResult.put(true, result); + erpResult.putOnce("success", true); } catch (Exception e) { - erpResult.put(false, e.getMessage()); + erpResult.putOnce("success", false); + erpResult.putOnce("errMsg", e.getMessage()); } return erpResult;