From a5c8858d76cc26b03525df55eef9812acded7832 Mon Sep 17 00:00:00 2001 From: "tanfengling@x-ri.com" <123456> Date: Wed, 5 Nov 2025 11:03:07 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=B3=9B=E5=BE=AE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E3=80=91=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93=E5=8F=8D=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E5=87=8F=E5=8E=BB=E5=95=86=E5=9F=8E=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../im/PurinUnauditSubGoodsQtyPlugin.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 lc123/cloud/app/plugin/operate/im/PurinUnauditSubGoodsQtyPlugin.java diff --git a/lc123/cloud/app/plugin/operate/im/PurinUnauditSubGoodsQtyPlugin.java b/lc123/cloud/app/plugin/operate/im/PurinUnauditSubGoodsQtyPlugin.java new file mode 100644 index 0000000..4cc7137 --- /dev/null +++ b/lc123/cloud/app/plugin/operate/im/PurinUnauditSubGoodsQtyPlugin.java @@ -0,0 +1,67 @@ +package tqq9.lc123.cloud.app.plugin.operate.im; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.operate.result.OperationResult; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.args.AfterOperationArgs; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 采购入库反审核 + * 减去商城商品中的数量 + */ +public class PurinUnauditSubGoodsQtyPlugin extends AbstractOperationServicePlugIn { + + @Override + public void afterExecuteOperationTransaction(AfterOperationArgs e) { + super.afterExecuteOperationTransaction(e); + OperationResult operationResult = this.getOperationResult(); + List successPkIds = operationResult.getSuccessPkIds(); + for (Object successPkId : successPkIds) { + DynamicObject bill = BusinessDataServiceHelper.loadSingle(successPkId, "im_purinbill"); + DynamicObjectCollection entries = bill.getDynamicObjectCollection("billentry"); + for (DynamicObject entry : entries) { + String lotnumber = entry.getString("lotnumber"); + DynamicObject warehouse = entry.getDynamicObject("warehouse"); + String whNumber = warehouse.getString("number"); + Date producedate = entry.getDate("producedate"); + Date expirydate = entry.getDate("expirydate"); + BigDecimal qty = entry.getBigDecimal("qty"); + DynamicObject tqq9_goods = entry.getDynamicObject("tqq9_goods"); + if(tqq9_goods != null){ + tqq9_goods = BusinessDataServiceHelper.loadSingle(tqq9_goods.getPkValue(), tqq9_goods.getDynamicObjectType().getName()); + DynamicObjectCollection goodsEntries = tqq9_goods.getDynamicObjectCollection(""); + for (DynamicObject goodsEntry : goodsEntries) { + DynamicObject tqq9_lot = goodsEntry.getDynamicObject("tqq9_lot"); + String lotNumber = tqq9_lot.getString("number");//批次号 + DynamicObject tqq9_basedatafield = goodsEntry.getDynamicObject("tqq9_basedatafield"); + String warehouseNumber = tqq9_basedatafield.getString("number");//仓库编码 + Date tqq9_productdate = goodsEntry.getDate("tqq9_productdate"); + Date tqq9_todate = goodsEntry.getDate("tqq9_todate"); + BigDecimal tqq9_availablestock = goodsEntry.getBigDecimal("tqq9_availablestock"); + BigDecimal tqq9_upstock = goodsEntry.getBigDecimal("tqq9_upstock"); + + if(((StringUtils.isBlank(lotNumber) && StringUtils.isBlank(lotnumber)) || lotNumber.equals(lotnumber)) + && ((StringUtils.isBlank(whNumber) && StringUtils.isBlank(warehouseNumber)) || whNumber.equals(warehouseNumber)) + && ((tqq9_productdate == null && producedate == null) || (tqq9_productdate.equals(producedate))) + && ((tqq9_todate == null && expirydate == null) || (tqq9_todate.equals(expirydate)))){ + tqq9_availablestock = tqq9_availablestock.subtract(qty); + tqq9_upstock = tqq9_upstock.subtract(qty); + goodsEntry.set("tqq9_availablestock", tqq9_availablestock); + goodsEntry.set("tqq9_upstock", tqq9_upstock); + SaveServiceHelper.save(new DynamicObject[]{tqq9_goods}); + break; + } + } + } + } + } + } +}