From e404ee6e60621f095a9dcbcc7bd8012890600bf7 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Wed, 6 Aug 2025 11:15:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E5=87=BA=E5=90=88=E5=90=8C=E7=BB=93?= =?UTF-8?q?=E7=AE=97=E6=96=B0=E5=A2=9E=E5=90=88=E5=90=8C=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E9=A1=B9=E6=98=8E=E7=BB=86=E5=90=8E=E5=B0=86=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E5=88=86=E5=BD=95=E6=8B=86=E5=88=86=E8=87=B3?= =?UTF-8?q?=E5=B7=A5=E5=BA=8F=E5=88=86=E6=91=8A=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/form/ContractSettleBillPlugin.java | 44 ++++++++- .../plugin/form/CostAllocatorBillPlugin.java | 91 +++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CostAllocatorBillPlugin.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java index 94ace25..b31aae6 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java @@ -1,6 +1,8 @@ package zcgj.zcdev.zcdev.pr.plugin.form; import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType; import kd.bos.dataentity.utils.StringUtils; import kd.bos.entity.datamodel.events.ChangeData; import kd.bos.entity.datamodel.events.PropertyChangedArgs; @@ -49,6 +51,7 @@ public class ContractSettleBillPlugin extends ContractSettleCommonEditPlugin{ DynamicObject contract = (DynamicObject)changeData.getNewValue(); this.clearUnitproject(); this.contractChanged(contract); + this.clearOrNewProcessAlloc();//清除或者新增工序分摊分录 } else if (StringUtils.equals(name, "period")) { this.periodChanged(changeData); } else if (!StringUtils.equals(name, "begindate") && !StringUtils.equals(name, "enddate")) { @@ -158,7 +161,7 @@ public class ContractSettleBillPlugin extends ContractSettleCommonEditPlugin{ this.getModel().setValue("taxamt",taxamt,rowIndex); SettleUpdateAmtUtils.setItemEntrySumAmt(this.getView()); SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - + } private void clearUnitproject() { @@ -168,4 +171,43 @@ public class ContractSettleBillPlugin extends ContractSettleCommonEditPlugin{ } + private void clearOrNewProcessAlloc() { + DynamicObjectCollection payItemDetailEntryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("payitemdetailentry");//合同支付项明细 + DynamicObjectCollection itemEntryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("itementry");//支付项分录 + if (itemEntryCollection.size() == 0) { + return; + } + if (payItemDetailEntryCollection.size() > 0) { + for (DynamicObject payItemDetailEntry : payItemDetailEntryCollection) { + + DynamicObject itemEntry = itemEntryCollection.get(0); + DynamicObjectCollection processAllocEntityCollection = itemEntry.getDynamicObjectCollection("zcgj_processallocatentity");//工序分摊 + DynamicObjectType processAllocEntityType = processAllocEntityCollection.getDynamicObjectType(); + + long referBillId = payItemDetailEntry.getLong("referbillid");//关联单据id + DynamicObject EcOutContractMeasure = BusinessDataServiceHelper.loadSingle(referBillId, "ec_outcontractmeasure");//支出合同计量 + if (EcOutContractMeasure != null) { + DynamicObjectCollection ListModelEntryCollection = EcOutContractMeasure.getDynamicObjectCollection("listmodelentry");//模板分录 + for (DynamicObject ListModelEntry : ListModelEntryCollection) { + DynamicObjectCollection listEntryCollection = ListModelEntry.getDynamicObjectCollection("listentry");//清单分录 + for (DynamicObject listEntry : listEntryCollection) { + DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType); + newProcessAllocEntity.set("zcgj_pa_process", listEntry.get("listcbs"));//工序-成本分解结构 + newProcessAllocEntity.set("zcgj_pa_amount", listEntry.get("thisoftaxmount"));//价税合计-本期计量含税金额 + newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额 + newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率(%)-税率(%) + newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额 + newProcessAllocEntity.set("zcgj_pa_remark", listEntry.get("desc"));//费用说明-说明 + processAllocEntityCollection.add(newProcessAllocEntity); + } + } + } + } + this.getView().updateView("zcgj_processallocatentity");//工序分摊 + } else { + itemEntryCollection.clear(); + this.getView().updateView("itementry");//支付项分录 + this.getView().updateView("zcgj_processallocatentity");//工序分摊分录 + } + } } \ No newline at end of file diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CostAllocatorBillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CostAllocatorBillPlugin.java new file mode 100644 index 0000000..1a19433 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CostAllocatorBillPlugin.java @@ -0,0 +1,91 @@ +package zcgj.zcdev.zcdev.pr.plugin.form; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType; +import kd.bos.entity.datamodel.RowDataEntity; +import kd.bos.entity.datamodel.events.AfterAddRowEventArgs; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.servicehelper.BusinessDataServiceHelper; + +import java.util.EventObject; + +/* + * 使用插件注册位置:支出合同结算表单插件 + * 说明:新增合同支付项明细后将对应不同分录拆分至工序分摊中 + */ +public class CostAllocatorBillPlugin extends AbstractFormPlugin { + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + this.addItemClickListeners("payitemdetaitoolap");//合同支付项明细工具栏 + } + + @Override + public void itemClick(ItemClickEvent evt) { + super.itemClick(evt); + String itemKey = evt.getItemKey(); + if (itemKey.equals("advconbaritemap3")) { + //合同支付项明细删除按钮 + DynamicObjectCollection payItemDetailEntryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("payitemdetailentry");//合同支付项明细 + DynamicObjectCollection itemEntryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("itementry");//支付项分录 + if (itemEntryCollection.size() == 0) { + return; + } + if (payItemDetailEntryCollection.size() > 0) { + for (DynamicObject payItemDetailEntry : payItemDetailEntryCollection) { + + DynamicObject itemEntry = itemEntryCollection.get(0); + DynamicObjectCollection processAllocEntityCollection = itemEntry.getDynamicObjectCollection("zcgj_processallocatentity");//工序分摊 + processAllocEntityCollection.clear(); + DynamicObjectType processAllocEntityType = processAllocEntityCollection.getDynamicObjectType(); + + long referBillId = payItemDetailEntry.getLong("referbillid");//关联单据id + DynamicObject EcOutContractMeasure = BusinessDataServiceHelper.loadSingle(referBillId, "ec_outcontractmeasure");//支出合同计量 + if (EcOutContractMeasure != null) { + DynamicObjectCollection ListModelEntryCollection = EcOutContractMeasure.getDynamicObjectCollection("listmodelentry");//模板分录 + for (DynamicObject ListModelEntry : ListModelEntryCollection) { + DynamicObjectCollection listEntryCollection = ListModelEntry.getDynamicObjectCollection("listentry");//清单分录 + for (DynamicObject listEntry : listEntryCollection) { + DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType); + newProcessAllocEntity.set("zcgj_pa_process", listEntry.get("listcbs"));//工序-成本分解结构 + newProcessAllocEntity.set("zcgj_pa_amount", listEntry.get("thisoftaxmount"));//价税合计-本期计量含税金额 + newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额 + newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率(%)-税率(%) + newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额 + newProcessAllocEntity.set("zcgj_pa_remark", listEntry.get("desc"));//费用说明-说明 + processAllocEntityCollection.add(newProcessAllocEntity); + } + } + } + } + this.getView().updateView("zcgj_processallocatentity");//工序分摊 + } else { + DynamicObjectCollection processAllocEntityCollection = itemEntryCollection.get(0).getDynamicObjectCollection("zcgj_processallocatentity");//工序分摊分录 + processAllocEntityCollection.clear(); + this.getView().updateView("itementry");//支付项分录 + this.getView().updateView("zcgj_processallocatentity");//工序分摊分录 + } + } + } + + @Override + public void afterAddRow(AfterAddRowEventArgs e) { + super.afterAddRow(e); +// RowDataEntity[] rowDataEntities = e.getRowDataEntities(); +// System.out.println(); + } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); +// if ("totalsettleoftaxamount".equals(name)) { +// //关联单据 +// System.out.println(); +// } + } +}