设置头码车路径寻找逻辑修改
This commit is contained in:
parent
3d712e6486
commit
8e58d6ba89
@ -28,10 +28,7 @@ import org.springframework.util.StringUtils;
|
|||||||
|
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -302,13 +299,24 @@ public class AtsTrainService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(selectRouting,
|
if (selectRouting != null) {
|
||||||
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
|
||||||
List<Section> sections = selectRouting.getSectionsFrom(fromSection);
|
List<Section> sections = selectRouting.getSectionsFrom(fromSection);
|
||||||
if (!sections.get(0).equals(headSection)) {
|
if (!sections.get(0).equals(headSection)) {
|
||||||
sections.add(0, headSection);
|
sections.add(0, headSection);
|
||||||
}
|
}
|
||||||
supervisedTrain.setHctPath(new SectionRunPath(sections, selectRouting.isRight()));
|
supervisedTrain.setHctPath(new SectionRunPath(sections, selectRouting.isRight()));
|
||||||
|
} else {
|
||||||
|
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(destinationSection, headSection);
|
||||||
|
BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(routePaths,
|
||||||
|
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
||||||
|
RoutePath routePath = routePaths.stream()
|
||||||
|
.min(Comparator.comparingDouble(RoutePath::getReverseSwitchQuantity))
|
||||||
|
.get();
|
||||||
|
List<Section> sections = routePath.getSectionList().stream()
|
||||||
|
.filter(Section::isSpecialSection)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
supervisedTrain.setHctPath(new SectionRunPath(sections, routePath.isRight()));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new SimulationException(SimulationExceptionType.System_Fault, String.format("无法识别的目的地码类型[%s]", destinationCodeDefinition.getType()));
|
throw new SimulationException(SimulationExceptionType.System_Fault, String.format("无法识别的目的地码类型[%s]", destinationCodeDefinition.getType()));
|
||||||
|
Loading…
Reference in New Issue
Block a user