二开系统插件-企业成本核算提交操作插件添加

This commit is contained in:
xuhaihui 2025-11-24 16:46:51 +08:00
parent dffdba4772
commit adb793af06
1 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,102 @@
package zcgj.zcdev.zcdev.pr.plugin.operate;
import ec.ecco.opplugin.ContractCostMustInputOP;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.resource.ResManager;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.validate.AbstractValidator;
import kd.ec.basedata.common.enums.CostControlModelEnum;
import kd.ec.basedata.common.utils.EcProjectHelper;
import java.util.Iterator;
import java.util.List;
/**
* 二开系统插件-企业成本核算提交操作插件
*/
public class ContractCostMustInputOPExt extends AbstractOperationServicePlugIn {
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
e.getFieldKeys().add("costaccount");
e.getFieldKeys().add("cbs");
e.getFieldKeys().add("boq");
e.getFieldKeys().add("resource");
e.getFieldKeys().add("unitproject");
}
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
e.getValidators().add(new OtestValidator());
}
private class OtestValidator extends AbstractValidator {
private OtestValidator() {
}
public void validate() {
String key = this.getOperateKey();
if (StringUtils.equals(key, "submit")) {
ExtendedDataEntity[] dataEntities = this.getDataEntities();
ExtendedDataEntity[] var3 = dataEntities;
int var4 = dataEntities.length;
for (int var5 = 0; var5 < var4; ++var5) {
ExtendedDataEntity extendedDataEntity = var3[var5];
DynamicObject dynamicObject = extendedDataEntity.getDataEntity();
DynamicObjectCollection collection = dynamicObject.getDynamicObjectCollection("entryentity");
if (collection != null) {
for (int i = 0; i < collection.size(); ++i) {
DynamicObject entry = (DynamicObject) collection.get(i);
DynamicObject project = entry.getDynamicObject("project");
if (project != null) {
Long projectId = project.getLong("id");
List<String> modelList = EcProjectHelper.getCostControlModelList(projectId);
Iterator var14 = modelList.iterator();
while (var14.hasNext()) {
String string = (String) var14.next();
DynamicObject rs;
if (StringUtils.equals(string, CostControlModelEnum.CBS.getValue())) {
/* rs = entry.getDynamicObject("cbs");
if (rs == null) {
this.addErrorMessage(extendedDataEntity, String.format(ResManager.loadKDString("分录第[%1$s]行的项目勾选了%2$s核算维度请填写%3$s字段", "ContractCostMustInputOP_0", "ec-ecco-opplugin", new Object[0]), i + 1, "CBS", "“CBS”"));
}*/
} else if (StringUtils.equals(string, CostControlModelEnum.CA.getValue())) {
rs = entry.getDynamicObject("costaccount");
if (rs == null) {
this.addErrorMessage(extendedDataEntity, String.format(ResManager.loadKDString("分录第[%1$s]行的项目勾选了%2$s核算维度请填写%3$s字段", "ContractCostMustInputOP_0", "ec-ecco-opplugin", new Object[0]), i + 1, "CA", "“CA”"));
}
} else if (StringUtils.equals(string, CostControlModelEnum.BOQ.getValue())) {
rs = entry.getDynamicObject("boq");
if (rs == null) {
this.addErrorMessage(extendedDataEntity, String.format(ResManager.loadKDString("分录第[%1$s]行的项目勾选了%2$s核算维度请填写%3$s字段", "ContractCostMustInputOP_0", "ec-ecco-opplugin", new Object[0]), i + 1, "BOQ", "“BOQ”"));
}
} else if (StringUtils.equals(string, CostControlModelEnum.RS.getValue())) {
rs = entry.getDynamicObject("resource");
if (rs == null) {
this.addErrorMessage(extendedDataEntity, String.format(ResManager.loadKDString("分录第[%1$s]行的项目勾选了%2$s核算维度请填写%3$s字段", "ContractCostMustInputOP_0", "ec-ecco-opplugin", new Object[0]), i + 1, "RS", ResManager.loadKDString("“资源名称”", "ContractCostMustInputOP_1", "ec-ecco-opplugin", new Object[0])));
}
}
}
String boqMode = project.getString("boqmode");
if (boqMode != null && "unitproject".equals(boqMode)) {
DynamicObject unitProject = entry.getDynamicObject("unitproject");
if (unitProject == null) {
this.addErrorMessage(extendedDataEntity, String.format(ResManager.loadKDString("分录第[%1$s]行的项目的业务核算模式为按单位工程/标段核算,请填写%2$s字段", "ContractCostMustInputOP_2", "ec-ecco-opplugin", new Object[0]), i + 1, ResManager.loadKDString("“单位工程/标段”", "ContractCostMustInputOP_3", "ec-ecco-opplugin", new Object[0])));
}
}
}
}
}
}
}
}
}
}