From a18dd70de7662e47ca319893b7160bebd99b9b4d Mon Sep 17 00:00:00 2001 From: ggxl <194689125@qq.com> Date: Mon, 18 Nov 2024 10:05:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=8E=B7=E5=8F=96=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E6=95=B0=E6=8D=AE=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContractListDateFilterPlugin.java | 104 ++++++++++++------ 1 file changed, 69 insertions(+), 35 deletions(-) diff --git a/main/java/shkd/repc/resm/formplugin/ContractListDateFilterPlugin.java b/main/java/shkd/repc/resm/formplugin/ContractListDateFilterPlugin.java index a24289d..dcc1a5b 100644 --- a/main/java/shkd/repc/resm/formplugin/ContractListDateFilterPlugin.java +++ b/main/java/shkd/repc/resm/formplugin/ContractListDateFilterPlugin.java @@ -8,6 +8,8 @@ import kd.bos.dataentity.resource.ResManager; import kd.bos.dataentity.utils.StringUtils; import kd.bos.entity.EntityMetadataCache; import kd.bos.entity.datamodel.IDataModel; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.form.container.Tab; import kd.bos.form.control.Control; import kd.bos.orm.query.QCP; @@ -102,48 +104,80 @@ public class ContractListDateFilterPlugin extends AbstractBillPlugIn implements if (contractEntries.isEmpty()) { this.getView().showTipNotification(ResManager.loadKDString("没有符合条件的合同,请检查。", "EvalPlanEdit_13", "repc-resm-formplugin", new Object[0])); - Tab tabap = (Tab)this.getView().getControl("tabap"); + Tab tabap = (Tab) this.getView().getControl("tabap"); tabap.activeTab("tab_info"); - return; } + } + } - for (int i = 0; i < contractEntries.size(); i++) { - DynamicObject contractEntry = contractEntries.get(i); - DynamicObject eyContract = contractEntry.getDynamicObject("ey_contract"); - if (eyContract != null) { - DynamicObject contract = BusinessDataServiceHelper.loadSingle(eyContract.getPkValue(), "resm_contract_book", "id,sign_date,contract,ismaincontract,maincontract"); - Date signDate = contract.getDate("sign_date");// 签约日期 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(signDate); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - signDate = calendar.getTime(); - model.setValue("qeug_sign_date", signDate, i); + @Override + public void propertyChanged(PropertyChangedArgs e) { + String name = e.getProperty().getName(); + if ("ey_contract".equals(name)) { + IDataModel model = this.getModel(); + ChangeData changeData = e.getChangeSet()[0]; + int rowIndex = changeData.getRowIndex(); + DynamicObject eyContract = (DynamicObject) model.getValue("ey_contract", rowIndex); - String evalTypeNum = contractEntry.getString("ey_eval_type.number");// 评估类型 - if (!"007".equals(evalTypeNum)) continue; + if (eyContract == null) { + model.setValue("qeug_sign_date", null, rowIndex); + model.setValue("qeug_bizdate", null, rowIndex); + } else { + DynamicObject contract = BusinessDataServiceHelper.loadSingle(eyContract.getPkValue(), "resm_contract_book", "id,sign_date,contract,ismaincontract,maincontract,bizstatus"); + Date signDate = contract.getDate("sign_date");// 签约日期 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(signDate); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + signDate = calendar.getTime(); + model.setValue("qeug_sign_date", signDate, rowIndex); - DynamicObject contractSettle; - boolean isMainContract = contract.getBoolean("ismaincontract"); - DynamicObject mainContract = contract.getDynamicObject("maincontract");// 关联主合同 - if (!isMainContract && mainContract != null) { - mainContract = BusinessDataServiceHelper.loadSingle(mainContract.getPkValue(), "resm_contract_book", "id,sign_date,contract"); - Long contractId = mainContract.getLong("contract"); - QFilter idQF = new QFilter("contractbill", QCP.equals, contractId); - contractSettle = BusinessDataServiceHelper.loadSingle("recon_consettlebill", "id,bizdate", idQF.toArray());// 合同结算 - } else { - Long contractId = contract.getLong("contract"); - QFilter idQF = new QFilter("contractbill", QCP.equals, contractId); - contractSettle = BusinessDataServiceHelper.loadSingle("recon_consettlebill", "id,bizdate", idQF.toArray());// 合同结算 - } - if (contractSettle != null) { - Date bizDate = contractSettle.getDate("bizdate");// 结算日期 - model.setValue("qeug_bizdate", bizDate, i); - } + String evalType = ""; + List evalTypeList = this.getEvalTypeByContract(contract); + if (!evalTypeList.isEmpty()) { + DynamicObject dynamicObject = evalTypeList.get(0); + if (dynamicObject != null) evalType = dynamicObject.getString("number"); + } + + if (!"007".equals(evalType)) return; + + DynamicObject contractSettle; + boolean isMainContract = contract.getBoolean("ismaincontract"); + DynamicObject mainContract = contract.getDynamicObject("maincontract");// 关联主合同 + if (!isMainContract && mainContract != null) { + mainContract = BusinessDataServiceHelper.loadSingle(mainContract.getPkValue(), "resm_contract_book", "id,sign_date,contract"); + Long contractId = mainContract.getLong("contract"); + QFilter idQF = new QFilter("contractbill", QCP.equals, contractId); + contractSettle = BusinessDataServiceHelper.loadSingle("recon_consettlebill", "id,bizdate", idQF.toArray());// 合同结算 + } else { + Long contractId = contract.getLong("contract"); + QFilter idQF = new QFilter("contractbill", QCP.equals, contractId); + contractSettle = BusinessDataServiceHelper.loadSingle("recon_consettlebill", "id,bizdate", idQF.toArray());// 合同结算 + } + if (contractSettle != null) { + Date bizDate = contractSettle.getDate("bizdate");// 结算日期 + model.setValue("qeug_bizdate", bizDate, rowIndex); } } } } + + protected List getEvalTypeByContract(DynamicObject contract) { + String bizStatus = contract.getString("bizstatus"); + QFilter qFilter = new QFilter("enable", "=", true); + qFilter.and("stage", "=", "2"); + DynamicObject[] evalTypeArr = BusinessDataServiceHelper.load("resm_evaltype", "stage,bizstatus", qFilter.toArray(), "number"); + List evalTypeList = (List)Arrays.stream(evalTypeArr).filter((item) -> { + return item.getString("bizstatus").contains(bizStatus); + }).collect(Collectors.toList()); + if (evalTypeList.isEmpty()) { + evalTypeList = (List)Arrays.stream(evalTypeArr).filter((item) -> { + return StringUtils.isEmpty(item.getString("bizstatus")); + }).collect(Collectors.toList()); + } + + return evalTypeList; + } } \ No newline at end of file