From 2821eb9d68ffc18a3831ea0002d82fde270b5bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8E?= <125556714+Topfunplus@users.noreply.github.com> Date: Mon, 19 May 2025 10:34:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=9B=98=E7=82=B9=E5=8D=95?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E5=90=8E=E5=90=8C=E6=AD=A5=20MES=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新盘点单同步接口 URL - 重新定义请求数据结构,按照新规范构建请求参数- 优化日期处理逻辑 - 添加仓库编码、部门编码等字段的处理 - 重构明细数组,增加序号转换、物料编码、货位等字段 - 添加盘存数量、盘盈数量、盘亏数量等计算字段 - 优化异常处理和日志记录 --- .../AfterApprovingSynchronizeRuleMES.java | 117 ++++++++++-------- 1 file changed, 66 insertions(+), 51 deletions(-) diff --git a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java index d5afcd1..e420d26 100644 --- a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java +++ b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java @@ -12,10 +12,12 @@ import nc.jdbc.framework.processor.ColumnProcessor; import nc.vo.bd.cust.CustomerVO; import nc.vo.bd.material.MaterialVO; import nc.vo.bd.rack.RackVO; +import nc.vo.bd.stordoc.StordocVO; import nc.vo.bd.supplier.SupplierVO; import nc.vo.ic.m4r.entity.InvCountBillVO; import nc.vo.ic.m4r.entity.InvCountBodyVO; import nc.vo.ic.m4r.entity.InvCountHeaderVO; +import nc.vo.org.DeptVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDate; import nc.vo.pub.lang.UFDouble; @@ -29,8 +31,7 @@ import java.text.SimpleDateFormat; * ̵㣨MES */ public class AfterApprovingSynchronizeRuleMES implements IRule { - private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/N_MISPRO/InvCount.ashx/SaveData"; // ̵㵥ͬӿ - private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/U20231172_N_XSSJJSA/102397009.ashx/KCPD_INSERT"; // ̵㵥ͬӿ private static final String logginfo = "OALOG"; private static final Log obmlog = Log.getInstance(logginfo); private static final BaseDAO dao = new BaseDAO(); @@ -79,72 +80,86 @@ public class AfterApprovingSynchronizeRuleMES implements IRule { obmlog.debug("AfterApprovingSynchronizeRule-۳ⵥ,Ϊ˵֯ǵ: " + hvo.getVbillcode()); return null; } + + // ¹淶 JSONObject requestData = new JSONObject(); - // Ϊ - requestData.put("operation_type", "I"); - // info - սӿҪñֶ - JSONObject info = new JSONObject(); + // ̵Ϣ ̵㵥 ΪʱԶ + requestData.put("PDDH", null); - // ֶ - info.put("storeId", hvo.getCwarehouseid()); // ֿID(cwarehouseid) - - info.put("departmentId", hvo.getCdptvid()); // ID(cdptvid) - + // ȡֿ + String warehouseCode = transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, hvo.getCwarehouseid()); + requestData.put("CKID", warehouseCode); + + // ̵㲿ű + String deptCode = transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE, DeptVO.PK_DEPT, hvo.getCdptvid()); + requestData.put("BMID", deptCode); + // ̵ + requestData.put("PDR", getStringValue(hvo.getCountoperator())); // ڴ - ̵ UFDate dcountdate = hvo.getDcountdate(); if (dcountdate != null) { - info.put("date", dateTimeFormat.format(dcountdate.toDate())); // ̵(dcountdate) - + requestData.put("PDRQ", dcountdate.toString()); // ̵ - } else { - // ̵Ϊգʹõ - UFDate dbilldate = hvo.getDbilldate(); - if (dbilldate != null) { - info.put("date", dateTimeFormat.format(dbilldate.toDate())); - } else { - // ӿҪֶαûʹõǰ - info.put("date", dateTimeFormat.format(new java.util.Date())); - } + requestData.put("PDRQ", null); } + // ע + requestData.put("BZ", getStringValue(hvo.getVnote())); - // ֶ - info.put("worker", getStringValue(hvo.getCountoperator())); // ̵(countoperator) - info.put("mark", "N"); // ɱ־ĬΪN - info.put("remark", getStringValue(hvo.getVnote())); // ע(vnote) - - // detailsϸ + // ϸ JSONArray details = new JSONArray(); if (bvos != null) { for (InvCountBodyVO bvo : bvos) { JSONObject detail = new JSONObject(); - // - תΪ - detail.put("sequenceNum", bvo.getCrowno()); - // ID(cmaterialvid) - - detail.put("materialId", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.PK_MATERIAL, MaterialVO.CODE, bvo.getCmaterialvid())); - // λ(clocationid) - - detail.put("storageId", transferCodeByPk(RackVO.getDefaultTableName(), RackVO.CODE, RackVO.PK_RACK, bvo.getClocationid())); - // (vbatchcode) - - detail.put("batchNum", getStringValue(bvo.getVbatchcode())); - // ̴ - ʹʵ - UFDouble countNum = bvo.getNcountnum(); - detail.put("panQty", countNum.doubleValue()); // ̴(ncountnum) - - // ͻID - detail.put("customId", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, bvo.getCasscustid())); - // ӦID - detail.put("supplierId", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, bvo.getCvendorid())); - // ڴ - detail.put("manufactureDate", null); - detail.put("color", null); - // װϢԶԣ - detail.put("packLen", null); - detail.put("packSize", null); - // ע - detail.put("remark", getStringValue(bvo.getVnotebody())); // ע(vnotebody) + // ȡŲתΪ + String crownStr = bvo.getCrowno(); + try { + detail.put("XH", Double.parseDouble(crownStr)); // - + } catch (NumberFormatException e) { + detail.put("XH", null); // Ĭ + } + // ϱ - + detail.put("WLID", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, bvo.getCmaterialvid())); + // λ + detail.put("KW", transferCodeByPk(RackVO.getDefaultTableName(), RackVO.CODE, RackVO.PK_RACK, bvo.getClocationid())); + // + detail.put("WLPH", getStringValue(bvo.getVbatchcode())); + + // ̴ -> ʵ + UFDouble pcNum = bvo.getNcountnum(); + // + UFDouble zmNum = bvo.getNonhandnum(); + if (pcNum != null) { + // ̴ -> ʵ + detail.put("PCSL", pcNum.getDouble()); + if (zmNum != null) { + // ӯ -> - ʵ + detail.put("PYSL", zmNum.getDouble() - pcNum.getDouble()); + // ̿ -> ʵ - + detail.put("PKSL", pcNum.getDouble() - zmNum.getDouble()); + } else { + detail.put("PYSL", null); + detail.put("PKSL", null); + } + } else { + detail.put("PCSL", null); + detail.put("PYSL", null); + detail.put("PKSL", null); + } + // ӯ + detail.put("YCDJ", null); + // ӯԭ + detail.put("YKYY", getStringValue(bvo.getVnotebody())); + // ͻ + detail.put("KHID", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, bvo.getCasscustid())); + // Ӧ̱ + detail.put("GYSID", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, bvo.getCvendorid())); + details.add(detail); } } - info.put("details", details); - - // infoӵ - requestData.put("info", info); + requestData.put("DETAILS", details); return requestData; }