From f04a7b98e63f1aa42649232866d0deed703ed17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E8=B1=86=E8=B1=86?= <13356128+sunandmoon60@user.noreply.gitee.com> Date: Fri, 31 Oct 2025 14:46:12 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BB=A3=E7=A0=81=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/WMSPurInController.java | 37 ++--- .../api/controller/WMSSaleOutController.java | 37 ++--- .../plugin/operate/im/PurInConvertPlugin.java | 128 ++++++++++++------ .../im/ReturnStockSyncNotifierPlugin.java | 8 +- .../app/plugin/utils/BotpParamUtils.java | 5 +- 5 files changed, 133 insertions(+), 82 deletions(-) diff --git a/lc123/cloud/app/api/controller/WMSPurInController.java b/lc123/cloud/app/api/controller/WMSPurInController.java index 7216e89..987400e 100644 --- a/lc123/cloud/app/api/controller/WMSPurInController.java +++ b/lc123/cloud/app/api/controller/WMSPurInController.java @@ -170,10 +170,10 @@ public class WMSPurInController { } //参数值组装 Long id = receiptnotice.getLong("id"); - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map - JSONObject detailObject = new JSONObject(); for (Object detail : details) { + JSONObject detailObject = new JSONObject(); JSONObject detail1 = (JSONObject) detail; String entryId = detail1.getString("erpDetailId");//金蝶源头单据细单号 String wmsDetailId = detail1.getString("wmsDetailId");//WMS入库单细单号 @@ -197,7 +197,8 @@ public class WMSPurInController { detailObject.put("producer", producer); detailObject.put("VoucherType", VoucherType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(detail1.getLong("erpDetailId")); - param.put(entryId, detailObject); + param.computeIfAbsent(entryId, k -> new HashSet<>()).add(detailObject); + } //开始下推 String rule = BotpParamUtils.getBotpRuleId(RECEIPTNOTICE, PURINBILL, "收货通知单_采购入库单_转换规则"); @@ -274,10 +275,10 @@ public class WMSPurInController { } //参数值组装 Long id = pm_purrefundapplybill.getLong("id"); - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map - JSONObject detailObject = new JSONObject(); for (Object detail : details) { + JSONObject detailObject = new JSONObject(); JSONObject detail1 = (JSONObject) detail; String entryId = detail1.getString("erpDetailId");//金蝶源头单据细单号 BigDecimal quantity = detail1.getBigDecimal("quantity");//入库数量 @@ -299,7 +300,7 @@ public class WMSPurInController { detailObject.put("producer", producer); detailObject.put("VoucherType", VoucherType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(detail1.getLong("erpDetailId")); - param.put(entryId, detailObject); + param.computeIfAbsent(entryId, k -> new HashSet<>()).add(detailObject); } //开始下推 String rule = BotpParamUtils.getBotpRuleId(PM_PURREFUNDAPPLYBILL, PURINBILL, "采购退货申请_采购入库_转换规则_扩展"); @@ -376,10 +377,10 @@ public class WMSPurInController { } //组装参数值 Long id = tqq9_otherinapply.getLong("id"); - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map - JSONObject detailObject = new JSONObject(); for (Object detail : details) { + JSONObject detailObject = new JSONObject(); JSONObject detail1 = (JSONObject) detail; String entryId = detail1.getString("erpDetailId");//金蝶源头单据细单号 BigDecimal quantity = detail1.getBigDecimal("quantity");//入库数量 @@ -401,7 +402,7 @@ public class WMSPurInController { detailObject.put("producer", producer); detailObject.put("VoucherType", VoucherType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(detail1.getLong("erpDetailId")); - param.put(entryId, detailObject); + param.computeIfAbsent(entryId, k -> new HashSet<>()).add(detailObject); } //开始下推 String rule = BotpParamUtils.getBotpRuleId(TQQ9_OTHERINAPPLY, IM_OTHERINBILL, "其他入库申请_其他入库_转换规则"); @@ -586,7 +587,7 @@ public class WMSPurInController { response.setFlag("failure"); return CustomApiResult.success(wmsXmlReturn); } - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map //参数值组装 if (orderLines.get("orderLine") instanceof Map) { @@ -629,7 +630,7 @@ public class WMSPurInController { detailObject.put("producer", key2); detailObject.put("VoucherType", entryOrderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } else { JSONArray orderLine = orderLines.getJSONArray("orderLine"); for (Object obj : orderLine) { @@ -672,7 +673,7 @@ public class WMSPurInController { detailObject.put("producer", key2); detailObject.put("VoucherType", entryOrderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine1.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } } //开始下推 @@ -751,7 +752,7 @@ public class WMSPurInController { response.setFlag("failure"); return CustomApiResult.success(wmsXmlReturn); } - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map //参数值组装 if (orderLines.get("orderLine") instanceof Map) { @@ -794,7 +795,7 @@ public class WMSPurInController { detailObject.put("producer", key2); detailObject.put("VoucherType", entryOrderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } else { JSONArray orderLine = orderLines.getJSONArray("orderLine"); for (Object obj : orderLine) { @@ -837,7 +838,7 @@ public class WMSPurInController { detailObject.put("producer", key2); detailObject.put("VoucherType", entryOrderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine1.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } } @@ -919,7 +920,7 @@ public class WMSPurInController { response.setFlag("failure"); return CustomApiResult.success(wmsXmlReturn); } - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map //参数值组装 if (orderLines.get("orderLine") instanceof Map) { @@ -962,7 +963,7 @@ public class WMSPurInController { detailObject.put("producer", key2); detailObject.put("VoucherType", entryOrderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } else { JSONArray orderLine = orderLines.getJSONArray("orderLine"); for (Object obj : orderLine) { @@ -1005,7 +1006,7 @@ public class WMSPurInController { detailObject.put("producer", key2); detailObject.put("VoucherType", entryOrderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine1.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } } diff --git a/lc123/cloud/app/api/controller/WMSSaleOutController.java b/lc123/cloud/app/api/controller/WMSSaleOutController.java index 057dffe..9ea6f56 100644 --- a/lc123/cloud/app/api/controller/WMSSaleOutController.java +++ b/lc123/cloud/app/api/controller/WMSSaleOutController.java @@ -163,10 +163,10 @@ public class WMSSaleOutController { } //参数值组装 Long id = sm_delivernotice.getLong("id"); - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map - JSONObject detailObject = new JSONObject(); for (Object detail : details) { + JSONObject detailObject = new JSONObject(); JSONObject detail1 = (JSONObject) detail; String entryId = detail1.getString("erpDetailId");//金蝶源头单据细单号 String wmsDetailId = detail1.getString("wmsDetailId");//WMS入库单细单号 @@ -190,7 +190,7 @@ public class WMSSaleOutController { detailObject.put("producer", producer); detailObject.put("VoucherType", VoucherType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(detail1.getLong("erpDetailId")); - param.put(entryId, detailObject); + param.computeIfAbsent(entryId, k -> new HashSet<>()).add(detailObject); } //开始下推 String rule = BotpParamUtils.getBotpRuleId(SM_DELIVERNOTICE, IM_SALOUTBILL, "发货通知单_销售出库单_转换规则_扩展"); @@ -267,10 +267,10 @@ public class WMSSaleOutController { } //参数值组装 Long id = sm_returnapply.getLong("id"); - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map - JSONObject detailObject = new JSONObject(); for (Object detail : details) { + JSONObject detailObject = new JSONObject(); JSONObject detail1 = (JSONObject) detail; String entryId = detail1.getString("erpDetailId");//金蝶源头单据细单号 BigDecimal quantity = detail1.getBigDecimal("quantity");//出库数量 @@ -292,7 +292,8 @@ public class WMSSaleOutController { detailObject.put("producer", producer); detailObject.put("VoucherType", VoucherType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(detail1.getLong("erpDetailId")); - param.put(entryId, detailObject); + param.computeIfAbsent(entryId, k -> new HashSet<>()).add(detailObject); + } //开始下推 String rule = BotpParamUtils.getBotpRuleId(SM_RETURNAPPLY, IM_SALOUTBILL, "销售退货申请单_销售出库单_转换规则_扩展"); @@ -381,10 +382,10 @@ public class WMSSaleOutController { String rule = BotpParamUtils.getBotpRuleId(TQQ9_OTHEROUTAPPLY, IM_OTHEROUTBILL, rulanema); //组装参数值 Long id = tqq9_otheroutapply.getLong("id"); - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map - JSONObject detailObject = new JSONObject(); for (Object detail : details) { + JSONObject detailObject = new JSONObject(); JSONObject detail1 = (JSONObject) detail; String entryId = detail1.getString("erpDetailId");//金蝶源头单据细单号 BigDecimal quantity = detail1.getBigDecimal("quantity");//出库数量 @@ -406,7 +407,7 @@ public class WMSSaleOutController { detailObject.put("producer", producer); detailObject.put("VoucherType", VoucherType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(detail1.getLong("erpDetailId")); - param.put(entryId, detailObject); + param.computeIfAbsent(entryId, k -> new HashSet<>()).add(detailObject); } //开始下推 PushArgs pushArgs = BotpParamUtils.getPushArgs(TQQ9_OTHEROUTAPPLY, IM_OTHEROUTBILL, BILLENTRY, param, entitypkMap, rule); @@ -586,7 +587,7 @@ public class WMSSaleOutController { response.setFlag("failure"); return CustomApiResult.success(wmsXmlReturn); } - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map //参数值组装 if (orderLines.get("orderLine") instanceof Map) { @@ -629,7 +630,7 @@ public class WMSSaleOutController { detailObject.put("producer", key2); detailObject.put("VoucherType", orderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } else { JSONArray orderLine = orderLines.getJSONArray("orderLine"); for (Object obj : orderLine) { @@ -672,7 +673,7 @@ public class WMSSaleOutController { detailObject.put("producer", key2); detailObject.put("VoucherType", orderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine1.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } } //开始下推 @@ -752,7 +753,7 @@ public class WMSSaleOutController { return CustomApiResult.success(wmsXmlReturn); } //参数值组装 - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map if (orderLines.get("orderLine") instanceof Map) { JSONObject orderLine = orderLines.getJSONObject("orderLine"); @@ -794,7 +795,7 @@ public class WMSSaleOutController { detailObject.put("producer", key2); detailObject.put("VoucherType", orderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } else { JSONArray orderLine = orderLines.getJSONArray("orderLine"); for (Object obj : orderLine) { @@ -837,7 +838,7 @@ public class WMSSaleOutController { detailObject.put("producer", key2); detailObject.put("VoucherType", orderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine1.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } } //开始下推 @@ -931,7 +932,7 @@ public class WMSSaleOutController { } String rule = BotpParamUtils.getBotpRuleId(TQQ9_OTHEROUTAPPLY, IM_OTHEROUTBILL, rulanema); //组装参数值 - Map param = new HashMap<>();//传入转换规则处理参数 + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>();//上下游id映射Map if (orderLines.get("orderLine") instanceof Map) { JSONObject orderLine = orderLines.getJSONObject("orderLine"); @@ -973,7 +974,7 @@ public class WMSSaleOutController { detailObject.put("producer", key2); detailObject.put("VoucherType", orderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } else { JSONArray orderLine = orderLines.getJSONArray("orderLine"); for (Object obj : orderLine) { @@ -1016,7 +1017,7 @@ public class WMSSaleOutController { detailObject.put("producer", key2); detailObject.put("VoucherType", orderType); entitypkMap.computeIfAbsent(id, k -> new HashSet<>()).add(orderLine1.getLong("orderLineNo")); - param.put(orderLineNo, detailObject); + param.computeIfAbsent(orderLineNo, k -> new HashSet<>()).add(detailObject); } } //开始下推 diff --git a/lc123/cloud/app/plugin/operate/im/PurInConvertPlugin.java b/lc123/cloud/app/plugin/operate/im/PurInConvertPlugin.java index bba2950..75f2c34 100644 --- a/lc123/cloud/app/plugin/operate/im/PurInConvertPlugin.java +++ b/lc123/cloud/app/plugin/operate/im/PurInConvertPlugin.java @@ -1,24 +1,27 @@ package tqq9.lc123.cloud.app.plugin.operate.im; -import com.google.gson.Gson; +import com.alibaba.nacos.common.utils.StringUtils; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; -import kd.bos.dataentity.utils.StringUtils; +import kd.bos.dataentity.metadata.IDataEntityProperty; +import kd.bos.dataentity.metadata.clr.DataEntityPropertyCollection; +import kd.bos.entity.EntityMetadataCache; import kd.bos.entity.ExtendedDataEntity; import kd.bos.entity.ExtendedDataEntitySet; import kd.bos.entity.botp.plugin.AbstractConvertPlugIn; import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; +import kd.bos.orm.ORM; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.sdk.plugin.Plugin; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * 采购入库转换插件 @@ -51,50 +54,91 @@ public class PurInConvertPlugin extends AbstractConvertPlugIn implements Plugin //采购入库单 DynamicObject dataEntity = extendedDataEntity.getDataEntity(); DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("billentry"); - for (DynamicObject entry : dynamicObjectCollection) { + ListIterator iterator = dynamicObjectCollection.listIterator(); + while (iterator.hasNext()) { + DynamicObject entry = iterator.next(); String srcbillentryid = entry.getString("srcbillentryid"); //核心单据号一致,写入数据 if (variables.containsKey(srcbillentryid)) { String jsonString = variables.get(srcbillentryid); - Gson gson = new Gson(); - // 将 JSON 字符串转换为 HashMap - HashMap jsonMap = gson.fromJson(jsonString, HashMap.class); - String VoucherType = jsonMap.get("VoucherType").toString();//类型 - Double manufacture = (Double) jsonMap.get("manufactureDate"); - Double expiration = (Double) jsonMap.get("expirationDate"); - Date manufactureDate = null; - Date expirationDate = null; - if (manufacture != null && expiration != null) { - manufactureDate = new Date(manufacture.longValue()); //生产日期 - expirationDate = new Date(expiration.longValue()); //失效期 - } BigDecimal quantity = BigDecimal.ZERO; - if (StringUtils.equals("pm_receiptnotice", VoucherType)) { - quantity = new BigDecimal(jsonMap.get("quantity").toString());//入库数量 - } else { - quantity = new BigDecimal(jsonMap.get("quantity").toString()).negate();//入库数量 + ObjectMapper objectMapper = new ObjectMapper(); + List> jsonList = null; + try { + jsonList = objectMapper.readValue(jsonString, objectMapper.getTypeFactory().constructCollectionType(List.class, HashMap.class)); + } catch (JsonProcessingException ex) { + throw new RuntimeException(ex); + } + if (jsonList != null) { + for (int i = 0; i < jsonList.size(); i++) { + HashMap jsonMap = jsonList.get(i); + String VoucherType = jsonMap.get("VoucherType").toString();//类型 + Date manufactureDate = null; + Date expirationDate = null; + if (jsonMap.get("manufactureDate") instanceof Long) { + manufactureDate = new Date((Long) jsonMap.get("manufactureDate")); //生产日期 + + } + if (jsonMap.get("expirationDate") instanceof Long) { + expirationDate = new Date((Long) jsonMap.get("expirationDate")); //生产日期 + + } + BigDecimal quantity = BigDecimal.ZERO; + if (StringUtils.equals("pm_receiptnotice", VoucherType)) { + quantity = new BigDecimal(jsonMap.get("quantity").toString());//入库数量 + } else { + quantity = new BigDecimal(jsonMap.get("quantity").toString()).negate();//入库数量 + } + String batch = jsonMap.get("batch") != null ? jsonMap.get("batch").toString() : null; // 批次 + String wmsDetailId = jsonMap.get("wmsDetailId") != null ? jsonMap.get("wmsDetailId").toString() : null; // WMS分录id + String uniqueCode = jsonMap.get("uniqueCode") != null ? jsonMap.get("uniqueCode").toString() : null; // 商品编码 + String registrationCode = jsonMap.get("registrationCode") != null ? jsonMap.get("registrationCode").toString() : null; // 注册证号 + String licenceCode = jsonMap.get("licenceCode") != null ? jsonMap.get("licenceCode").toString() : null; // 生产许可证号 + String producer = jsonMap.get("producer") != null ? jsonMap.get("producer").toString() : null; // 生产厂商 + DynamicObject tqq9_goodspackage = BusinessDataServiceHelper.loadSingle("tqq9_goodspackage", new QFilter[]{new QFilter("tqq9_mater.number", QCP.equals, uniqueCode).and("tqq9_isauto", QCP.equals, true)}); + DynamicObject tqq9_registration = BusinessDataServiceHelper.loadSingle("tqq9_registration", new QFilter[]{new QFilter("number", QCP.equals, registrationCode)}); + DynamicObject tqq9_proxyandfactory = BusinessDataServiceHelper.loadSingle("tqq9_proxyandfactory", new QFilter[]{new QFilter("number", QCP.equals, producer)}); + // 处理第一次逻辑 + if (i == 0) { + // 第一次直接赋值 + entry.set("qty", quantity); + entry.set("baseqty", quantity); + entry.set("tqq9_goods", tqq9_goodspackage); + entry.set("producedate", manufactureDate); + entry.set("expirydate", expirationDate); + entry.set("lotnumber", batch); + entry.set("tqq9_wmsdetailid", wmsDetailId); + entry.set("tqq9_licenseno", licenceCode); + entry.set("tqq9_registration", tqq9_registration); + entry.set("tqq9_proxyandfactory", tqq9_proxyandfactory); + } else { + DataEntityPropertyCollection properties = entry.getDataEntityType().getProperties(); + // 后续循环复制entry并赋值 + DynamicObject newEntry = new DynamicObject(dynamicObjectCollection.getDynamicObjectType()); + for (IDataEntityProperty property : properties) { + newEntry.set(property.getName(), entry.get(property.getName())); + } + ORM orm = ORM.create(); + Long id = orm.genLongId(EntityMetadataCache.getDataEntityType("im_purinbill")); + newEntry.set("id",id); + newEntry.set("qty", quantity); + newEntry.set("baseqty", quantity); + newEntry.set("tqq9_goods", tqq9_goodspackage); + newEntry.set("producedate", manufactureDate); + newEntry.set("expirydate", expirationDate); + newEntry.set("lotnumber", batch); + newEntry.set("tqq9_wmsdetailid", wmsDetailId); + newEntry.set("tqq9_licenseno", licenceCode); + newEntry.set("tqq9_registration", tqq9_registration); + newEntry.set("tqq9_proxyandfactory", tqq9_proxyandfactory); + // 处理完新entry后的逻辑(比如加入集合或其他操作) + iterator.add(newEntry); + } + + } + } - String batch = jsonMap.get("batch") != null ? jsonMap.get("batch").toString() : null; // 批次 - String wmsDetailId = jsonMap.get("wmsDetailId") != null ? jsonMap.get("wmsDetailId").toString() : null; // WMS分录id - String uniqueCode = jsonMap.get("uniqueCode") != null ? jsonMap.get("uniqueCode").toString() : null; // 商品编码 - String registrationCode = jsonMap.get("registrationCode") != null ? jsonMap.get("registrationCode").toString() : null; // 注册证号 - String licenceCode = jsonMap.get("licenceCode") != null ? jsonMap.get("licenceCode").toString() : null; // 生产许可证号 - String producer = jsonMap.get("producer") != null ? jsonMap.get("producer").toString() : null; // 生产厂商 - DynamicObject tqq9_goodspackage = BusinessDataServiceHelper.loadSingle("tqq9_goodspackage", new QFilter[]{new QFilter("tqq9_mater.number", QCP.equals, uniqueCode).and("tqq9_isauto", QCP.equals, true)}); - DynamicObject tqq9_registration = BusinessDataServiceHelper.loadSingle("tqq9_registration", new QFilter[]{new QFilter("number", QCP.equals, registrationCode)}); - DynamicObject tqq9_proxyandfactory = BusinessDataServiceHelper.loadSingle("tqq9_proxyandfactory", new QFilter[]{new QFilter("number", QCP.equals, producer)}); - entry.set("qty", quantity); - entry.set("baseqty", quantity); - entry.set("tqq9_goods", tqq9_goodspackage); - entry.set("producedate", manufactureDate); - entry.set("expirydate", expirationDate); - entry.set("lotnumber", batch); - entry.set("tqq9_wmsdetailid", wmsDetailId); - entry.set("tqq9_licenseno", licenceCode); - entry.set("tqq9_registration", tqq9_registration); - entry.set("tqq9_proxyandfactory", tqq9_proxyandfactory); } } - } } diff --git a/lc123/cloud/app/plugin/operate/im/ReturnStockSyncNotifierPlugin.java b/lc123/cloud/app/plugin/operate/im/ReturnStockSyncNotifierPlugin.java index e73db84..ab7eed0 100644 --- a/lc123/cloud/app/plugin/operate/im/ReturnStockSyncNotifierPlugin.java +++ b/lc123/cloud/app/plugin/operate/im/ReturnStockSyncNotifierPlugin.java @@ -1,5 +1,6 @@ package tqq9.lc123.cloud.app.plugin.operate.im; +import com.alibaba.fastjson.JSONObject; import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; @@ -49,7 +50,7 @@ public class ReturnStockSyncNotifierPlugin extends AbstractOperationServicePlugI //采购入库单 DynamicObject im_purinbill = BusinessDataServiceHelper.loadSingle("im_purinbill", new QFilter[]{new QFilter("billno", QCP.equals, billno)}); DynamicObjectCollection billentry = im_purinbill.getDynamicObjectCollection("billentry"); - Map param = new HashMap<>(); + Map> param = new HashMap<>();//传入转换规则处理参数 HashMap> entitypkMap = new HashMap<>(); OperationResult operationResult1 = this.getOperationResult(); OperateOption option = this.getOption(); @@ -66,7 +67,10 @@ public class ReturnStockSyncNotifierPlugin extends AbstractOperationServicePlugI String id = entry1.getString("id"); if (StringUtils.equals(id, mainbillentryid)) { entitypkMap.computeIfAbsent(pm_purorderbill.getLong("id"), k -> new HashSet<>()).add(entry1.getLong("id")); - param.put(id, qty); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("qty",qty); + param.computeIfAbsent(id, k -> new HashSet<>()).add(jsonObject); + } } diff --git a/lc123/cloud/app/plugin/utils/BotpParamUtils.java b/lc123/cloud/app/plugin/utils/BotpParamUtils.java index f615bc4..0b4627f 100644 --- a/lc123/cloud/app/plugin/utils/BotpParamUtils.java +++ b/lc123/cloud/app/plugin/utils/BotpParamUtils.java @@ -1,6 +1,7 @@ package tqq9.lc123.cloud.app.plugin.utils; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import kd.bos.data.BusinessDataReader; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.LocaleString; @@ -74,7 +75,7 @@ public class BotpParamUtils { * @throws KDBizException */ public static PushArgs getPushArgs(String srcEntityNumber, String targetEntityNumber, String srcEntryEntity, - Map param, HashMap> entitypkMap, String rule) throws KDBizException{ + Map> param, HashMap> entitypkMap, String rule) throws KDBizException{ PushArgs pushArgs = new PushArgs(); pushArgs.setSourceEntityNumber(srcEntityNumber); // 必选,源单标识 pushArgs.setTargetEntityNumber(targetEntityNumber); // 必选,目标单标识 @@ -86,7 +87,7 @@ public class BotpParamUtils { //传递参数 if(param != null) { - for(Map.Entry obj : param.entrySet()) { + for(Map.Entry> obj : param.entrySet()) { pushArgs.getCustomParams().put(obj.getKey(),JSON.toJSONString(obj.getValue())); } }