付款申请单提交审核反审核操作插件二开系统插件标记
This commit is contained in:
parent
9176867a2a
commit
5f0e76c04e
|
@ -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<String> 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<Long, BigDecimal> 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<Long, BigDecimal> 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<Long, BigDecimal> 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue