From 9f5e7703ea78c6f2ce1a1d174fed8ae153fe260a Mon Sep 17 00:00:00 2001 From: maolei Date: Thu, 15 May 2025 15:24:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(ic):=20=E5=AE=9E=E7=8E=B0=20=E8=B0=83?= =?UTF-8?q?=E6=8B=A8=E5=92=8C=E5=85=B6=E5=AE=83=E5=87=BA=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=8D=95=20=E5=90=8C=E6=AD=A5=E5=88=B0=20MES=20=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=20-=20=E4=BF=AE=E6=94=B9=20HttpPostOtherSysImpl=20?= =?UTF-8?q?=E7=B1=BB=EF=BC=8C=E4=BD=BF=E7=94=A8=20callMes=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=9B=BF=E4=BB=A3=20callLE=20-=20=E5=9C=A8=20SignBP?= =?UTF-8?q?=20=E4=B8=AD=E6=B7=BB=E5=8A=A0=E5=90=8C=E6=AD=A5=E8=A7=84?= =?UTF-8?q?=E5=88=99=20-=20=E6=9B=B4=E6=96=B0=E7=9B=B8=E5=85=B3=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BB=A5=E6=94=AF=E6=8C=81=E6=96=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ic/src/private/nc/bs/ic/m4a/sign/SignBP.java | 37 ++++ .../rule/AfterSignRuleSyncMesProcess.java | 182 ++++++++++++++++++ .../rule/AfterSigningSynchronizeRule.java | 3 +- ic/src/private/nc/bs/ic/m4i/sign/SignBP.java | 39 ++++ .../rule/AfterSignRuleSyncMesProcess.java | 176 +++++++++++++++++ .../rule/AfterApprovingSynchronizeRule.java | 6 +- .../impl/utils/HttpPostOtherSysImpl.java | 2 +- .../commen/itf/utils/IHttpPostOtherSys.java | 39 +++- 8 files changed, 475 insertions(+), 9 deletions(-) create mode 100644 ic/src/private/nc/bs/ic/m4a/sign/SignBP.java create mode 100644 ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncMesProcess.java create mode 100644 ic/src/private/nc/bs/ic/m4i/sign/SignBP.java create mode 100644 ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java diff --git a/ic/src/private/nc/bs/ic/m4a/sign/SignBP.java b/ic/src/private/nc/bs/ic/m4a/sign/SignBP.java new file mode 100644 index 0000000..78b9bf8 --- /dev/null +++ b/ic/src/private/nc/bs/ic/m4a/sign/SignBP.java @@ -0,0 +1,37 @@ + +package nc.bs.ic.m4a.sign; + + +import nc.bs.ic.general.rule.after.UpdateSCOnhandRule; +import nc.bs.ic.general.rule.before.InOutAuditDateCheck; +import nc.bs.ic.general.sign.ISignBP; +import nc.bs.ic.general.sign.ISignRuleProvider; +import nc.bs.ic.general.sign.SignBPTemplate; +import nc.bs.ic.m4a.base.BPPlugInPoint; +import nc.bs.ic.m4a.sign.rule.AfterSignRuleForLiabilityProcess; +import nc.bs.ic.m4a.sign.rule.AfterSignRuleSyncMesProcess; +import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; +import nc.vo.ic.m4a.entity.GeneralInVO; + +public class SignBP implements ISignBP, ISignRuleProvider { + + public void addAfterRule(GeneralInVO[] vos, AroundProcesser processor) { + processor.addAfterRule(new UpdateSCOnhandRule(false, true)); + processor.addAfterRule(new AfterSignRuleSyncMesProcess()); + processor.addAfterRule(new AfterSignRuleForLiabilityProcess()); + processor.addBeforeRule(new AfterSignRuleSyncMesProcess()); + } + + public void addBeforeRule(GeneralInVO[] vos, AroundProcesser processor) { + processor.addBeforeRule(new VOSagaFrozenValidateRule(true)); + processor.addBeforeRule(new InOutAuditDateCheck()); + } + + public GeneralInVO[] sign(GeneralInVO[] bills) { + SignBPTemplate insertBP = new SignBPTemplate(BPPlugInPoint.SignAction, this); + GeneralInVO[] resultVOs = (GeneralInVO[]) insertBP.sign(bills); + return resultVOs; + } + +} diff --git a/ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncMesProcess.java b/ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncMesProcess.java new file mode 100644 index 0000000..90417a7 --- /dev/null +++ b/ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncMesProcess.java @@ -0,0 +1,182 @@ +package nc.bs.ic.m4a.sign.rule; + + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.framework.common.NCLocator; +import nc.bs.logging.Log; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.itf.uif.pub.IUifService; +import nc.vo.bd.material.MaterialVersionVO; +import nc.vo.bd.stordoc.StordocVO; +import nc.vo.ic.m4a.entity.GeneralInBodyVO; +import nc.vo.ic.m4a.entity.GeneralInHeadVO; +import nc.vo.ic.m4a.entity.GeneralInVO; +import nc.vo.pub.BusinessException; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nccloud.pubift.commen.impl.utils.HttpPostOtherSysImpl; +import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; + +import java.util.Objects; + +public class AfterSignRuleSyncMesProcess implements IRule { + + public static final IHttpPostOtherSys LOOKUP = new HttpPostOtherSysImpl(); + + private static final String LOG_INFO_NAME = "OALOG"; + + private static final Log obmlog = Log.getInstance(LOG_INFO_NAME); + + private static final IUifService IUIFSERVICE = NCLocator.getInstance().lookup(IUifService.class); + + public void process(GeneralInVO[] vos) { + if (vos != null && vos.length != 0) { + try { + for (GeneralInVO vo : vos) { + syncOtherSystem(vo); + } + } catch (BusinessException ex) { + ExceptionUtils.wrappException(ex); + } + } + } + + private void syncOtherSystem(GeneralInVO generalInVO) throws BusinessException { + GeneralInHeadVO head = generalInVO.getHead(); + obmlog.debug("触发同步其它入库单(M4A), 单据号:" + head.getVbillcode() + ", 出库类型编码:" + head.getVtrantypecode() + "开始拼接数据"); + + // 调拨入库 + if ("4A-02".equals(head.getVtrantypecode())) { + // 表体body信息拼接 + JSONArray details = new JSONArray(); + // 填充details + for (GeneralInBodyVO body : generalInVO.getBodys()) { + JSONObject temp = new JSONObject(); + temp.put("orderNo", head.getVbillcode()); + temp.put("sequenceNum", body.getCrowno()); + temp.put("type", "DBCK"); + MaterialVersionVO materialVersionVO = (MaterialVersionVO) IUIFSERVICE.queryByPrimaryKey(MaterialVersionVO.class, body.getCmaterialvid()); + if (Objects.isNull(materialVersionVO)) { + throw new BusinessException("物料信息不存在, 主键:" + body.getCmaterialvid()); + } + temp.put("materialId", materialVersionVO.getCode()); + temp.put("outQty", body.getNshouldnum() != null ? body.getNshouldnum().doubleValue() : null); + temp.put("actOutQty", body.getNnum() != null ? body.getNnum().doubleValue() : null); + temp.put("assistActOutQry", ""); // Per example for similar field + temp.put("productNum", null); + temp.put("outStorageId", body.getClocationid()); // 拨入库位 (destination location) + temp.put("outBatchNum", body.getVbatchcode()); // 批号 (received batch) + temp.put("customId", null); + temp.put("supplierId", null); + temp.put("manufactureDate", null); + temp.put("color", null); + temp.put("packLen", null); + temp.put("packSize", null); + temp.put("remark", body.getVnotebody()); + details.add(temp); + } + + JSONObject info = new JSONObject(); + info.put("details", details); + // 从head中取数 + info.put("orderNo", head.getVbillcode()); + info.put("type", "DBCK"); + info.put("genType", null); + info.put("outDate", head.getDbilldate() != null ? head.getDbilldate().toString() : null); + + StordocVO outWarehouse = (StordocVO) IUIFSERVICE.queryByPrimaryKey(StordocVO.class, head.getCwarehouseid()); + if (Objects.isNull(outWarehouse)) { + throw new BusinessException("拨出仓库信息不存在, 主键:" + head.getCwarehouseid()); + } + info.put("outStoreId", outWarehouse.getCode()); + + StordocVO inWarehouse = (StordocVO) IUIFSERVICE.queryByPrimaryKey(StordocVO.class, head.getCotherwhid()); + if (Objects.isNull(inWarehouse)) { + throw new BusinessException("拨入仓库信息不存在, 主键:" + head.getCotherwhid()); + } + info.put("inStoreId", inWarehouse.getCode()); + + info.put("workerNo", null); + info.put("worker", null); + info.put("storeKeeper", head.getCwhsmanagerid()); + info.put("returned", "N"); + info.put("mark", "N"); + info.put("remark", head.getVnote()); + info.put("oldOrderNo", null); + + // 拼接数据,先创建一个jsonObject + JSONObject requestData = new JSONObject(); + requestData.put("operation_type", "I"); // 固定给I 操作 + requestData.put("info", info); + obmlog.debug("调拨入库requestData:" + requestData.toJSONString()); + + IHttpPostOtherSys httpService = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); + httpService.sendToExternalSystem("test", requestData); + obmlog.debug("调拨入库单 " + head.getVbillcode() + " 同步成功"); + } + // 其它入库 + else if ("4A-01".equals(head.getVtrantypecode())) { + obmlog.debug("开始处理其它入库单(4A-01): " + head.getVbillcode()); + // 表体body信息拼接 + JSONArray details = new JSONArray(); + // 填充details + for (GeneralInBodyVO body : generalInVO.getBodys()) { + JSONObject temp = new JSONObject(); + temp.put("orderNo", head.getVbillcode()); + temp.put("sequenceNum", body.getCrowno()); + temp.put("type", "QTRK"); + + MaterialVersionVO materialVersionVO = (MaterialVersionVO) IUIFSERVICE.queryByPrimaryKey(MaterialVersionVO.class, body.getCmaterialvid()); + if (Objects.isNull(materialVersionVO)) { + throw new BusinessException("物料信息不存在, 主键:" + body.getCmaterialvid()); + } + temp.put("materialId", materialVersionVO.getCode()); + temp.put("recQty", body.getNshouldnum() != null ? body.getNshouldnum().doubleValue() : null); + temp.put("actQty", body.getNnum() != null ? body.getNnum().doubleValue() : null); + temp.put("assistActQry", ""); + temp.put("productNum", null); + temp.put("storageId", body.getClocationid()); + temp.put("batchNum", body.getVbatchcode()); + temp.put("customId", null); + temp.put("supplierId", null); + temp.put("manufactureDate", null); + temp.put("color", null); + temp.put("packLen", null); + temp.put("packSize", null); + temp.put("remark", body.getVnotebody()); + details.add(temp); + } + + JSONObject info = new JSONObject(); + info.put("details", details); + // 从head中取数 + info.put("orderNo", head.getVbillcode()); + info.put("type", "QTRK"); + info.put("actureDate", head.getDmakedate() != null ? head.getDmakedate().toString() : null); + + StordocVO warehouse = (StordocVO) IUIFSERVICE.queryByPrimaryKey(StordocVO.class, head.getCwarehouseid()); + if (Objects.isNull(warehouse)) { + throw new BusinessException("仓库信息不存在, 主键:" + head.getCwarehouseid()); + } + info.put("storeId", warehouse.getCode()); + + info.put("workerNo", null); + info.put("worker", null); + info.put("storeKeeper", head.getCwhsmanagerid()); + info.put("returned", "N"); + info.put("mark", "N"); + info.put("remark", head.getVnote()); + + // 拼接数据,先创建一个jsonObject + JSONObject requestData = new JSONObject(); + requestData.put("operation_type", "I"); // 固定给I 操作 + requestData.put("info", info); + obmlog.debug("其它入库(4A-01) requestData:" + requestData.toJSONString()); + + IHttpPostOtherSys httpService = LOOKUP; + httpService.sendToExternalSystem("test", requestData); + obmlog.debug("其它入库单(4A-01) " + head.getVbillcode() + " 同步成功"); + } + } + +} diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java index 03650ba..bdfd9ba 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java @@ -11,7 +11,6 @@ import nc.vo.ic.m4c.entity.SaleOutHeadVO; import nc.vo.ic.m4c.entity.SaleOutVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDate; -import nccloud.pubift.commen.impl.utils.HttpPostOtherSysImpl; import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; import java.text.SimpleDateFormat; @@ -42,7 +41,7 @@ public class AfterSigningSynchronizeRule implements IRule { // 构建要发送的数据 JSONObject syncData = buildSyncData(hvo, bvos); // 发送数据到金思维系统(使用HttpPostOtherSysImpl处理网络请求) - String mesResponse = httpPostOtherSys.callLE(SALE_OUT_URL, syncData); + String mesResponse = httpPostOtherSys.callMes(SALE_OUT_URL, syncData); obmlog.debug("AfterSigningSynchronizeRule-金思维系统响应: " + mesResponse); // 解析响应,处理结果 processResponse(hvo.getVbillcode(), mesResponse); diff --git a/ic/src/private/nc/bs/ic/m4i/sign/SignBP.java b/ic/src/private/nc/bs/ic/m4i/sign/SignBP.java new file mode 100644 index 0000000..1c9ef8a --- /dev/null +++ b/ic/src/private/nc/bs/ic/m4i/sign/SignBP.java @@ -0,0 +1,39 @@ +package nc.bs.ic.m4i.sign; + + +import nc.bs.ic.general.rule.after.UpdateSCOnhandRule; +import nc.bs.ic.general.rule.before.InOutAuditDateCheck; +import nc.bs.ic.general.sign.ISignBP; +import nc.bs.ic.general.sign.ISignRuleProvider; +import nc.bs.ic.general.sign.SignBPTemplate; +import nc.bs.ic.m4i.base.BPPlugInPoint; +import nc.bs.ic.m4i.sign.rule.AfterSignRuleForFinanceProcess; +import nc.bs.ic.m4i.sign.rule.AfterSignRuleForLiabilityProcess; +import nc.bs.ic.m4i.sign.rule.AfterSignRuleForMatterApp; +import nc.bs.ic.m4i.sign.rule.AfterSignRuleSyncMesProcess; +import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; +import nc.vo.ic.m4i.entity.GeneralOutVO; + +public class SignBP implements ISignBP, ISignRuleProvider { + + public void addAfterRule(GeneralOutVO[] vos, AroundProcesser processor) { + processor.addAfterRule(new UpdateSCOnhandRule(false, false)); + processor.addAfterRule(new AfterSignRuleForFinanceProcess()); + processor.addAfterRule(new AfterSignRuleForLiabilityProcess()); + processor.addAfterRule(new AfterSignRuleForMatterApp()); + processor.addBeforeRule(new AfterSignRuleSyncMesProcess()); + } + + public void addBeforeRule(GeneralOutVO[] vos, AroundProcesser processor) { + processor.addBeforeRule(new VOSagaFrozenValidateRule(true)); + processor.addBeforeRule(new InOutAuditDateCheck()); + } + + public GeneralOutVO[] sign(GeneralOutVO[] bills) { + SignBPTemplate insertBP = new SignBPTemplate(BPPlugInPoint.SignAction, this); + GeneralOutVO[] resultVOs = (GeneralOutVO[]) insertBP.sign(bills); + return resultVOs; + } + +} diff --git a/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java b/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java new file mode 100644 index 0000000..39d1903 --- /dev/null +++ b/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java @@ -0,0 +1,176 @@ +package nc.bs.ic.m4i.sign.rule; + + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.framework.common.NCLocator; +import nc.bs.logging.Log; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.itf.uif.pub.IUifService; +import nc.vo.bd.material.MaterialVersionVO; +import nc.vo.bd.stordoc.StordocVO; +import nc.vo.ic.m4i.entity.GeneralOutBodyVO; +import nc.vo.ic.m4i.entity.GeneralOutHeadVO; +import nc.vo.ic.m4i.entity.GeneralOutVO; +import nc.vo.pub.BusinessException; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; + +import java.util.Objects; + +public class AfterSignRuleSyncMesProcess implements IRule { + + + private static String logginfo = "OALOG"; + + private static Log obmlog = Log.getInstance(logginfo); + + private IUifService iUifService = NCLocator.getInstance().lookup(IUifService.class); + + public void process(GeneralOutVO[] vos) { + if (vos != null && vos.length != 0) { + try { + for (GeneralOutVO vo : vos) { + syncOtherSystem(vo); + } + } catch (BusinessException ex) { + ExceptionUtils.wrappException(ex); + } + + } + } + + + private void syncOtherSystem(GeneralOutVO generalOutVO) throws BusinessException { + obmlog.debug("触发同步其它出库单,出库类型编码:" + generalOutVO.getHead().getVtrantypecode() + "开始拼接数据"); + +// if (!generalOutVO.getHead().getPk_org().equals("0001A110000000000677")) { +// obmlog.debug("仅同步山东泰开电缆有限公司,当前组织:" + generalOutVO.getHead().getPk_org()); +// return; // 仅操作山东泰开电缆有限公司 +// } + + // 其它出库 + if (generalOutVO.getHead().getVtrantypecode().equals("4I-01")) { + // 表体body信息拼接 + JSONArray details = new JSONArray(); + GeneralOutHeadVO head = generalOutVO.getHead(); + // 填充details + for (GeneralOutBodyVO body : generalOutVO.getBodys()) {// body中取数 + JSONObject temp = new JSONObject(); + temp.put("orderNo", head.getVbillcode()); + temp.put("sequenceNum", body.getCrowno()); + temp.put("type", "QTCK"); + MaterialVersionVO materialVersionVO = (MaterialVersionVO) iUifService.queryByPrimaryKey(MaterialVersionVO.class, body.getCmaterialoid()); + if (Objects.isNull(materialVersionVO)) { + throw new BusinessException("搜索物料信息不存在"); + } + temp.put("materialId", materialVersionVO.getCode()); + temp.put("issuedQty", body.getNshouldnum().doubleValue()); + temp.put("actQty", body.getNnum().doubleValue()); + temp.put("assistActQry", ""); + temp.put("productNum", null); + temp.put("storageId", body.getClocationid()); + temp.put("batchNum", body.getVbatchcode()); + temp.put("customId", null); + temp.put("supplierId", null); + temp.put("manufactureDate", null); + temp.put("remark", body.getVnotebody()); + details.add(temp); + } + JSONObject info = new JSONObject(); + info.put("details", details); + // 从head中取数 + info.put("orderNo", head.getVbillcode()); + info.put("type", "QTCK"); + info.put("actureDate", head.getDmakedate().toString()); + StordocVO warehouse = (StordocVO) iUifService.queryByPrimaryKey(StordocVO.class, head.getCwarehouseid()); + if (Objects.isNull(warehouse)) { + throw new BusinessException("仓库信息不存在,主键:" + head.getCwarehouseid()); + } + info.put("storeId", warehouse.getCode()); + info.put("workerNo", null); + info.put("worker", null); + info.put("storeKeeper", head.getCwhsmanagerid()); + info.put("returned", "N"); + info.put("mark", "N"); + info.put("remark", head.getVnote()); + + // 拼接数据,先创建一个jsonObject + JSONObject requestData = new JSONObject(); + requestData.put("operation_type", "I");// 固定给I 操作 + requestData.put("info", info); + obmlog.debug("其它出库requestData:" + requestData.toJSONString()); + } + // 调拨出库/转库单 + if (generalOutVO.getHead().getVtrantypecode().equals("4I-02")) { + // 表体body信息拼接 + JSONArray details = new JSONArray(); + GeneralOutHeadVO head = generalOutVO.getHead(); + // 填充details + for (GeneralOutBodyVO body : generalOutVO.getBodys()) {// body中取数 + JSONObject temp = new JSONObject(); + temp.put("orderNo", head.getVbillcode()); + temp.put("sequenceNum", body.getCrowno()); + temp.put("type", "DBCK"); + temp.put("genType", null); + MaterialVersionVO materialVersionVO = (MaterialVersionVO) iUifService.queryByPrimaryKey(MaterialVersionVO.class, body.getCmaterialoid()); + if (Objects.isNull(materialVersionVO)) { + throw new BusinessException("搜索物料信息不存在"); + } + temp.put("materialId", materialVersionVO.getCode()); + temp.put("issuedQty", body.getNshouldnum().doubleValue()); + temp.put("actQty", body.getNnum().doubleValue()); + temp.put("outQty", body.getNnum().doubleValue()); + temp.put("assistActQry", ""); + temp.put("productNum", null); + temp.put("outStorageId", body.getClocationid()); + temp.put("outBatchNum", body.getVbatchcode()); + temp.put("customId", null); + temp.put("supplierId", null); + temp.put("manufactureDate", null); + temp.put("color", null); + temp.put("packLen", null); + temp.put("packSize", null); + temp.put("remark", body.getVnotebody()); + details.add(temp); + } + JSONObject info = new JSONObject(); + info.put("details", details); + // 从head中取数 + info.put("orderNo", head.getVbillcode()); + info.put("type", "DBCK"); + info.put("genType", null); + info.put("outDate", head.getDbilldate().toString()); + + StordocVO outWarehouse = (StordocVO) iUifService.queryByPrimaryKey(StordocVO.class, head.getCwarehouseid()); + if (Objects.isNull(outWarehouse)) { + throw new BusinessException("出库仓库信息不存在,主键:" + head.getCwarehouseid()); + } + info.put("outStoreId", outWarehouse.getCode()); + + StordocVO inWarehouse = (StordocVO) iUifService.queryByPrimaryKey(StordocVO.class, head.getCotherwhid()); + if (Objects.isNull(inWarehouse)) { + throw new BusinessException("入库仓库信息不存在,主键:" + head.getCotherwhid()); + } + info.put("inStoreId", inWarehouse.getCode()); + info.put("workerNo", null); + info.put("worker", null); + info.put("storeKeeper", head.getCwhsmanagerid()); + info.put("returned", "N"); + info.put("mark", "N"); + info.put("remark", head.getVnote()); + + // 拼接数据,先创建一个jsonObject + JSONObject requestData = new JSONObject(); + requestData.put("operation_type", "I");// 固定给I 操作 + requestData.put("info", info); + obmlog.debug("其它出库requestData:" + requestData.toJSONString()); + + IHttpPostOtherSys httpService = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); + httpService.sendToExternalSystem("test", requestData); + } + + } + + +} diff --git a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java index 6d48aaf..44a1525 100644 --- a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java +++ b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java @@ -1,5 +1,6 @@ package nc.bs.ic.m4r.approve.rule; + import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.yonyou.cloud.utils.StringUtils; @@ -7,12 +8,11 @@ import nc.bs.framework.common.NCLocator; import nc.bs.logging.Log; import nc.impl.pubapp.pattern.rule.IRule; import nc.vo.ic.m4r.entity.InvCountBillVO; -import nc.vo.ic.m4r.entity.InvCountHeaderVO; import nc.vo.ic.m4r.entity.InvCountBodyVO; +import nc.vo.ic.m4r.entity.InvCountHeaderVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDate; import nc.vo.pub.lang.UFDouble; -import nccloud.pubift.commen.impl.utils.HttpPostOtherSysImpl; import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; import java.text.SimpleDateFormat; @@ -46,7 +46,7 @@ public class AfterApprovingSynchronizeRule implements IRule { JSONObject syncData = buildSyncData(hvo, bvos); // 发送数据到金思维系统(使用HttpPostOtherSysImpl处理网络请求) - String mesResponse = httpPostOtherSys.callLE(INV_COUNT_URL, syncData); + String mesResponse = httpPostOtherSys.callMes(INV_COUNT_URL, syncData); obmlog.debug("AfterApprovingSynchronizeRule-金思维系统响应: " + mesResponse); // 解析响应,处理结果 diff --git a/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java b/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java index bc21517..ec6f650 100644 --- a/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java +++ b/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java @@ -22,7 +22,7 @@ public class HttpPostOtherSysImpl implements IHttpPostOtherSys { private static final String LOGIN_URL = "/GTHINKING/AjaxService/N_MISPRO/100208057.ashx/Login"; @Override - public String callLE(String url, JSONObject json) { + public String callMes(String url, JSONObject json) { // String leip = SysParaInitQuery.getParaString(PubEnv.getPk_group(), "LEIP"); String mesip = "http://192.168.29.32"; String baseurl = mesip + url; diff --git a/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java b/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java index c4da62e..2b4ba2e 100644 --- a/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java +++ b/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java @@ -1,15 +1,48 @@ package nccloud.pubift.commen.itf.utils; import com.alibaba.fastjson.JSONObject; +import nc.bs.framework.common.NCLocator; +import nc.vo.pub.BusinessException; + +import java.util.Iterator; +import java.util.Map; public interface IHttpPostOtherSys { /** - * xuwjl@yonyou.com 2025年4月24日 15:24:14 - * @param url LE的接口地址,不包含ip + * @param apiPath MES的接口地址,不包含ip * @param json 入参 */ - public String callLE(String url, JSONObject json); + public String callMes(String apiPath, JSONObject json); + /** + * 发送数据到外部系统 + */ + default void sendToExternalSystem(String apiPaht, Map requestData) throws BusinessException { + try { + IHttpPostOtherSys httpService = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); + JSONObject jsonRequest = new JSONObject(requestData); + String response = httpService.callMes(apiPaht, jsonRequest); + JSONObject jsonResponse = JSONObject.parseObject(response); + + int code = jsonResponse.getIntValue("code"); + if (code != 0) { + throw new Exception("自定义档案同步失败,错误码:" + code + ",消息:" + jsonResponse.getString("message")); + } + + if (jsonResponse.containsKey("data") && !jsonResponse.getJSONObject("data").isEmpty()) { + JSONObject data = jsonResponse.getJSONObject("data"); + StringBuilder errorMsg = new StringBuilder("自定义档案同步出现错误:"); + Iterator keys = data.keySet().iterator(); + while (keys.hasNext()) { + String key = keys.next(); + errorMsg.append("\n编码 ").append(key).append(": ").append(data.get(key)); + } + throw new Exception(errorMsg.toString()); + } + } catch (Exception e) { + throw new BusinessException("调用外部接口失败:" + e.getMessage(), e); + } + } }