From f6b3c01b151fb21dab3419f7700ce770e9700bd3 Mon Sep 17 00:00:00 2001 From: ggxl <194689125@qq.com> Date: Fri, 22 Nov 2024 11:08:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E5=87=86=E6=88=90=E6=9C=AC=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=9B=9E=E4=BC=A0=E5=8F=8D=E5=86=99=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=90=8E=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DecisionJumpToConPlanPlugin.java | 43 +++++---- .../WriteBackAdjustAmountOpPlugin.java | 94 +++++++++++++++++++ .../GetDecisionAndPurProjectPlugin.java | 5 + 3 files changed, 122 insertions(+), 20 deletions(-) create mode 100644 main/java/shkd/repc/rebm/opplugin/WriteBackAdjustAmountOpPlugin.java diff --git a/main/java/shkd/repc/rebm/formplugin/DecisionJumpToConPlanPlugin.java b/main/java/shkd/repc/rebm/formplugin/DecisionJumpToConPlanPlugin.java index 0d2713d..2d511a6 100644 --- a/main/java/shkd/repc/rebm/formplugin/DecisionJumpToConPlanPlugin.java +++ b/main/java/shkd/repc/rebm/formplugin/DecisionJumpToConPlanPlugin.java @@ -25,6 +25,7 @@ import kd.bos.form.events.AfterDoOperationEventArgs; import kd.bos.form.field.AmountEdit; import kd.bos.form.field.DecimalEdit; import kd.bos.portal.util.OpenPageUtils; +import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.sdk.plugin.Plugin; import kd.svc.control.events.AppNavigationMenuEvent; @@ -37,10 +38,10 @@ import java.util.*; public class DecisionJumpToConPlanPlugin extends AbstractBillPlugIn implements Plugin { /* - * 定标 - * 1.点击‘变更合约规划’按钮跳转到成本管理的 目标成本调整 - * 2.将采购明细中的规划金额 < 供应商信息的最终价 所对应的采购项目带到目标成本调整中 - * */ + * 定标 + * 1.点击‘变更合约规划’按钮跳转到成本管理的 目标成本调整 + * 2.将采购明细中的规划金额 < 供应商信息的最终价 所对应的采购项目带到目标成本调整中 + * */ @Override public void afterBindData(EventObject e) { @@ -108,34 +109,34 @@ public class DecisionJumpToConPlanPlugin extends AbstractBillPlugIn implements P String purProjectNum = ""; DynamicObjectCollection bidSections = model.getEntryEntity("bidsection");// 标段 DynamicObjectCollection bottomSections = model.getEntryEntity("bottomsection");// 标底标段 - DynamicObjectCollection supplierEntries = model.getEntryEntity("supplierentry");// 定标供应商 - DynamicObjectCollection bottomEntries = model.getEntryEntity("bottomentry");// 采购明细 - if (bidSections != null && supplierEntries != null && bottomSections != null && bottomEntries != null) { + + int seqNum = 0; + if (bidSections != null && bottomSections != null) { for (DynamicObject bidSection : bidSections) { BigDecimal finalPriceSum = new BigDecimal(0); int seq = bidSection.getInt("seq"); - long entryId = bidSection.getLong("id"); + DynamicObjectCollection supplierEntries = bidSection.getDynamicObjectCollection("supplierentry");// 定标供应商 + if (supplierEntries == null) continue; for (DynamicObject supplierEntry : supplierEntries) { - DynamicObject parent = (DynamicObject) supplierEntry.getParent(); - if (entryId == parent.getLong("id")) {// 判断是否该标段对应的供应商 - if (supplierEntry.getBoolean("isrecommended")) {// 是否中标单位 - BigDecimal finalPrice = supplierEntry.getBigDecimal("finalprice"); - finalPriceSum = finalPriceSum.add(finalPrice); - } + if (supplierEntry.getBoolean("isrecommended")) {// 是否中标单位 + BigDecimal finalPrice = supplierEntry.getBigDecimal("finalprice"); + finalPriceSum = finalPriceSum.add(finalPrice); } } + if (finalPriceSum.equals(new BigDecimal(0))) continue; + DynamicObject project = null; BigDecimal controlAmountSum = new BigDecimal(0); for (DynamicObject bottomSection : bottomSections) { int bottomSeq = bottomSection.getInt("seq"); if (seq == bottomSeq) { - long bottomEntryId = bottomSection.getLong("id"); - if (!bottomEntries.isEmpty()) project = bottomEntries.get(0).getDynamicObject("botpurentryproject"); + DynamicObjectCollection bottomEntries = bottomSection.getDynamicObjectCollection("bottomentry");// 采购明细 + if (bottomEntries != null) { + if (!bottomEntries.isEmpty()) + project = bottomEntries.get(0).getDynamicObject("botpurentryproject"); - for (DynamicObject bottomEntry : bottomEntries) { - DynamicObject parent = (DynamicObject) bottomEntry.getParent(); - if (bottomEntryId == parent.getLong("id")) { + for (DynamicObject bottomEntry : bottomEntries) { BigDecimal controlAmount = bottomEntry.getBigDecimal("botcontrolamount");// 采购控制金额(含税) controlAmountSum = controlAmountSum.add(controlAmount); } @@ -144,8 +145,9 @@ public class DecisionJumpToConPlanPlugin extends AbstractBillPlugIn implements P } if (finalPriceSum.compareTo(controlAmountSum) >= 1) { - if (!bottomEntries.isEmpty() && project != null) { + if (project != null) { purProjectNum = project.getString("number"); + seqNum = seq; break; } } @@ -163,6 +165,7 @@ public class DecisionJumpToConPlanPlugin extends AbstractBillPlugIn implements P billShowParameter.setCustomParam("decision_id", model.getDataEntity().getLong("id")); billShowParameter.setCustomParam("purproject_number", purProjectNum); + billShowParameter.setCustomParam("seqNum", seqNum); appPageView.showForm(billShowParameter); getView().sendFormAction(appPageView); diff --git a/main/java/shkd/repc/rebm/opplugin/WriteBackAdjustAmountOpPlugin.java b/main/java/shkd/repc/rebm/opplugin/WriteBackAdjustAmountOpPlugin.java new file mode 100644 index 0000000..aa39519 --- /dev/null +++ b/main/java/shkd/repc/rebm/opplugin/WriteBackAdjustAmountOpPlugin.java @@ -0,0 +1,94 @@ +package shkd.repc.rebm.opplugin; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.args.AfterOperationArgs; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.math.BigDecimal; + +/** + * 单据操作插件 + */ +public class WriteBackAdjustAmountOpPlugin extends AbstractOperationServicePlugIn implements Plugin { + + /* + * 目标成本调整-审核/反审核时触发,根据合约规划回‘传调整后金额’ + * */ + + @Override + public void afterExecuteOperationTransaction(AfterOperationArgs e) { + super.afterExecuteOperationTransaction(e); + String operationKey = e.getOperationKey(); + if ("audit".equals(operationKey) || "test".equals(operationKey)) { + DynamicObject[] dataEntities = e.getDataEntities(); + for (DynamicObject dataEntity : dataEntities) { + dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), "recos_aimadjust"); + DynamicObject decision = dataEntity.getDynamicObject("qeug_decision");//定标 + DynamicObjectCollection conPlanAdjustEntries = dataEntity.getDynamicObjectCollection("conplanadjustentry");// 未签约调整分录 + if (decision != null) { + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(decision.getPkValue(), "rebm_decision"); + int sectionSeq = dataEntity.getInt("qeug_section_seq"); + + DynamicObjectCollection bottomSections = dynamicObject.getDynamicObjectCollection("bottomsection"); + if (bottomSections != null) { + for (DynamicObject bottomSection : bottomSections) { + int bottomSeq = bottomSection.getInt("seq"); + if (sectionSeq == bottomSeq) { + DynamicObjectCollection bottomEntries = bottomSection.getDynamicObjectCollection("bottomentry");// 采购明细 + if (bottomEntries != null) { + String billNo = dynamicObject.getString("billno"); + QFilter billNoQF = new QFilter("billno", QCP.equals, billNo); + DynamicObject project = BusinessDataServiceHelper.loadSingle("rebm_project", billNoQF.toArray());// 标前预备会 + if (project != null) { + DynamicObjectCollection bidSections = project.getDynamicObjectCollection("bidsection");// 标段 + DynamicObject bidSection = bidSections.get(sectionSeq - 1); + DynamicObjectCollection projectEntries = bidSection.getDynamicObjectCollection("projectentry");// 采购明细 + + for (int i = 0; i < bottomEntries.size(); i++) { + DynamicObject bottomEntry = bottomEntries.get(i); + BigDecimal planAmount = bottomEntry.getBigDecimal("planamount"); + if (planAmount.intValue() == 0) continue; + + DynamicObject projectEntry = projectEntries.get(i); + DynamicObject cqprogcon = projectEntry.getDynamicObject("cqprogcon");// 合约规划 + if (conPlanAdjustEntries != null) { + for (DynamicObject conPlanAdjustEntry : conPlanAdjustEntries) { + DynamicObject conplan = conPlanAdjustEntry.getDynamicObject("cpentry_conplan"); + if (conplan.getLong("id") == cqprogcon.getLong("id")) { + BigDecimal adjustSumAmt = conPlanAdjustEntry.getBigDecimal("cpentry_adjustsumamt");// 调整后金额 + bottomEntry.set("qeug_planamount", bottomEntry.getBigDecimal("planamount")); + bottomEntry.set("qeug_botcontrolamount", bottomEntry.getBigDecimal("botcontrolamount")); + + bottomEntry.set("planamount", adjustSumAmt); + bottomEntry.set("botcontrolamount", adjustSumAmt); + bottomEntry.set("botctrlamtexceptvat", adjustSumAmt); + bottomEntry.set("nottaxplanamount", adjustSumAmt); + + BigDecimal controlamount = dynamicObject.getBigDecimal("controlamount").add(adjustSumAmt.subtract(bottomEntry.getBigDecimal("botcontrolamount"))); + dynamicObject.set("controlamount", controlamount); + dynamicObject.set("exctaxcontrolamount", controlamount); + } + } + } + } + + bottomSection.set("bottomentry", bottomEntries); + dynamicObject.set("bottomsection", bottomSections); + dynamicObject.set("qeug_conplan_adjust", String.valueOf(dataEntity.getPkValue())); + SaveServiceHelper.update(dynamicObject); + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/main/java/shkd/repc/recos/formplugin/GetDecisionAndPurProjectPlugin.java b/main/java/shkd/repc/recos/formplugin/GetDecisionAndPurProjectPlugin.java index cb960e4..6d0b85d 100644 --- a/main/java/shkd/repc/recos/formplugin/GetDecisionAndPurProjectPlugin.java +++ b/main/java/shkd/repc/recos/formplugin/GetDecisionAndPurProjectPlugin.java @@ -26,12 +26,17 @@ public class GetDecisionAndPurProjectPlugin extends AbstractBillPlugIn implement FormShowParameter formShowParameter = this.getView().getFormShowParameter(); Object decisionId = formShowParameter.getCustomParam("decision_id"); Object purProjectNumber = formShowParameter.getCustomParam("purproject_number"); + Object seqNum = formShowParameter.getCustomParam("seqNum"); IDataModel model = this.getModel(); if (decisionId != null && 0 != (Long) decisionId) { model.setValue("qeug_decision", decisionId); } + if (seqNum != null) { + model.setValue("qeug_section_seq", seqNum); + } + if (purProjectNumber != null && !((String) purProjectNumber).isEmpty()) { DynamicObject project = (DynamicObject) this.getModel().getValue("project"); if (project == null) {