校验修改

This commit is contained in:
DU 2021-04-06 19:18:32 +08:00
parent d81ec9f650
commit c9c491848b

View File

@ -945,14 +945,17 @@ public class RunPlanDraftService implements IRunPlanDraftService {
//同站相邻车次间隔时间
if (CollectionUtils.isEmpty(errorList)) {
Map<String, List<RunPlanTripTimeInfo>> tripTimesOnSection = planVO.getTripList().stream().flatMap(tripVO -> tripVO.getTimeList().stream().map(tripTime ->
new RunPlanTripTimeInfo(tripVO.getServiceNumber(), tripVO.getTripNumber(), tripVO.getStartTime(), tripVO.getRight(), tripTime)
{
int i = tripVO.getTimeList().indexOf(tripTime);
return new RunPlanTripTimeInfo(tripVO.getServiceNumber(), tripVO.getTripNumber(), i > 0 ? tripVO.getTimeList().get(i - 1).getDepartureTime() : null, tripVO.getRight(), tripTime);
}
)).collect(Collectors.groupingBy(RunPlanTripTimeInfo::getSectionCode));
tripTimesOnSection.forEach((s, runPlanTripTimeInfos) -> {
if (!CollectionUtils.isEmpty(errorList)) return;
if (!CollectionUtils.isEmpty(errorList)) return;
Map<Boolean, List<RunPlanTripTimeInfo>> list = runPlanTripTimeInfos.stream().collect(Collectors.groupingBy(RunPlanTripTimeInfo::isRight));
list.values().stream().forEach(l -> {
if (!CollectionUtils.isEmpty(errorList)) return;
l.sort(Comparator.comparing(RunPlanTripTimeInfo::getTripStartTime));
if (!CollectionUtils.isEmpty(errorList)) return;
l.sort(Comparator.comparing(RunPlanTripTimeInfo::getPreDepartTime));
RunPlanTripTimeInfo pre = l.get(0);
for (int i = 1; i < l.size(); i++) {
RunPlanTripTimeInfo cur = l.get(i);
@ -965,7 +968,7 @@ public class RunPlanDraftService implements IRunPlanDraftService {
if (cur.getArrivalTime().isBefore(pre.getDepartureTime())) {
errorList.add(String.format("相邻车次[%s-%s] 与 车次[%s-%s]在车站停车点[%s]撞车,应保证前后车运行安全间隔不小于1分钟",
pre.getServiceNumber(), pre.getTripNumber(),
cur.getServiceNumber(), cur.getTripNumber(),map.findStation(cur.getStationCode()).getName()));
cur.getServiceNumber(), cur.getTripNumber(), map.findStation(cur.getStationCode()).getName()));
return;
}
if (ChronoUnit.SECONDS.between(pre.getDepartureTime(), cur.getArrivalTime()) < 60) {
@ -986,7 +989,7 @@ public class RunPlanDraftService implements IRunPlanDraftService {
private class RunPlanTripTimeInfo extends RunPlanTripTimeVO {
private String serviceNumber;
private String tripNumber;
private LocalTime tripStartTime;
private LocalTime preDepartTime;
private boolean right;
public RunPlanTripTimeInfo(String serviceNumber, String tripNumber, RunPlanTripTimeVO tripTime) {
@ -995,11 +998,11 @@ public class RunPlanDraftService implements IRunPlanDraftService {
this.tripNumber = tripNumber;
}
public RunPlanTripTimeInfo(String serviceNumber, String tripNumber,LocalTime tripStartTime, boolean right, RunPlanTripTimeVO tripTime) {
public RunPlanTripTimeInfo(String serviceNumber, String tripNumber,LocalTime preDepartTime, boolean right, RunPlanTripTimeVO tripTime) {
super(tripTime.getStationCode(), tripTime.getSectionCode(), tripTime.getArrivalTime(), tripTime.getDepartureTime());
this.serviceNumber = serviceNumber;
this.tripNumber = tripNumber;
this.tripStartTime = tripStartTime;
this.preDepartTime = preDepartTime;
this.right = right;
}
}