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] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E7=94=B3=E8=AF=B7=E5=8D=95?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=AE=A1=E6=A0=B8=E5=8F=8D=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=8F=92=E4=BB=B6=E4=BA=8C=E5=BC=80=E7=B3=BB?= =?UTF-8?q?=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); + } +}