From 1d42049cf1863d619f83962a2acf1c48435f3cbf Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Tue, 17 Jun 2025 16:47:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BA=8C=E5=BC=80=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/PaymentContSubmitOpExt.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/PaymentContSubmitOpExt.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/PaymentContSubmitOpExt.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/PaymentContSubmitOpExt.java new file mode 100644 index 0000000..1429d91 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/PaymentContSubmitOpExt.java @@ -0,0 +1,99 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package zcgj.zcdev.zcdev.pr.plugin.operate; + + +import java.util.HashSet; +import java.util.Set; +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.ExtendedDataEntity; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.AddValidatorsEventArgs; +import kd.bos.entity.plugin.PreparePropertysEventArgs; +import kd.bos.entity.validate.AbstractValidator; +import kd.bos.entity.validate.ErrorLevel; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.ec.basedata.common.enums.ContractStatusEnum; + +public class PaymentContSubmitOpExt extends AbstractOperationServicePlugIn { + public PaymentContSubmitOpExt() { + } + + public void onPreparePropertys(PreparePropertysEventArgs e) { + super.onPreparePropertys(e); + } + + public void onAddValidators(AddValidatorsEventArgs e) { + super.onAddValidators(e); + e.addValidator(new AbstractValidator() { + public void validate() { + String operateKey = this.getOperateKey(); + if (StringUtils.equals(operateKey, "submit")) { + ExtendedDataEntity[] dataEntities = this.getDataEntities(); + ExtendedDataEntity[] var3 = dataEntities; + int var4 = dataEntities.length; + + for(int var5 = 0; var5 < var4; ++var5) { + ExtendedDataEntity dataEntity = var3[var5]; + long newFormId = (Long)dataEntity.getDataEntity().getPkValue(); + DynamicObjectCollection entryEntity = dataEntity.getDataEntity().getDynamicObjectCollection("entryentity"); + + for(int i = 0; i < entryEntity.size(); ++i) { + DynamicObject row = (DynamicObject)entryEntity.get(i); + DynamicObject contract = row.getDynamicObject("contract"); + if (contract != null) { + String contStatus = contract.getString("contstatus"); + String contName = contract.getString("name"); + if (StringUtils.equals(contStatus, ContractStatusEnum.CLOSED.getValue())) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1s】的状态为%2s状态,不能进行业务操作", "PaymentContSubmitOp_5", "ec-ecpf-opplugin", new Object[0]), contName, ContractStatusEnum.getEnumByValue(contStatus).getName())); + } else { + QFilter filters = new QFilter("contract", "=", contract.getPkValue()); + filters.and(new QFilter("billstatus", "=", "B")); + QFilter pauseFilter = new QFilter("afterstatus", "=", ContractStatusEnum.PAUSE.getValue()); + QFilter relieveFilter = new QFilter("afterstatus", "=", ContractStatusEnum.RELIEVE.getValue()); + QFilter closedFilter = new QFilter("afterstatus", "=", ContractStatusEnum.CLOSED.getValue()); + QFilter runningFilter = new QFilter("afterstatus", "=", ContractStatusEnum.RUNNING.getValue()); + boolean pauseExist = QueryServiceHelper.exists("ec_statusmanage", new QFilter[]{filters, pauseFilter}); + boolean relieveExist = QueryServiceHelper.exists("ec_statusmanage", new QFilter[]{filters, relieveFilter}); + boolean closedExist = QueryServiceHelper.exists("ec_statusmanage", new QFilter[]{filters, closedFilter}); + boolean runningExist = QueryServiceHelper.exists("ec_statusmanage", new QFilter[]{filters, runningFilter}); + if (pauseExist) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1s】的状态正在变更为%2s状态,不能进行业务操作", "PaymentContSubmitOp_3", "ec-ecpf-opplugin", new Object[0]), contName, ContractStatusEnum.PAUSE.getName())); + } + + if (relieveExist) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1s】的状态正在变更为%2s状态,不能进行业务操作", "PaymentContSubmitOp_3", "ec-ecpf-opplugin", new Object[0]), contName, ContractStatusEnum.RELIEVE.getName())); + } + + if (closedExist) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1s】的状态正在变更为%2s状态,不能进行业务操作", "PaymentContSubmitOp_3", "ec-ecpf-opplugin", new Object[0]), contName, ContractStatusEnum.CLOSED.getName())); + } + + if (runningExist) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1s】的状态正在变更为%2s状态,不能进行业务操作", "PaymentContSubmitOp_3", "ec-ecpf-opplugin", new Object[0]), contName, ContractStatusEnum.RUNNING.getName())); + } + + Set contStatusSet = new HashSet(4); + contStatusSet.add(ContractStatusEnum.PAUSE.getValue()); + contStatusSet.add(ContractStatusEnum.RELIEVE.getValue()); + contStatusSet.add(ContractStatusEnum.OVERSETTLE.getValue()); + if (contStatusSet.contains(contStatus)) { + this.addMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1s】的合同状态为%2s状态,是否继续,请确认?", "PaymentContSubmitOp_4", "ec-ecpf-opplugin", new Object[0]), contName, ContractStatusEnum.getEnumByValue(contStatus).getName()), ErrorLevel.Warning); + } + } + } + } + } + } + + } + }); + } +} From 5f0e76c04ec083ef2ccd514e964f5757135d4241 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Tue, 17 Jun 2025 17:03:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=8D=95=E6=8F=90=E4=BA=A4=E5=AE=A1=E6=A0=B8=E5=8F=8D=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=93=8D=E4=BD=9C=E6=8F=92=E4=BB=B6=E4=BA=8C=E5=BC=80?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=8F=92=E4=BB=B6=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/operate/PaymentApplyFundOpExt.java | 232 ++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/PaymentApplyFundOpExt.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/PaymentApplyFundOpExt.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/PaymentApplyFundOpExt.java new file mode 100644 index 0000000..09592fc --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/PaymentApplyFundOpExt.java @@ -0,0 +1,232 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package zcgj.zcdev.zcdev.pr.plugin.operate; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.EntityMetadataCache; +import kd.bos.entity.MainEntityType; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.AddValidatorsEventArgs; +import kd.bos.entity.plugin.PreparePropertysEventArgs; +import kd.bos.entity.plugin.args.EndOperationTransactionArgs; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.DeleteServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.ec.basedata.common.enums.PlanAmtTypeEnum; +import kd.ec.contract.opplugin.fund.validator.PaymentDeductionValidator; +import kd.ec.contract.opplugin.fund.validator.PaymentMaxAmountValidator; +import kd.ec.contract.opplugin.fund.validator.PaymentPlanValidator; +import kd.ec.contract.opplugin.fund.validator.PaymentProgressValidator; +import kd.ec.contract.opplugin.fund.validator.PaymentReferenceValidator; +import kd.ec.contract.opplugin.fund.validator.PaymentTypeValidator; + +public class PaymentApplyFundOpExt extends AbstractOperationServicePlugIn { + public PaymentApplyFundOpExt() { + } + + public void onPreparePropertys(PreparePropertysEventArgs e) { + List fieldKeys = e.getFieldKeys(); + fieldKeys.add("org"); + fieldKeys.add("billstatus"); + fieldKeys.add("contract"); + fieldKeys.add("amount"); + fieldKeys.add("applyoftaxamount"); + fieldKeys.add("maxapplyamt"); + fieldKeys.add("thisapplyoftax"); + fieldKeys.add("thisdeduction"); + fieldKeys.add("controlrate"); + fieldKeys.add("paymenttype"); + fieldKeys.add("totalshowpayamt"); + fieldKeys.add("paynode"); + fieldKeys.add("applyinvoftaxamt"); + fieldKeys.add("subentryentity"); + fieldKeys.add("maxshouldpayamt"); + fieldKeys.add("paynodetext"); + fieldKeys.add("nodedate"); + } + + public void onAddValidators(AddValidatorsEventArgs e) { + e.getValidators().add(new PaymentTypeValidator()); + e.getValidators().add(new PaymentPlanValidator()); + e.getValidators().add(new PaymentMaxAmountValidator()); + e.getValidators().add(new PaymentProgressValidator()); + e.getValidators().add(new PaymentDeductionValidator()); + e.getValidators().add(new PaymentReferenceValidator()); + } + + public void endOperationTransaction(EndOperationTransactionArgs e) { + String operationKey = e.getOperationKey(); + DynamicObject[] dataEntities = e.getDataEntities(); + switch (operationKey) { + case "audit": + this.updateContTypeAmtTotalShowAmt(dataEntities); + break; + case "unaudit": + this.updateContTypeAmtTotalShowAmtWhenUnAudit(dataEntities); + } + + } + + protected void updateContTypeAmtTotalShowAmt(DynamicObject[] dataEntities) { + Map contractDeductionMap = new HashMap(16); + DynamicObject[] var3 = dataEntities; + int var4 = dataEntities.length; + + label50: + for(int var5 = 0; var5 < var4; ++var5) { + DynamicObject paymentApply = var3[var5]; + DynamicObjectCollection entryCol = paymentApply.getDynamicObjectCollection("entryentity"); + Iterator var8 = entryCol.iterator(); + + while(true) { + while(true) { + if (!var8.hasNext()) { + continue label50; + } + + DynamicObject entry = (DynamicObject)var8.next(); + DynamicObject contract = entry.getDynamicObject("contract"); + BigDecimal thisApplyOfTaxAmt = entry.getBigDecimal("applyoftaxamount"); + BigDecimal deduction = entry.getBigDecimal("thisdeduction"); + BigDecimal contractDeduction = (BigDecimal)contractDeductionMap.getOrDefault(contract.getLong("id"), BigDecimal.ZERO); + contractDeductionMap.put(contract.getLong("id"), contractDeduction.add(deduction)); + String type = entry.getString("paymenttype"); + QFilter contractFilter = new QFilter("contract", "=", contract.getLong("id")); + QFilter typeFilter = new QFilter("type", "=", type); + DynamicObject node = entry.getDynamicObject("paynode"); + String nodeText = entry.getString("paynodetext"); + if (node != null) { + typeFilter.and("paynode", "=", node.getPkValue()); + } else if (StringUtils.isNotEmpty(nodeText)) { + typeFilter.and("node", "=", nodeText); + } + + DynamicObject[] contTypeAmts = BusinessDataServiceHelper.load("ecpf_conttypeamt", "totalshowamt,totaldeductionamt", new QFilter[]{contractFilter, typeFilter}); + if (contTypeAmts != null && contTypeAmts.length != 0) { + DynamicObject[] var28 = contTypeAmts; + int var26 = contTypeAmts.length; + + for(int var27 = 0; var27 < var26; ++var27) { + DynamicObject contTypeAmt = var28[var27]; + BigDecimal totalShowAmt = contTypeAmt.getBigDecimal("totalshowamt"); + contTypeAmt.set("totalshowamt", totalShowAmt.add(thisApplyOfTaxAmt)); + BigDecimal totalDeduction = contTypeAmt.getBigDecimal("totaldeductionamt"); + contTypeAmt.set("totaldeductionamt", totalDeduction.add(deduction)); + } + + SaveServiceHelper.save(contTypeAmts); + } else { + BigDecimal payRate = entry.getBigDecimal("controlrate"); + MainEntityType entityType = EntityMetadataCache.getDataEntityType("ecpf_conttypeamt"); + DynamicObject newContTypeAmtObj = new DynamicObject(entityType); + newContTypeAmtObj.set("contract", contract); + newContTypeAmtObj.set("type", type); + newContTypeAmtObj.set("ratio", payRate); + newContTypeAmtObj.set("totalshowamt", thisApplyOfTaxAmt); + newContTypeAmtObj.set("totaldeductionamt", deduction); + newContTypeAmtObj.set("paynode", entry.get("paynode")); + newContTypeAmtObj.set("node", entry.get("paynode") == null ? entry.get("paynodetext") : ""); + SaveServiceHelper.save(new DynamicObject[]{newContTypeAmtObj}); + } + } + } + } + + this.updatePrePaymentDeduction(contractDeductionMap, true); + } + + protected void updatePrePaymentDeduction(Map contractDeductionMap, boolean isAdd) { + QFilter contractFilter = new QFilter("contract", "in", contractDeductionMap.keySet()); + QFilter typeFilter = new QFilter("type", "=", PlanAmtTypeEnum.PREPAYMENT.getValue()); + DynamicObject[] contTypeAmounts = BusinessDataServiceHelper.load("ecpf_conttypeamt", "contract,totaldeductionamt", new QFilter[]{contractFilter, typeFilter}); + DynamicObject[] var6 = contTypeAmounts; + int var7 = contTypeAmounts.length; + + for(int var8 = 0; var8 < var7; ++var8) { + DynamicObject contTypeAmt = var6[var8]; + DynamicObject contract = contTypeAmt.getDynamicObject("contract"); + if (contract != null) { + BigDecimal totalDeduction = contTypeAmt.getBigDecimal("totaldeductionamt"); + contTypeAmt.set("totaldeductionamt", isAdd ? totalDeduction.add((BigDecimal)contractDeductionMap.getOrDefault(contract.getLong("id"), BigDecimal.ZERO)) : totalDeduction.subtract((BigDecimal)contractDeductionMap.getOrDefault(contract.getLong("id"), BigDecimal.ZERO))); + } + } + + SaveServiceHelper.save(contTypeAmounts); + } + + protected void updateContTypeAmtTotalShowAmtWhenUnAudit(DynamicObject[] dataEntities) { + Map contractDeductionMap = new HashMap(16); + DynamicObject[] var3 = dataEntities; + int var4 = dataEntities.length; + + label61: + for(int var5 = 0; var5 < var4; ++var5) { + DynamicObject paymentApply = var3[var5]; + DynamicObjectCollection entryCol = paymentApply.getDynamicObjectCollection("entryentity"); + Iterator var8 = entryCol.iterator(); + + while(true) { + BigDecimal thisApplyOfTaxAmt; + BigDecimal deduction; + DynamicObject[] contTypeAmts; + do { + do { + if (!var8.hasNext()) { + continue label61; + } + + DynamicObject entry = (DynamicObject)var8.next(); + DynamicObject contract = entry.getDynamicObject("contract"); + thisApplyOfTaxAmt = entry.getBigDecimal("applyoftaxamount"); + deduction = entry.getBigDecimal("thisdeduction"); + BigDecimal contractDeduction = (BigDecimal)contractDeductionMap.getOrDefault(contract.getLong("id"), BigDecimal.ZERO); + contractDeductionMap.put(contract.getLong("id"), contractDeduction.add(deduction)); + String type = entry.getString("paymenttype"); + QFilter contractFilter = new QFilter("contract", "=", contract.getLong("id")); + QFilter typeFilter = new QFilter("type", "=", type); + DynamicObject node = entry.getDynamicObject("paynode"); + String nodeText = entry.getString("paynodetext"); + if (node != null) { + typeFilter.and("paynode", "=", node.getPkValue()); + } else if (StringUtils.isNotEmpty(nodeText)) { + typeFilter.and("node", "=", nodeText); + } + + contTypeAmts = BusinessDataServiceHelper.load("ecpf_conttypeamt", "totaldeductionamt,totalshowamt,totalrealamt,ratio,source", new QFilter[]{contractFilter, typeFilter}); + } while(contTypeAmts == null); + } while(contTypeAmts.length == 0); + + DynamicObject[] var20 = contTypeAmts; + int var21 = contTypeAmts.length; + + for(int var22 = 0; var22 < var21; ++var22) { + DynamicObject contTypeAmt = var20[var22]; + BigDecimal totalShowAmt = contTypeAmt.getBigDecimal("totalshowamt"); + String source = contTypeAmt.getString("source"); + contTypeAmt.set("totalshowamt", totalShowAmt.subtract(thisApplyOfTaxAmt)); + BigDecimal totalDeduction = contTypeAmt.getBigDecimal("totaldeductionamt"); + totalDeduction = totalDeduction == null ? BigDecimal.ZERO : totalDeduction; + contTypeAmt.set("totaldeductionamt", totalDeduction.subtract(deduction)); + if (StringUtils.isBlank(source) && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalshowamt")) == 0 && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalrealamt")) == 0 && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totaldeductionamt")) == 0) { + DeleteServiceHelper.delete("ecpf_conttypeamt", new QFilter[]{new QFilter("id", "=", contTypeAmt.getLong("id"))}); + } + } + + SaveServiceHelper.save(contTypeAmts); + } + } + + this.updatePrePaymentDeduction(contractDeductionMap, false); + } +} From 59ee6ccb4267969ed9f9c948624761e3b075963e Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Tue, 17 Jun 2025 17:28:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BA=8C=E5=BC=80?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/form/PaymentTypeValidatorExt.java | 223 ++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PaymentTypeValidatorExt.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PaymentTypeValidatorExt.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PaymentTypeValidatorExt.java new file mode 100644 index 0000000..af41e73 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PaymentTypeValidatorExt.java @@ -0,0 +1,223 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package zcgj.zcdev.zcdev.pr.plugin.form; + +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.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.dataentity.utils.StringUtils; +import kd.bos.entity.EntityMetadataCache; +import kd.bos.entity.ExtendedDataEntity; +import kd.bos.entity.MainEntityType; +import kd.bos.entity.ValueMapItem; +import kd.bos.entity.property.ComboProp; +import kd.bos.entity.validate.AbstractValidator; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.ec.basedata.common.enums.BillStatusEnum; +import kd.ec.basedata.common.enums.ContractStatusEnum; +import kd.ec.basedata.common.enums.PlanAmtTypeEnum; + +public class PaymentTypeValidatorExt extends AbstractValidator { + public PaymentTypeValidatorExt() { + } + + public void validate() { + String operateKey = this.getOperateKey(); + if (StringUtils.equals("submit", operateKey)) { + this.validatePayType(); + } + + } + + protected void validatePayType() { + Set balanceContractIds = new HashSet(16); + Set bondContractIds = new HashSet(16); + Set otherSubmitContractIds = new HashSet(16); + Set submitBalanceContractIds = new HashSet(16); + Set contractIds = new HashSet(16); + Set paymentIds = new HashSet(16); + ExtendedDataEntity[] dataEntities = this.getDataEntities(); + ExtendedDataEntity[] var8 = dataEntities; + int var9 = dataEntities.length; + + for(int var10 = 0; var10 < var9; ++var10) { + ExtendedDataEntity dataEntity = var8[var10]; + DynamicObject bill = dataEntity.getDataEntity(); + paymentIds.add(bill.getLong("id")); + DynamicObjectCollection entries = bill.getDynamicObjectCollection("entryentity"); + Iterator var14 = entries.iterator(); + + while(var14.hasNext()) { + DynamicObject entry = (DynamicObject)var14.next(); + String payType = entry.getString("paymenttype"); + long contractId = entry.getDynamicObject("contract").getLong("id"); + contractIds.add(contractId); + if (StringUtils.equals(PlanAmtTypeEnum.BALANCE.getValue(), payType)) { + balanceContractIds.add(contractId); + submitBalanceContractIds.add(contractId); + } else if (StringUtils.equals(PlanAmtTypeEnum.BOND.getValue(), payType)) { + bondContractIds.add(contractId); + } else { + otherSubmitContractIds.add(contractId); + } + } + } + + QFilter filter = new QFilter("entryentity.contract", "in", contractIds); + filter.and("id", "not in", paymentIds); + filter.and("billstatus", "in", new String[]{BillStatusEnum.SUBMIT.getValue(), BillStatusEnum.AUDIT.getValue()}); + DynamicObjectCollection payments = QueryServiceHelper.query("ec_paymentapply", "billstatus,entryentity.contract,entryentity.paymenttype", new QFilter[]{filter}); + Iterator var24 = payments.iterator(); + + while(var24.hasNext()) { + DynamicObject payment = (DynamicObject)var24.next(); + String payType = payment.getString("entryentity.paymenttype"); + long contractId = payment.getLong("entryentity.contract"); + if (StringUtils.equals(PlanAmtTypeEnum.BALANCE.getValue(), payType)) { + balanceContractIds.add(contractId); + if (StringUtils.equals(BillStatusEnum.SUBMIT.getValue(), payment.getString("billstatus"))) { + submitBalanceContractIds.add(contractId); + } + } else if (StringUtils.equals(PlanAmtTypeEnum.BOND.getValue(), payType)) { + bondContractIds.add(contractId); + } else if (StringUtils.equals(BillStatusEnum.SUBMIT.getValue(), payment.getString("billstatus"))) { + otherSubmitContractIds.add(contractId); + } + } + + Map> contractPayPlanTypes = this.getContractPayPlanTypes(contractIds); + Map payTypeCombo = this.getPayTypeCombo(); + ExtendedDataEntity[] var29 = dataEntities; + int var31 = dataEntities.length; + + for(int var32 = 0; var32 < var31; ++var32) { + ExtendedDataEntity dataEntity = var29[var32]; + DynamicObject bill = dataEntity.getDataEntity(); + DynamicObjectCollection entries = bill.getDynamicObjectCollection("entryentity"); + Iterator var18 = entries.iterator(); + + while(var18.hasNext()) { + DynamicObject entry = (DynamicObject)var18.next(); + DynamicObject contract = entry.getDynamicObject("contract"); + String payType = entry.getString("paymenttype"); + this.contractPayPlanValidate(dataEntity, contract, payType, contractPayPlanTypes, payTypeCombo); + this.prePayTypeValidate(dataEntity, contract, payType); + this.payStageValidate(balanceContractIds, bondContractIds, payTypeCombo, dataEntity, contract, payType); + this.payMethodValidate(dataEntity, contract, payType); + this.balanceTypeValidate(otherSubmitContractIds, dataEntity, contract, payType); + this.bondTypeValidate(submitBalanceContractIds, otherSubmitContractIds, dataEntity, contract, payType); + } + } + + } + + protected void contractPayPlanValidate(ExtendedDataEntity dataEntity, DynamicObject contract, String payType, Map> contractPayPlanTypes, Map payTypeCombo) { + Set types = (Set)contractPayPlanTypes.get(contract.getLong("id")); + if (types != null && !types.contains(payType) && !StringUtils.equals(PlanAmtTypeEnum.BALANCE.getValue(), payType)) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1$s】付款条件中不包含付款类型【%2$s】,不允许付款。", "PaymentTypeValidator_8", "ec-contract-opplugin", new Object[0]), contract.getString("name"), payTypeCombo.getOrDefault(payType, ""))); + } + + } + + protected Map> getContractPayPlanTypes(Set contractIds) { + Map> payPlanTypeMap = new HashMap(contractIds.size()); + QFilter contractFilter = new QFilter("id", "in", contractIds); + DynamicObjectCollection contracts = QueryServiceHelper.query("ec_out_contract", "id,outcontpayplanentry.paytype", new QFilter[]{contractFilter}); + + Iterator var5; + long contractId; + Set payPlanTypes; + for(var5 = contracts.iterator(); var5.hasNext(); payPlanTypeMap.put(contractId, payPlanTypes)) { + DynamicObject contract = (DynamicObject)var5.next(); + contractId = contract.getLong("id"); + payPlanTypes = (Set)payPlanTypeMap.getOrDefault(contractId, new HashSet(4)); + String type = contract.getString("outcontpayplanentry.paytype"); + if (StringUtils.isNotEmpty(type)) { + payPlanTypes.add(type); + } + } + + var5 = payPlanTypeMap.values().iterator(); + + while(var5.hasNext()) { + Set planTypes = (Set)var5.next(); + if (planTypes.isEmpty()) { + planTypes.add(PlanAmtTypeEnum.PREPAYMENT.getValue()); + planTypes.add(PlanAmtTypeEnum.SETTLEPAYMENT.getValue()); + planTypes.add(PlanAmtTypeEnum.BALANCE.getValue()); + planTypes.add(PlanAmtTypeEnum.BOND.getValue()); + } + } + + return payPlanTypeMap; + } + + protected void bondTypeValidate(Set submitBalanceContractIds, Set otherSubmitContractIds, ExtendedDataEntity dataEntity, DynamicObject contract, String payType) { + long contractId = contract.getLong("id"); + if (StringUtils.equals(payType, PlanAmtTypeEnum.BOND.getValue()) && (otherSubmitContractIds.contains(contractId) || submitBalanceContractIds.contains(contractId))) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%s】存在其他在途付款申请,无法进行质保金支付。", "PaymentTypeValidator_1", "ec-contract-opplugin", new Object[0]), contract.getString("name"))); + } + + } + + protected void balanceTypeValidate(Set otherSubmitContractIds, ExtendedDataEntity dataEntity, DynamicObject contract, String payType) { + if (StringUtils.equals(payType, PlanAmtTypeEnum.BALANCE.getValue()) && otherSubmitContractIds.contains(contract.getLong("id"))) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%s】存在其他在途付款申请,无法进行尾款支付。", "PaymentTypeValidator_2", "ec-contract-opplugin", new Object[0]), contract.getString("name"))); + } + + } + + protected void payMethodValidate(ExtendedDataEntity dataEntity, DynamicObject contract, String payType) { + if (contract.getBoolean("ispaybytasknode") && StringUtils.equals(PlanAmtTypeEnum.SETTLEPAYMENT.getValue(), payType)) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%s】为按节点支付,无法进行结算款支付。", "PaymentTypeValidator_3", "ec-contract-opplugin", new Object[0]), contract.getString("name"))); + } else if (!contract.getBoolean("ispaybytasknode") && StringUtils.equals(PlanAmtTypeEnum.PROGRESSPAYMENT.getValue(), payType)) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%s】为按月支付,无法进行进度款支付。", "PaymentTypeValidator_4", "ec-contract-opplugin", new Object[0]), contract.getString("name"))); + } + + } + + protected void payStageValidate(Set balanceContractIds, Set bondContractIds, Map payTypeCombo, ExtendedDataEntity dataEntity, DynamicObject contract, String payType) { + if (bondContractIds.contains(contract.getLong("id")) && !StringUtils.equals(PlanAmtTypeEnum.BOND.getValue(), payType)) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1$s】已进入质保金支付阶段,无法进行%2$s支付。", "PaymentTypeValidator_9", "ec-contract-opplugin", new Object[0]), contract.getString("name"), payTypeCombo.get(payType))); + } else if (balanceContractIds.contains(contract.getLong("id")) && !StringUtils.equals(PlanAmtTypeEnum.BALANCE.getValue(), payType) && !StringUtils.equals(PlanAmtTypeEnum.BOND.getValue(), payType)) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1$s】已进入尾款支付阶段,无法进行%2$s支付。", "PaymentTypeValidator_10", "ec-contract-opplugin", new Object[0]), contract.getString("name"), payTypeCombo.get(payType))); + } + + } + + protected void prePayTypeValidate(ExtendedDataEntity dataEntity, DynamicObject contract, String payType) { + String contStatus = contract.getString("contstatus"); + if (StringUtils.equals(contStatus, ContractStatusEnum.OVERSETTLE.getValue()) && StringUtils.equals(PlanAmtTypeEnum.PREPAYMENT.getValue(), payType)) { + this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%s】已决算,无法进行预付款支付。", "PaymentTypeValidator_7", "ec-contract-opplugin", new Object[0]), contract.getString("name"))); + } + + } + + protected Map getPayTypeCombo() { + MainEntityType paymentType = EntityMetadataCache.getDataEntityType("ec_paymentapply"); + DynamicObject paymentBill = new DynamicObject(paymentType); + DynamicObjectType entryType = paymentBill.getDynamicObjectCollection("entryentity").getDynamicObjectType(); + ComboProp payTypeCombo = (ComboProp)entryType.getProperty("paymenttype"); + List comboItems = payTypeCombo.getComboItems(); + Map payTypeComboMap = new HashMap(comboItems.size()); + Iterator var7 = comboItems.iterator(); + + while(var7.hasNext()) { + ValueMapItem comboItem = (ValueMapItem)var7.next(); + payTypeComboMap.put(comboItem.getValue(), comboItem.getName().getLocaleValue()); + } + + return payTypeComboMap; + } +}