From 3d242fe7261d40d7309669dd842e0a5cc409c5e6 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Sun, 28 Sep 2025 14:52:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E6=88=90=E6=9C=AC=E6=A0=B8?= =?UTF-8?q?=E7=AE=97=E8=A1=A8=E5=8D=95=E6=8F=92=E4=BB=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E9=80=BB=E8=BE=91=E5=92=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AD=90=E5=88=86=E5=BD=95=E8=B5=8B=E5=80=BC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/form/EntCostSplitBillPlugin.java | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/EntCostSplitBillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/EntCostSplitBillPlugin.java index 2b7547a..8429e69 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/EntCostSplitBillPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/EntCostSplitBillPlugin.java @@ -4,6 +4,7 @@ import kd.bos.bill.AbstractBillPlugIn; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType; +import kd.bos.dataentity.resource.ResManager; import kd.bos.form.events.BeforeDoOperationEventArgs; import kd.bos.form.operate.FormOperate; import kd.bos.orm.query.QCP; @@ -51,38 +52,40 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn { filter.and(new QFilter("zcgj_isnew", QCP.equals, true));//是否最新 DynamicObjectCollection rptAssistBalanceGxCollection = QueryServiceHelper.query("zcgj_rpt_assistbalancegx", "id,zcgj_account,zcgj_processname", - new QFilter[]{filter});//核算维度余额取数表(矿山工序维度) + new QFilter[]{filter});//"核算维度余额取数表(矿山工序维度)" for (DynamicObject rptAssistBalanceGx : rptAssistBalanceGxCollection) { QFilter[] qFilter = new QFilter[]{new QFilter("id", QCP.equals, rptAssistBalanceGx.get("zcgj_account"))}; DynamicObject bd_accountview = BusinessDataServiceHelper.loadSingle("bd_accountview", - "id,number,name", qFilter);//会计科目 + "id,number,name", qFilter);//"会计科目" if (bd_accountview == null) { continue; } - QFilter filter1 = new QFilter("zcgj_acccostentry.zcgj_accountname", QCP.equals, bd_accountview.getString("name"));//科目名称 - filter1.and(new QFilter("zcgj_acccostentry.zcgj_accountnumber", QCP.equals, bd_accountview.getString("number")));//科目编码 -// filter1.and(new QFilter("zcgj_org", QCP.equals, org1.getPkValue()));//组织 + QFilter filter1 = new QFilter("zcgj_acccostentry.zcgj_accountnumber", QCP.equals, bd_accountview.getString("number"));//科目编码 DynamicObject zcgj_accountcost = QueryServiceHelper.queryOne("zcgj_accountcost", "id,zcgj_acccostentry.zcgj_costtype,zcgj_acccostentry.zcgj_sectype", - new QFilter[]{filter1});//会计科目与成本项目 + new QFilter[]{filter1});//"会计科目与成本项目" QFilter[] qFilters = new QFilter[]{new QFilter("name", QCP.equals, rptAssistBalanceGx.get("zcgj_processname"))};//工序名称 - DynamicObject ec_ecbd_pro_cbs = BusinessDataServiceHelper.loadSingle("ec_ecbd_pro_cbs", "id", qFilters);//项目工序 + DynamicObject ec_ecbd_pro_cbs = BusinessDataServiceHelper.loadSingle("ec_ecbd_pro_cbs", "id", qFilters);//"项目工序" QFilter filter2 = new QFilter("fiaccountorg", QCP.equals, org1.getPkValue());//财务记账组织 filter2.and(new QFilter("billstatus", QCP.equals, "C"));//单据状态 - DynamicObject[] ec_projects = BusinessDataServiceHelper.load("ec_project", "id,zcgj_init", new QFilter[]{filter2});// 项目 + DynamicObject[] ec_projects = BusinessDataServiceHelper.load("ec_project", "id,zcgj_init", new QFilter[]{filter2});// "项目" if (ec_ecbd_pro_cbs == null && zcgj_accountcost == null && ec_projects.length == 0) { continue; } DynamicObject newEntry = new DynamicObject(entryType); + DynamicObjectCollection subEntryEntityCollection = newEntry.getDynamicObjectCollection("zcgj_subentryentity");//成本核算维度明细 + DynamicObjectType subEntryEntityType = subEntryEntityCollection.getDynamicObjectType(); + DynamicObject newEntrySubEntryEntity = new DynamicObject(subEntryEntityType); if (ec_projects.length != 0) { for (DynamicObject ec_project : ec_projects) { boolean zcgj_init = ec_project.getBoolean("zcgj_init");//默认项目 if (zcgj_init) { DynamicObject ec_project_f7 = BusinessDataServiceHelper.loadSingle("ec_project_f7", "id", new QFilter[]{new QFilter("id", QCP.equals, ec_project.getPkValue())});//项目 - newEntry.set("project", ec_project_f7);//项目 + newEntry.set("project", ec_project_f7);//"项目" + newEntrySubEntryEntity.set("zcgj_project", ec_project_f7); break; } } @@ -91,19 +94,42 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn { DynamicObject ec_project_f7 = BusinessDataServiceHelper.loadSingle("ec_project_f7", "id", new QFilter[]{new QFilter("id", QCP.equals, ec_projects[0].getPkValue())});//项目 newEntry.set("project", ec_project_f7);//项目 + newEntrySubEntryEntity.set("zcgj_project", ec_project_f7); } } if (ec_ecbd_pro_cbs != null) { newEntry.set("cbs", ec_ecbd_pro_cbs);//成本分解结构 + newEntrySubEntryEntity.set("zcgj_cbs", ec_ecbd_pro_cbs); } if (zcgj_accountcost != null) { newEntry.set("costtype", zcgj_accountcost.get("zcgj_acccostentry.zcgj_costtype"));//成本项 newEntry.set("zcgj_sectype", zcgj_accountcost.get("zcgj_acccostentry.zcgj_sectype"));//二级分类 + newEntrySubEntryEntity.set("zcgj_costtype", zcgj_accountcost.get("zcgj_acccostentry.zcgj_costtype")); + newEntrySubEntryEntity.set("zcgj_sectype1", zcgj_accountcost.get("zcgj_acccostentry.zcgj_sectype")); } entryCollection.add(newEntry); + subEntryEntityCollection.add(newEntrySubEntryEntity); } this.getView().updateView("entryentity");//刷新分录 + this.getView().updateView("zcgj_subentryentity");//刷新分录 this.getModel().endInit(); + this.getView().invokeOperation("save"); + this.getView().invokeOperation("refresh"); + } else if ("newentry1".equals(formOperate.getOperateKey())) { + //成本核算维度明细子分录增行按钮 + int rowIndex = this.getModel().getEntryCurrentRowIndex("entryentity");//企业费用成本分摊明细分录行索引 + int rowCount = this.getModel().getEntryRowCount("entryentity");//企业费用成本分摊明细分录总行数 + if (rowCount > 0 && rowIndex >= 0) { + int subInd = this.getModel().createNewEntryRow("zcgj_subentryentity");//新增子分录行数 + this.getModel().setValue("zcgj_project", this.getModel().getValue("project", rowIndex), subInd); + this.getModel().setValue("zcgj_cbs", this.getModel().getValue("cbs", rowIndex), subInd); + this.getModel().setValue("zcgj_costtype", this.getModel().getValue("costtype", rowIndex), subInd); + this.getModel().setValue("zcgj_sectype1", this.getModel().getValue("zcgj_sectype", rowIndex), subInd); + args.setCancel(true); + } else { + this.getView().showTipNotification(ResManager.loadKDString("请先选中1行企业费用成本分摊明细分录行数据", "MaterialCostBillPlugin_1", "ec-ecco-formplugin", new Object[0])); + args.setCancel(true); + } } } }