优化代码 提交校验

This commit is contained in:
xiaoshi 2024-12-17 11:14:09 +08:00
parent e04585a124
commit 5af47982cd
2 changed files with 17 additions and 29 deletions

View File

@ -19,32 +19,27 @@ public class InContractSettlementValidator extends InContractSettleValidator {
ExtendedDataEntity[] var2 = dataEntities; ExtendedDataEntity[] var2 = dataEntities;
int var3 = dataEntities.length; int var3 = dataEntities.length;
for(int var4 = 0; var4 < var3; ++var4) { for (int var4 = 0; var4 < var3; ++var4) {
ExtendedDataEntity dataEntity = var2[var4]; ExtendedDataEntity dataEntity = var2[var4];
BigDecimal settleOfTaxAmount = dataEntity.getDataEntity().getBigDecimal("settleoftaxamount"); BigDecimal settleOfTaxAmount = dataEntity.getDataEntity().getBigDecimal("settleoftaxamount");
DynamicObject contractTemp = dataEntity.getDataEntity().getDynamicObject("contract"); DynamicObject contractTemp = dataEntity.getDataEntity().getDynamicObject("contract");
if (contractTemp == null) { if (contractTemp == null) {
return; return;
} }
long id = dataEntity.getDataEntity().getLong("id"); DynamicObjectCollection itementry = dataEntity.getDataEntity().getDynamicObjectCollection("itementry");
QFilter f1 = new QFilter("id", "=", id); if (itementry != null) {
DynamicObject incontractsettle = BusinessDataServiceHelper.loadSingle("ec_in_contract_settle", new QFilter[]{f1}); if (itementry.size() == 0) {
if(incontractsettle!=null){ this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
DynamicObjectCollection itementry = incontractsettle.getDynamicObjectCollection("itementry"); }
if(itementry == null) { DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_in_contract");
if(itementry.isEmpty()) { BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount");
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); BigDecimal totalOfTaxAmount = contract.getBigDecimal("totaloftaxamount");
} DynamicObject contractType = contract.getDynamicObject("contracttype");
DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_in_contract"); DynamicObject contractAttr = contractType == null ? null : contractType.getDynamicObject("contattr");
BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount"); boolean validateAmount = true;
BigDecimal totalOfTaxAmount = contract.getBigDecimal("totaloftaxamount"); if (contractAttr != null) {
DynamicObject contractType = contract.getDynamicObject("contracttype"); contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr");
DynamicObject contractAttr = contractType == null ? null : contractType.getDynamicObject("contattr"); validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype"));
boolean validateAmount = true;
if (contractAttr != null) {
contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr");
validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype"));
}
} }
} }
// DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap"); // DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap");

View File

@ -17,12 +17,8 @@ public class OutContractSettlementValidator extends OutContractSettleValidator {
{ {
BigDecimal settleOfTaxAmount = dataEntity.getDataEntity().getBigDecimal("settleoftaxamount"); BigDecimal settleOfTaxAmount = dataEntity.getDataEntity().getBigDecimal("settleoftaxamount");
DynamicObject contractTemp = dataEntity.getDataEntity().getDynamicObject("contract"); DynamicObject contractTemp = dataEntity.getDataEntity().getDynamicObject("contract");
long id = dataEntity.getDataEntity().getLong("id");
QFilter f1 = new QFilter("id", "=", id); DynamicObjectCollection itementry = dataEntity.getDataEntity().getDynamicObjectCollection("itementry");
DynamicObject incontractsettle = BusinessDataServiceHelper.loadSingle("ec_in_contract_settle", new QFilter[]{f1});
if(incontractsettle!=null){
DynamicObjectCollection itementry = incontractsettle.getDynamicObjectCollection("itementry");
// DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap");
if(itementry.isEmpty()) { if(itementry.isEmpty()) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
} }
@ -48,9 +44,6 @@ public class OutContractSettlementValidator extends OutContractSettleValidator {
return true; return true;
} }
} }
}
} }
return true;
} }
} }