定标环节如果定标总金额大于采购控制金额不允许提交

This commit is contained in:
李贵强 2025-03-15 14:53:44 +08:00
parent 0ec2c7e885
commit e4ea1655f8
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,52 @@
package shkd.repc.rebm.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.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
/**
* 动态表单插件
* 定标环节如果定标总金额大于采购控制金额不允许提交
*/
public class DecisionAmountValidator extends AbstractValidator {
@Override
public void validate() {
ExtendedDataEntity[] dataEntities = this.getDataEntities();
if (dataEntities == null || dataEntities.length == 0) {
return;
}
for (ExtendedDataEntity dataEntity : dataEntities) {
if (dataEntity == null) {
continue;
}
DynamicObject bill = dataEntity.getDataEntity();
DynamicObject decisionBill = BusinessDataServiceHelper.loadSingle(bill.getLong("id"), "rebm_decision");
if (decisionBill == null) {
continue;
}
//采购控制明细
DynamicObjectCollection bottomEntry = decisionBill.getDynamicObjectCollection("bottomentry");
if (!bottomEntry.isEmpty()){
BigDecimal allEntryAmount=BigDecimal.ZERO;
for (DynamicObject dynamicObject : bottomEntry) {
//采购控制金额含税
BigDecimal botControlAmount = dynamicObject.getBigDecimal("botcontrolamount");
allEntryAmount=allEntryAmount.add(botControlAmount);
}
//定标总金额
BigDecimal amount = decisionBill.getBigDecimal("amount");
if (amount.compareTo(allEntryAmount)>0){
this.addErrorMessage(dataEntity, "提交失败!定标总金额不能大于采购控制金额(含税)!");
}
}
}
}
}

View File

@ -51,7 +51,7 @@ public class ConNoTextValidator extends AbstractValidator {
// 计算占用金额并收集提示信息
BigDecimal occupationAmount = BigDecimal.ZERO;
StringBuilder message = new StringBuilder();
message.append("申请超额:\n");
for (DynamicObject otherBill : relatedBills) {
if (otherBill.getLong("id") == currentBill.getLong("id")) {
continue; // 跳过当前单据