1:收款申请提交操作添加校验:校验分录中是否存在相同的合同加支付类型组合值;2:优化付款申请单提交校验插件的注释
This commit is contained in:
parent
57071d39c5
commit
c6211f7dde
|
@ -0,0 +1,62 @@
|
||||||
|
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||||
|
|
||||||
|
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.plugin.PreparePropertysEventArgs;
|
||||||
|
import kd.bos.entity.validate.AbstractValidator;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收款申请(项目资金)提交操作校验插件
|
||||||
|
* 说明:1:校验分录中是否存在相同的合同加支付类型组合值
|
||||||
|
*/
|
||||||
|
public class IncomeApplyValidatorSubOp extends AbstractOperationServicePlugIn {
|
||||||
|
@Override
|
||||||
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||||
|
super.onPreparePropertys(e);
|
||||||
|
e.getFieldKeys().add("contract");//合同名称
|
||||||
|
e.getFieldKeys().add("paytype");//支付类型
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||||
|
super.onAddValidators(e);
|
||||||
|
e.getValidators().add(new ValidatorExt());
|
||||||
|
}
|
||||||
|
|
||||||
|
class ValidatorExt extends AbstractValidator {
|
||||||
|
@Override
|
||||||
|
public void validate() {
|
||||||
|
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
|
||||||
|
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
||||||
|
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||||
|
DynamicObjectCollection entryEntityCollection = dataEntity.getDynamicObjectCollection("entryentity");//合同请款分录
|
||||||
|
Map<String, List<Integer>> combinationIndices = new HashMap<>();
|
||||||
|
for (int i = 0; i < entryEntityCollection.size(); i++) {
|
||||||
|
DynamicObject entryEntity = entryEntityCollection.get(i);
|
||||||
|
DynamicObject contract = entryEntity.getDynamicObject("contract");//合同名称
|
||||||
|
String contractNumber = null;
|
||||||
|
if (contract != null) {
|
||||||
|
contractNumber = contract.getString("number");//合同编号
|
||||||
|
}
|
||||||
|
String payType = entryEntity.getString("paytype");//支付类型
|
||||||
|
String combinationKey = contractNumber + "|" + payType;
|
||||||
|
if (combinationIndices.containsKey(combinationKey)) {
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, "合同请款分录中一个合同不能填写多行相同的支付类型!");
|
||||||
|
} else {
|
||||||
|
List<Integer> indices = new ArrayList<>();
|
||||||
|
indices.add(i);
|
||||||
|
combinationIndices.put(combinationKey, indices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,10 +44,10 @@ public class PaymentApplySubOp extends AbstractOperationServicePlugIn {
|
||||||
contractNumber = contract.getString("number");//合同编号
|
contractNumber = contract.getString("number");//合同编号
|
||||||
}
|
}
|
||||||
String paymentType = entryEntity.getString("paymenttype");//支付类型
|
String paymentType = entryEntity.getString("paymenttype");//支付类型
|
||||||
DynamicObject settleType = entryEntity.getDynamicObject("settletype");//合同名称
|
DynamicObject settleType = entryEntity.getDynamicObject("settletype");//结算方式
|
||||||
String settleTypeName = null;
|
String settleTypeName = null;
|
||||||
if (settleType != null) {
|
if (settleType != null) {
|
||||||
settleTypeName = settleType.getString("name");//合同编号
|
settleTypeName = settleType.getString("name");//结算方式编码
|
||||||
}
|
}
|
||||||
String combinationKey = contractNumber + "|" + paymentType + "|" + settleTypeName;
|
String combinationKey = contractNumber + "|" + paymentType + "|" + settleTypeName;
|
||||||
if (combinationIndices.containsKey(combinationKey)) {
|
if (combinationIndices.containsKey(combinationKey)) {
|
||||||
|
|
Loading…
Reference in New Issue