From acc73a5e078f411ff96fbed933badb325b4de61a Mon Sep 17 00:00:00 2001 From: ptt <2403326863@qq.com> Date: Fri, 7 Mar 2025 17:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=B9=E7=94=A8=E7=99=BB=E8=AE=B0=E4=BA=8C?= =?UTF-8?q?=E5=BC=80=E5=90=88=E8=AE=A1=E8=A1=8C=20=E6=88=90=E6=9C=AC?= =?UTF-8?q?=E6=B5=8B=E7=AE=97=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E6=89=8B=E5=B7=A5=E7=94=9F=E6=88=90=E7=9B=AE=E6=A0=87=E6=88=90?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../formplugin/SumInvoiceEntryPlugin.java | 46 ++++++++++ .../formplugin/CreatTargetCostFormPlugin.java | 77 +++++++++++++++++ .../listplugin/CreatTargetCostListPlugin.java | 84 +++++++++++++++++++ 3 files changed, 207 insertions(+) create mode 100644 main/java/shkd/repc/recon/formplugin/SumInvoiceEntryPlugin.java create mode 100644 main/java/shkd/repc/recos/formplugin/CreatTargetCostFormPlugin.java create mode 100644 main/java/shkd/repc/recos/listplugin/CreatTargetCostListPlugin.java diff --git a/main/java/shkd/repc/recon/formplugin/SumInvoiceEntryPlugin.java b/main/java/shkd/repc/recon/formplugin/SumInvoiceEntryPlugin.java new file mode 100644 index 0000000..bc7e3ba --- /dev/null +++ b/main/java/shkd/repc/recon/formplugin/SumInvoiceEntryPlugin.java @@ -0,0 +1,46 @@ +package shkd.repc.recon.formplugin; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.form.events.AfterDoOperationEventArgs; +import kd.sdk.plugin.Plugin; + +import java.math.BigDecimal; +import java.util.EventObject; + +/** + * 单据界面插件 + */ +public class SumInvoiceEntryPlugin extends AbstractBillPlugIn implements Plugin { + + @Override + public void afterBindData(EventObject e) { + super.afterBindData(e); + updateAmt(); + } + + private void updateAmt(){ + DynamicObject dataEntity = this.getModel().getDataEntity(); + DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry"); + if (invoiceentry!=null) { + for (int i = 0; i < invoiceentry.size(); i++) { + DynamicObject dynamicObject = invoiceentry.get(i); + DynamicObject inventry_invoicebill = dynamicObject.getDynamicObject("inventry_invoicebill"); + BigDecimal notaxamt = inventry_invoicebill.getBigDecimal("notaxamt"); + BigDecimal tax = inventry_invoicebill.getBigDecimal("tax"); + BigDecimal amount = inventry_invoicebill.getBigDecimal("amount"); + dynamicObject.set("qeug_notaxamt",notaxamt); + dynamicObject.set("qeug_tax",tax); + dynamicObject.set("qeug_amount",amount); + } + this.getView().updateView("invoiceentry"); + } + } + + @Override + public void afterDoOperation(AfterDoOperationEventArgs args) { + super.afterDoOperation(args); + updateAmt(); + } +} \ No newline at end of file diff --git a/main/java/shkd/repc/recos/formplugin/CreatTargetCostFormPlugin.java b/main/java/shkd/repc/recos/formplugin/CreatTargetCostFormPlugin.java new file mode 100644 index 0000000..5406c57 --- /dev/null +++ b/main/java/shkd/repc/recos/formplugin/CreatTargetCostFormPlugin.java @@ -0,0 +1,77 @@ +package shkd.repc.recos.formplugin; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.operate.result.IOperateInfo; +import kd.bos.entity.operate.result.OperationResult; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.repc.rebas.common.enums.ReBillStatusEnum; +import kd.repc.recos.business.aimcost.AimCostGenByMeasureHelper; +import kd.repc.recos.business.conplan.ReConPlanHelper; +import kd.sdk.plugin.Plugin; + +import java.util.EventObject; + +/** + * 单据界面插件 + */ +public class CreatTargetCostFormPlugin extends AbstractBillPlugIn implements Plugin { + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + this.addItemClickListeners("qeug_creat"); + this.addItemClickListeners("qeug_revoked"); + } + + @Override + public void itemClick(ItemClickEvent evt) { + DynamicObject dynamicObject = this.getModel().getDataEntity(); + Object primaryKeyValue = dynamicObject.getPkValue(); + if ("qeug_creat".equals(evt.getItemKey())) { + QFilter measurecostid = new QFilter("measurecostid", QCP.equals, primaryKeyValue); + DynamicObject dynamicObject2 = BusinessDataServiceHelper.loadSingle("recos_aimcost", measurecostid.toArray()); + if (dynamicObject2!=null) { + this.getView().showMessage("存在对应目标成本,无法生成"); + return; + } + dynamicObject.set("aimversionflag",true); + SaveServiceHelper.update(dynamicObject); + AimCostGenByMeasureHelper.generateAimCost((Long)dynamicObject.getPkValue()); + this.getView().updateView("aimversionflag"); + this.getView().showSuccessNotification("生成成功"); + }else if("qeug_revoked".equals(evt.getItemKey())){ + boolean aimversionflag = dynamicObject.getBoolean("aimversionflag"); + DynamicObject project = dynamicObject.getDynamicObject("project"); + if (aimversionflag) { + boolean projectConPlan = QueryServiceHelper.exists("recos_conplan", new QFilter[]{new QFilter("billstatus", "in", new String[]{ReBillStatusEnum.SUBMITTED.getValue(), ReBillStatusEnum.AUDITTED.getValue()}), new QFilter("project", "=", project.getPkValue())}); + if (projectConPlan) { + this.getView().showMessage("对应项目分期合约规划为已审核状态或已提交, 无法撤销目标成本。"); + return; + } + } + if (dynamicObject.getBoolean("aimversionflag")) { + Boolean hasSaveConPlan = ReConPlanHelper.checkConPlanStatus(project.getLong("id")); + if (hasSaveConPlan) { + OperationResult unAuditOpResult = AimCostGenByMeasureHelper.unAuditAimCost(dynamicObject.getPkValue()); + if (null != unAuditOpResult && !unAuditOpResult.isSuccess()) { + this.getView().showMessage(((IOperateInfo)unAuditOpResult.getAllErrorOrValidateInfo().get(0)).getMessage()); + } + } + } + if (dynamicObject.getBoolean("aimversionflag")) { + Boolean hasSaveConPlan = ReConPlanHelper.checkConPlanStatus(project.getLong("id")); + if (hasSaveConPlan) { + AimCostGenByMeasureHelper.deleteAimCost(dynamicObject.getPkValue()); + } + } + dynamicObject.set("aimversionflag",false); + SaveServiceHelper.update(dynamicObject); + } + + } +} diff --git a/main/java/shkd/repc/recos/listplugin/CreatTargetCostListPlugin.java b/main/java/shkd/repc/recos/listplugin/CreatTargetCostListPlugin.java new file mode 100644 index 0000000..50f40c7 --- /dev/null +++ b/main/java/shkd/repc/recos/listplugin/CreatTargetCostListPlugin.java @@ -0,0 +1,84 @@ +package shkd.repc.recos.listplugin; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.entity.operate.result.IOperateInfo; +import kd.bos.entity.operate.result.OperationResult; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.list.plugin.AbstractListPlugin; +import kd.bos.mvc.list.ListView; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.repc.rebas.common.enums.ReBillStatusEnum; +import kd.repc.recos.business.aimcost.AimCostGenByMeasureHelper; +import kd.repc.recos.business.conplan.ReConPlanHelper; +import kd.sdk.plugin.Plugin; + +import java.util.EventObject; + +/** + * 标准单据列表插件 + */ +public class CreatTargetCostListPlugin extends AbstractListPlugin implements Plugin { + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + this.addItemClickListeners("qeug_creat"); + this.addItemClickListeners("qeug_revoked"); + } + + @Override + public void itemClick(ItemClickEvent evt) { + ListView listView = (ListView) this.getView(); + if ("qeug_creat".equals(evt.getItemKey())) { + ListSelectedRowCollection selectedRows = listView.getSelectedRows(); + Object primaryKeyValue = selectedRows.get(0).getPrimaryKeyValue(); + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(primaryKeyValue, listView.getBillFormId()); + QFilter measurecostid = new QFilter("measurecostid", QCP.equals, primaryKeyValue); + DynamicObject dynamicObject2 = BusinessDataServiceHelper.loadSingle("recos_aimcost", measurecostid.toArray()); + if (dynamicObject2!=null) { + this.getView().showMessage("存在对应目标成本,无法生成"); + return; + } + dynamicObject.set("aimversionflag",true); + SaveServiceHelper.update(dynamicObject); + AimCostGenByMeasureHelper.generateAimCost((Long)dynamicObject.getPkValue()); + this.getView().showSuccessNotification("生成成功"); + }else if("qeug_revoked".equals(evt.getItemKey())){ + ListSelectedRowCollection selectedRows = listView.getSelectedRows(); + Object primaryKeyValue = selectedRows.get(0).getPrimaryKeyValue(); + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(primaryKeyValue, listView.getBillFormId()); + boolean aimversionflag = dynamicObject.getBoolean("aimversionflag"); + DynamicObject project = dynamicObject.getDynamicObject("project"); + if (aimversionflag) { + boolean projectConPlan = QueryServiceHelper.exists("recos_conplan", new QFilter[]{new QFilter("billstatus", "in", new String[]{ReBillStatusEnum.SUBMITTED.getValue(), ReBillStatusEnum.AUDITTED.getValue()}), new QFilter("project", "=", project.getPkValue())}); + if (projectConPlan) { + this.getView().showMessage("对应项目分期合约规划为已审核状态或已提交, 无法撤销目标成本。"); + return; + } + } + if (dynamicObject.getBoolean("aimversionflag")) { + Boolean hasSaveConPlan = ReConPlanHelper.checkConPlanStatus(project.getLong("id")); + if (hasSaveConPlan) { + OperationResult unAuditOpResult = AimCostGenByMeasureHelper.unAuditAimCost(dynamicObject.getPkValue()); + if (null != unAuditOpResult && !unAuditOpResult.isSuccess()) { + this.getView().showMessage(((IOperateInfo)unAuditOpResult.getAllErrorOrValidateInfo().get(0)).getMessage()); + } + } + } + if (dynamicObject.getBoolean("aimversionflag")) { + Boolean hasSaveConPlan = ReConPlanHelper.checkConPlanStatus(project.getLong("id")); + if (hasSaveConPlan) { + AimCostGenByMeasureHelper.deleteAimCost(dynamicObject.getPkValue()); + } + } + dynamicObject.set("aimversionflag",false); + SaveServiceHelper.update(dynamicObject); + } + + } +} \ No newline at end of file