差旅报销单提交按钮操作逻辑优化
This commit is contained in:
parent
12e0744b63
commit
4d53ece9f8
|
@ -29,6 +29,8 @@ public class TravelItineraryTimeValidatorSubOp extends AbstractOperationServiceP
|
||||||
e.getFieldKeys().add("tripentry");//行程信息分录
|
e.getFieldKeys().add("tripentry");//行程信息分录
|
||||||
e.getFieldKeys().add("startdate");//行程开始时间
|
e.getFieldKeys().add("startdate");//行程开始时间
|
||||||
e.getFieldKeys().add("enddate");//行程结束时间
|
e.getFieldKeys().add("enddate");//行程结束时间
|
||||||
|
e.getFieldKeys().add("from");//出发地
|
||||||
|
e.getFieldKeys().add("to");//目的地
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,26 +51,76 @@ public class TravelItineraryTimeValidatorSubOp extends AbstractOperationServiceP
|
||||||
if (OrgCheckUtils.isKS(companyId)) {
|
if (OrgCheckUtils.isKS(companyId)) {
|
||||||
//仅针对矿山下组织下的逻辑
|
//仅针对矿山下组织下的逻辑
|
||||||
DynamicObjectCollection tripEntryCollection = dataEntity.getDynamicObjectCollection("tripentry");//行程信息
|
DynamicObjectCollection tripEntryCollection = dataEntity.getDynamicObjectCollection("tripentry");//行程信息
|
||||||
Set<Date> startDateSet = new HashSet<>();
|
Set<Date> startDateSet = new HashSet<>();//开始时间
|
||||||
Set<Date> endDateSet = new HashSet<>();
|
Set<Date> endDateSet = new HashSet<>();//结束时间
|
||||||
|
Set<String> fromStartCombinationSet = new HashSet<>(); // 出发地+开始时间组合
|
||||||
|
Set<String> toEndCombinationSet = new HashSet<>(); // 目的地+结束时间组合
|
||||||
|
Set<String> matchedFromStartCombinations = new HashSet<>();
|
||||||
|
Set<String> matchedToEndCombinations = new HashSet<>();
|
||||||
for (DynamicObject tripEntry : tripEntryCollection) {
|
for (DynamicObject tripEntry : tripEntryCollection) {
|
||||||
Date startDate = tripEntry.getDate("startdate");//开始日期
|
Date startDate = tripEntry.getDate("startdate");//开始日期
|
||||||
Date endDate = tripEntry.getDate("enddate");//结束日期
|
Date endDate = tripEntry.getDate("enddate");//结束日期
|
||||||
// 校验开始日期是否重复
|
DynamicObject from = tripEntry.getDynamicObject("from");//出发地
|
||||||
if (startDate != null) {
|
DynamicObject to = tripEntry.getDynamicObject("to");//目的地
|
||||||
if (startDateSet.contains(startDate)) {
|
|
||||||
this.addFatalErrorMessage(extendedDataEntity, "存在相同的行程开始日期,请检查行程信息!");
|
// 构建组合键
|
||||||
return;
|
String fromStartKey = null;
|
||||||
}
|
String toEndKey = null;
|
||||||
startDateSet.add(startDate);
|
|
||||||
|
if (from != null && startDate != null) {
|
||||||
|
Long fromId = from.getLong("id");
|
||||||
|
fromStartKey = fromId + "_" + startDate.getTime();
|
||||||
}
|
}
|
||||||
// 校验结束日期是否重复
|
|
||||||
if (endDate != null) {
|
if (to != null && endDate != null) {
|
||||||
if (endDateSet.contains(endDate)) {
|
Long toId = to.getLong("id");
|
||||||
this.addFatalErrorMessage(extendedDataEntity, "存在相同的行程结束日期,请检查行程信息!");
|
toEndKey = toId + "_" + endDate.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否存在"出发地+开始时间"与"目的地+结束时间"相同的组合
|
||||||
|
if (fromStartKey != null && toEndKey != null && fromStartKey.equals(toEndKey)) {
|
||||||
|
matchedFromStartCombinations.add(fromStartKey);
|
||||||
|
matchedToEndCombinations.add(toEndKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
// // 分别校验开始日期是否重复
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 校验出发地+开始时间组合是否重复(排除与目的地+结束时间相同的组合)
|
||||||
|
if (fromStartKey != null) {
|
||||||
|
// 如果这个组合在matchedFromStartCombinations中,则允许重复
|
||||||
|
if (fromStartCombinationSet.contains(fromStartKey)
|
||||||
|
&& !matchedFromStartCombinations.contains(fromStartKey)) {
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, "存在相同的出发地和开始时间组合,请检查行程信息!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
endDateSet.add(endDate);
|
fromStartCombinationSet.add(fromStartKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验目的地+结束时间组合是否重复(排除与出发地+开始时间相同的组合)
|
||||||
|
if (toEndKey != null) {
|
||||||
|
// 如果这个组合在matchedToEndCombinations中,则允许重复
|
||||||
|
if (toEndCombinationSet.contains(toEndKey)
|
||||||
|
&& !matchedToEndCombinations.contains(toEndKey)) {
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, "存在相同的目的地和结束时间组合,请检查行程信息!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toEndCombinationSet.add(toEndKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue