parent
935b609247
commit
12e0744b63
|
@ -0,0 +1,79 @@
|
||||||
|
package zcgj.zcdev.zcdev.fs.plugin.operate;
|
||||||
|
|
||||||
|
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 kd.bos.logging.Log;
|
||||||
|
import kd.bos.logging.LogFactory;
|
||||||
|
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据注册位置:差旅报销单提交按钮
|
||||||
|
* 说明:校验不同行程信息开始结束时间是否存在相同的日期
|
||||||
|
*/
|
||||||
|
public class TravelItineraryTimeValidatorSubOp extends AbstractOperationServicePlugIn {
|
||||||
|
private static final Log logger = LogFactory.getLog(TravelItineraryTimeValidatorSubOp.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||||
|
super.onPreparePropertys(e);
|
||||||
|
e.getFieldKeys().add("costcompany");//费用承担公司
|
||||||
|
e.getFieldKeys().add("tripentry");//行程信息分录
|
||||||
|
e.getFieldKeys().add("startdate");//行程开始时间
|
||||||
|
e.getFieldKeys().add("enddate");//行程结束时间
|
||||||
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
DynamicObject costCompany = dataEntity.getDynamicObject("costcompany");//费用承担公司
|
||||||
|
if (costCompany != null) {
|
||||||
|
Long companyId = costCompany.getLong("id");
|
||||||
|
if (OrgCheckUtils.isKS(companyId)) {
|
||||||
|
//仅针对矿山下组织下的逻辑
|
||||||
|
DynamicObjectCollection tripEntryCollection = dataEntity.getDynamicObjectCollection("tripentry");//行程信息
|
||||||
|
Set<Date> startDateSet = new HashSet<>();
|
||||||
|
Set<Date> endDateSet = new HashSet<>();
|
||||||
|
for (DynamicObject tripEntry : tripEntryCollection) {
|
||||||
|
Date startDate = tripEntry.getDate("startdate");//开始日期
|
||||||
|
Date endDate = tripEntry.getDate("enddate");//结束日期
|
||||||
|
// 校验开始日期是否重复
|
||||||
|
if (startDate != null) {
|
||||||
|
if (startDateSet.contains(startDate)) {
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, "存在相同的行程开始日期,请检查行程信息!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
startDateSet.add(startDate);
|
||||||
|
}
|
||||||
|
// 校验结束日期是否重复
|
||||||
|
if (endDate != null) {
|
||||||
|
if (endDateSet.contains(endDate)) {
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, "存在相同的行程结束日期,请检查行程信息!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
endDateSet.add(endDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue