From 8e58d6ba89382313c7364f5a584f3484ffaf795d Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Thu, 5 Aug 2021 09:51:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A4=B4=E7=A0=81=E8=BD=A6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=AF=BB=E6=89=BE=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/service/AtsTrainService.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java index 49d997e21..4ae420a2a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java @@ -28,10 +28,7 @@ import org.springframework.util.StringUtils; import java.time.LocalTime; import java.time.temporal.ChronoUnit; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; /** @@ -302,13 +299,24 @@ public class AtsTrainService { break; } } - BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(selectRouting, - String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode())); - List
sections = selectRouting.getSectionsFrom(fromSection); - if (!sections.get(0).equals(headSection)) { - sections.add(0, headSection); + if (selectRouting != null) { + List
sections = selectRouting.getSectionsFrom(fromSection); + if (!sections.get(0).equals(headSection)) { + sections.add(0, headSection); + } + supervisedTrain.setHctPath(new SectionRunPath(sections, selectRouting.isRight())); + } else { + List 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
sections = routePath.getSectionList().stream() + .filter(Section::isSpecialSection) + .collect(Collectors.toList()); + supervisedTrain.setHctPath(new SectionRunPath(sections, routePath.isRight())); } - supervisedTrain.setHctPath(new SectionRunPath(sections, selectRouting.isRight())); break; default: throw new SimulationException(SimulationExceptionType.System_Fault, String.format("无法识别的目的地码类型[%s]", destinationCodeDefinition.getType()));