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 e60d992..2b7547a 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 @@ -38,6 +38,7 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn { this.getView().showTipNotification("请选择期间"); return; } + this.getModel().beginInit(); DynamicObject org1 = (DynamicObject) org;//所属组织 DynamicObject period1 = (DynamicObject) period;//期间 DynamicObjectCollection entryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("entryentity");//企业费用成本分摊明细分录 @@ -67,16 +68,33 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn { 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);//项目工序 + 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});// 项目 - if (ec_ecbd_pro_cbs == null && zcgj_accountcost == null) { + if (ec_ecbd_pro_cbs == null && zcgj_accountcost == null && ec_projects.length == 0) { continue; } DynamicObject newEntry = new DynamicObject(entryType); -// QFilter[] qFilters1 = new QFilter[]{new QFilter("number", QCP.equals, "10000000-XM014")}; -// DynamicObject ec_project_f7 = BusinessDataServiceHelper.loadSingle("ec_project_f7", "id", qFilters1); -// newEntry.set("project", ec_project_f7); + 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);//项目 + break; + } + } + Object project = newEntry.get("project"); + if (project == null) { + 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);//项目 + } + } if (ec_ecbd_pro_cbs != null) { - newEntry.set("cbs", ec_ecbd_pro_cbs.getPkValue());//成本分解结构 + newEntry.set("cbs", ec_ecbd_pro_cbs);//成本分解结构 } if (zcgj_accountcost != null) { newEntry.set("costtype", zcgj_accountcost.get("zcgj_acccostentry.zcgj_costtype"));//成本项 @@ -85,6 +103,7 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn { entryCollection.add(newEntry); } this.getView().updateView("entryentity");//刷新分录 + this.getModel().endInit(); } } }