From 4d3a5daba2a223ad5ce220c0fd71d88161ab0da5 Mon Sep 17 00:00:00 2001 From: maolei Date: Wed, 21 May 2025 16:28:06 +0800 Subject: [PATCH] =?UTF-8?q?ic=5F=E5=85=B6=E5=AE=83=E5=87=BA=E5=85=A5?= =?UTF-8?q?=E5=BA=93&=E8=B0=83=E6=8B=A8=E5=87=BA=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 AfterSignRuleSyncInToMesProcess 类用于处理入库单同步 - 新增 AfterSignRuleSyncOutToMesProcess 类用于处理出库单同步 - 删除旧的 AfterSignRuleSyncMesProcess 类 - 更新 SignBP 类中的规则引用 --- ic/src/private/nc/bs/ic/m4a/sign/SignBP.java | 8 +- .../rule/AfterSignRuleSyncInToMesProcess.java | 208 ++++++++++++++++++ .../rule/AfterSignRuleSyncMesProcess.java | 182 --------------- ic/src/private/nc/bs/ic/m4i/sign/SignBP.java | 5 +- ... => AfterSignRuleSyncOutToMesProcess.java} | 96 ++++---- 5 files changed, 268 insertions(+), 231 deletions(-) create mode 100644 ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncInToMesProcess.java delete mode 100644 ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncMesProcess.java rename ic/src/private/nc/bs/ic/m4i/sign/rule/{AfterSignRuleSyncMesProcess.java => AfterSignRuleSyncOutToMesProcess.java} (61%) diff --git a/ic/src/private/nc/bs/ic/m4a/sign/SignBP.java b/ic/src/private/nc/bs/ic/m4a/sign/SignBP.java index 78b9bf8..0a6d304 100644 --- a/ic/src/private/nc/bs/ic/m4a/sign/SignBP.java +++ b/ic/src/private/nc/bs/ic/m4a/sign/SignBP.java @@ -1,4 +1,3 @@ - package nc.bs.ic.m4a.sign; @@ -8,8 +7,9 @@ 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.AfterSignRuleForFinanceProcess; import nc.bs.ic.m4a.sign.rule.AfterSignRuleForLiabilityProcess; -import nc.bs.ic.m4a.sign.rule.AfterSignRuleSyncMesProcess; +import nc.bs.ic.m4a.sign.rule.AfterSignRuleSyncInToMesProcess; import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; import nc.vo.ic.m4a.entity.GeneralInVO; @@ -18,9 +18,9 @@ public class SignBP implements ISignBP, ISignRuleProvider processor) { processor.addAfterRule(new UpdateSCOnhandRule(false, true)); - processor.addAfterRule(new AfterSignRuleSyncMesProcess()); + processor.addAfterRule(new AfterSignRuleForFinanceProcess()); processor.addAfterRule(new AfterSignRuleForLiabilityProcess()); - processor.addBeforeRule(new AfterSignRuleSyncMesProcess()); + processor.addBeforeRule(new AfterSignRuleSyncInToMesProcess()); } public void addBeforeRule(GeneralInVO[] vos, AroundProcesser processor) { diff --git a/ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncInToMesProcess.java b/ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncInToMesProcess.java new file mode 100644 index 0000000..1ab715f --- /dev/null +++ b/ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncInToMesProcess.java @@ -0,0 +1,208 @@ +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.itf.utils.IHttpPostOtherSys; + +import java.util.Objects; + +public class AfterSignRuleSyncInToMesProcess implements IRule { + + public static final IHttpPostOtherSys HTTP_POST_OTHER_SYS = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); + + 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 syncOtherIn(GeneralInVO generalInVO) throws BusinessException { + GeneralInHeadVO head = generalInVO.getHead(); + 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()); // ֪ͨID + 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()); // ID + temp.put("recQty", body.getNnum() != null ? body.getNnum().doubleValue() : null); // Ӧ + temp.put("actQty", body.getNshouldnum() != null ? body.getNshouldnum().doubleValue() : null); // ʵ + temp.put("assistActQry", body.getNassistnum() != null ? body.getNassistnum().doubleValue() : 0); // ʵ + temp.put("productNum", null); // Ʒ + temp.put("storageId", body.getClocationid()); // λ + temp.put("batchNum", body.getVbatchcode()); // + temp.put("customId", null); // ͻID + temp.put("supplierId", null); // ӦID + 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()); // ֪ͨID + info.put("type", "QTRK"); // + info.put("actureDate", head.getDmakedate() != null ? head.getDmakedate().toString() : null); // ʵ + + info.put("department", null); // + info.put("customId", null); // ͻ + info.put("supplierId", null); // Ӧ + + + StordocVO warehouse = (StordocVO) IUIFSERVICE.queryByPrimaryKey(StordocVO.class, head.getCwarehouseid()); + if (Objects.isNull(warehouse)) { + throw new BusinessException("ֿϢ, :" + head.getCwarehouseid()); + } + if (warehouse.getCode() != null && warehouse.getCode().length() > 4) { + throw new BusinessException("MESϵͳֿ[" + warehouse.getCode() + "]ܳ4λѡʵIJֿ!"); + } + info.put("storeId", warehouse.getCode()); // ֿID + + 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"); // + requestData.put("info", info); + obmlog.debug("(4A-01) requestData:" + requestData.toJSONString()); + + HTTP_POST_OTHER_SYS.sendToExternalSystem("/GTHINKING/AjaxService/N_KCSJJS/101527002.ashx/gt_rec_api_qtrkdj", requestData); + obmlog.debug("ⵥ(4A-01) " + head.getVbillcode() + " ͬɹ"); + } + + private void syncOtherSystem(GeneralInVO generalInVO) throws BusinessException { + GeneralInHeadVO head = generalInVO.getHead(); + obmlog.debug("ͬⵥ(M4A), ݺ:" + head.getVbillcode() + ", ͱ:" + head.getVtrantypecode() + "ʼƴ"); + +// if (!generalOutVO.getHead().getPk_org().equals("0001A110000000000677")) { +// obmlog.debug("ͬɽ̩޹˾,ǰ֯:" + generalOutVO.getHead().getPk_org()); +// return; // ɽ̩޹˾ +// } + + // + if ("4A-02".equals(head.getVtrantypecode())) { + syncTransferIn(generalInVO); + } + // + else if ("4A-01".equals(head.getVtrantypecode())) { + syncOtherIn(generalInVO); + } + } + + private void syncTransferIn(GeneralInVO generalInVO) throws BusinessException { + GeneralInHeadVO head = generalInVO.getHead(); + // bodyϢƴ + JSONArray details = new JSONArray(); + // details + for (GeneralInBodyVO body : generalInVO.getBodys()) { + JSONObject temp = new JSONObject(); + temp.put("orderNo", head.getVbillcode()); // ֪ͨID + temp.put("sequenceNum", body.getCrowno()); // ֪ͨ + temp.put("type", "DBRK"); // + MaterialVersionVO materialVersionVO = (MaterialVersionVO) IUIFSERVICE.queryByPrimaryKey(MaterialVersionVO.class, body.getCmaterialvid()); + if (Objects.isNull(materialVersionVO)) { + throw new BusinessException("Ϣ, :" + body.getCmaterialvid()); + } + temp.put("materialId", materialVersionVO.getCode()); // ID + temp.put("outQty", body.getNnum() != null ? body.getNnum().doubleValue() : null); // Ӧ + temp.put("actInQty", body.getNshouldnum() != null ? body.getNshouldnum().doubleValue() : null); // ʵ + temp.put("assistActInQry", body.getNassistnum() != null ? body.getNassistnum().doubleValue() : 0); // ʵ + temp.put("productNum", null); // Ʒ + temp.put("inStorageId", body.getClocationid()); // λ + temp.put("inBatchNum", body.getVbatchcode()); // + temp.put("customId", null); // ͻID + temp.put("supplierId", null); // ӦID + 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()); // ֪ͨID + info.put("type", "DBRK"); // + 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()); + } + if (outWarehouse.getCode() != null && outWarehouse.getCode().length() > 4) { + throw new BusinessException("MESϵͳֿ[" + outWarehouse.getCode() + "]ܳ4λѡʵIJֿ!"); + } + info.put("outStoreId", outWarehouse.getCode()); // ֿID + + StordocVO inWarehouse = (StordocVO) IUIFSERVICE.queryByPrimaryKey(StordocVO.class, head.getCotherwhid()); + if (Objects.isNull(inWarehouse)) { + throw new BusinessException("ֿϢ, :" + head.getCotherwhid()); + } + if (inWarehouse.getCode() != null && inWarehouse.getCode().length() > 4) { + throw new BusinessException("MESϵͳֿ[" + inWarehouse.getCode() + "]ܳ4λѡʵIJֿ!"); + } + info.put("inStoreId", inWarehouse.getCode()); // ֿID + + 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"); // + requestData.put("info", info); + obmlog.debug("requestData:" + requestData.toJSONString()); + + HTTP_POST_OTHER_SYS.sendToExternalSystem("/GTHINKING/AjaxService/N_KCSJJS/101527013.ashx/gt_rec_api_dbrkdj", requestData); + obmlog.debug("ⵥ " + head.getVbillcode() + " ͬɹ"); + } + +} 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 deleted file mode 100644 index 90417a7..0000000 --- a/ic/src/private/nc/bs/ic/m4a/sign/rule/AfterSignRuleSyncMesProcess.java +++ /dev/null @@ -1,182 +0,0 @@ -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/m4i/sign/SignBP.java b/ic/src/private/nc/bs/ic/m4i/sign/SignBP.java index 1c9ef8a..030c09f 100644 --- a/ic/src/private/nc/bs/ic/m4i/sign/SignBP.java +++ b/ic/src/private/nc/bs/ic/m4i/sign/SignBP.java @@ -1,3 +1,4 @@ + package nc.bs.ic.m4i.sign; @@ -10,7 +11,7 @@ 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.ic.m4i.sign.rule.AfterSignRuleSyncOutToMesProcess; import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; import nc.vo.ic.m4i.entity.GeneralOutVO; @@ -22,7 +23,7 @@ public class SignBP implements ISignBP, ISignRuleProvider processor) { diff --git a/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java b/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncOutToMesProcess.java similarity index 61% rename from ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java rename to ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncOutToMesProcess.java index a21bda9..b50be1d 100644 --- a/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java +++ b/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncOutToMesProcess.java @@ -18,14 +18,16 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; import java.util.Objects; -public class AfterSignRuleSyncMesProcess implements IRule { +public class AfterSignRuleSyncOutToMesProcess implements IRule { - private static String logginfo = "OALOG"; + public static final IHttpPostOtherSys HTTP_POST_OTHER_SYS = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); - private static Log obmlog = Log.getInstance(logginfo); + private static final String logginfo = "OALOG"; - private IUifService iUifService = NCLocator.getInstance().lookup(IUifService.class); + private static final Log obmlog = Log.getInstance(logginfo); + + private final IUifService iUifService = NCLocator.getInstance().lookup(IUifService.class); public void process(GeneralOutVO[] vos) { if (vos != null && vos.length != 0) { @@ -44,10 +46,10 @@ public class AfterSignRuleSyncMesProcess implements IRule { 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().getPk_org().equals("0001A110000000000677")) { +// obmlog.debug("ͬɽ̩޹˾,ǰ֯:" + generalOutVO.getHead().getPk_org()); +// return; // ɽ̩޹˾ +// } // if (generalOutVO.getHead().getVtrantypecode().equals("4I-01")) { @@ -57,20 +59,20 @@ public class AfterSignRuleSyncMesProcess implements IRule { // 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"); + temp.put("orderNo", head.getVbillcode()); // ֪ͨID + 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("materialId", materialVersionVO.getCode()); // ID + temp.put("issuedQty", body.getNnum() != null ? body.getNnum().doubleValue() : null); // Ӧ + temp.put("actQty", body.getNshouldnum() != null ? body.getNshouldnum().doubleValue() : null); // ʵ + temp.put("assistActQry", body.getNassistnum() != null ? body.getNassistnum().doubleValue() : ""); // ʵ temp.put("productNum", null); - temp.put("storageId", body.getClocationid()); - temp.put("batchNum", body.getVbatchcode()); + temp.put("storageId", body.getClocationid()); // λ + temp.put("batchNum", body.getVbatchcode()); // temp.put("customId", null); temp.put("supplierId", null); temp.put("manufactureDate", null); @@ -80,24 +82,27 @@ public class AfterSignRuleSyncMesProcess implements IRule { JSONObject info = new JSONObject(); info.put("details", details); // headȡ - info.put("orderNo", head.getVbillcode()); - info.put("type", "QTCK"); - info.put("actureDate", head.getDmakedate().toString()); + info.put("orderNo", head.getVbillcode()); // ֪ͨID + 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()); + if (warehouse.getCode() != null && warehouse.getCode().length() > 4) { + throw new BusinessException("MESϵͳֿ[" + warehouse.getCode() + "]ܳ4λѡʵIJֿ!"); + } + info.put("storeId", warehouse.getCode()); // ֿID info.put("workerNo", null); info.put("worker", null); info.put("storeKeeper", head.getCwhsmanagerid()); - info.put("returned", "N"); - info.put("mark", "N"); + 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("operation_type", "I");// requestData.put("info", info); obmlog.debug("requestData:" + requestData.toJSONString()); IHttpPostOtherSys httpService = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); @@ -111,22 +116,22 @@ public class AfterSignRuleSyncMesProcess implements IRule { // 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("orderNo", head.getVbillcode()); // ֪ͨID + 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("materialId", materialVersionVO.getCode()); // ID + temp.put("issuedQty", body.getNnum() != null ? body.getNnum().doubleValue() : null); // Ӧ + temp.put("actOutQty", body.getNshouldnum() != null ? body.getNshouldnum().doubleValue() : null); // ʵ + temp.put("outQty", body.getNnum() != null ? body.getNnum().doubleValue() : null); + temp.put("assistActOutQry", body.getNassistnum() != null ? body.getNassistnum().doubleValue() : 0); // ʵ temp.put("productNum", null); - temp.put("outStorageId", body.getClocationid()); - temp.put("outBatchNum", body.getVbatchcode()); + temp.put("outStorageId", body.getClocationid()); // λ + temp.put("outBatchNum", body.getVbatchcode()); // temp.put("customId", null); temp.put("supplierId", null); temp.put("manufactureDate", null); @@ -139,8 +144,8 @@ public class AfterSignRuleSyncMesProcess implements IRule { JSONObject info = new JSONObject(); info.put("details", details); // headȡ - info.put("orderNo", head.getVbillcode()); - info.put("type", "DBCK"); + info.put("orderNo", head.getVbillcode()); // ֪ͨID + info.put("type", "DBCK"); // info.put("genType", null); info.put("outDate", head.getDbilldate().toString()); @@ -148,28 +153,33 @@ public class AfterSignRuleSyncMesProcess implements IRule { if (Objects.isNull(outWarehouse)) { throw new BusinessException("ֿϢ,:" + head.getCwarehouseid()); } - info.put("outStoreId", outWarehouse.getCode()); + if (outWarehouse.getCode() != null && outWarehouse.getCode().length() > 4) { + throw new BusinessException("MESϵͳֿ[" + outWarehouse.getCode() + "]ܳ4λѡʵIJֿ!"); + } + info.put("outStoreId", outWarehouse.getCode()); // ֿID StordocVO inWarehouse = (StordocVO) iUifService.queryByPrimaryKey(StordocVO.class, head.getCotherwhid()); if (Objects.isNull(inWarehouse)) { throw new BusinessException("ֿϢ,:" + head.getCotherwhid()); } - info.put("inStoreId", inWarehouse.getCode()); + if (inWarehouse.getCode() != null && inWarehouse.getCode().length() > 4) { + throw new BusinessException("MESϵͳֿ[" + inWarehouse.getCode() + "]ܳ4λѡʵIJֿ!"); + } + info.put("inStoreId", inWarehouse.getCode()); // ֿID info.put("workerNo", null); info.put("worker", null); info.put("storeKeeper", head.getCwhsmanagerid()); - info.put("returned", "N"); - info.put("mark", "N"); + 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("operation_type", "I");// requestData.put("info", info); obmlog.debug("requestData:" + requestData.toJSONString()); - IHttpPostOtherSys httpService = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); - httpService.sendToExternalSystem("/GTHINKING/AjaxService/N_KCSJJS/101527009.ashx/gt_rec_api_dbckdj", requestData); + HTTP_POST_OTHER_SYS.sendToExternalSystem("/GTHINKING/AjaxService/N_KCSJJS/101527009.ashx/gt_rec_api_dbckdj", requestData); } }