From d38f89a0cc3b326e1cd4c89f282bf4a7f89c2c1c 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 18:14:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93=E4=B8=8B=E6=8E=A8=E8=A7=84?= =?UTF-8?q?=E5=88=99=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OtherInApplyPushOtherInConvertPlugin.java | 116 ++++++++++++----- ...therOutApplyPushOtherOutConvertPlugin.java | 114 ++++++++++++----- .../plugin/operate/im/PurInConvertPlugin.java | 14 +- .../operate/im/PurInlotReceiptPlugin.java | 29 +++-- .../im/PurOrderPushReceiptNoticePlugin.java | 26 +++- .../operate/im/SaleOutBillConvertPlugin.java | 121 ++++++++++++------ .../operate/pm/OtherInWareSaveOpPlugin.java | 52 ++++++++ .../operate/pm/OtherOutWareSaveOpPlugin.java | 51 ++++++++ .../operate/pm/PurInWareSaveOpPlugin.java | 53 ++++++++ .../pm/PurRefundApplySaveOpPlugin.java | 13 +- .../operate/pm/SaleOutWareSaveOpPlugin.java | 53 ++++++++ 11 files changed, 502 insertions(+), 140 deletions(-) create mode 100644 lc123/cloud/app/plugin/operate/pm/OtherInWareSaveOpPlugin.java create mode 100644 lc123/cloud/app/plugin/operate/pm/OtherOutWareSaveOpPlugin.java create mode 100644 lc123/cloud/app/plugin/operate/pm/PurInWareSaveOpPlugin.java create mode 100644 lc123/cloud/app/plugin/operate/pm/SaleOutWareSaveOpPlugin.java diff --git a/lc123/cloud/app/plugin/operate/im/OtherInApplyPushOtherInConvertPlugin.java b/lc123/cloud/app/plugin/operate/im/OtherInApplyPushOtherInConvertPlugin.java index 3d58269..a4058d6 100644 --- a/lc123/cloud/app/plugin/operate/im/OtherInApplyPushOtherInConvertPlugin.java +++ b/lc123/cloud/app/plugin/operate/im/OtherInApplyPushOtherInConvertPlugin.java @@ -1,8 +1,11 @@ package tqq9.lc123.cloud.app.plugin.operate.im; -import com.google.gson.Gson; +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.metadata.IDataEntityProperty; +import kd.bos.dataentity.metadata.clr.DataEntityPropertyCollection; import kd.bos.entity.ExtendedDataEntity; import kd.bos.entity.ExtendedDataEntitySet; import kd.bos.entity.botp.plugin.AbstractConvertPlugIn; @@ -15,9 +18,7 @@ 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.*; /** * 其他入库申请下推其他入库 @@ -37,6 +38,7 @@ public class OtherInApplyPushOtherInConvertPlugin extends AbstractConvertPlugIn * registrationCode 注册证号 * licenceCode 生产许可证号 * producer 生产厂商 + * * @param e */ @Override @@ -49,41 +51,87 @@ public class OtherInApplyPushOtherInConvertPlugin extends AbstractConvertPlugIn //采购入库单 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();//类型 - BigDecimal quantity = new BigDecimal(jsonMap.get("quantity").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()); //失效期 + 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) { + dataEntity.set("tqq9_isrebulidlink", true); + 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 (com.alibaba.nacos.common.utils.StringUtils.equals("sm_delivernotice", 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_zczh", tqq9_registration); + entry.set("tqq9_sccs", tqq9_proxyandfactory); + DynamicObjectCollection billentry_lk = entry.getDynamicObjectCollection("billentry_lk"); + billentry_lk.clear(); + } 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())); + } + 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_zczh", tqq9_registration); + newEntry.set("tqq9_sccs", tqq9_proxyandfactory); + DynamicObjectCollection billentry_lk = newEntry.getDynamicObjectCollection("billentry_lk"); + billentry_lk.clear(); + // 处理完新entry后的逻辑(比如加入集合或其他操作) + iterator.add(newEntry); + } + } } - String batch = jsonMap.get("batch") != null ? jsonMap.get("batch").toString() : null; // 批次 - 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_licenseno", licenceCode); - entry.set("tqq9_registration", tqq9_registration); - entry.set("tqq9_sccs", tqq9_proxyandfactory); } } diff --git a/lc123/cloud/app/plugin/operate/im/OtherOutApplyPushOtherOutConvertPlugin.java b/lc123/cloud/app/plugin/operate/im/OtherOutApplyPushOtherOutConvertPlugin.java index 3f5a2e3..6e75d6f 100644 --- a/lc123/cloud/app/plugin/operate/im/OtherOutApplyPushOtherOutConvertPlugin.java +++ b/lc123/cloud/app/plugin/operate/im/OtherOutApplyPushOtherOutConvertPlugin.java @@ -1,8 +1,11 @@ package tqq9.lc123.cloud.app.plugin.operate.im; -import com.google.gson.Gson; +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.metadata.IDataEntityProperty; +import kd.bos.dataentity.metadata.clr.DataEntityPropertyCollection; import kd.bos.entity.ExtendedDataEntity; import kd.bos.entity.ExtendedDataEntitySet; import kd.bos.entity.botp.plugin.AbstractConvertPlugIn; @@ -15,9 +18,7 @@ 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.*; /** * 其他出库申请下推其他出库 @@ -49,40 +50,87 @@ public class OtherOutApplyPushOtherOutConvertPlugin extends AbstractConvertPlugI //采购入库单 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); - BigDecimal quantity = new BigDecimal(jsonMap.get("quantity").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()); //失效期 + 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) { + dataEntity.set("tqq9_isrebulidlink", true); + 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 (com.alibaba.nacos.common.utils.StringUtils.equals("sm_delivernotice", 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_zczh", tqq9_registration); + entry.set("tqq9_scs", tqq9_proxyandfactory); + DynamicObjectCollection billentry_lk = entry.getDynamicObjectCollection("billentry_lk"); + billentry_lk.clear(); + } 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())); + } + 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_zczh", tqq9_registration); + newEntry.set("tqq9_scs", tqq9_proxyandfactory); + DynamicObjectCollection billentry_lk = newEntry.getDynamicObjectCollection("billentry_lk"); + billentry_lk.clear(); + // 处理完新entry后的逻辑(比如加入集合或其他操作) + iterator.add(newEntry); + } + } } - String batch = jsonMap.get("batch") != null ? jsonMap.get("batch").toString() : null; // 批次 - 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_licenseno", licenceCode); - entry.set("tqq9_zczh", tqq9_registration); - entry.set("tqq9_scs", tqq9_proxyandfactory); } } diff --git a/lc123/cloud/app/plugin/operate/im/PurInConvertPlugin.java b/lc123/cloud/app/plugin/operate/im/PurInConvertPlugin.java index 75f2c34..7ace034 100644 --- a/lc123/cloud/app/plugin/operate/im/PurInConvertPlugin.java +++ b/lc123/cloud/app/plugin/operate/im/PurInConvertPlugin.java @@ -7,14 +7,12 @@ import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; 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; @@ -69,6 +67,7 @@ public class PurInConvertPlugin extends AbstractConvertPlugIn implements Plugin throw new RuntimeException(ex); } if (jsonList != null) { + dataEntity.set("tqq9_isrebulidlink",true); for (int i = 0; i < jsonList.size(); i++) { HashMap jsonMap = jsonList.get(i); String VoucherType = jsonMap.get("VoucherType").toString();//类型 @@ -76,11 +75,9 @@ public class PurInConvertPlugin extends AbstractConvertPlugIn implements Plugin 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)) { @@ -110,6 +107,8 @@ public class PurInConvertPlugin extends AbstractConvertPlugIn implements Plugin entry.set("tqq9_licenseno", licenceCode); entry.set("tqq9_registration", tqq9_registration); entry.set("tqq9_proxyandfactory", tqq9_proxyandfactory); + DynamicObjectCollection billentry_lk = entry.getDynamicObjectCollection("billentry_lk"); + billentry_lk.clear(); } else { DataEntityPropertyCollection properties = entry.getDataEntityType().getProperties(); // 后续循环复制entry并赋值 @@ -117,9 +116,6 @@ public class PurInConvertPlugin extends AbstractConvertPlugIn implements Plugin 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); @@ -130,12 +126,12 @@ public class PurInConvertPlugin extends AbstractConvertPlugIn implements Plugin newEntry.set("tqq9_licenseno", licenceCode); newEntry.set("tqq9_registration", tqq9_registration); newEntry.set("tqq9_proxyandfactory", tqq9_proxyandfactory); + DynamicObjectCollection billentry_lk = newEntry.getDynamicObjectCollection("billentry_lk"); + billentry_lk.clear(); // 处理完新entry后的逻辑(比如加入集合或其他操作) iterator.add(newEntry); } - } - } } } diff --git a/lc123/cloud/app/plugin/operate/im/PurInlotReceiptPlugin.java b/lc123/cloud/app/plugin/operate/im/PurInlotReceiptPlugin.java index 8079d9c..28b31df 100644 --- a/lc123/cloud/app/plugin/operate/im/PurInlotReceiptPlugin.java +++ b/lc123/cloud/app/plugin/operate/im/PurInlotReceiptPlugin.java @@ -4,7 +4,6 @@ import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.utils.StringUtils; import kd.bos.entity.plugin.AbstractOperationServicePlugIn; -import kd.bos.entity.plugin.PreparePropertysEventArgs; import kd.bos.entity.plugin.args.AfterOperationArgs; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; @@ -16,8 +15,8 @@ import kd.sdk.plugin.Plugin; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; -import java.util.List; /** * 采购入库反写批号主档 @@ -33,7 +32,7 @@ public class PurInlotReceiptPlugin extends AbstractOperationServicePlugIn implem if (StringUtils.equals("audit", operationKey)) { for (DynamicObject dataEntity : e.getDataEntities()) { ArrayList billnos = new ArrayList<>(); - HashMap entryMap = new HashMap<>(); + HashMap> entryMap = new HashMap<>(); String billno1 = dataEntity.getString("billno"); DynamicObject im_purinbill = BusinessDataServiceHelper.loadSingle("im_purinbill", new QFilter[]{new QFilter("billno", QCP.equals, billno1)}); DynamicObjectCollection billentry = im_purinbill.getDynamicObjectCollection("billentry"); @@ -44,7 +43,9 @@ public class PurInlotReceiptPlugin extends AbstractOperationServicePlugIn implem Long entryid = dynamicObject.getLong("mainbillentryid");//核心单据行id DynamicObject lot = dynamicObject.getDynamicObject("lot");//批号主档 billnos.add(billno); - entryMap.put(entryid, lot); + entryMap.computeIfAbsent(entryid, k -> new HashSet<>()).add(lot); + +// entryMap.put(entryid, lot); } //查询采购订单 QFilter qFilter = new QFilter("billno", QCP.in, billnos); @@ -56,14 +57,18 @@ public class PurInlotReceiptPlugin extends AbstractOperationServicePlugIn implem for (DynamicObject dynamicObject : billentry1) { long id = dynamicObject.getLong("id"); + DynamicObjectCollection tqq9_bd_lot = dynamicObject.getDynamicObjectCollection("tqq9_bd_lot"); + if (entryMap.containsKey(id)) { - DynamicObject lot = entryMap.get(id); - DynamicObjectCollection tqq9_bd_lot = dynamicObject.getDynamicObjectCollection("tqq9_bd_lot"); - DynamicObject newlot = new DynamicObject(tqq9_bd_lot.getDynamicObjectType()); - newlot.set("fbasedataId", lot); - if (!tqq9_bd_lot.contains(newlot)) { - tqq9_bd_lot.add(newlot); + HashSet lots = entryMap.get(id); + for (DynamicObject lot : lots) { + DynamicObject newlot = new DynamicObject(tqq9_bd_lot.getDynamicObjectType()); + newlot.set("fbasedataId", lot); + if (!tqq9_bd_lot.contains(newlot)) { + tqq9_bd_lot.add(newlot); + } } + } } } @@ -93,10 +98,10 @@ public class PurInlotReceiptPlugin extends AbstractOperationServicePlugIn implem for (DynamicObject dynamicObject : billentry1) { DynamicObjectCollection tqq9_bd_lot = dynamicObject.getDynamicObjectCollection("tqq9_bd_lot"); Iterator iterator = tqq9_bd_lot.iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { DynamicObject lot = iterator.next(); DynamicObject bd_lot = lot.getDynamicObject("fbasedataId"); - if(bd_lot!=null){ + if (bd_lot != null) { bd_lot = BusinessDataServiceHelper.loadSingle("bd_lot", new QFilter[]{new QFilter("id", QCP.equals, bd_lot.getLong("id"))}); String lotstatus = bd_lot.getString("lotstatus"); if (lotstatus.equals("B")) { diff --git a/lc123/cloud/app/plugin/operate/im/PurOrderPushReceiptNoticePlugin.java b/lc123/cloud/app/plugin/operate/im/PurOrderPushReceiptNoticePlugin.java index 04394e1..f8ba363 100644 --- a/lc123/cloud/app/plugin/operate/im/PurOrderPushReceiptNoticePlugin.java +++ b/lc123/cloud/app/plugin/operate/im/PurOrderPushReceiptNoticePlugin.java @@ -1,5 +1,7 @@ package tqq9.lc123.cloud.app.plugin.operate.im; +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.entity.ExtendedDataEntity; @@ -11,6 +13,8 @@ import kd.bos.logging.LogFactory; import kd.sdk.plugin.Plugin; import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -35,10 +39,24 @@ public class PurOrderPushReceiptNoticePlugin extends AbstractConvertPlugIn imple String mainbillentryid = dynamicObject.getString("mainbillentryid"); //核心单据号一致,修改补货数量 if (variables.containsKey(mainbillentryid)) { - String qty = variables.get(mainbillentryid); - BigDecimal entry_qty = new BigDecimal(qty).negate(); - dynamicObject.set("qty", entry_qty);//数量 - dynamicObject.set("baseqty", entry_qty);//基本数量 + String jsonString = variables.get(mainbillentryid); + 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); + BigDecimal entry_qty = (BigDecimal) jsonMap.get("qty");//类型 + dynamicObject.set("qty", entry_qty);//数量 + dynamicObject.set("baseqty", entry_qty);//基本数量 + } + + } + } } } diff --git a/lc123/cloud/app/plugin/operate/im/SaleOutBillConvertPlugin.java b/lc123/cloud/app/plugin/operate/im/SaleOutBillConvertPlugin.java index 7faee6e..75b5fc1 100644 --- a/lc123/cloud/app/plugin/operate/im/SaleOutBillConvertPlugin.java +++ b/lc123/cloud/app/plugin/operate/im/SaleOutBillConvertPlugin.java @@ -1,9 +1,11 @@ package tqq9.lc123.cloud.app.plugin.operate.im; -import com.google.gson.Gson; +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.ExtendedDataEntity; import kd.bos.entity.ExtendedDataEntitySet; import kd.bos.entity.botp.plugin.AbstractConvertPlugIn; @@ -16,9 +18,7 @@ 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,48 +51,87 @@ public class SaleOutBillConvertPlugin extends AbstractConvertPlugIn implements P //采购入库单 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();//类型 - BigDecimal quantity = BigDecimal.ZERO; - if (StringUtils.equals("sm_delivernotice", 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); } - 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()); //失效期 + if (jsonList != null) { + dataEntity.set("tqq9_isrebulidlink", true); + 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 (com.alibaba.nacos.common.utils.StringUtils.equals("sm_delivernotice", 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_scs", tqq9_proxyandfactory); + DynamicObjectCollection billentry_lk = entry.getDynamicObjectCollection("billentry_lk"); + billentry_lk.clear(); + } 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())); + } + 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_scs", tqq9_proxyandfactory); + DynamicObjectCollection billentry_lk = newEntry.getDynamicObjectCollection("billentry_lk"); + billentry_lk.clear(); + // 处理完新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_sccs", tqq9_proxyandfactory); } } diff --git a/lc123/cloud/app/plugin/operate/pm/OtherInWareSaveOpPlugin.java b/lc123/cloud/app/plugin/operate/pm/OtherInWareSaveOpPlugin.java new file mode 100644 index 0000000..410867d --- /dev/null +++ b/lc123/cloud/app/plugin/operate/pm/OtherInWareSaveOpPlugin.java @@ -0,0 +1,52 @@ +package tqq9.lc123.cloud.app.plugin.operate.pm; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.args.BeforeOperationArgs; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; +import tqq9.lc123.cloud.app.plugin.utils.AutoFixLinkUtil; + +import java.util.stream.Collectors; + +/** + * 其他入库单保存操作插件 + */ +public class OtherInWareSaveOpPlugin extends AbstractOperationServicePlugIn implements Plugin { + private final static Log logger = LogFactory.getLog(OtherInWareSaveOpPlugin.class); + private static String IM_OTHERINBILL = "im_otherinbill";//其他入库 + private static String TQQ9_OTHERINAPPLY = "tqq9_otherinapply";//其他入库申请 + private static String billentry = "billentry";//分录标识 + + @Override + public void beforeExecuteOperationTransaction(BeforeOperationArgs e) { + super.beforeExecuteOperationTransaction(e); + DynamicObject[] dataEntities1 = e.getDataEntities(); + if (dataEntities1.length > 0) { + + DynamicObject dynamicObject = dataEntities1[0]; + if (dynamicObject.getBoolean("tqq9_isrebulidlink")) { + DynamicObjectCollection billentry1 = dynamicObject.getDynamicObjectCollection("billentry"); + if (billentry1.size() > 0) { + DynamicObject dynamicObject1 = billentry1.get(0); + String srcbillnumber = dynamicObject1.getString("srcbillnumber"); + DynamicObject pm_purorderbill = BusinessDataServiceHelper.loadSingle(TQQ9_OTHERINAPPLY, new QFilter[]{new QFilter("billno", QCP.equals, srcbillnumber)}); + DynamicObjectCollection dynamicObjects = new DynamicObjectCollection(); + dynamicObjects.add(pm_purorderbill); + dynamicObjects.stream().collect(Collectors.toList()); + AutoFixLinkUtil fixLinkHelp = new AutoFixLinkUtil(); + fixLinkHelp.linkSourceRow(dynamicObject, dynamicObjects.stream().collect(Collectors.toList()), IM_OTHERINBILL, billentry, "srcbillentryid", + TQQ9_OTHERINAPPLY, billentry, "", "billentry_lk"); + } + + } + } + + } + +} \ No newline at end of file diff --git a/lc123/cloud/app/plugin/operate/pm/OtherOutWareSaveOpPlugin.java b/lc123/cloud/app/plugin/operate/pm/OtherOutWareSaveOpPlugin.java new file mode 100644 index 0000000..45b80c7 --- /dev/null +++ b/lc123/cloud/app/plugin/operate/pm/OtherOutWareSaveOpPlugin.java @@ -0,0 +1,51 @@ +package tqq9.lc123.cloud.app.plugin.operate.pm; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.args.BeforeOperationArgs; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; +import tqq9.lc123.cloud.app.plugin.utils.AutoFixLinkUtil; + +import java.util.stream.Collectors; + +/** + * 其他出库单保存操作插件 + */ +public class OtherOutWareSaveOpPlugin extends AbstractOperationServicePlugIn implements Plugin { + private final static Log logger = LogFactory.getLog(OtherOutWareSaveOpPlugin.class); + private static String IM_OTHERINBILL = "im_otherinbill";//其他入库 + private static String TQQ9_OTHERINAPPLY = "tqq9_otherinapply";//其他入库申请 + private static String billentry = "billentry";//分录标识 + + @Override + public void beforeExecuteOperationTransaction(BeforeOperationArgs e) { + super.beforeExecuteOperationTransaction(e); + DynamicObject[] dataEntities1 = e.getDataEntities(); + if (dataEntities1.length > 0) { + + DynamicObject dynamicObject = dataEntities1[0]; + if (dynamicObject.getBoolean("tqq9_isrebulidlink")) { + DynamicObjectCollection billentry1 = dynamicObject.getDynamicObjectCollection("billentry"); + if (billentry1.size() > 0) { + DynamicObject dynamicObject1 = billentry1.get(0); + String srcbillnumber = dynamicObject1.getString("srcbillnumber"); + DynamicObject pm_purorderbill = BusinessDataServiceHelper.loadSingle(TQQ9_OTHERINAPPLY, new QFilter[]{new QFilter("billno", QCP.equals, srcbillnumber)}); + DynamicObjectCollection dynamicObjects = new DynamicObjectCollection(); + dynamicObjects.add(pm_purorderbill); + dynamicObjects.stream().collect(Collectors.toList()); + AutoFixLinkUtil fixLinkHelp = new AutoFixLinkUtil(); + fixLinkHelp.linkSourceRow(dynamicObject, dynamicObjects.stream().collect(Collectors.toList()), IM_OTHERINBILL, billentry, "srcbillentryid", + TQQ9_OTHERINAPPLY, billentry, "", "billentry_lk"); + } + + } + } + + } +} \ No newline at end of file diff --git a/lc123/cloud/app/plugin/operate/pm/PurInWareSaveOpPlugin.java b/lc123/cloud/app/plugin/operate/pm/PurInWareSaveOpPlugin.java new file mode 100644 index 0000000..9dbcad5 --- /dev/null +++ b/lc123/cloud/app/plugin/operate/pm/PurInWareSaveOpPlugin.java @@ -0,0 +1,53 @@ +package tqq9.lc123.cloud.app.plugin.operate.pm; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.args.BeforeOperationArgs; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; +import tqq9.lc123.cloud.app.plugin.utils.AutoFixLinkUtil; + +import java.util.stream.Collectors; + +/** + * 采购入库单保存操作插件 + */ +public class PurInWareSaveOpPlugin extends AbstractOperationServicePlugIn implements Plugin { + private final static Log logger = LogFactory.getLog(PurInWareSaveOpPlugin.class); + private static String IM_PURINBILL = "im_purinbill";//采购入库单 + private static String PM_RECEIPTNOTICE = "pm_receiptnotice";//收货通知 + private static String billentry = "billentry";//分录标识 + + @Override + public void beforeExecuteOperationTransaction(BeforeOperationArgs e) { + super.beforeExecuteOperationTransaction(e); + DynamicObject[] dataEntities1 = e.getDataEntities(); + if (dataEntities1.length > 0) { + + DynamicObject dynamicObject = dataEntities1[0]; + if (dynamicObject.getBoolean("tqq9_isrebulidlink")) { + DynamicObjectCollection billentry1 = dynamicObject.getDynamicObjectCollection("billentry"); + if (billentry1.size() > 0) { + DynamicObject dynamicObject1 = billentry1.get(0); + String srcbillentity = dynamicObject1.getString("srcbillentity"); + String srcbillnumber = dynamicObject1.getString("srcbillnumber"); + DynamicObject pm_purorderbill = BusinessDataServiceHelper.loadSingle(srcbillentity, new QFilter[]{new QFilter("billno", QCP.equals, srcbillnumber)}); + DynamicObjectCollection dynamicObjects = new DynamicObjectCollection(); + dynamicObjects.add(pm_purorderbill); + dynamicObjects.stream().collect(Collectors.toList()); + AutoFixLinkUtil fixLinkHelp = new AutoFixLinkUtil(); + fixLinkHelp.linkSourceRow(dynamicObject, dynamicObjects.stream().collect(Collectors.toList()), IM_PURINBILL, billentry, "srcbillentryid", + srcbillentity, billentry, "", "billentry_lk"); + } + + } + } + + } + +} \ No newline at end of file diff --git a/lc123/cloud/app/plugin/operate/pm/PurRefundApplySaveOpPlugin.java b/lc123/cloud/app/plugin/operate/pm/PurRefundApplySaveOpPlugin.java index 68a0be3..06f22e7 100644 --- a/lc123/cloud/app/plugin/operate/pm/PurRefundApplySaveOpPlugin.java +++ b/lc123/cloud/app/plugin/operate/pm/PurRefundApplySaveOpPlugin.java @@ -19,7 +19,6 @@ import java.util.stream.Collectors; */ - public class PurRefundApplySaveOpPlugin extends AbstractOperationServicePlugIn implements Plugin { private final static Log logger = LogFactory.getLog(PurRefundApplySaveOpPlugin.class); private static String PM_PURREFUNDAPPLYBILL = "pm_purrefundapplybill";//采购退货申请单 @@ -30,19 +29,19 @@ public class PurRefundApplySaveOpPlugin extends AbstractOperationServicePlugIn i public void beforeExecuteOperationTransaction(BeforeOperationArgs e) { super.beforeExecuteOperationTransaction(e); DynamicObject[] dataEntities1 = e.getDataEntities(); - if(dataEntities1.length>0){ + if (dataEntities1.length > 0) { DynamicObject dynamicObject = dataEntities1[0]; DynamicObjectCollection billentry1 = dynamicObject.getDynamicObjectCollection("billentry"); - if(billentry1.size()>0){ + if (billentry1.size() > 0) { DynamicObject dynamicObject1 = billentry1.get(0); String srcbillnumber = dynamicObject1.getString("srcbillnumber"); DynamicObject pm_purorderbill = BusinessDataServiceHelper.loadSingle(PM_PURORDERBILL, new QFilter[]{new QFilter("billno", QCP.equals, srcbillnumber)}); DynamicObjectCollection dynamicObjects = new DynamicObjectCollection(); dynamicObjects.add(pm_purorderbill); - dynamicObjects.stream().collect(Collectors.toList()) -; AutoFixLinkUtil fixLinkHelp = new AutoFixLinkUtil(); - fixLinkHelp.linkSourceRow(dynamicObject, dynamicObjects.stream().collect(Collectors.toList()), PM_PURREFUNDAPPLYBILL, billentry,"srcbillentryid", - PM_PURORDERBILL, billentry,"","billentry_lk"); + dynamicObjects.stream().collect(Collectors.toList()); + AutoFixLinkUtil fixLinkHelp = new AutoFixLinkUtil(); + fixLinkHelp.linkSourceRow(dynamicObject, dynamicObjects.stream().collect(Collectors.toList()), PM_PURREFUNDAPPLYBILL, billentry, "srcbillentryid", + PM_PURORDERBILL, billentry, "", "billentry_lk"); } } diff --git a/lc123/cloud/app/plugin/operate/pm/SaleOutWareSaveOpPlugin.java b/lc123/cloud/app/plugin/operate/pm/SaleOutWareSaveOpPlugin.java new file mode 100644 index 0000000..58fea9c --- /dev/null +++ b/lc123/cloud/app/plugin/operate/pm/SaleOutWareSaveOpPlugin.java @@ -0,0 +1,53 @@ +package tqq9.lc123.cloud.app.plugin.operate.pm; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.args.BeforeOperationArgs; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; +import tqq9.lc123.cloud.app.plugin.utils.AutoFixLinkUtil; + +import java.util.stream.Collectors; + +/** + * 销售出库单保存操作插件 + */ +public class SaleOutWareSaveOpPlugin extends AbstractOperationServicePlugIn implements Plugin { + private final static Log logger = LogFactory.getLog(PurInWareSaveOpPlugin.class); + private static String IM_OTHEROUTBILL = "im_otheroutbill";//其他出库 + private static String TQQ9_OTHEROUTAPPLY = "tqq9_otheroutapply";//其他出库申请 + private static String billentry = "billentry";//分录标识 + + @Override + public void beforeExecuteOperationTransaction(BeforeOperationArgs e) { + super.beforeExecuteOperationTransaction(e); + DynamicObject[] dataEntities1 = e.getDataEntities(); + if (dataEntities1.length > 0) { + + DynamicObject dynamicObject = dataEntities1[0]; + if (dynamicObject.getBoolean("tqq9_isrebulidlink")) { + DynamicObjectCollection billentry1 = dynamicObject.getDynamicObjectCollection("billentry"); + if (billentry1.size() > 0) { + DynamicObject dynamicObject1 = billentry1.get(0); + String srcbillentity = dynamicObject1.getString("srcbillentity"); + String srcbillnumber = dynamicObject1.getString("srcbillnumber"); + DynamicObject pm_purorderbill = BusinessDataServiceHelper.loadSingle(srcbillentity, new QFilter[]{new QFilter("billno", QCP.equals, srcbillnumber)}); + DynamicObjectCollection dynamicObjects = new DynamicObjectCollection(); + dynamicObjects.add(pm_purorderbill); + dynamicObjects.stream().collect(Collectors.toList()); + AutoFixLinkUtil fixLinkHelp = new AutoFixLinkUtil(); + fixLinkHelp.linkSourceRow(dynamicObject, dynamicObjects.stream().collect(Collectors.toList()), IM_OTHEROUTBILL, billentry, "srcbillentryid", + srcbillentity, billentry, "", "billentry_lk"); + } + + } + } + + } + +} \ No newline at end of file