贷记单反审核时只允许反审核最大流水号的单据:

举例:如贷记单存在001、002、003的单号时,想要反审核002,必须先将003单据反审核,在反审核002,然后按照顺序依次将0002、0003提交审核。
This commit is contained in:
ljw 2024-12-23 18:44:01 +08:00
parent ad5308a091
commit d36c529e33
2 changed files with 12 additions and 34 deletions

View File

@ -1,27 +1,21 @@
package com.yem.wm.im.debcrednotenew.op;
import com.yem.wm.im.debcrednotenew.utils.DebCredUtils;
import com.yem.wm.utils.FunctionalCommon;
import com.yem.wm.im.debcrednotenew.validator.DebCredNewUnAuditValidator;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.operate.result.IOperateInfo;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
import kd.bos.exception.KDBizException;
import kd.bos.exception.KDException;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhouc
* @date 2024/3/28 14:32
@ -29,6 +23,14 @@ import java.util.List;
* @description 贷记单反审核服务插件
*/
public class DebCredNewUnAuditPlugin extends AbstractOperationServicePlugIn {
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
e.addValidator(new DebCredNewUnAuditValidator());
}
@Override
public void endOperationTransaction(EndOperationTransactionArgs e) {
DynamicObject[] dataEnties = e.getDataEntities();

View File

@ -3,11 +3,6 @@ package com.yem.wm.im.debcrednotenew.validator;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.validate.AbstractValidator;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.math.BigDecimal;
/**
* @author ljw
@ -19,28 +14,9 @@ public class DebCredNewUnAuditValidator extends AbstractValidator {
@Override
public void validate() {
ExtendedDataEntity[] dataEntities = this.getDataEntities();
for (ExtendedDataEntity dataEntitie : dataEntities) {
for(ExtendedDataEntity dataEntitie : dataEntities){
DynamicObject dataEntity = dataEntitie.getDataEntity();
String billno = dataEntity.getString("billno");
if (billno.length() > 4) {
BigDecimal bigDecimal = BigDecimal.ZERO;
String modifiedString = billno.substring(0, billno.length() - 4);
String substringed = billno.substring(billno.length() - 4);
DynamicObject[] loaded = BusinessDataServiceHelper.load("yem_debcrednote", "id,billno"
, new QFilter[]{new QFilter("billno", QCP.like, modifiedString + "%")});
for (DynamicObject dynamicObject : loaded) {
String dynamicObjectString = dynamicObject.getString("billno");
String substring = dynamicObjectString.substring(dynamicObjectString.length() - 4);
BigDecimal decimal = BigDecimal.valueOf(Double.parseDouble(substring));
if (decimal.compareTo(bigDecimal) > 0) {
bigDecimal = decimal;
}
}
BigDecimal decimal = BigDecimal.valueOf(Double.parseDouble(substringed));
if (bigDecimal.compareTo(BigDecimal.ZERO) != 0 && decimal.compareTo(bigDecimal) != 0) {
this.addMessage(dataEntitie, "当前单不是最大单号,请从最大单号开始删除!!!");
}
}
}
}
}