2024-11-27 05:52:58 +00:00
|
|
|
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;
|
2025-02-11 09:44:49 +00:00
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
2024-11-27 05:52:58 +00:00
|
|
|
|
|
|
|
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();
|
2025-02-11 09:44:49 +00:00
|
|
|
DynamicObjectCollection qeugBondentrys;
|
|
|
|
try {
|
|
|
|
qeugBondentrys = dataEntity.getDynamicObjectCollection("qeug_bondentry");
|
|
|
|
}catch (Exception e){
|
|
|
|
dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(),"recon_contractbill");
|
|
|
|
qeugBondentrys = dataEntity.getDynamicObjectCollection("qeug_bondentry");
|
|
|
|
}
|
2024-11-27 05:52:58 +00:00
|
|
|
BigDecimal qeugMarginlevel = BigDecimal.ZERO;
|
2025-02-09 08:33:38 +00:00
|
|
|
if (!qeugBondentrys.isEmpty()) {
|
2024-11-27 05:52:58 +00:00
|
|
|
for (DynamicObject qeugBondentry : qeugBondentrys) {
|
|
|
|
qeugMarginlevel = qeugMarginlevel.add(qeugBondentry.getBigDecimal("qeug_marginlevel"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (qeugMarginlevel.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
this.addErrorMessage(extendedDataEntity, "保证金明细:保证金比例(%)之和不能大于100");
|
|
|
|
}
|
2025-02-11 09:44:49 +00:00
|
|
|
//合同清单(定额)
|
|
|
|
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, "合同清单(定额)的金额之和不能大于合同金额");
|
|
|
|
}
|
2024-11-27 05:52:58 +00:00
|
|
|
}
|
|
|
|
break;
|
2025-02-09 08:33:38 +00:00
|
|
|
case "qeug_attatchment":
|
|
|
|
for (ExtendedDataEntity extendedDataEntity : dataEntities1) {
|
|
|
|
//合同正文(盖章件)不能为空
|
|
|
|
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
|
|
|
DynamicObjectCollection attachmentpanel = dataEntity.getDynamicObjectCollection("attachmentpanel");
|
|
|
|
if (attachmentpanel.isEmpty()) {
|
|
|
|
this.addMessage(extendedDataEntity, "合同正文(盖章件)不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2024-11-27 05:52:58 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|