入库下推规则调整

This commit is contained in:
龚豆豆 2025-10-31 18:14:18 +08:00
parent 441cb007e6
commit d38f89a0cc
11 changed files with 502 additions and 140 deletions

View File

@ -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<DynamicObject> 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<String, Object> 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<HashMap<String, Object>> 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<String, Object> 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);
}
}

View File

@ -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<DynamicObject> 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<String, Object> 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<HashMap<String, Object>> 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<String, Object> 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);
}
}

View File

@ -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<String, Object> 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);
}
}
}
}
}

View File

@ -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<String> billnos = new ArrayList<>();
HashMap<Long, DynamicObject> entryMap = new HashMap<>();
HashMap<Long, HashSet<DynamicObject>> 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<DynamicObject> 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<DynamicObject> 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")) {

View File

@ -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<HashMap<String, Object>> 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<String, Object> jsonMap = jsonList.get(i);
BigDecimal entry_qty = (BigDecimal) jsonMap.get("qty");//类型
dynamicObject.set("qty", entry_qty);//数量
dynamicObject.set("baseqty", entry_qty);//基本数量
}
}
}
}
}

View File

@ -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<DynamicObject> 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<String, Object> 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<HashMap<String, Object>> 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<String, Object> 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);
}
}

View File

@ -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");
}
}
}
}
}

View File

@ -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");
}
}
}
}
}

View File

@ -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");
}
}
}
}
}

View File

@ -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");
}
}

View File

@ -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");
}
}
}
}
}