From 93cfdf1fad68ce025ac69ebd749f8f618a2e9d46 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Mon, 8 Dec 2025 15:53:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/CbsDynamicCostFormPluginExt.java | 1340 +++++++++++++++++ 1 file changed, 1340 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CbsDynamicCostFormPluginExt.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CbsDynamicCostFormPluginExt.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CbsDynamicCostFormPluginExt.java new file mode 100644 index 0000000..5c79935 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CbsDynamicCostFormPluginExt.java @@ -0,0 +1,1340 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package zcgj.zcdev.zcdev.pr.plugin.form; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import kd.bos.bill.BillShowParameter; +import kd.bos.context.RequestContext; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.resource.ResManager; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.entity.report.CellStyle; +import kd.bos.form.CloseCallBack; +import kd.bos.form.FormShowParameter; +import kd.bos.form.ShowType; +import kd.bos.form.StyleCss; +import kd.bos.form.control.EntryGrid; +import kd.bos.form.events.AfterDoOperationEventArgs; +import kd.bos.form.events.ClosedCallBackEvent; +import kd.bos.form.events.HyperLinkClickEvent; +import kd.bos.form.events.HyperLinkClickListener; +import kd.bos.form.field.BasedataEdit; +import kd.bos.form.field.MulBasedataEdit; +import kd.bos.form.field.events.BeforeF7SelectEvent; +import kd.bos.form.field.events.BeforeF7SelectListener; +import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.orm.ORM; +import kd.bos.orm.query.QFilter; +import kd.bos.permission.api.HasPermOrgResult; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.ec.basedata.common.enums.BillStatusEnum; +import kd.ec.basedata.common.enums.PayDirectionEnum; +import kd.ec.basedata.common.enums.ReferBillTypeEnum; +import kd.ec.basedata.common.permission.ProjectPermissionHelper; +import kd.ec.basedata.common.utils.OpenPageUtils; +import kd.ec.contract.common.enums.DirectionEnum; +import kd.ec.contract.common.utils.CurrencyFormatUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.jetbrains.annotations.NotNull; + +public class CbsDynamicCostFormPluginExt extends AbstractFormPlugin implements BeforeF7SelectListener, HyperLinkClickListener { + public static final String QUERY_PROJECT = "queryProject"; + public static final String CBS_CACHE = "cbsCache"; + public static final String QUERY_CBS_CACHE = "queryCbsCache"; + + public CbsDynamicCostFormPluginExt() { + } + + public void registerListener(EventObject e) { + super.registerListener(e); + BasedataEdit project = (BasedataEdit) this.getControl("project"); + project.addBeforeF7SelectListener(this); + MulBasedataEdit unitProject = (MulBasedataEdit) this.getControl("queryunitproject"); + unitProject.addBeforeF7SelectListener(this); + MulBasedataEdit cbs = (MulBasedataEdit) this.getControl("querycbs"); + cbs.addBeforeF7SelectListener(this); + EntryGrid grid = (EntryGrid) this.getControl("treeentryentity"); + grid.addHyperClickListener(this); + } + + public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) { + String name = beforeF7SelectEvent.getProperty().getName(); + if (StringUtils.equals(name, "project")) { + this.beforeProjectSelect(beforeF7SelectEvent); + } else if (StringUtils.equals(name, "queryunitproject")) { + this.beforeUnitProjectSelect(beforeF7SelectEvent); + } else if (StringUtils.equals(name, "querycbs")) { + this.beforeCbsSelect(beforeF7SelectEvent); + } + + } + + protected void beforeCbsSelect(BeforeF7SelectEvent beforeF7SelectEvent) { + beforeF7SelectEvent.setCancel(true); + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); + DynamicObjectCollection unitProjects = (DynamicObjectCollection) this.getModel().getValue("queryunitproject"); + if (project == null) { + this.getView().showTipNotification(ResManager.loadKDString("请先选择项目。", "CbsDynamicCostFormPlugin_0", "ec-ecco-formplugin", new Object[0])); + } else { + FormShowParameter formShowParameter = new FormShowParameter(); + formShowParameter.setFormId("ecco_cbsrange"); + formShowParameter.setCustomParam("projectId", project.getPkValue()); + Set unitProjectIds = new HashSet(unitProjects.size()); + unitProjects.forEach((o) -> { + unitProjectIds.add(o.getDynamicObject("fbasedataid").getPkValue()); + }); + formShowParameter.setCustomParam("unitProjectIds", unitProjectIds); + String cbsCache = this.getPageCache().get("queryCbsCache"); + if (cbsCache != null) { + formShowParameter.setCustomParam("selectedCbs", cbsCache); + } + + formShowParameter.getOpenStyle().setShowType(ShowType.Modal); + StyleCss css = new StyleCss(); + css.setHeight("680px"); + css.setWidth("1300px"); + formShowParameter.getOpenStyle().setInlineStyleCss(css); + formShowParameter.setCloseCallBack(new CloseCallBack(this, "queryCbs")); + this.getView().showForm(formShowParameter); + } + } + + protected void beforeUnitProjectSelect(BeforeF7SelectEvent beforeF7SelectEvent) { + DynamicObject org = (DynamicObject) this.getModel().getValue("org"); + if (org == null) { + this.getView().showTipNotification(ResManager.loadKDString("请先选择组织。", "CbsDynamicCostFormPlugin_1", "ec-ecco-formplugin", new Object[0])); + beforeF7SelectEvent.setCancel(true); + } else { + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); + if (project == null) { + this.getView().showTipNotification(ResManager.loadKDString("请先选择项目。", "CbsDynamicCostFormPlugin_0", "ec-ecco-formplugin", new Object[0])); + beforeF7SelectEvent.setCancel(true); + } else { + beforeF7SelectEvent.getCustomQFilters().add(this.getUnitProjectFilter()); + } + } + } + + protected QFilter getUnitProjectFilter() { + DynamicObject org = (DynamicObject) this.getModel().getValue("org"); + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); + if (org != null && project != null) { + QFilter filter = new QFilter("parent", "=", project.getPkValue()); + DynamicObject projectOrg = project.getDynamicObject("projectorg"); + String appId = this.getView().getFormShowParameter().getAppId(); + String formId = this.getView().getFormShowParameter().getFormId(); + HasPermOrgResult allPermOrg = ProjectPermissionHelper.getAllPermOrg(RequestContext.get().getCurrUserId(), appId, formId); + if (allPermOrg.hasAllOrgPerm()) { + return filter; + } else if (CollectionUtils.isNotEmpty(allPermOrg.getHasPermOrgs()) && allPermOrg.getHasPermOrgs().contains((Long) projectOrg.getPkValue())) { + return filter; + } else { + QFilter responsibleOrgFilter = new QFilter("responsibleorg", "=", projectOrg.getPkValue()); + return filter.and(responsibleOrgFilter); + } + } else { + return new QFilter("id", "=", 0L); + } + } + + protected void beforeProjectSelect(BeforeF7SelectEvent beforeF7SelectEvent) { + DynamicObject org = (DynamicObject) this.getModel().getValue("org"); + if (org != null) { + beforeF7SelectEvent.getCustomQFilters().add(new QFilter("projectorg", "=", org.getPkValue())); + } + + } + + public void propertyChanged(PropertyChangedArgs e) { + String name = e.getProperty().getName(); + ChangeData changeData = e.getChangeSet()[0]; + switch (name) { + case "org": + this.orgChanged(); + break; + case "project": + this.projectChanged(changeData); + break; + case "queryunitproject": + this.getPageCache().remove("cbsCache"); + this.getPageCache().remove("queryCbsCache"); + } + + } + + protected void projectChanged(ChangeData changeData) { + this.getPageCache().remove("cbsCache"); + this.getPageCache().remove("queryCbsCache"); + DynamicObject project = (DynamicObject) changeData.getNewValue(); + if (project == null) { + this.getModel().setValue("queryunitproject", (Object) null); + this.getModel().setValue("querycbs", (Object) null); + } else { + if (project.getBoolean("editonunit")) { + QFilter filter = this.getUnitProjectFilter(); + Map unitProjects = BusinessDataServiceHelper.loadFromCache("ec_ecbd_unitproject", new QFilter[]{filter}); + if (unitProjects != null && !unitProjects.isEmpty()) { + this.getModel().setValue("queryunitproject", unitProjects.keySet().toArray(new Object[0])); + } else { + this.getModel().setValue("queryunitproject", (Object) null); + } + } else { + this.getModel().setValue("queryunitproject", (Object) null); + } + + this.carryAllCbs(); + } + } + + protected void carryAllCbs() { + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); + if (project != null) { + QFilter filter = new QFilter("project", "=", project.getPkValue()); + filter.and("enable", "=", "1"); + Map proCbsMap = BusinessDataServiceHelper.loadFromCache("ec_ecbd_pro_cbs", "id", new QFilter[]{filter}, "number"); + if (proCbsMap != null && !proCbsMap.isEmpty()) { + this.getModel().setValue("querycbs", proCbsMap.keySet().toArray(new Object[0])); + } else { + this.getModel().setValue("querycbs", (Object) null); + } + } else { + this.getModel().setValue("querycbs", (Object) null); + } + + } + + protected void orgChanged() { + this.getModel().setValue("project", (Object) null); + this.getPageCache().remove("cbsCache"); + this.getPageCache().remove("queryCbsCache"); + this.getModel().setValue("queryunitproject", (Object) null); + this.getModel().setValue("querycbs", (Object) null); + } + + public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) { + super.closedCallBack(closedCallBackEvent); + String actionId = closedCallBackEvent.getActionId(); + if (StringUtils.equals(actionId, "queryCbs")) { + this.cbsCloseCallBack((List) closedCallBackEvent.getReturnData()); + } + + } + + protected void cbsCloseCallBack(List returnData) { + if (returnData != null && !returnData.isEmpty()) { + JSONArray cbsCache = new JSONArray(); + Set cbsIds = new HashSet(16); + Iterator var4 = returnData.iterator(); + + while (var4.hasNext()) { + DynamicObject data = (DynamicObject) var4.next(); + JSONObject cbsObject = new JSONObject(); + DynamicObject cbs = data.getDynamicObject("cbs"); + cbsObject.put("cbs", cbs == null ? "0" : cbs.getPkValue().toString()); + if (cbs != null) { + cbsIds.add(cbs.getLong("id")); + } + + DynamicObject unitProject = data.getDynamicObject("unitproject"); + cbsObject.put("unitProject", unitProject == null ? "0" : unitProject.getPkValue().toString()); + cbsCache.add(cbsObject); + } + + this.getPageCache().put("queryCbsCache", cbsCache.toJSONString()); + this.getModel().setValue("querycbs", cbsIds.toArray(new Object[0])); + } + } + + public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) { + super.afterDoOperation(afterDoOperationEventArgs); + String operateKey = afterDoOperationEventArgs.getOperateKey(); + if (!StringUtils.equals(operateKey, "view") && !StringUtils.equals(operateKey, "dorefresh")) { + if (StringUtils.equals(operateKey, "projectkanbanview")) { + this.projectKanbanView(); + } + } else { + this.query(); + } + + } + + protected void projectKanbanView() { + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); + if (project == null) { + this.getView().showTipNotification(ResManager.loadKDString("请先选择项目。", "CbsDynamicCostFormPlugin_0", "ec-ecco-formplugin", new Object[0])); + } else { + Map map = new HashMap(); + map.put("project", project.getPkValue()); + map.put("formId", "ec_project_board"); + FormShowParameter parameter = FormShowParameter.createFormShowParameter(map); + parameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); + this.getView().showForm(parameter); + } + } + + protected void query() { + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); + if (project == null) { + this.getView().showTipNotification(ResManager.loadKDString("请先选择项目。", "CbsDynamicCostFormPlugin_0", "ec-ecco-formplugin", new Object[0])); + } else { + JSONArray unitProjectCbsArray = this.getCbsCache(); + JSONArray queryCbsArray = this.getQueryCbsCache(); + if (unitProjectCbsArray != null && queryCbsArray != null) { + this.getPageCache().put("queryProject", project.getPkValue().toString()); + DynamicObject currency = project.getDynamicObject("currency"); + this.getModel().setValue("currency", currency == null ? 1L : currency.getPkValue()); + currency = (DynamicObject) this.getModel().getValue("currency"); + Set cbsIds = new HashSet(16); + unitProjectCbsArray.forEach((ox) -> { + cbsIds.add(Long.valueOf(((JSONObject) ox).getString("cbs"))); + }); + Map cbsMap = BusinessDataServiceHelper.loadFromCache("ec_ecbd_pro_cbs", new QFilter[]{new QFilter("id", "in", cbsIds)}); + Set unitProjectIds = new HashSet(16); + unitProjectCbsArray.forEach((ox) -> { + String unitProjectId = ((JSONObject) ox).getString("unitProject"); + if (unitProjectId != null && !StringUtils.equals(unitProjectId, "0")) { + unitProjectIds.add(Long.valueOf(unitProjectId)); + } + + }); + Map unitProjectMap = BusinessDataServiceHelper.loadFromCache("ec_ecbd_unitproject", new QFilter[]{new QFilter("id", "in", unitProjectIds)}); + Set queryCbsKeySet = new HashSet(queryCbsArray.size()); + queryCbsArray.forEach((ox) -> { + JSONObject object = (JSONObject) ox; + queryCbsKeySet.add(this.concatKey(object.getString("cbs"), object.getString("unitProject"))); + }); + DynamicObjectCollection treeEntries = this.getModel().getEntryEntity("treeentryentity"); + treeEntries.clear(); + Map> subJsonObject = new HashMap(16); + List firstLevelJsonObject = new ArrayList(10); + Iterator var13 = unitProjectCbsArray.iterator(); + + while (var13.hasNext()) { + Object o = var13.next(); + JSONObject jsonObject = (JSONObject) o; + String cbsStr = jsonObject.getString("cbs"); + String unitProjectStr = jsonObject.getString("unitProject"); + if (!StringUtils.equals(cbsStr, "0")) { + DynamicObject cbsObject = (DynamicObject) cbsMap.get(Long.valueOf(cbsStr)); + DynamicObject parent = cbsObject.getDynamicObject("parent"); + if (parent != null) { + String parentKey = this.concatKey(parent.getString("id"), unitProjectStr); + List sameParentList = (List) subJsonObject.getOrDefault(parentKey, new ArrayList(10)); + sameParentList.add(jsonObject); + subJsonObject.put(parentKey, sameParentList); + } else { + firstLevelJsonObject.add(jsonObject); + } + } + } + + this.fillTreeList(treeEntries, firstLevelJsonObject, 0L, subJsonObject, cbsMap, unitProjectMap); + Map aimCostMap = new HashMap(16); + this.queryAimCost(project, unitProjectIds, aimCostMap); + Map confirmCostMap = new HashMap(16); + Map notSplitCostMap = new HashMap(16); + Map notConfirmCostMap = new HashMap(16); + this.queryCostData(project, confirmCostMap, notSplitCostMap, notConfirmCostMap); + BigDecimal totalAimCostAmount = BigDecimal.ZERO; + + BigDecimal totalAimCost; + for (Iterator var46 = aimCostMap.values().iterator(); var46.hasNext(); totalAimCostAmount = totalAimCostAmount.add(totalAimCost)) { + totalAimCost = (BigDecimal) var46.next(); + } + + BigDecimal remainingAmount = this.queryRemainingAmount(project, totalAimCostAmount, currency.getInt("amtprecision")); + totalAimCost = BigDecimal.ZERO; + int splitCbsCount = 0; + Iterator var50 = treeEntries.iterator(); + + DynamicObject treeEntry; + while (var50.hasNext()) { + treeEntry = (DynamicObject) var50.next(); + DynamicObject cbsObj = treeEntry.getDynamicObject("cbs"); + DynamicObject unitProj = treeEntry.getDynamicObject("unitproject"); + String key = this.concatKey(cbsObj.getString("id"), unitProj == null ? "0" : unitProj.getString("id")); + if (cbsObj.getBoolean("isleaf") && queryCbsKeySet.contains(key)) { + totalAimCost = totalAimCost.add((BigDecimal) aimCostMap.getOrDefault(key, BigDecimal.ZERO)); + ++splitCbsCount; + } + } + + BigDecimal avgSplitAmount = splitCbsCount == 0 ? BigDecimal.ZERO : remainingAmount.divide(new BigDecimal(splitCbsCount), currency.getInt("amtprecision"), 4); + BigDecimal totalSplitRemainingAmount = BigDecimal.ZERO; + Iterator var53 = treeEntries.iterator(); + + BigDecimal aimCost; + BigDecimal dynamicCost; + BigDecimal periodExceed; + while (var53.hasNext()) { + treeEntry = (DynamicObject) var53.next(); + DynamicObject cbsObj = treeEntry.getDynamicObject("cbs"); + DynamicObject unitProj = treeEntry.getDynamicObject("unitproject"); + String key = this.concatKey(cbsObj.getString("id"), unitProj == null ? "0" : unitProj.getString("id")); + if (cbsObj.getBoolean("isleaf")) { + BigDecimal aimCostVal = (BigDecimal) aimCostMap.getOrDefault(key, BigDecimal.ZERO); + treeEntry.set("aimcost", aimCostVal); + BigDecimal confirmCost = (BigDecimal) confirmCostMap.getOrDefault(key, BigDecimal.ZERO); + treeEntry.set("confirmcost", confirmCost); + BigDecimal notSplitCost = (BigDecimal) notSplitCostMap.getOrDefault(key, BigDecimal.ZERO); + treeEntry.set("notsplitcost", notSplitCost); + BigDecimal notConfirmCost = (BigDecimal) notConfirmCostMap.getOrDefault(key, BigDecimal.ZERO); + treeEntry.set("notconfirmcost", notConfirmCost); + BigDecimal residualCost = BigDecimal.ZERO; + if (queryCbsKeySet.contains(key)) { + residualCost = totalAimCost.compareTo(BigDecimal.ZERO) != 0 ? remainingAmount.multiply(aimCostVal).divide(totalAimCost, currency.getInt("amtprecision"), 4) : avgSplitAmount; + totalSplitRemainingAmount = totalSplitRemainingAmount.add(residualCost); + --splitCbsCount; + if (splitCbsCount == 0 && totalSplitRemainingAmount.compareTo(remainingAmount) != 0) { + residualCost = residualCost.add(remainingAmount).subtract(totalSplitRemainingAmount); + } + } + + treeEntry.set("residualcost", residualCost); + aimCost = confirmCost.add(notSplitCost).add(notConfirmCost); + treeEntry.set("totalcost", aimCost); + if (aimCost.compareTo(BigDecimal.ZERO) != 0) { + treeEntry.set("totalcostrate", aimCost.divide(aimCost, 4, 4)); + } + + dynamicCost = aimCost.add(residualCost); + treeEntry.set("dynamiccost", dynamicCost); + periodExceed = aimCost.subtract(dynamicCost); + treeEntry.set("periodexceed", periodExceed); + if (aimCost.compareTo(BigDecimal.ZERO) != 0) { + treeEntry.set("periodexceedrate", periodExceed.divide(aimCost, 4, 4)); + } + } + } + + Map parentAimCostMap = new HashMap(16); + Map parentConfirmCostMap = new HashMap(16); + Map parentNotSplitCostMap = new HashMap(16); + Map parentNotConfirmCostMap = new HashMap(16); + Map parentResidualCostMap = new HashMap(16); + + for (int i = treeEntries.size() - 1; i >= 0; --i) { + DynamicObject treeEntryItem = (DynamicObject) treeEntries.get(i); + DynamicObject cbsObj = treeEntryItem.getDynamicObject("cbs"); + DynamicObject unitProj = treeEntryItem.getDynamicObject("unitproject"); + String key = this.concatKey(cbsObj.getString("id"), unitProj == null ? "0" : unitProj.getString("id")); + if (!cbsObj.getBoolean("isleaf")) { + BigDecimal aimCostVal = (BigDecimal) parentAimCostMap.getOrDefault(key, BigDecimal.ZERO); + treeEntryItem.set("aimcost", aimCostVal); + BigDecimal confirmCostVal = (BigDecimal) parentConfirmCostMap.getOrDefault(key, BigDecimal.ZERO); + treeEntryItem.set("confirmcost", confirmCostVal); + BigDecimal notSplitCostVal = (BigDecimal) parentNotSplitCostMap.getOrDefault(key, BigDecimal.ZERO); + treeEntryItem.set("notsplitcost", notSplitCostVal); + BigDecimal notConfirmCostVal = (BigDecimal) parentNotConfirmCostMap.getOrDefault(key, BigDecimal.ZERO); + treeEntryItem.set("notconfirmcost", notConfirmCostVal); + BigDecimal totalCost = confirmCostVal.add(notSplitCostVal).add(notConfirmCostVal); + treeEntryItem.set("totalcost", totalCost); + if (aimCostVal.compareTo(BigDecimal.ZERO) != 0) { + treeEntryItem.set("totalcostrate", totalCost.divide(aimCostVal, 4, 4)); + } + + BigDecimal residualCost = (BigDecimal) parentResidualCostMap.getOrDefault(key, BigDecimal.ZERO); + treeEntryItem.set("residualcost", residualCost); + BigDecimal dynamicCostVal = totalCost.add(residualCost); + treeEntryItem.set("dynamiccost", dynamicCostVal); + BigDecimal periodExceedVal = aimCostVal.subtract(dynamicCostVal); + treeEntryItem.set("periodexceed", periodExceedVal); + if (aimCostVal.compareTo(BigDecimal.ZERO) != 0) { + treeEntryItem.set("periodexceedrate", periodExceedVal.divide(aimCostVal, 4, 4)); + } + } + + DynamicObject parent = cbsObj.getDynamicObject("parent"); + if (parent != null) { + String parentKey = this.concatKey(parent.getString("id"), unitProj == null ? "0" : unitProj.getString("id")); + parentAimCostMap.merge(parentKey, treeEntryItem.getBigDecimal("aimcost"), BigDecimal::add); + parentConfirmCostMap.merge(parentKey, treeEntryItem.getBigDecimal("confirmcost"), BigDecimal::add); + parentNotSplitCostMap.merge(parentKey, treeEntryItem.getBigDecimal("notsplitcost"), BigDecimal::add); + parentNotConfirmCostMap.merge(parentKey, treeEntryItem.getBigDecimal("notconfirmcost"), BigDecimal::add); + parentResidualCostMap.merge(parentKey, treeEntryItem.getBigDecimal("residualcost"), BigDecimal::add); + } + } + + this.getModel().updateEntryCache(treeEntries); + this.getView().updateView("treeentryentity"); + this.setCellStyle(); + this.setGridSum(); + } else { + this.getView().showTipNotification(ResManager.loadKDString("请选择“待发生成本计算范围”。", "CbsDynamicCostFormPlugin_2", "ec-ecco-formplugin", new Object[0])); + } + } + } + + protected void setGridSum() { + EntryGrid grid = (EntryGrid) this.getView().getControl("treeentryentity"); + int rowCount = this.getModel().getEntryRowCount("treeentryentity"); + BigDecimal totalAimCost = BigDecimal.ZERO; + BigDecimal totalDynamicCost = BigDecimal.ZERO; + BigDecimal totalPeriodExceed = BigDecimal.ZERO; + BigDecimal totalCost = BigDecimal.ZERO; + BigDecimal totalConfirmCost = BigDecimal.ZERO; + BigDecimal totalNotSplitCost = BigDecimal.ZERO; + BigDecimal totalNotConfirmCost = BigDecimal.ZERO; + BigDecimal totalResidualCost = BigDecimal.ZERO; + + for (int i = 0; i < rowCount; ++i) { + DynamicObject rowEntity = this.getModel().getEntryRowEntity("treeentryentity", i); + DynamicObject cbs = rowEntity.getDynamicObject("cbs"); + if (cbs != null && cbs.getBoolean("isleaf")) { + totalAimCost = totalAimCost.add(rowEntity.getBigDecimal("aimcost")); + totalDynamicCost = totalDynamicCost.add(rowEntity.getBigDecimal("dynamiccost")); + totalPeriodExceed = totalPeriodExceed.add(rowEntity.getBigDecimal("periodexceed")); + totalCost = totalCost.add(rowEntity.getBigDecimal("totalcost")); + totalConfirmCost = totalConfirmCost.add(rowEntity.getBigDecimal("confirmcost")); + totalNotSplitCost = totalNotSplitCost.add(rowEntity.getBigDecimal("notsplitcost")); + totalNotConfirmCost = totalNotConfirmCost.add(rowEntity.getBigDecimal("notconfirmcost")); + totalResidualCost = totalResidualCost.add(rowEntity.getBigDecimal("residualcost")); + } + } + + BigDecimal periodExceedRate = BigDecimal.ZERO; + BigDecimal totalCostRate = BigDecimal.ZERO; + if (totalAimCost.compareTo(BigDecimal.ZERO) != 0) { + periodExceedRate = totalPeriodExceed.divide(totalAimCost, 4, 4).multiply(new BigDecimal(100)).setScale(2, 4); + totalCostRate = totalCost.divide(totalAimCost, 4, 4).multiply(new BigDecimal(100)).setScale(2, 4); + } + + Map floatData = new HashMap(16); + DynamicObject currency = this.getModel().getDataEntity().getDynamicObject("currency"); + floatData.put("aimcost", totalAimCost.compareTo(BigDecimal.ZERO) == 0 ? "" : CurrencyFormatUtil.getAfterFormatString(currency, totalAimCost)); + floatData.put("dynamiccost", totalDynamicCost.compareTo(BigDecimal.ZERO) == 0 ? "" : CurrencyFormatUtil.getAfterFormatString(currency, totalDynamicCost)); + floatData.put("periodexceed", totalPeriodExceed.compareTo(BigDecimal.ZERO) == 0 ? "" : CurrencyFormatUtil.getAfterFormatString(currency, totalPeriodExceed)); + floatData.put("totalcost", totalCost.compareTo(BigDecimal.ZERO) == 0 ? "" : CurrencyFormatUtil.getAfterFormatString(currency, totalCost)); + floatData.put("confirmcost", totalConfirmCost.compareTo(BigDecimal.ZERO) == 0 ? "" : CurrencyFormatUtil.getAfterFormatString(currency, totalConfirmCost)); + floatData.put("notsplitcost", totalNotSplitCost.compareTo(BigDecimal.ZERO) == 0 ? "" : CurrencyFormatUtil.getAfterFormatString(currency, totalNotSplitCost)); + floatData.put("notconfirmcost", totalNotConfirmCost.compareTo(BigDecimal.ZERO) == 0 ? "" : CurrencyFormatUtil.getAfterFormatString(currency, totalNotConfirmCost)); + floatData.put("residualcost", totalResidualCost.compareTo(BigDecimal.ZERO) == 0 ? "" : CurrencyFormatUtil.getAfterFormatString(currency, totalResidualCost)); + floatData.put("periodexceedrate", periodExceedRate.compareTo(BigDecimal.ZERO) == 0 ? "" : periodExceedRate.toPlainString() + "%"); + floatData.put("totalcostrate", totalCostRate.compareTo(BigDecimal.ZERO) == 0 ? "" : totalCostRate.toPlainString() + "%"); + grid.setFloatButtomData(floatData); + } + + protected void setCellStyle() { + EntryGrid grid = (EntryGrid) this.getView().getControl("treeentryentity"); + int rowCount = this.getModel().getEntryRowCount("treeentryentity"); + List cellStyles = new ArrayList(); + + for (int i = 0; i < rowCount; ++i) { + BigDecimal periodExceed = (BigDecimal) this.getModel().getValue("periodexceed", i); + if (periodExceed.compareTo(BigDecimal.ZERO) < 0) { + cellStyles.add(this.genCellStyle("periodexceed", "#ff3300", i)); + } else if (periodExceed.compareTo(BigDecimal.ZERO) > 0) { + cellStyles.add(this.genCellStyle("periodexceed", "#00cc00", i)); + } + + BigDecimal periodExceedRate = (BigDecimal) this.getModel().getValue("periodexceedrate", i); + if (periodExceedRate.compareTo(BigDecimal.ZERO) < 0) { + cellStyles.add(this.genCellStyle("periodexceedrate", "#ff3300", i)); + } else if (periodExceedRate.compareTo(BigDecimal.ZERO) > 0) { + cellStyles.add(this.genCellStyle("periodexceedrate", "#00cc00", i)); + } + + BigDecimal totalCostRate = (BigDecimal) this.getModel().getValue("totalcostrate", i); + if (totalCostRate.compareTo(BigDecimal.ONE) > 0) { + cellStyles.add(this.genCellStyle("totalcostrate", "#ff3300", i)); + } else { + cellStyles.add(this.genCellStyle("totalcostrate", "#000000", i)); + } + } + + grid.setCellStyle(cellStyles); + } + + protected CellStyle genCellStyle(String fieldKey, String color, int rowIndex) { + CellStyle cellStyle = new CellStyle(); + cellStyle.setFieldKey(fieldKey); + cellStyle.setForeColor(color); + cellStyle.setRow(rowIndex); + return cellStyle; + } + + protected void fillTreeList(DynamicObjectCollection entries, List objArr, long pid, Map> subMap, Map cbsMap, Map unitProjectMap) { + if (objArr != null && objArr.size() != 0) { + ORM orm = ORM.create(); + long[] ids = orm.genLongIds(entries.getDynamicObjectType(), objArr.size()); + + for (int i = 0; i < objArr.size(); ++i) { + DynamicObject newEntry = new DynamicObject(entries.getDynamicObjectType()); + newEntry.set("id", ids[i]); + newEntry.set("pid", pid); + entries.add(newEntry); + JSONObject jsonObject = (JSONObject) objArr.get(i); + String cbs = jsonObject.getString("cbs"); + String unitProject = jsonObject.getString("unitProject"); + String key = this.concatKey(cbs, unitProject); + DynamicObject unitProjectObject; + if (!StringUtils.equals(cbs, "0")) { + unitProjectObject = (DynamicObject) cbsMap.get(Long.valueOf(cbs)); + newEntry.set("cbs", unitProjectObject); + } + + if (unitProject != null && !StringUtils.equals(unitProject, "0")) { + unitProjectObject = (DynamicObject) unitProjectMap.get(Long.valueOf(unitProject)); + newEntry.set("unitproject", unitProjectObject); + } + + List subCbs = (List) subMap.get(key); + if (subCbs != null && subCbs.size() > 0) { + this.fillTreeList(entries, subCbs, ids[i], subMap, cbsMap, unitProjectMap); + } + } + + } + } + + protected BigDecimal queryRemainingAmount(DynamicObject project, BigDecimal totalAimCostAmount, int precision) { + BigDecimal contractAmount = BigDecimal.ZERO; + QFilter contractFilter = new QFilter("project", "=", project.getPkValue()); + contractFilter.and("billstatus", "=", BillStatusEnum.AUDIT.getValue()); + contractFilter.and("paydirection", "=", PayDirectionEnum.IN.getValue()); + DynamicObjectCollection inContractBills = QueryServiceHelper.query("ec_in_contract", "totalamount", new QFilter[]{contractFilter}); + + DynamicObject inContractBill; + for (Iterator var7 = inContractBills.iterator(); var7.hasNext(); contractAmount = contractAmount.add(inContractBill.getBigDecimal("totalamount"))) { + inContractBill = (DynamicObject) var7.next(); + } + + BigDecimal remainingAmount = contractAmount; + QFilter settleFilter = new QFilter("project", "=", project.getPkValue()); + settleFilter.and("billstatus", "in", new String[]{BillStatusEnum.SUBMIT.getValue(), BillStatusEnum.AUDIT.getValue()}); + settleFilter.and("paydirection", "=", PayDirectionEnum.IN.getValue()); + DynamicObjectCollection inSettleBills = QueryServiceHelper.query("ec_in_contract_settle", "settleamount", new QFilter[]{settleFilter}); + + DynamicObject inSettleBill; + for (Iterator var10 = inSettleBills.iterator(); var10.hasNext(); remainingAmount = remainingAmount.subtract(inSettleBill.getBigDecimal("settleamount"))) { + inSettleBill = (DynamicObject) var10.next(); + } + + return contractAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : remainingAmount.multiply(totalAimCostAmount).divide(contractAmount, precision, 4); + } + + protected void queryCostData(DynamicObject project, Map confirmCostMap, Map notSplitCostMap, Map notConfirmCostMap) { + QFilter costFilter = new QFilter("project", "=", project.getPkValue()); + costFilter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()}); + DynamicObjectCollection contractCostBills = QueryServiceHelper.query("ecco_contractcost", "billstatus,entryentity.settleid,entryentity.splitbilltype,entryentity.subentryentity.unitproject,entryentity.subentryentity.procbs,entryentity.subentryentity.amount", new QFilter[]{costFilter}); + Set splitReferenceMeasureSet = new HashSet(16); + Set splitReferenceSettleSet = new HashSet(16); + Iterator var9 = contractCostBills.iterator(); + + long unitProjectId; + long cbsId; + String status; + BigDecimal noSplitCostAmount; + while (var9.hasNext()) { + DynamicObject contractCostBill = (DynamicObject) var9.next(); + String statusVal = contractCostBill.getString("billstatus"); + String type = contractCostBill.getString("entryentity.splitbilltype"); + long billId = contractCostBill.getLong("entryentity.settleid"); + if (StringUtils.equals(type, "settle")) { + splitReferenceSettleSet.add(billId); + } else if (StringUtils.equals(type, "measure")) { + splitReferenceMeasureSet.add(billId); + } + + unitProjectId = contractCostBill.getLong("entryentity.subentryentity.unitproject"); + cbsId = contractCostBill.getLong("entryentity.subentryentity.procbs"); + String key = this.concatKey(String.valueOf(cbsId), String.valueOf(unitProjectId)); + if (StringUtils.equals(statusVal, BillStatusEnum.AUDIT.getValue())) { + noSplitCostAmount = (BigDecimal) confirmCostMap.getOrDefault(key, BigDecimal.ZERO); + noSplitCostAmount = noSplitCostAmount.add(contractCostBill.getBigDecimal("entryentity.subentryentity.amount")); + confirmCostMap.put(key, noSplitCostAmount); + } else if (StringUtils.equals(statusVal, BillStatusEnum.SUBMIT.getValue())) { + noSplitCostAmount = (BigDecimal) notSplitCostMap.getOrDefault(key, BigDecimal.ZERO); + noSplitCostAmount = noSplitCostAmount.add(contractCostBill.getBigDecimal("entryentity.subentryentity.amount")); + notSplitCostMap.put(key, noSplitCostAmount); + } + } + + QFilter entCostFilter = new QFilter("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()}); + entCostFilter.and("entryentity.project", "=", project.getPkValue()); + DynamicObjectCollection entCostBills = QueryServiceHelper.query("ecco_entcostsplit", "billstatus,entryentity.unitproject,entryentity.cbs,entryentity.costamount", new QFilter[]{entCostFilter}); + Iterator var55 = entCostBills.iterator(); + + String statusVal; + while (var55.hasNext()) { + DynamicObject entCostBill = (DynamicObject) var55.next(); + String statusEnt = entCostBill.getString("billstatus"); + long unitProjectEnt = entCostBill.getLong("entryentity.unitproject"); + long cbsEnt = entCostBill.getLong("entryentity.cbs"); + String key = this.concatKey(String.valueOf(cbsEnt), String.valueOf(unitProjectEnt)); + BigDecimal noSplitCostAmountEnt; + if (StringUtils.equals(statusEnt, BillStatusEnum.AUDIT.getValue())) { + noSplitCostAmountEnt = (BigDecimal) confirmCostMap.getOrDefault(key, BigDecimal.ZERO); + noSplitCostAmountEnt = noSplitCostAmountEnt.add(entCostBill.getBigDecimal("entryentity.costamount")); + confirmCostMap.put(key, noSplitCostAmountEnt); + } else if (StringUtils.equals(statusEnt, BillStatusEnum.SUBMIT.getValue())) { + noSplitCostAmountEnt = (BigDecimal) notSplitCostMap.getOrDefault(key, BigDecimal.ZERO); + noSplitCostAmountEnt = noSplitCostAmountEnt.add(entCostBill.getBigDecimal("entryentity.costamount")); + notSplitCostMap.put(key, noSplitCostAmountEnt); + } + } + + DynamicObjectCollection projectCostBills = QueryServiceHelper.query("ecco_procostsplit", "billstatus,procostsplitentry.unitproject,procostsplitentry.procbs,procostsplitentry.costamt", new QFilter[]{costFilter}); + Iterator var58 = projectCostBills.iterator(); + + while (var58.hasNext()) { + DynamicObject projectCostBill = (DynamicObject) var58.next(); + String statusProj = projectCostBill.getString("billstatus"); + unitProjectId = projectCostBill.getLong("procostsplitentry.unitproject"); + cbsId = projectCostBill.getLong("procostsplitentry.procbs"); + String key = this.concatKey(String.valueOf(cbsId), String.valueOf(unitProjectId)); + if (StringUtils.equals(statusProj, BillStatusEnum.AUDIT.getValue())) { + noSplitCostAmount = (BigDecimal) confirmCostMap.getOrDefault(key, BigDecimal.ZERO); + noSplitCostAmount = noSplitCostAmount.add(projectCostBill.getBigDecimal("procostsplitentry.costamt")); + confirmCostMap.put(key, noSplitCostAmount); + } else if (StringUtils.equals(statusProj, BillStatusEnum.SUBMIT.getValue())) { + noSplitCostAmount = (BigDecimal) notSplitCostMap.getOrDefault(key, BigDecimal.ZERO); + noSplitCostAmount = noSplitCostAmount.add(projectCostBill.getBigDecimal("procostsplitentry.costamt")); + notSplitCostMap.put(key, noSplitCostAmount); + } + } + + DynamicObjectCollection mainMaterialCostBills = QueryServiceHelper.query("ecco_mainmatcost", "billstatus,entryentity.sourcetype,entryentity.entrybillno,entryentity.subentryentity.unitproject,entryentity.subentryentity.procbs,entryentity.subentryentity.amount", new QFilter[]{costFilter}); + Set splitReferenceInBillNoSet = new HashSet(16); + Set splitReferenceOutBillNoSet = new HashSet(16); + Iterator var65 = mainMaterialCostBills.iterator(); + + long unitProjectMat; + String keyMat; + BigDecimal noSplitCostAmountMat; + String billTypeMat; + while (var65.hasNext()) { + DynamicObject mainMaterialCostBill = (DynamicObject) var65.next(); + String statusMat = mainMaterialCostBill.getString("billstatus"); + billTypeMat = mainMaterialCostBill.getString("entryentity.sourcetype"); + String billNoMat = mainMaterialCostBill.getString("entryentity.entrybillno"); + if (StringUtils.equals(billTypeMat, "IN")) { + splitReferenceInBillNoSet.add(billNoMat); + } else if (StringUtils.equals(billTypeMat, "OUT")) { + splitReferenceOutBillNoSet.add(billNoMat); + } + + unitProjectMat = mainMaterialCostBill.getLong("entryentity.subentryentity.unitproject"); + long cbsMat = mainMaterialCostBill.getLong("entryentity.subentryentity.procbs"); + keyMat = this.concatKey(String.valueOf(cbsMat), String.valueOf(unitProjectMat)); + if (StringUtils.equals(statusMat, BillStatusEnum.AUDIT.getValue())) { + noSplitCostAmountMat = (BigDecimal) confirmCostMap.getOrDefault(keyMat, BigDecimal.ZERO); + noSplitCostAmountMat = noSplitCostAmountMat.add(mainMaterialCostBill.getBigDecimal("entryentity.subentryentity.amount")); + confirmCostMap.put(keyMat, noSplitCostAmountMat); + } else if (StringUtils.equals(statusMat, BillStatusEnum.SUBMIT.getValue())) { + noSplitCostAmountMat = (BigDecimal) notSplitCostMap.getOrDefault(keyMat, BigDecimal.ZERO); + noSplitCostAmountMat = noSplitCostAmountMat.add(mainMaterialCostBill.getBigDecimal("entryentity.subentryentity.amount")); + notSplitCostMap.put(keyMat, noSplitCostAmountMat); + } + } + + DynamicObjectCollection sporadicMaterialCostBills = QueryServiceHelper.query("ecco_sporadicmatcost", "billstatus,entryentity.sourcetype,entryentity.entrybillno,entryentity.subentryentity.unitproject,entryentity.subentryentity.procbs,entryentity.subentryentity.amount", new QFilter[]{costFilter}); + Iterator var68 = sporadicMaterialCostBills.iterator(); + + while (var68.hasNext()) { + DynamicObject sporadicMaterialCostBill = (DynamicObject) var68.next(); + statusVal = sporadicMaterialCostBill.getString("billstatus"); + String sourceType = sporadicMaterialCostBill.getString("entryentity.sourcetype"); + String billNo = sporadicMaterialCostBill.getString("entryentity.entrybillno"); + if (StringUtils.equals(sourceType, "IN")) { + splitReferenceInBillNoSet.add(billNo); + } else if (StringUtils.equals(sourceType, "OUT")) { + splitReferenceOutBillNoSet.add(billNo); + } + + long unitProjectSp = sporadicMaterialCostBill.getLong("entryentity.subentryentity.unitproject"); + long cbsSp = sporadicMaterialCostBill.getLong("entryentity.subentryentity.procbs"); + String keySp = this.concatKey(String.valueOf(cbsSp), String.valueOf(unitProjectSp)); + BigDecimal noSplitCostAmountSp; + if (StringUtils.equals(statusVal, BillStatusEnum.AUDIT.getValue())) { + noSplitCostAmountSp = (BigDecimal) confirmCostMap.getOrDefault(keySp, BigDecimal.ZERO); + noSplitCostAmountSp = noSplitCostAmountSp.add(sporadicMaterialCostBill.getBigDecimal("entryentity.subentryentity.amount")); + confirmCostMap.put(keySp, noSplitCostAmountSp); + } else if (StringUtils.equals(statusVal, BillStatusEnum.SUBMIT.getValue())) { + noSplitCostAmountSp = (BigDecimal) notSplitCostMap.getOrDefault(keySp, BigDecimal.ZERO); + noSplitCostAmountSp = noSplitCostAmountSp.add(sporadicMaterialCostBill.getBigDecimal("entryentity.subentryentity.amount")); + notSplitCostMap.put(keySp, noSplitCostAmountSp); + } + } + + DynamicObjectCollection costAdjustBills = QueryServiceHelper.query("ecco_costadjust", "billstatus,entryentity.subentryentity.subunitproject,entryentity.subentryentity.procbs,entryentity.subentryentity.afteradjustbalance", new QFilter[]{costFilter}); + Iterator var72 = costAdjustBills.iterator(); + + while (var72.hasNext()) { + DynamicObject costAdjustBill = (DynamicObject) var72.next(); + statusVal = costAdjustBill.getString("billstatus"); + unitProjectId = costAdjustBill.getLong("entryentity.subentryentity.subunitproject"); + long cbsAdj = costAdjustBill.getLong("entryentity.subentryentity.procbs"); + String keyAdj = this.concatKey(String.valueOf(cbsAdj), String.valueOf(unitProjectId)); + if (StringUtils.equals(statusVal, BillStatusEnum.AUDIT.getValue())) { + noSplitCostAmount = (BigDecimal) confirmCostMap.getOrDefault(keyAdj, BigDecimal.ZERO); + noSplitCostAmount = noSplitCostAmount.add(costAdjustBill.getBigDecimal("entryentity.subentryentity.afteradjustbalance")); + confirmCostMap.put(keyAdj, noSplitCostAmount); + } else if (StringUtils.equals(statusVal, BillStatusEnum.SUBMIT.getValue())) { + noSplitCostAmount = (BigDecimal) notSplitCostMap.getOrDefault(keyAdj, BigDecimal.ZERO); + noSplitCostAmount = noSplitCostAmount.add(costAdjustBill.getBigDecimal("entryentity.subentryentity.afteradjustbalance")); + notSplitCostMap.put(keyAdj, noSplitCostAmount); + } + } + + DynamicObjectCollection equipmentCostBills = QueryServiceHelper.query("eceq_costsplit", "billstatus,settlesplitentity.settleid,settlesplitentity.costsplitentity.unitproject,settlesplitentity.costsplitentity.procbs,settlesplitentity.costsplitentity.splitamount", new QFilter[]{costFilter}); + Set splitReferenceEqSettleSet = new HashSet(16); + Iterator var79 = equipmentCostBills.iterator(); + + while (var79.hasNext()) { + DynamicObject equipmentCostBill = (DynamicObject) var79.next(); + splitReferenceEqSettleSet.add(equipmentCostBill.getLong("settlesplitentity.settleid")); + String statusEq = equipmentCostBill.getString("billstatus"); + unitProjectId = equipmentCostBill.getLong("settlesplitentity.costsplitentity.unitproject"); + long cbsEq = equipmentCostBill.getLong("settlesplitentity.costsplitentity.procbs"); + String keyEq = this.concatKey(String.valueOf(cbsEq), String.valueOf(unitProjectId)); + BigDecimal noSplitCostAmountEq; + if (StringUtils.equals(statusEq, BillStatusEnum.AUDIT.getValue())) { + noSplitCostAmountEq = (BigDecimal) confirmCostMap.getOrDefault(keyEq, BigDecimal.ZERO); + noSplitCostAmountEq = noSplitCostAmountEq.add(equipmentCostBill.getBigDecimal("settlesplitentity.costsplitentity.splitamount")); + confirmCostMap.put(keyEq, noSplitCostAmountEq); + } else if (StringUtils.equals(statusEq, BillStatusEnum.SUBMIT.getValue())) { + noSplitCostAmountEq = (BigDecimal) notSplitCostMap.getOrDefault(keyEq, BigDecimal.ZERO); + noSplitCostAmountEq = noSplitCostAmountEq.add(equipmentCostBill.getBigDecimal("settlesplitentity.costsplitentity.splitamount")); + notSplitCostMap.put(keyEq, noSplitCostAmountEq); + } + } + + QFilter settleFilter = new QFilter("contract.isincost", "=", "1"); + settleFilter.and("isincost", "=", "0"); + settleFilter.and("id", "not in", splitReferenceSettleSet); + settleFilter.and("project", "=", project.getPkValue()); + settleFilter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()}); + Map settleBills = BusinessDataServiceHelper.loadFromCache("ec_out_contract_settle", new QFilter[]{settleFilter}); + Set notSplitClaimSet = new HashSet(16); + Set notConfirmClaimSet = new HashSet(16); + Set notSplitVisaSet = new HashSet(16); + Set notConfirmVisaSet = new HashSet(16); + Set notSplitPerformSet = new HashSet(16); + Set notConfirmPerformSet = new HashSet(16); + Set notSplitMeasureSet = new HashSet(16); + Set notConfirmMeasureSet = new HashSet(16); + Set notSplitEqSettleSet = new HashSet(16); + Set notConfirmEqSettleSet = new HashSet(16); + Iterator var31 = settleBills.values().iterator(); + + while (var31.hasNext()) { + DynamicObject settleBill = (DynamicObject) var31.next(); + String statusSettle = settleBill.getString("billstatus"); + boolean isNotSplitCost = StringUtils.equals(statusSettle, BillStatusEnum.AUDIT.getValue()); + DynamicObjectCollection detailEntries = settleBill.getDynamicObjectCollection("payitemdetailentry"); + Set itemList = new HashSet(); + Iterator var37 = detailEntries.iterator(); + + DynamicObject itemEntry; + while (var37.hasNext()) { + DynamicObject detailEntry = (DynamicObject) var37.next(); + itemEntry = detailEntry.getDynamicObject("detailpayitem"); + if (itemEntry != null) { + itemList.add(itemEntry.getPkValue()); + } + + String billType = detailEntry.getString("referbilltype"); + long billId = detailEntry.getLong("referbillid"); + if (StringUtils.equals(billType, ReferBillTypeEnum.CLAIM.getValue())) { + if (isNotSplitCost) { + notSplitClaimSet.add(billId); + } else { + notConfirmClaimSet.add(billId); + } + } else if (StringUtils.equals(billType, ReferBillTypeEnum.VISA.getValue())) { + if (isNotSplitCost) { + notSplitVisaSet.add(billId); + } else { + notConfirmVisaSet.add(billId); + } + } else if (StringUtils.equals(billType, ReferBillTypeEnum.PERFORM.getValue())) { + if (isNotSplitCost) { + notSplitPerformSet.add(billId); + } else { + notConfirmPerformSet.add(billId); + } + } else if (StringUtils.equals(billType, ReferBillTypeEnum.MEASURE.getValue())) { + if (isNotSplitCost) { + notSplitMeasureSet.add(billId); + } else { + notConfirmMeasureSet.add(billId); + } + } + } + + DynamicObjectCollection itemEntries = settleBill.getDynamicObjectCollection("itementry"); + Iterator var102 = itemEntries.iterator(); + + DynamicObject eqSettleEntry; + String direction; + while (var102.hasNext()) { + itemEntry = (DynamicObject) var102.next(); + eqSettleEntry = itemEntry.getDynamicObject("payitem"); + if (eqSettleEntry != null && !itemList.contains(eqSettleEntry.getPkValue())) { + direction = eqSettleEntry.getString("direction"); + if (!DirectionEnum.NON.getValue().equals(direction)) { + DynamicObject unitProjectItem = itemEntry.getDynamicObject("itemunitproject"); + DynamicObject cbsItem = itemEntry.getDynamicObject("itemcbs"); + String keyItem = this.concatKey(cbsItem == null ? "0" : cbsItem.getString("id"), unitProjectItem == null ? "0" : unitProjectItem.getString("id")); + BigDecimal amount = itemEntry.getBigDecimal("amount"); + if (DirectionEnum.SUB.getValue().equals(direction)) { + amount = amount.negate(); + } + + if (isNotSplitCost) { + notSplitCostMap.put(keyItem, ((BigDecimal) notSplitCostMap.getOrDefault(keyItem, BigDecimal.ZERO)).add(amount)); + } else { + notConfirmCostMap.put(keyItem, ((BigDecimal) notConfirmCostMap.getOrDefault(keyItem, BigDecimal.ZERO)).add(amount)); + } + } + } + } + + DynamicObjectCollection eqSettleEntries = settleBill.getDynamicObjectCollection("eqsettleentry"); + Iterator var105 = eqSettleEntries.iterator(); + + while (var105.hasNext()) { + eqSettleEntry = (DynamicObject) var105.next(); + direction = eqSettleEntry.getString("eqsettleid"); + if (isNotSplitCost) { + notSplitEqSettleSet.add(Long.valueOf(direction)); + } else { + notConfirmEqSettleSet.add(Long.valueOf(direction)); + } + } + } + + QFilter measureFilter = new QFilter("contract.isincost", "=", "1"); + measureFilter.and("isincost", "=", "0"); + measureFilter.and("issettled", "=", "0"); + measureFilter.and("id", "not in", splitReferenceMeasureSet); + measureFilter.and("id", "not in", notSplitMeasureSet); + measureFilter.and("id", "not in", notConfirmMeasureSet); + measureFilter.and("project", "=", project.getPkValue()); + measureFilter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()}); + Map measureBills = BusinessDataServiceHelper.loadFromCache("ec_outcontractmeasure", new QFilter[]{measureFilter}); + this.processMeasureBills(notConfirmCostMap, measureBills); + Map notSplitMeasureBills = BusinessDataServiceHelper.loadFromCache("ec_outcontractmeasure", new QFilter[]{(new QFilter("id", "in", notSplitMeasureSet)).and("id", "not in", splitReferenceMeasureSet)}); + this.processMeasureBills(notSplitCostMap, notSplitMeasureBills); + Map notConfirmMeasureBills = BusinessDataServiceHelper.loadFromCache("ec_outcontractmeasure", new QFilter[]{(new QFilter("id", "in", notConfirmMeasureSet)).and("id", "not in", splitReferenceMeasureSet)}); + this.processMeasureBills(notConfirmCostMap, notConfirmMeasureBills); + QFilter claimFilter = new QFilter("contract.isincost", "=", "1"); + claimFilter.and("issettle", "=", "0"); + claimFilter.and("isneedsettle", "=", "1"); + claimFilter.and("id", "not in", notSplitClaimSet); + claimFilter.and("id", "not in", notConfirmClaimSet); + claimFilter.and("project", "=", project.getPkValue()); + claimFilter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()}); + Map claimBills = BusinessDataServiceHelper.loadFromCache("ec_outclaimbill", new QFilter[]{claimFilter}); + this.processClaimBills(notConfirmCostMap, claimBills); + Map notSplitClaimBills = BusinessDataServiceHelper.loadFromCache("ec_outclaimbill", new QFilter[]{new QFilter("id", "in", notSplitClaimSet)}); + this.processClaimBills(notSplitCostMap, notSplitClaimBills); + Map notConfirmClaimBills = BusinessDataServiceHelper.loadFromCache("ec_outclaimbill", new QFilter[]{new QFilter("id", "in", notConfirmClaimSet)}); + this.processClaimBills(notConfirmCostMap, notConfirmClaimBills); + QFilter visaFilter = new QFilter("contract.isincost", "=", "1"); + visaFilter.and("issettle", "=", "0"); + visaFilter.and("isneedsettle", "=", "1"); + visaFilter.and("id", "not in", notSplitVisaSet); + visaFilter.and("id", "not in", notConfirmVisaSet); + visaFilter.and("project", "=", project.getPkValue()); + visaFilter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()}); + Map visaBills = BusinessDataServiceHelper.loadFromCache("ec_outvisabill", new QFilter[]{visaFilter}); + this.processVisaBills(notConfirmCostMap, visaBills); + Map notSplitVisaBills = BusinessDataServiceHelper.loadFromCache("ec_outvisabill", new QFilter[]{new QFilter("id", "in", notSplitVisaSet)}); + this.processVisaBills(notSplitCostMap, notSplitVisaBills); + Map notConfirmVisaBills = BusinessDataServiceHelper.loadFromCache("ec_outvisabill", new QFilter[]{new QFilter("id", "in", notConfirmVisaSet)}); + this.processVisaBills(notConfirmCostMap, notConfirmVisaBills); + QFilter performFilter = new QFilter("contract.isincost", "=", "1"); + performFilter.and("id", "not in", notSplitPerformSet); + performFilter.and("id", "not in", notConfirmPerformSet); + performFilter.and("project", "=", project.getPkValue()); + performFilter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()}); + Map performBills = BusinessDataServiceHelper.loadFromCache("ec_out_performrecords", new QFilter[]{performFilter}); + this.processPerformBills(notConfirmCostMap, performBills, false); + Map notSplitPerformBills = BusinessDataServiceHelper.loadFromCache("ec_out_performrecords", new QFilter[]{new QFilter("id", "in", notSplitPerformSet)}); + this.processPerformBills(notSplitCostMap, notSplitPerformBills, true); + Map notConfirmPerformBills = BusinessDataServiceHelper.loadFromCache("ec_out_performrecords", new QFilter[]{new QFilter("id", "in", notConfirmPerformSet)}); + this.processPerformBills(notConfirmCostMap, notConfirmPerformBills, false); + QFilter matOutFilter = new QFilter("project", "=", project.getPkValue()); + matOutFilter.and("transtype.impactcost", "=", "1"); + matOutFilter.and("matbilltype", "=", "materialout"); + matOutFilter.and("iscompleted", "=", "0"); + matOutFilter.and("billno", "not in", splitReferenceOutBillNoSet); + matOutFilter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()}); + DynamicObjectCollection matOutBills = QueryServiceHelper.query("ecma_materialoutbill", "billstatus,entryentity.unitproject,entryentity.procbs,entryentity.amount", new QFilter[]{matOutFilter}); + this.processMaterialBills(notSplitCostMap, notConfirmCostMap, matOutBills); + QFilter matInFilter = new QFilter("project", "=", project.getPkValue()); + matInFilter.and("transtype.impactcost", "=", "1"); + matInFilter.and("matbilltype", "=", "materialin"); + matInFilter.and("iscompleted", "=", "0"); + matInFilter.and("billno", "not in", splitReferenceInBillNoSet); + matInFilter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()}); + DynamicObjectCollection matInBills = QueryServiceHelper.query("ecma_materialinbill", "billstatus,entryentity.unitproject,entryentity.procbs,entryentity.amount", new QFilter[]{matInFilter}); + this.processMaterialBills(notSplitCostMap, notConfirmCostMap, matInBills); + QFilter eqSettleFilter = new QFilter("billstatus", "=", BillStatusEnum.AUDIT.getValue()); + eqSettleFilter.and("issettle", "=", "0"); + eqSettleFilter.and("isallsplit", "=", "0"); + eqSettleFilter.and("project", "=", project.getPkValue()); + eqSettleFilter.and("id", "not in", splitReferenceEqSettleSet); + eqSettleFilter.and("id", "not in", notSplitEqSettleSet); + eqSettleFilter.and("id", "not in", notConfirmEqSettleSet); + DynamicObjectCollection eqSettleBills = QueryServiceHelper.query("eceq_settle", "unitproject,entryentity.procbs,entryentity.amount", new QFilter[]{eqSettleFilter}); + this.processEqSettleBills(notSplitCostMap, eqSettleBills); + eqSettleBills = QueryServiceHelper.query("eceq_settle", "unitproject,entryentity.procbs,entryentity.amount", new QFilter[]{new QFilter("id", "in", notSplitEqSettleSet)}); + this.processEqSettleBills(notSplitCostMap, eqSettleBills); + eqSettleFilter = new QFilter("project", "=", project.getPkValue()); + eqSettleFilter.and("billstatus", "=", BillStatusEnum.SUBMIT.getValue()); + eqSettleBills = QueryServiceHelper.query("eceq_settle", "unitproject,entryentity.procbs,entryentity.amount", new QFilter[]{eqSettleFilter}); + this.processEqSettleBills(notConfirmCostMap, eqSettleBills); + eqSettleBills = QueryServiceHelper.query("eceq_settle", "unitproject,entryentity.procbs,entryentity.amount", new QFilter[]{new QFilter("id", "in", notConfirmEqSettleSet)}); + this.processEqSettleBills(notConfirmCostMap, eqSettleBills); + } + + protected void queryAimCost(DynamicObject project, Set unitProjectIds, Map aimCostMap) { + QFilter aimCostFilter = new QFilter("project", "=", project.getPkValue()); + if (project.getBoolean("editonunit") && !unitProjectIds.isEmpty()) { + aimCostFilter.and("unitproject", "in", unitProjectIds); + } + + aimCostFilter.and("isenable", "=", "1"); + DynamicObject[] aimCostBills = BusinessDataServiceHelper.load("ecco_aimcostbillcbs", "unitproject,treeentryentity,treeentryentity.cbs,treeentryentity.pdamount", new QFilter[]{aimCostFilter}); + DynamicObject[] var6 = aimCostBills; + int var7 = aimCostBills.length; + + for (int var8 = 0; var8 < var7; ++var8) { + DynamicObject aimCostBill = var6[var8]; + DynamicObject unitProject = aimCostBill.getDynamicObject("unitproject"); + String unitProjectId = unitProject == null ? "0" : unitProject.getString("id"); + DynamicObjectCollection aimEntries = aimCostBill.getDynamicObjectCollection("treeentryentity"); + Iterator var13 = aimEntries.iterator(); + + while (var13.hasNext()) { + DynamicObject aimEntry = (DynamicObject) var13.next(); + DynamicObject cbs = aimEntry.getDynamicObject("cbs"); + if (cbs.getBoolean("isleaf")) { + String key = this.concatKey(cbs.getString("id"), unitProjectId); + BigDecimal totalAimCost = (BigDecimal) aimCostMap.getOrDefault(key, BigDecimal.ZERO); + totalAimCost = totalAimCost.add(aimEntry.getBigDecimal("pdamount")); + aimCostMap.put(key, totalAimCost); + } + } + } + + } + + protected void processEqSettleBills(Map costMap, DynamicObjectCollection eqSettleBills) { + Iterator var3 = eqSettleBills.iterator(); + + while (var3.hasNext()) { + DynamicObject eqSettleBill = (DynamicObject) var3.next(); + long unitProject = eqSettleBill.getLong("unitproject"); + long cbs = eqSettleBill.getLong("entryentity.procbs"); + String key = this.concatKey(String.valueOf(cbs), String.valueOf(unitProject)); + costMap.put(key, ((BigDecimal) costMap.getOrDefault(key, BigDecimal.ZERO)).add(eqSettleBill.getBigDecimal("entryentity.amount"))); + } + + } + + protected void processMaterialBills(Map notSplitCostMap, Map notConfirmCostMap, DynamicObjectCollection matBills) { + Iterator var4 = matBills.iterator(); + + while (var4.hasNext()) { + DynamicObject matBill = (DynamicObject) var4.next(); + String status = matBill.getString("billstatus"); + long unitProject = matBill.getLong("entryentity.unitproject"); + long cbs = matBill.getLong("entryentity.procbs"); + BigDecimal amount = matBill.getBigDecimal("entryentity.amount"); + String key = this.concatKey(String.valueOf(cbs), String.valueOf(unitProject)); + if (StringUtils.equals(status, BillStatusEnum.AUDIT.getValue())) { + notSplitCostMap.put(key, ((BigDecimal) notSplitCostMap.getOrDefault(key, BigDecimal.ZERO)).add(amount)); + } else if (StringUtils.equals(status, BillStatusEnum.SUBMIT.getValue())) { + notConfirmCostMap.put(key, ((BigDecimal) notConfirmCostMap.getOrDefault(key, BigDecimal.ZERO)).add(amount)); + } + } + + } + + protected void processPerformBills(Map costMap, Map performBills, boolean isCountSettle) { + Iterator var4 = performBills.values().iterator(); + + label42: + while (var4.hasNext()) { + DynamicObject performBill = (DynamicObject) var4.next(); + DynamicObjectCollection entries = performBill.getDynamicObjectCollection("entryentity"); + Iterator var7 = entries.iterator(); + + while (true) { + DynamicObject entry; + boolean needSettle; + boolean isSettle; + do { + do { + if (!var7.hasNext()) { + continue label42; + } + + entry = (DynamicObject) var7.next(); + needSettle = entry.getBoolean("isneedsettle"); + isSettle = entry.getBoolean("issettle"); + } while (!needSettle); + } while (isSettle && !isCountSettle); + + DynamicObject unitProject = entry.getDynamicObject("unitproject"); + DynamicObject cbs = entry.getDynamicObject("cbs"); + String key = this.concatKey(cbs == null ? "0" : cbs.getString("id"), unitProject == null ? "0" : unitProject.getString("id")); + BigDecimal thisAmt = entry.getBigDecimal("notaxamount"); + costMap.put(key, ((BigDecimal) costMap.getOrDefault(key, BigDecimal.ZERO)).add(thisAmt)); + } + } + + } + + protected void processVisaBills(Map costMap, Map visaBills) { + Iterator var3 = visaBills.values().iterator(); + + while (var3.hasNext()) { + DynamicObject visaBill = (DynamicObject) var3.next(); + DynamicObjectCollection entries = visaBill.getDynamicObjectCollection("entryentity"); + Iterator var6 = entries.iterator(); + + while (var6.hasNext()) { + DynamicObject entry = (DynamicObject) var6.next(); + DynamicObject unitProject = entry.getDynamicObject("unitproject"); + DynamicObject cbs = entry.getDynamicObject("cbs"); + String key = this.concatKey(cbs == null ? "0" : cbs.getString("id"), unitProject == null ? "0" : unitProject.getString("id")); + BigDecimal thisAmt = entry.getBigDecimal("unitvisaamt"); + costMap.put(key, ((BigDecimal) costMap.getOrDefault(key, BigDecimal.ZERO)).add(thisAmt)); + } + } + + } + + protected void processClaimBills(Map costMap, Map claimBills) { + Iterator var3 = claimBills.values().iterator(); + + while (var3.hasNext()) { + DynamicObject claimBill = (DynamicObject) var3.next(); + DynamicObjectCollection entries = claimBill.getDynamicObjectCollection("entryentity"); + Iterator var6 = entries.iterator(); + + while (var6.hasNext()) { + DynamicObject entry = (DynamicObject) var6.next(); + DynamicObject unitProject = entry.getDynamicObject("unitproject"); + DynamicObject cbs = entry.getDynamicObject("cbs"); + String key = this.concatKey(cbs == null ? "0" : cbs.getString("id"), unitProject == null ? "0" : unitProject.getString("id")); + BigDecimal thisAmt = entry.getBigDecimal("unitclaimamt"); + costMap.put(key, ((BigDecimal) costMap.getOrDefault(key, BigDecimal.ZERO)).add(thisAmt)); + } + } + + } + + protected void processMeasureBills(Map costMap, Map measureBills) { + Iterator var3 = measureBills.values().iterator(); + + label72: + while (true) { + DynamicObject headCbs; + DynamicObjectCollection modelEntries; + do { + do { + if (!var3.hasNext()) { + return; + } + + DynamicObject measureBill = (DynamicObject) var3.next(); + DynamicObject contract = measureBill.getDynamicObject("contract"); + headCbs = contract.getDynamicObject("cbs"); + modelEntries = measureBill.getDynamicObjectCollection("listmodelentry"); + } while (modelEntries == null); + } while (modelEntries.isEmpty()); + + Iterator var8 = modelEntries.iterator(); + + while (true) { + BigDecimal cmpRate; + DynamicObjectCollection entries; + do { + do { + if (!var8.hasNext()) { + continue label72; + } + + DynamicObject modelEntry = (DynamicObject) var8.next(); + cmpRate = getCmpRate(modelEntry.getString("cmptype")); + entries = modelEntry.getDynamicObjectCollection("listentry"); + } while (entries == null); + } while (entries.isEmpty()); + + Iterator var12 = entries.iterator(); + + while (var12.hasNext()) { + DynamicObject entry = (DynamicObject) var12.next(); + DynamicObject listCbs = entry.getDynamicObject("listcbs"); + listCbs = listCbs == null ? headCbs : listCbs; + DynamicObject listUnitProject; + if (listCbs == null) { + listUnitProject = entry.getDynamicObject("resourceitem"); + listCbs = listUnitProject == null ? null : listUnitProject.getDynamicObject("cbs"); + } + + listUnitProject = entry.getDynamicObject("listunitproject"); + String key = this.concatKey(listCbs == null ? "0" : listCbs.getString("id"), listUnitProject == null ? "0" : listUnitProject.getString("id")); + BigDecimal thisAmt = entry.getBigDecimal("thisamount").multiply(cmpRate); + costMap.put(key, ((BigDecimal) costMap.getOrDefault(key, BigDecimal.ZERO)).add(thisAmt)); + } + } + } + } + + protected static BigDecimal getCmpRate(String cmpType) { + if (cmpType != null && !StringUtils.equals("(+)", cmpType)) { + return StringUtils.equals("(-)", cmpType) ? BigDecimal.valueOf(-1L) : BigDecimal.ZERO; + } else { + return BigDecimal.ONE; + } + } + + @NotNull + protected String concatKey(String cbs, String unitProject) { + return cbs + "#" + unitProject; + } + + protected JSONArray getCbsCache() { + String cbsCache = this.getPageCache().get("cbsCache"); + JSONArray unitProjectCbsArray; + if (cbsCache != null) { + unitProjectCbsArray = JSONArray.parseArray(cbsCache); + } else { + unitProjectCbsArray = new JSONArray(); + DynamicObjectCollection unitProjects = (DynamicObjectCollection) this.getModel().getValue("queryunitproject"); + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); + if (project == null) { + return null; + } + + QFilter filter = new QFilter("project", "=", project.getPkValue()); + filter.and("enable", "=", "1"); + Map proCbsMap = BusinessDataServiceHelper.loadFromCache("ec_ecbd_pro_cbs", "id", new QFilter[]{filter}, "number"); + if (proCbsMap == null || proCbsMap.isEmpty()) { + return null; + } + + Iterator var7; + DynamicObject unitProject; + if (unitProjects != null && !unitProjects.isEmpty()) { + var7 = unitProjects.iterator(); + + while (var7.hasNext()) { + unitProject = (DynamicObject) var7.next(); + Iterator var12 = proCbsMap.values().iterator(); + + while (var12.hasNext()) { + DynamicObject cbs = (DynamicObject) var12.next(); + JSONObject cbsObject = new JSONObject(); + cbsObject.put("cbs", cbs == null ? "0" : cbs.getPkValue().toString()); + cbsObject.put("unitProject", unitProject.getDynamicObject("fbasedataid").getPkValue().toString()); + unitProjectCbsArray.add(cbsObject); + } + } + } else { + var7 = proCbsMap.values().iterator(); + + while (var7.hasNext()) { + unitProject = (DynamicObject) var7.next(); + JSONObject cbsObject = new JSONObject(); + cbsObject.put("cbs", unitProject == null ? "0" : unitProject.getPkValue().toString()); + cbsObject.put("unitProject", "0"); + unitProjectCbsArray.add(cbsObject); + } + } + } + + this.getPageCache().put("cbsCache", unitProjectCbsArray.toJSONString()); + return unitProjectCbsArray; + } + + protected JSONArray getQueryCbsCache() { + String cbsCache = this.getPageCache().get("queryCbsCache"); + JSONArray unitProjectCbsArray; + if (cbsCache != null) { + unitProjectCbsArray = JSONArray.parseArray(cbsCache); + } else { + unitProjectCbsArray = this.getCbsCache(); + } + + return unitProjectCbsArray; + } + + public void hyperLinkClick(HyperLinkClickEvent hyperLinkClickEvent) { + String fieldName = hyperLinkClickEvent.getFieldName(); + int rowIndex = hyperLinkClickEvent.getRowIndex(); + if (StringUtils.equals(fieldName, "aimcost")) { + this.showAimCostBill(rowIndex); + } else if (StringUtils.equals(fieldName, "confirmcost")) { + this.showPeriodDetailCost(rowIndex, "1"); + } else if (StringUtils.equals(fieldName, "notsplitcost")) { + this.showPeriodDetailCost(rowIndex, "2"); + } else if (StringUtils.equals(fieldName, "notconfirmcost")) { + this.showPeriodDetailCost(rowIndex, "3"); + } + + } + + protected void showAimCostBill(int rowIndex) { + DynamicObject unitProject = (DynamicObject) this.getModel().getValue("unitproject", rowIndex); + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); + QFilter aimCostFilter = new QFilter("project", "=", project.getPkValue()); + aimCostFilter.and("unitproject", "=", unitProject == null ? 0L : unitProject.getPkValue()); + aimCostFilter.and("isenable", "=", "1"); + DynamicObject aimCostBill = QueryServiceHelper.queryOne("ecco_aimcostbillcbs", "id", new QFilter[]{aimCostFilter}); + if (aimCostBill != null) { + BillShowParameter showParameter = OpenPageUtils.buildBillShowParam(aimCostBill.getLong("id"), "ecco_aimcostbillcbs"); + this.getView().showForm(showParameter); + } + + } + + protected void showPeriodDetailCost(int rowIndex, String splitType) { + Map paramMap = new HashMap(); + DynamicObject cbs = (DynamicObject) this.getModel().getValue("cbs", rowIndex); + if (cbs != null && cbs.getBoolean("isleaf")) { + paramMap.put("projectId", this.getPageCache().get("queryProject")); + DynamicObject unitProject = (DynamicObject) this.getModel().getValue("unitproject", rowIndex); + if (unitProject != null) { + paramMap.put("unitProjectPks", unitProject.getString("id")); + } + + paramMap.put("selectedtype", "1"); + paramMap.put("splitType", splitType); + paramMap.put("entityId", cbs.getString("id")); + paramMap.put("formId", "ecco_periodrealcost"); + paramMap.put("timeString", "total"); + FormShowParameter showParameter = FormShowParameter.createFormShowParameter(paramMap); + showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); + this.getView().showForm(showParameter); + } else { + this.getView().showTipNotification(ResManager.loadKDString("请选择明细节点进行联查。", "CbsDynamicCostFormPlugin_3", "ec-ecco-formplugin", new Object[0])); + } + } +}