添加入库单提交操作校验插件:分录中资源编码不是火工材料和燃料类的分录行,且单价大于两千的分录行,则需要上传比价附件

This commit is contained in:
xuhaihui 2025-10-11 14:14:14 +08:00
parent ca2827f957
commit ea17708cde
1 changed files with 17 additions and 7 deletions

View File

@ -11,14 +11,20 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.math.BigDecimal;
/** /**
* 入库单提交操作校验插件 * 入库单提交操作校验插件
* 说明 * 说明分录中资源编码不是火工材料和燃料类的分录行且单价大于两千的分录行则需要上传比价附件
*/ */
public class MaterialInBillOrgSubmitValidatorOp extends AbstractOperationServicePlugIn { public class MaterialInBillOrgSubmitValidatorOp extends AbstractOperationServicePlugIn {
public void onPreparePropertys(PreparePropertysEventArgs e) { public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e); super.onPreparePropertys(e);
e.getFieldKeys().add("fiaccountOrg"); e.getFieldKeys().add("fiaccountOrg");
e.getFieldKeys().add("entryentity");
e.getFieldKeys().add("material");
e.getFieldKeys().add("price");
e.getFieldKeys().add("zcgj_attachmentcount");
} }
@Override @Override
@ -33,7 +39,7 @@ public class MaterialInBillOrgSubmitValidatorOp extends AbstractOperationService
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities(); ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) { for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
DynamicObject ecma_MaterialInBill = extendedDataEntity.getDataEntity(); DynamicObject ecma_MaterialInBill = extendedDataEntity.getDataEntity();
DynamicObject fiaccountOrg = ecma_MaterialInBill.getDynamicObject("fiaccountOrg");//财务记账组织 DynamicObject fiaccountOrg = ecma_MaterialInBill.getDynamicObject("fiaccountorg");//财务记账组织
if (fiaccountOrg == null) { if (fiaccountOrg == null) {
return; return;
} }
@ -43,20 +49,24 @@ public class MaterialInBillOrgSubmitValidatorOp extends AbstractOperationService
new QFilter[]{f1.and(f2)});//入库单公司过滤 new QFilter[]{f1.and(f2)});//入库单公司过滤
if (zcgj_authorizedcompany != null) { if (zcgj_authorizedcompany != null) {
DynamicObjectCollection entryEntityCollection = ecma_MaterialInBill.getDynamicObjectCollection("entryentity");//入库单分录 DynamicObjectCollection entryEntityCollection = ecma_MaterialInBill.getDynamicObjectCollection("entryentity");//入库单分录
for (int i = 0; i < entryEntityCollection.size(); i++) { boolean isPrice = false;
DynamicObject entryEntity = entryEntityCollection.get(i); for (DynamicObject entryEntity : entryEntityCollection) {
DynamicObject material = entryEntity.getDynamicObject("material");//资源编码 DynamicObject material = entryEntity.getDynamicObject("material");//资源编码
if (material != null) { if (material != null) {
DynamicObject resource = material.getDynamicObject("resource");//资源编码-清单分类 DynamicObject resource = material.getDynamicObject("resource");//资源编码-清单分类
if (resource != null) { if (resource != null) {
String number = resource.getString("number");//清单分类-编码 String number = resource.getString("number");//清单分类-编码
if (number.contains("ZCKS03") || number.contains("ZCKS05")) { BigDecimal price = entryEntity.getBigDecimal("price");//入库单价
return; if (price.compareTo(new BigDecimal("2000")) > 0 && !number.contains("ZCKS03") && !number.contains("ZCKS05")) {
isPrice = true;
} }
} }
} }
} }
ecma_MaterialInBill.getString("zcgj_attachmentcountfield");//附件数 int zcgj_attachmentcount = ecma_MaterialInBill.getInt("zcgj_attachmentcount"); //比价附件数
if (zcgj_attachmentcount == 0 && isPrice) {
this.addFatalErrorMessage(extendedDataEntity, "入库单价大于2000需要上传比价附件");
}
} }
} }
} }