无合同付款不校验合同相关信息

This commit is contained in:
owan 2025-06-13 10:17:19 +08:00
parent 5e462e8b94
commit b8bcdb5249
2 changed files with 331 additions and 51 deletions

View File

@ -0,0 +1,276 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package kd.ec.contract.opplugin.fund;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
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.BeginOperationTransactionArgs;
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
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.contract.opplugin.fund.validator.PaymentRegisterFundValidator;
public class PaymentRegisterFundOp extends AbstractOperationServicePlugIn {
private static final Log log = LogFactory.getLog(PaymentRegisterFundOp.class);
public PaymentRegisterFundOp() {
}
public void onPreparePropertys(PreparePropertysEventArgs e) {
List<String> fieldKeys = e.getFieldKeys();
fieldKeys.add("thispaymentoftaxamount");
fieldKeys.add("contract");
fieldKeys.add("paytype");
fieldKeys.add("paymentapply");
fieldKeys.add("controlrate");
fieldKeys.add("paynode");
fieldKeys.add("paynodetext");
}
public void onAddValidators(AddValidatorsEventArgs e) {
e.getValidators().add(new PaymentRegisterFundValidator());
}
public void beginOperationTransaction(BeginOperationTransactionArgs e) {
}
public void endOperationTransaction(EndOperationTransactionArgs e) {
String operationKey = e.getOperationKey();
DynamicObject[] dataEntities = e.getDataEntities();
switch (operationKey) {
case "audit":
log.info("执行PaymentRegisterFundOp的审核操作开始更新合同付款类型实付金额");
this.updateContTypeAmtTotalRealAmt(dataEntities);
log.info("执行PaymentRegisterFundOp的审核操作完成更新合同付款类型实付金额");
log.info("执行PaymentRegisterFundOp的审核操作开始更新请款单实付金额");
this.updateInApplyRealPayAmt(dataEntities, true);
log.info("执行PaymentRegisterFundOp的审核操作完成更新请款单实付金额");
break;
case "unaudit":
this.updateContTypeAmtTotalRealAmtWhenUnAudit(dataEntities);
this.updateInApplyRealPayAmt(dataEntities, false);
}
}
protected void updateInApplyRealPayAmt(DynamicObject[] dataEntities, boolean isAudit) {
BigDecimal ratio = BigDecimal.ONE;
if (!isAudit) {
ratio = BigDecimal.ZERO.subtract(ratio);
}
DynamicObject[] var4 = dataEntities;
int var5 = dataEntities.length;
label69:
for(int var6 = 0; var6 < var5; ++var6) {
DynamicObject object = var4[var6];
DynamicObjectCollection entryCol = object.getDynamicObjectCollection("entryentity");
Iterator var9 = entryCol.iterator();
while(true) {
DynamicObject paymentApplyF7;
DynamicObject contract;
BigDecimal thisOfTaxAmt;
String payType;
do {
if (!var9.hasNext()) {
continue label69;
}
DynamicObject entry = (DynamicObject)var9.next();
paymentApplyF7 = entry.getDynamicObject("paymentapply");
contract = entry.getDynamicObject("contract");
thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount");
thisOfTaxAmt = thisOfTaxAmt.multiply(ratio);
payType = entry.getString("paytype");
} while(paymentApplyF7 == null);
QFilter paymentApplyFilter = new QFilter("id", "=", paymentApplyF7.getLong("id"));
DynamicObject paymentApply = BusinessDataServiceHelper.loadSingle("ec_paymentapply", "realpayamt,billcompletepay,ismulticurrency,exchangerate,stdrealpayamt,entryentity,contract,paymenttype,applyoftaxamount,thisrealpayamt,thiswaitpayamt,completepay", new QFilter[]{paymentApplyFilter});
DynamicObjectCollection paymentEntryCol = paymentApply.getDynamicObjectCollection("entryentity");
boolean billcompletepay = true;
Iterator var19 = paymentEntryCol.iterator();
while(var19.hasNext()) {
DynamicObject paymentEntry = (DynamicObject)var19.next();
String applyPayType = paymentEntry.getString("paymenttype");
DynamicObject applyContract = paymentEntry.getDynamicObject("contract");
if (contract != null && applyContract != null && StringUtils.equals(contract.getString("id"), applyContract.getString("id")) && StringUtils.equals(payType, applyPayType)) {
BigDecimal oldRealPayAmt = paymentEntry.getBigDecimal("thisrealpayamt");
BigDecimal applyOfTaxAmount = paymentEntry.getBigDecimal("applyoftaxamount");
BigDecimal thisRealPayAmt = oldRealPayAmt.add(thisOfTaxAmt);
BigDecimal thisWaitPayAmt = applyOfTaxAmount.subtract(thisRealPayAmt);
paymentEntry.set("thisrealpayamt", thisRealPayAmt);
paymentEntry.set("thiswaitpayamt", thisWaitPayAmt);
if (thisRealPayAmt.compareTo(applyOfTaxAmount) >= 0) {
paymentEntry.set("completepay", true);
} else {
paymentEntry.set("completepay", false);
}
}
}
BigDecimal totalRealpayAmt = BigDecimal.ZERO;
DynamicObject inComeEntry;
for(Iterator var28 = paymentEntryCol.iterator(); var28.hasNext(); totalRealpayAmt = totalRealpayAmt.add(inComeEntry.getBigDecimal("thisrealpayamt"))) {
inComeEntry = (DynamicObject)var28.next();
if (!inComeEntry.getBoolean("completepay")) {
billcompletepay = false;
}
}
if (paymentApply.getBoolean("ismulticurrency")) {
BigDecimal exchangerate = paymentApply.getBigDecimal("exchangerate");
BigDecimal stdRealPayAmt = totalRealpayAmt.multiply(exchangerate);
paymentApply.set("stdrealpayamt", stdRealPayAmt);
}
paymentApply.set("realpayamt", totalRealpayAmt);
paymentApply.set("billcompletepay", billcompletepay);
SaveServiceHelper.save(new DynamicObject[]{paymentApply});
}
}
}
protected void updateContTypeAmtTotalRealAmt(DynamicObject[] dataEntities) {
DynamicObject[] var2 = dataEntities;
int var3 = dataEntities.length;
label50:
for(int var4 = 0; var4 < var3; ++var4) {
DynamicObject object = var2[var4];
DynamicObjectCollection entryCol = object.getDynamicObjectCollection("entryentity");
Iterator var7 = entryCol.iterator();
while(true) {
while(true) {
if (!var7.hasNext()) {
continue label50;
}
DynamicObject entry = (DynamicObject)var7.next();
DynamicObject contract = entry.getDynamicObject("contract");
if(contract != null){
BigDecimal thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount");
String type = entry.getString("paytype");
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", "totalrealamt", new QFilter[]{contractFilter, typeFilter});
if (contTypeAmts != null && contTypeAmts.length != 0) {
DynamicObject[] var22 = contTypeAmts;
int var23 = contTypeAmts.length;
for(int var24 = 0; var24 < var23; ++var24) {
DynamicObject contTypeAmt = var22[var24];
BigDecimal totalRealAmt = contTypeAmt.getBigDecimal("totalrealamt");
contTypeAmt.set("totalrealamt", totalRealAmt.add(thisOfTaxAmt));
}
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("totalrealamt", thisOfTaxAmt);
newContTypeAmtObj.set("paynode", entry.get("paynode"));
newContTypeAmtObj.set("node", entry.get("paynode") == null ? entry.get("paynodetext") : "");
SaveServiceHelper.save(new DynamicObject[]{newContTypeAmtObj});
}
}
}
}
}
}
protected void updateContTypeAmtTotalRealAmtWhenUnAudit(DynamicObject[] dataEntities) {
DynamicObject[] var2 = dataEntities;
int var3 = dataEntities.length;
label54:
for(int var4 = 0; var4 < var3; ++var4) {
DynamicObject object = var2[var4];
DynamicObjectCollection entryCol = object.getDynamicObjectCollection("entryentity");
Iterator var7 = entryCol.iterator();
while(true) {
BigDecimal thisOfTaxAmt;
DynamicObject[] contTypeAmts;
do {
do {
if (!var7.hasNext()) {
continue label54;
}
DynamicObject entry = (DynamicObject)var7.next();
DynamicObject contract = entry.getDynamicObject("contract");
thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount");
String type = entry.getString("paytype");
QFilter contractFilter = null;
if(contract != null )
contractFilter = new QFilter("contract", "=", contract.getLong("id"));
else
contractFilter = new QFilter("contract", "=", Long.parseLong("99999999999999"));
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", "totalrealamt,totalshowamt,ratio,source", new QFilter[]{contractFilter, typeFilter});
} while(contTypeAmts == null);
} while(contTypeAmts.length == 0);
DynamicObject[] var17 = contTypeAmts;
int var18 = contTypeAmts.length;
for(int var19 = 0; var19 < var18; ++var19) {
DynamicObject contTypeAmt = var17[var19];
BigDecimal totalRealAmt = contTypeAmt.getBigDecimal("totalrealamt");
String source = contTypeAmt.getString("source");
contTypeAmt.set("totalrealamt", totalRealAmt.subtract(thisOfTaxAmt));
if (StringUtils.isBlank(source) && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalshowamt")) == 0 && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalrealamt")) == 0) {
DeleteServiceHelper.delete("ecpf_conttypeamt", new QFilter[]{new QFilter("id", "=", contTypeAmt.getLong("id"))});
}
}
SaveServiceHelper.save(contTypeAmts);
}
}
}
}

View File

@ -141,37 +141,39 @@ public class PaymentRegisterFundOpExt extends PaymentRegisterFundOp {
for(DynamicObject object : dataEntities) {
for(DynamicObject entry : object.getDynamicObjectCollection("entryentity")) {
DynamicObject contract = entry.getDynamicObject("contract");
BigDecimal thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount");
String type = entry.getString("paytype");
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", "totalrealamt", new QFilter[]{contractFilter, typeFilter});
if (contTypeAmts != null && contTypeAmts.length != 0) {
for(DynamicObject contTypeAmt : contTypeAmts) {
BigDecimal totalRealAmt = contTypeAmt.getBigDecimal("totalrealamt");
contTypeAmt.set("totalrealamt", totalRealAmt.add(thisOfTaxAmt));
if(contract!=null){
BigDecimal thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount");
String type = entry.getString("paytype");
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);
}
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("totalrealamt", thisOfTaxAmt);
newContTypeAmtObj.set("paynode", entry.get("paynode"));
newContTypeAmtObj.set("node", entry.get("paynode") == null ? entry.get("paynodetext") : "");
SaveServiceHelper.save(new DynamicObject[]{newContTypeAmtObj});
DynamicObject[] contTypeAmts = BusinessDataServiceHelper.load("ecpf_conttypeamt", "totalrealamt", new QFilter[]{contractFilter, typeFilter});
if (contTypeAmts != null && contTypeAmts.length != 0) {
for(DynamicObject contTypeAmt : contTypeAmts) {
BigDecimal totalRealAmt = contTypeAmt.getBigDecimal("totalrealamt");
contTypeAmt.set("totalrealamt", totalRealAmt.add(thisOfTaxAmt));
}
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("totalrealamt", thisOfTaxAmt);
newContTypeAmtObj.set("paynode", entry.get("paynode"));
newContTypeAmtObj.set("node", entry.get("paynode") == null ? entry.get("paynodetext") : "");
SaveServiceHelper.save(new DynamicObject[]{newContTypeAmtObj});
}
}
}
}
@ -183,30 +185,32 @@ public class PaymentRegisterFundOpExt extends PaymentRegisterFundOp {
for(DynamicObject object : dataEntities) {
for(DynamicObject entry : object.getDynamicObjectCollection("entryentity")) {
DynamicObject contract = entry.getDynamicObject("contract");
BigDecimal thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount");
String type = entry.getString("paytype");
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", "totalrealamt,totalshowamt,ratio,source", new QFilter[]{contractFilter, typeFilter});
if (contTypeAmts != null && contTypeAmts.length != 0) {
for(DynamicObject contTypeAmt : contTypeAmts) {
BigDecimal totalRealAmt = contTypeAmt.getBigDecimal("totalrealamt");
String source = contTypeAmt.getString("source");
contTypeAmt.set("totalrealamt", totalRealAmt.subtract(thisOfTaxAmt));
if (StringUtils.isBlank(source) && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalshowamt")) == 0 && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalrealamt")) == 0) {
DeleteServiceHelper.delete("ecpf_conttypeamt", new QFilter[]{new QFilter("id", "=", contTypeAmt.getLong("id"))});
}
if(contract!=null){
BigDecimal thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount");
String type = entry.getString("paytype");
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);
}
SaveServiceHelper.save(contTypeAmts);
DynamicObject[] contTypeAmts = BusinessDataServiceHelper.load("ecpf_conttypeamt", "totalrealamt,totalshowamt,ratio,source", new QFilter[]{contractFilter, typeFilter});
if (contTypeAmts != null && contTypeAmts.length != 0) {
for(DynamicObject contTypeAmt : contTypeAmts) {
BigDecimal totalRealAmt = contTypeAmt.getBigDecimal("totalrealamt");
String source = contTypeAmt.getString("source");
contTypeAmt.set("totalrealamt", totalRealAmt.subtract(thisOfTaxAmt));
if (StringUtils.isBlank(source) && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalshowamt")) == 0 && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalrealamt")) == 0) {
DeleteServiceHelper.delete("ecpf_conttypeamt", new QFilter[]{new QFilter("id", "=", contTypeAmt.getLong("id"))});
}
}
SaveServiceHelper.save(contTypeAmts);
}
}
}
}