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