From 5b4dc55bc3e2a12c8fc7896e03f5c38b85c1f636 Mon Sep 17 00:00:00 2001 From: sez Date: Tue, 25 Nov 2025 11:24:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=A6=E6=88=AA=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/plugin/form/result/CloneBill.java | 87 +++++++++---------- .../form/result/OtherInApplyFormPlugin.java | 7 +- .../form/result/OtherInApplyListPlugin.java | 7 +- .../form/result/OtherOutApplyFormPlugin.java | 5 ++ .../form/result/OtherOutApplyListPlugin.java | 5 ++ .../result/PmPurRefundApplyBillPlugin.java | 5 ++ .../result/PmPurRefundApplyListPlugin.java | 5 ++ .../result/PmReceiptNoticeFormPlugin.java | 7 +- .../result/PmReceiptNoticeListPlugin.java | 7 +- .../result/SmDeliverNoticeBillPlugin.java | 5 ++ .../result/SmDeliverNoticeListPlugin.java | 6 +- .../plugin/utils/BillCloseCancelUtils.java | 4 +- 12 files changed, 99 insertions(+), 51 deletions(-) diff --git a/lc123/cloud/app/plugin/form/result/CloneBill.java b/lc123/cloud/app/plugin/form/result/CloneBill.java index 5d24db2..bd4496a 100644 --- a/lc123/cloud/app/plugin/form/result/CloneBill.java +++ b/lc123/cloud/app/plugin/form/result/CloneBill.java @@ -1,16 +1,18 @@ package tqq9.lc123.cloud.app.plugin.form.result; +import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.entity.CloneUtils; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.entity.botp.runtime.BFRow; +import kd.bos.entity.operate.result.OperationResult; 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.bos.servicehelper.botp.BFTrackerServiceHelper; +import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; import java.util.List; @@ -19,56 +21,53 @@ import java.util.Map; public class CloneBill extends AbstractOperationServicePlugIn { private final static Log logger = LogFactory.getLog(CloneBill.class); - //先调用拦截,没有回传则调用,然后调用关闭 - @Override - public void beforeExecuteOperationTransaction(BeforeOperationArgs e) { - super.beforeExecuteOperationTransaction(e); - DynamicObject[] dataEntities1 = e.getDataEntities(); - for (DynamicObject dynamicObject : dataEntities1) { - StringBuilder billnoSet = new StringBuilder(); - Map> sourceBillsMap = BFTrackerServiceHelper.findDirtSourceBills(dynamicObject.getDataEntityType().getName(), new Long[]{dynamicObject.getLong("id")}); - if (null != sourceBillsMap && sourceBillsMap.size() > 0) { - List bfRows = sourceBillsMap.get(dynamicObject.getLong("id")); - if (null != bfRows) { - for (BFRow bfRow : bfRows) { - Long billId = bfRow.getSId().getBillId();//获取到采购退货申请id - DynamicObject[] pm_purrefundapplybill = BusinessDataServiceHelper.load("pm_purrefundapplybill", "billno", - new QFilter[]{new QFilter("id", "=", billId)}); - for (int i = 0; i < pm_purrefundapplybill.length; i++) { - DynamicObject object = pm_purrefundapplybill[i]; - String billno = object.getString("billno"); - billnoSet.append(billno); - if (i < pm_purrefundapplybill.length-1) { - billnoSet.append("、"); - } + public static void cloneOperation(DynamicObject dynamicObject) { + String entityNumber = dynamicObject.getDataEntityType().getName(); + StringBuilder billnoSet = new StringBuilder(); + //找直接上游单据,将上游单据编号存在复制的单据上面 + Map> sourceBillsMap = BFTrackerServiceHelper.findDirtSourceBills(entityNumber, new Long[]{dynamicObject.getLong("id")}); + if (null != sourceBillsMap && sourceBillsMap.size() > 0) { + List bfRows = sourceBillsMap.get(dynamicObject.getLong("id")); + if (null != bfRows) { + for (BFRow bfRow : bfRows) { + Long billId = bfRow.getSId().getBillId();//获取到采购退货申请id + DynamicObject[] pm_purrefundapplybill = BusinessDataServiceHelper.load("pm_purrefundapplybill", "billno", + new QFilter[]{new QFilter("id", "=", billId)}); + + for (int i = 0; i < pm_purrefundapplybill.length; i++) { + DynamicObject object = pm_purrefundapplybill[i]; + String billno = object.getString("billno"); + billnoSet.append(billno); + if (i < pm_purrefundapplybill.length - 1) { + billnoSet.append("、"); } - } + } } - dynamicObject = BusinessDataServiceHelper.loadSingle(dynamicObject.getDataEntityType().getName(), - new QFilter[]{new QFilter("id", QCP.equals, dynamicObject.getLong("id"))}); - DynamicObject newData = (DynamicObject) new CloneUtils(false, true).clone(dynamicObject); - newData.set("billno", dynamicObject.getString("billno")); - newData.set("billstatus", "C"); - newData.set("tqq9_sourcebillno",billnoSet); - SaveServiceHelper.save(new DynamicObject[]{newData}); - StringBuilder message = new StringBuilder(); - /*OperateOption option = OperateOption.create(); - OperationResult unauditResult = OperationServiceHelper.executeOperate("unaudit", dynamicObject.getDataEntityType().getName(), new DynamicObject[]{dynamicObject}, OperateOption.create()); - if (unauditResult.isSuccess()) { - OperationResult deleteResult = OperationServiceHelper.executeOperate("delete", dynamicObject.getDataEntityType().getName(), new DynamicObject[]{dynamicObject}, OperateOption.create()); + } + dynamicObject = BusinessDataServiceHelper.loadSingle(entityNumber, new QFilter[]{new QFilter("id", QCP.equals, dynamicObject.getLong("id"))}); + DynamicObject newData = (DynamicObject) new CloneUtils(false, true).clone(dynamicObject); + newData.set("billno", dynamicObject.getString("billno")); + newData.set("billstatus", "C"); + newData.set("tqq9_sourcebillno", billnoSet); + SaveServiceHelper.save(new DynamicObject[]{newData}); + StringBuilder message = new StringBuilder(); + OperationResult unauditResult = OperationServiceHelper.executeOperate("unaudit", entityNumber, new DynamicObject[]{dynamicObject}, OperateOption.create()); + if (unauditResult.isSuccess()) { + OperationResult deleteResult = OperationServiceHelper.executeOperate("delete", entityNumber, new DynamicObject[]{dynamicObject}, OperateOption.create()); - deleteResult.getAllErrorOrValidateInfo().forEach((error) -> { - message.append(error.getMessage()); - }); + deleteResult.getAllErrorOrValidateInfo().forEach((error) -> { + message.append(error.getMessage()); + }); - } else { - unauditResult.getAllErrorOrValidateInfo().forEach((error) -> { - message.append(error.getMessage()); - }); - }*/ + logger.info(dynamicObject.getString("billno") + "删除失败:" + message); + } else { + unauditResult.getAllErrorOrValidateInfo().forEach((error) -> { + message.append(error.getMessage()); + }); + logger.info(dynamicObject.getString("billno") + "反审核失败:" + message); } } } diff --git a/lc123/cloud/app/plugin/form/result/OtherInApplyFormPlugin.java b/lc123/cloud/app/plugin/form/result/OtherInApplyFormPlugin.java index ca1f0b3..41d79ba 100644 --- a/lc123/cloud/app/plugin/form/result/OtherInApplyFormPlugin.java +++ b/lc123/cloud/app/plugin/form/result/OtherInApplyFormPlugin.java @@ -14,6 +14,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils; import java.util.EventObject; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //其他入库申请单(单据取消) public class OtherInApplyFormPlugin extends AbstractBillPlugIn { @@ -95,7 +97,7 @@ public class OtherInApplyFormPlugin extends AbstractBillPlugIn { } entityName = "WMS-SH-其他入库申请单取消"; - message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); + message = BillCloseCancelUtils.wmsPartClose(orderType, warehouseCode, billNo, entityType, entityName, label); } else if ("BJLC".equals(number)) { String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); entityName = "WMS-BJ-其他入库申请单取消"; @@ -107,6 +109,9 @@ public class OtherInApplyFormPlugin extends AbstractBillPlugIn { message = BillCloseCancelUtils.BGCloseOtherVouchIn(billNo, GZURL, entityType, entityName, label); } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); + } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); } diff --git a/lc123/cloud/app/plugin/form/result/OtherInApplyListPlugin.java b/lc123/cloud/app/plugin/form/result/OtherInApplyListPlugin.java index 1435300..6522333 100644 --- a/lc123/cloud/app/plugin/form/result/OtherInApplyListPlugin.java +++ b/lc123/cloud/app/plugin/form/result/OtherInApplyListPlugin.java @@ -19,6 +19,8 @@ import java.util.EventObject; import java.util.List; import java.util.stream.Collectors; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //其他入库申请单(单据取消) public class OtherInApplyListPlugin extends AbstractListPlugin { @@ -127,7 +129,7 @@ public class OtherInApplyListPlugin extends AbstractListPlugin { entityName = "WMS-SH-其他入库申请单取消"; - message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); + message = BillCloseCancelUtils.wmsPartClose(orderType, warehouseCode, billNo, entityType, entityName, label); } else if ("BJLC".equals(number)) { String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); @@ -141,6 +143,9 @@ public class OtherInApplyListPlugin extends AbstractListPlugin { message = BillCloseCancelUtils.BGCloseOtherVouchIn(billNo, GZURL, entityType, entityName, label); } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); + } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); diff --git a/lc123/cloud/app/plugin/form/result/OtherOutApplyFormPlugin.java b/lc123/cloud/app/plugin/form/result/OtherOutApplyFormPlugin.java index b8a0b30..c0f57f2 100644 --- a/lc123/cloud/app/plugin/form/result/OtherOutApplyFormPlugin.java +++ b/lc123/cloud/app/plugin/form/result/OtherOutApplyFormPlugin.java @@ -13,6 +13,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils; import java.util.EventObject; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //其他出库申请单(单据取消) public class OtherOutApplyFormPlugin extends AbstractBillPlugIn { @@ -107,6 +109,9 @@ public class OtherOutApplyFormPlugin extends AbstractBillPlugIn { entityName = "WMS-GZ-其他出库申请单取消"; message = BillCloseCancelUtils.BGCloseOtherVouchOut(billNo, GZURL, entityType, entityName, label, orderType); } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); + } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); } diff --git a/lc123/cloud/app/plugin/form/result/OtherOutApplyListPlugin.java b/lc123/cloud/app/plugin/form/result/OtherOutApplyListPlugin.java index a7253cb..ab01720 100644 --- a/lc123/cloud/app/plugin/form/result/OtherOutApplyListPlugin.java +++ b/lc123/cloud/app/plugin/form/result/OtherOutApplyListPlugin.java @@ -18,6 +18,8 @@ import java.util.EventObject; import java.util.List; import java.util.stream.Collectors; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //其他出库申请单(单据取消) public class OtherOutApplyListPlugin extends AbstractListPlugin { @@ -139,6 +141,9 @@ public class OtherOutApplyListPlugin extends AbstractListPlugin { entityName = "WMS-GZ-其他出库申请单取消"; message = BillCloseCancelUtils.BGCloseOtherVouchOut(billNo, GZURL, entityType, entityName, label, orderType); } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); + } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); } diff --git a/lc123/cloud/app/plugin/form/result/PmPurRefundApplyBillPlugin.java b/lc123/cloud/app/plugin/form/result/PmPurRefundApplyBillPlugin.java index 0f521b2..3ddfc89 100644 --- a/lc123/cloud/app/plugin/form/result/PmPurRefundApplyBillPlugin.java +++ b/lc123/cloud/app/plugin/form/result/PmPurRefundApplyBillPlugin.java @@ -14,6 +14,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils; import java.util.EventObject; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //采购退货申请单(单据取消) public class PmPurRefundApplyBillPlugin extends AbstractBillPlugIn { @@ -86,6 +88,9 @@ public class PmPurRefundApplyBillPlugin extends AbstractBillPlugIn { message = BillCloseCancelUtils.BGPuCancelPurReturn(billNo, GZURL, entityType, entityName, label); } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); + } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); diff --git a/lc123/cloud/app/plugin/form/result/PmPurRefundApplyListPlugin.java b/lc123/cloud/app/plugin/form/result/PmPurRefundApplyListPlugin.java index 728f8d8..739d1f0 100644 --- a/lc123/cloud/app/plugin/form/result/PmPurRefundApplyListPlugin.java +++ b/lc123/cloud/app/plugin/form/result/PmPurRefundApplyListPlugin.java @@ -19,6 +19,8 @@ import java.util.EventObject; import java.util.List; import java.util.stream.Collectors; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //采购退货申请单(单据取消) public class PmPurRefundApplyListPlugin extends AbstractListPlugin { @@ -119,6 +121,9 @@ public class PmPurRefundApplyListPlugin extends AbstractListPlugin { message = BillCloseCancelUtils.BGPuCancelPurReturn(billNo, GZURL, entityType, entityName, label); } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); + } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); diff --git a/lc123/cloud/app/plugin/form/result/PmReceiptNoticeFormPlugin.java b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeFormPlugin.java index 956ac52..e0c5b96 100644 --- a/lc123/cloud/app/plugin/form/result/PmReceiptNoticeFormPlugin.java +++ b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeFormPlugin.java @@ -14,6 +14,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils; import java.util.EventObject; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //收货通知单(单据取消) public class PmReceiptNoticeFormPlugin extends AbstractBillPlugIn { @@ -74,7 +76,7 @@ public class PmReceiptNoticeFormPlugin extends AbstractBillPlugIn { } String orderType = "CGRK"; entityName = "WMS-SH-收货通知单取消"; - message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); + message = BillCloseCancelUtils.wmsPartClose(orderType, warehouseCode, billNo, entityType, entityName, label); } else if ("BJLC".equals(number)) { String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); entityName = "WMS-BJ-收货通知单取消"; @@ -86,6 +88,9 @@ public class PmReceiptNoticeFormPlugin extends AbstractBillPlugIn { message = BillCloseCancelUtils.BGPurOrderCancel(billNo, GZURL, entityType, entityName, label); } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); + } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); diff --git a/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java index 32bfe13..53d0b3c 100644 --- a/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java +++ b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java @@ -21,6 +21,8 @@ import java.util.EventObject; import java.util.List; import java.util.stream.Collectors; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //收货通知单(单据取消) public class PmReceiptNoticeListPlugin extends AbstractListPlugin { @@ -108,7 +110,7 @@ public class PmReceiptNoticeListPlugin extends AbstractListPlugin { } String orderType = "CGRK"; entityName = "WMS-SH-收货通知单取消"; - message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); + message = BillCloseCancelUtils.wmsPartClose(orderType, warehouseCode, billNo, entityType, entityName, label); } else if ("BJLC".equals(number)) { String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); entityName = "WMS-BJ-收货通知单取消"; @@ -120,6 +122,9 @@ public class PmReceiptNoticeListPlugin extends AbstractListPlugin { message = BillCloseCancelUtils.BGPurOrderCancel(billNo, GZURL, entityType, entityName, label); } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); + } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); diff --git a/lc123/cloud/app/plugin/form/result/SmDeliverNoticeBillPlugin.java b/lc123/cloud/app/plugin/form/result/SmDeliverNoticeBillPlugin.java index 71f392d..ed4ce6a 100644 --- a/lc123/cloud/app/plugin/form/result/SmDeliverNoticeBillPlugin.java +++ b/lc123/cloud/app/plugin/form/result/SmDeliverNoticeBillPlugin.java @@ -13,6 +13,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils; import java.util.EventObject; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //发货通知单(单据取消) public class SmDeliverNoticeBillPlugin extends AbstractBillPlugIn { @@ -82,6 +84,9 @@ public class SmDeliverNoticeBillPlugin extends AbstractBillPlugIn { message = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, GZURL, entityType, entityName, label); } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); + } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); diff --git a/lc123/cloud/app/plugin/form/result/SmDeliverNoticeListPlugin.java b/lc123/cloud/app/plugin/form/result/SmDeliverNoticeListPlugin.java index 8b782d0..7efb7dc 100644 --- a/lc123/cloud/app/plugin/form/result/SmDeliverNoticeListPlugin.java +++ b/lc123/cloud/app/plugin/form/result/SmDeliverNoticeListPlugin.java @@ -18,6 +18,8 @@ import java.util.EventObject; import java.util.List; import java.util.stream.Collectors; +import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation; + //发货通知单(单据取消) public class SmDeliverNoticeListPlugin extends AbstractListPlugin { @@ -113,7 +115,9 @@ public class SmDeliverNoticeListPlugin extends AbstractListPlugin { String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL"); entityName = "WMS-GZ-发货通知单取消"; message = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, GZURL, entityType, entityName, label); - + } + if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) { + cloneOperation(dataEntity); } if (StringUtils.isNotEmpty(message)) { this.getView().showMessage(String.valueOf(message)); diff --git a/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java b/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java index b9f7d09..f82973b 100644 --- a/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java +++ b/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java @@ -16,7 +16,7 @@ public class BillCloseCancelUtils { /** - * 通天晓单据取消接口 + * 通天晓单据取消接口-出库调用 * * @param orderType 单据类型 * @param warehouseCode 仓库编号 @@ -267,7 +267,7 @@ public class BillCloseCancelUtils { /** - * 通天晓单据部分关闭 + * 通天晓单据部分关闭-入库调用 * * @param orderType 单据类型 * @param warehouseCode 仓库编号