diff --git a/main/java/shkd/repc/recon/opplugin/ContractOPPlugin.java b/main/java/shkd/repc/recon/opplugin/ContractOPPlugin.java index a97b72c..0cbbf9f 100644 --- a/main/java/shkd/repc/recon/opplugin/ContractOPPlugin.java +++ b/main/java/shkd/repc/recon/opplugin/ContractOPPlugin.java @@ -8,6 +8,7 @@ import kd.bos.entity.plugin.AddValidatorsEventArgs; import kd.bos.entity.validate.AbstractValidator; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; +import kd.bos.servicehelper.BusinessDataServiceHelper; import java.math.BigDecimal; @@ -27,7 +28,13 @@ public class ContractOPPlugin extends AbstractOperationServicePlugIn { for (ExtendedDataEntity extendedDataEntity : dataEntities1) { //保证金明细 DynamicObject dataEntity = extendedDataEntity.getDataEntity(); - DynamicObjectCollection qeugBondentrys = dataEntity.getDynamicObjectCollection("qeug_bondentry"); + DynamicObjectCollection qeugBondentrys; + try { + qeugBondentrys = dataEntity.getDynamicObjectCollection("qeug_bondentry"); + }catch (Exception e){ + dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(),"recon_contractbill"); + qeugBondentrys = dataEntity.getDynamicObjectCollection("qeug_bondentry"); + } BigDecimal qeugMarginlevel = BigDecimal.ZERO; if (!qeugBondentrys.isEmpty()) { for (DynamicObject qeugBondentry : qeugBondentrys) { @@ -37,6 +44,26 @@ public class ContractOPPlugin extends AbstractOperationServicePlugIn { if (qeugMarginlevel.compareTo(BigDecimal.valueOf(100)) > 0) { this.addErrorMessage(extendedDataEntity, "保证金明细:保证金比例(%)之和不能大于100"); } + //合同清单(定额) + DynamicObjectCollection invoiceentryinfos; + try { + //合同监控列表点击提交会提示找不到:qeug_invoiceentryinfo属性 + invoiceentryinfos = dataEntity.getDynamicObjectCollection("qeug_invoiceentryinfo"); + }catch (Exception e){ + dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(),"recon_contractbill"); + invoiceentryinfos = dataEntity.getDynamicObjectCollection("qeug_invoiceentryinfo"); + } + BigDecimal qeug_amounts = BigDecimal.ZERO;//金额(元)_合计 + if (!invoiceentryinfos.isEmpty()) { + for (DynamicObject invoiceentryinfo : invoiceentryinfos) { + qeug_amounts = qeug_amounts.add(invoiceentryinfo.getBigDecimal("qeug_amount")); + } + } + BigDecimal amount = dataEntity.getBigDecimal("amount");//合同金额 + // 检查 qeug_amounts 是否大于 amount + if (qeug_amounts.compareTo(amount) > 0) { + this.addErrorMessage(extendedDataEntity, "合同清单(定额)的金额之和不能大于合同金额"); + } } break; case "qeug_attatchment":