项目建立提交计算校验器
This commit is contained in:
parent
bb8b370172
commit
4ecd7d8f64
|
@ -0,0 +1,51 @@
|
||||||
|
package shkd.repc.repmd.formplugin.validators;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
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.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态表单插件
|
||||||
|
*/
|
||||||
|
public class ProjectBillSubmitValidator extends AbstractValidator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate() {
|
||||||
|
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||||
|
if (dataEntities != null && dataEntities.length >= 1) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasBeenCalculated){
|
||||||
|
this.addErrorMessage(dataEntity, "有尚未计算的【面积数据】,请点击【面积汇总】按钮!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue