设置头码车逻辑修改
This commit is contained in:
parent
b2967dc346
commit
f291898071
@ -241,21 +241,38 @@ public class AtsTrainService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OTHER:
|
case OTHER:
|
||||||
Set<List<Section>> pathSet = CalculateService.querySectionPaths2Destination(headSection, destinationSection, right, stop);
|
// Set<List<Section>> pathSet = CalculateService.querySectionPaths2Destination(headSection, destinationSection, right, stop);
|
||||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(pathSet,
|
// if (CollectionUtils.isEmpty(pathSet)) {
|
||||||
|
// pathSet = CalculateService.querySectionPaths2Destination(headSection, destinationSection, !right, stop);
|
||||||
|
// }
|
||||||
|
// BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(pathSet,
|
||||||
|
// String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
||||||
|
// //从找到的路径中筛选出最短路径
|
||||||
|
// List<Section> path = null;
|
||||||
|
// if (pathSet.size() == 1) {
|
||||||
|
// path = pathSet.stream().findAny().get();
|
||||||
|
// } else if (pathSet.size() > 1) {
|
||||||
|
// Optional<List<Section>> pathOptional = pathSet.stream()
|
||||||
|
// .min(Comparator.comparingDouble(availablePath -> availablePath.stream().mapToDouble(Section::getLen).sum()));
|
||||||
|
// path = pathOptional.get();
|
||||||
|
// }
|
||||||
|
// BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(path,
|
||||||
|
// String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
||||||
|
// supervisedTrain.setHeadPath(path);
|
||||||
|
|
||||||
|
RoutePath routePath = null;
|
||||||
|
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(destinationSection, headSection);
|
||||||
|
BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(routePaths,
|
||||||
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
||||||
//从找到的路径中筛选出最短路径
|
for (RoutePath rp : routePaths) {
|
||||||
List<Section> path = null;
|
if (rp.isStraight()) {
|
||||||
if (pathSet.size() == 1) {
|
routePath = rp;
|
||||||
path = pathSet.stream().findAny().get();
|
}
|
||||||
} else if (pathSet.size() > 1) {
|
|
||||||
Optional<List<Section>> pathOptional = pathSet.stream()
|
|
||||||
.min(Comparator.comparingDouble(availablePath -> availablePath.stream().mapToDouble(Section::getLen).sum()));
|
|
||||||
path = pathOptional.get();
|
|
||||||
}
|
}
|
||||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(path,
|
if (routePath == null) {
|
||||||
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
routePath = routePaths.get(0);
|
||||||
supervisedTrain.setHeadPath(path);
|
}
|
||||||
|
supervisedTrain.setHeadPath(routePath.getAllSections());
|
||||||
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()));
|
||||||
@ -437,7 +454,7 @@ public class AtsTrainService {
|
|||||||
/* 寻找下一目标区段 */
|
/* 寻找下一目标区段 */
|
||||||
nextTarget = findNextTarget4HeadTrain(simulation, train, repository, headSection, headStation, trainRight, destDefinition);
|
nextTarget = findNextTarget4HeadTrain(simulation, train, repository, headSection, headStation, trainRight, destDefinition);
|
||||||
/* 判断换端并更新目标 */
|
/* 判断换端并更新目标 */
|
||||||
if (nextTarget != null){
|
if (nextTarget != null) {
|
||||||
if (nextTarget.getCode().equals(estimatedArriveStandTrack)) {
|
if (nextTarget.getCode().equals(estimatedArriveStandTrack)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -418,4 +418,12 @@ public class RoutePath {
|
|||||||
public boolean isOccupied() {
|
public boolean isOccupied() {
|
||||||
return end.isOccupied() || sectionList.stream().anyMatch(Section::isOccupied);
|
return end.isOccupied() || sectionList.stream().anyMatch(Section::isOccupied);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Section> getAllSections() {
|
||||||
|
List<Section> list = new ArrayList<>();
|
||||||
|
list.add(start);
|
||||||
|
list.addAll(this.sectionList);
|
||||||
|
list.add(end);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user