package shkd.repc.recon.opplugin; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.entity.ExtendedDataEntity; import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.AddValidatorsEventArgs; import kd.bos.entity.validate.AbstractValidator; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; import java.math.BigDecimal; public class ContractOPPlugin extends AbstractOperationServicePlugIn { private static final Log logger = LogFactory.getLog(ContractOPPlugin.class); @Override public void onAddValidators(AddValidatorsEventArgs e) { super.onAddValidators(e); e.addValidator(new AbstractValidator() { @Override public void validate() { String operateKey = this.getOperateKey(); ExtendedDataEntity[] dataEntities1 = this.getDataEntities(); switch (operateKey) { case "submit": for (ExtendedDataEntity extendedDataEntity : dataEntities1) { //保证金明细 DynamicObject dataEntity = extendedDataEntity.getDataEntity(); DynamicObjectCollection qeugBondentrys = dataEntity.getDynamicObjectCollection("qeug_bondentry"); BigDecimal qeugMarginlevel = BigDecimal.ZERO; if (qeugBondentrys.size() > 0) { for (DynamicObject qeugBondentry : qeugBondentrys) { qeugMarginlevel = qeugMarginlevel.add(qeugBondentry.getBigDecimal("qeug_marginlevel")); } } if (qeugMarginlevel.compareTo(BigDecimal.valueOf(100)) > 0) { this.addErrorMessage(extendedDataEntity, "保证金明细:保证金比例(%)之和不能大于100"); } } break; default: break; } } }); } }