校验器bug优化

This commit is contained in:
李贵强 2025-02-25 18:05:38 +08:00
parent 85169a3d9b
commit 49146f3849
1 changed files with 23 additions and 19 deletions

View File

@ -5,6 +5,7 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.ExtendedDataEntity; import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.validate.AbstractValidator; import kd.bos.entity.validate.AbstractValidator;
import kd.bos.form.plugin.AbstractFormPlugin; import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -21,27 +22,30 @@ public class ProjectBillSubmitValidator extends AbstractValidator {
for (ExtendedDataEntity dataEntity : dataEntities) { for (ExtendedDataEntity dataEntity : dataEntities) {
if (dataEntity != null) { if (dataEntity != null) {
DynamicObject bill = dataEntity.getDataEntity(); DynamicObject bill = dataEntity.getDataEntity();
//产品构成 DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle( bill.getLong("id"), "repmd_projectbill");
DynamicObjectCollection productEntry = bill.getDynamicObjectCollection("productentry"); if (null!=dynamicObject){
if (null != productEntry && productEntry.size() != 0) { //产品构成
boolean hasBeenCalculated = true; DynamicObjectCollection productEntry = dynamicObject.getDynamicObjectCollection("productentry");
for (int i = 0; i < productEntry.size(); i++) { if (null != productEntry && productEntry.size() != 0) {
//改建后建筑面积 boolean hasBeenCalculated = true;
BigDecimal buildingArea = productEntry.get(i).getBigDecimal("productentry_buildingarea"); for (int i = 0; i < productEntry.size(); i++) {
DynamicObjectCollection collections = productEntry.get(i).getDynamicObjectCollection("qeug_subentryentity"); //改建后建筑面积
if (null != collections && collections.size() != 0) { BigDecimal buildingArea = productEntry.get(i).getBigDecimal("productentry_buildingarea");
BigDecimal total = collections.stream() DynamicObjectCollection collections = productEntry.get(i).getDynamicObjectCollection("qeug_subentryentity");
.map(entry -> entry.getBigDecimal("qeug_jrgsbsz")) // 获取每个条目的 BigDecimal if (null != collections && collections.size() != 0) {
.filter(value -> value != null) // 过滤掉空值 BigDecimal total = collections.stream()
.reduce(BigDecimal.ZERO, BigDecimal::add); .map(entry -> entry.getBigDecimal("qeug_jrgsbsz")) // 获取每个条目的 BigDecimal
if (buildingArea.compareTo(total)!=0){ .filter(value -> value != null) // 过滤掉空值
hasBeenCalculated = false; .reduce(BigDecimal.ZERO, BigDecimal::add);
break; if (buildingArea.compareTo(total)!=0){
hasBeenCalculated = false;
break;
}
} }
} }
} if (!hasBeenCalculated){
if (!hasBeenCalculated){ this.addErrorMessage(dataEntity, "有尚未计算的【面积数据】,请点击【面积汇总】按钮!");
this.addErrorMessage(dataEntity, "有尚未计算的【面积数据】,请点击【面积汇总】按钮!"); }
} }
} }
} }