From 96812559160e3d29a6309d951570b6cb75ddd1e8 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Thu, 11 Mar 2021 10:26:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E8=BF=9B=E8=B7=AF=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=97=B6=E7=9A=84=E8=BF=AD=E4=BB=A3=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E6=94=B9=E4=B8=BA=E7=94=B1=E8=B0=83=E7=94=A8=E8=80=85?= =?UTF-8?q?=E4=BC=A0=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DraftMapCiDataGeneratorImpl.java | 16 ++++++------ .../simulation/SimulationSupportService.java | 2 +- .../ATS/service/AtsRouteSettingService.java | 4 +-- .../cbtc/ATS/service/AtsTrainService.java | 8 +++--- .../cbtc/build/InterlockBuilder2.java | 2 +- .../cbtc/build/SimulationBuilder.java | 4 +-- .../cbtc/data/CalculateService.java | 26 +++++++++---------- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index 0b53ac0a1..e6034eb58 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -400,20 +400,20 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { List
tbSections = new ArrayList<>(); if (right) { if (rightStandTrack.isTurnBackTrack() - && !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(rightStandTrack, adjacentLeftStandTrack, false))) { + && !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(rightStandTrack, adjacentLeftStandTrack, false, 10))) { tbSections.add(rightStandTrack); } if (leftStandTrack.isTurnBackTrack() - && !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(adjacentRightStandTrack, leftStandTrack, true))) { + && !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(adjacentRightStandTrack, leftStandTrack, true, 10))) { tbSections.add(leftStandTrack); } } else { if (rightStandTrack.isTurnBackTrack() - && !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(adjacentLeftStandTrack, rightStandTrack, false))) { + && !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(adjacentLeftStandTrack, rightStandTrack, false, 10))) { tbSections.add(rightStandTrack); } if (leftStandTrack.isTurnBackTrack() - && !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(leftStandTrack, adjacentRightStandTrack, true))) { + && !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(leftStandTrack, adjacentRightStandTrack, true, 10))) { tbSections.add(leftStandTrack); } } @@ -431,7 +431,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { } Section standTrack = station.getNormalStand(right).get(0).getSection(); return turnBackList.stream().filter(section -> !section.isNormalStandTrack()) - .filter(section -> !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(standTrack, section, right))) + .filter(section -> !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(standTrack, section, right, 10))) .collect(Collectors.toList()); } @@ -1404,10 +1404,10 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { runLevelVO.setEndSectionCode(endSection.getCode()); runLevelVO.setEndStationCode(endSection.getStation().getCode()); runLevelVO.setRight(right); - List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, right); + List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, right, 10); if (CollectionUtils.isEmpty(routePaths)) { // 未找到,反方向再找 - routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, !right); + routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, !right, 10); if (!CollectionUtils.isEmpty(routePaths)) { log.info(String.format("站间运行等级[%s]与交路[%s]方向相反,实际为[%s]", String.format("%s(%s(%s))->%s(%s(%s))", @@ -1463,7 +1463,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { adjacentSections.forEach(endSection -> { //验证是否是进路路径的站间 - List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, right); + List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, right, 10); if (CollectionUtils.isEmpty(routePaths)) { log.warn(String.format("站间运行等级数据生成失败:没有找到[%s(%s) ——> %s(%s)]对应方向[%s]的进路路径可达的站间", startSection.getStation().getName(), startSection.getName(), endSection.getStation().getName(), endSection.getName(), right ? "右向" : "左向")); diff --git a/src/main/java/club/joylink/rtss/services/simulation/SimulationSupportService.java b/src/main/java/club/joylink/rtss/services/simulation/SimulationSupportService.java index a9956d830..7f0689a3b 100644 --- a/src/main/java/club/joylink/rtss/services/simulation/SimulationSupportService.java +++ b/src/main/java/club/joylink/rtss/services/simulation/SimulationSupportService.java @@ -40,7 +40,7 @@ public class SimulationSupportService { VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); Section startSection = train.getHeadPosition().getSection(); - List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, destination, train.isRight()); + List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, destination, train.isRight(), 10); return routePaths.stream() .map(routePath -> CalculateService.selectUniqueRoutes(routePath, false) .stream().map(MapElement::getCode).collect(Collectors.toList())) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java index 394c7cf54..e68d29479 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java @@ -95,9 +95,9 @@ public class AtsRouteSettingService { return destDefinition.queryNextRoute(headSection); } else if (train.getEstimatedArriveStandTrack() != null) { Section targetSection = repository.getByCode(train.getEstimatedArriveStandTrack(), Section.class); - routePaths = CalculateService.queryRoutePathsOnDirection(headSection, targetSection, true); + routePaths = CalculateService.queryRoutePathsOnDirection(headSection, targetSection, true, 10); if (CollectionUtils.isEmpty(routePaths)) { - routePaths = CalculateService.queryRoutePathsOnDirection(headSection, targetSection, false); + routePaths = CalculateService.queryRoutePathsOnDirection(headSection, targetSection, false, 10); } } else { // 目的地定义存在,根据目的地定义查询路径,办理进路 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 e7e7614c0..db2fc40fb 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 @@ -515,7 +515,7 @@ public class AtsTrainService { Section tbSection = strategy.getSectionList().get(0); switch (strategy.getType()) { case FIRST: - List routePaths = CalculateService.queryRoutePathsOnDirection(headSection, tbSection, standRight); + List routePaths = CalculateService.queryRoutePathsOnDirection(headSection, tbSection, standRight, 10); if (routePaths.stream().anyMatch(path -> !path.isOccupied())) { nextTarget = tbSection; } @@ -532,7 +532,7 @@ public class AtsTrainService { if (section.isNormalStandTrack()) { continue; } - List routePaths = CalculateService.queryRoutePathsOnDirection(headSection, section, standRight); + List routePaths = CalculateService.queryRoutePathsOnDirection(headSection, section, standRight, 10); if (routePaths.stream().anyMatch(path -> !path.isOccupied())) { nextTarget = section; break; @@ -563,7 +563,7 @@ public class AtsTrainService { break; } nextTarget = adjacentStation.getNormalStand(!standRight).get(0).getSection(); - if (CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(headSection, nextTarget, standRight))) { + if (CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(headSection, nextTarget, standRight, 10))) { nextTarget = adjacentStation.getNormalStand(standRight).get(0).getSection(); } } else { @@ -582,7 +582,7 @@ public class AtsTrainService { if (nextTarget == null) { nextTarget = headStation.getNormalStand(destinationRight).get(0).getSection(); if (!headSection.equals(nextTarget)) { - List routePaths = CalculateService.queryRoutePathsOnDirection(headSection, nextTarget, destinationRight); + List routePaths = CalculateService.queryRoutePathsOnDirection(headSection, nextTarget, destinationRight, 10); if (!CollectionUtils.isEmpty(routePaths)) { break; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java index 2ca0a3c9a..4e0e4755b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java @@ -869,7 +869,7 @@ public class InterlockBuilder2 { Section startSection = runLevel.getStartSection(); Section endSection = runLevel.getEndSection(); boolean right = runLevel.isRight(); - List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, right); + List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, right, 10); if (CollectionUtils.isEmpty(routePaths)) { errMsgList.add(String.format("站间运行等级[%s]无法找到路径", runLevel.debugStr(), startSection.debugStr(), endSection.debugStr())); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java index 5158ee005..c522bc4d2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java @@ -157,10 +157,10 @@ public class SimulationBuilder { String key = RoutePath.buildKey(start, end); if (!routePathMap.containsKey(key)) { // 路径不存在,尝试构建 - List routePaths = CalculateService.queryRoutePathsOnDirection(start, end, tripPlan.isRight()); + List routePaths = CalculateService.queryRoutePathsOnDirection(start, end, tripPlan.isRight(), 10); if (CollectionUtils.isEmpty(routePaths)) { // 计划方向路径未找到,反向尝试 - routePaths = CalculateService.queryRoutePathsOnDirection(start, end, !tripPlan.isRight()); + routePaths = CalculateService.queryRoutePathsOnDirection(start, end, !tripPlan.isRight(), 10); } if (CollectionUtils.isEmpty(routePaths)) { // 依然未找到 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java index aa16dfce0..2bf9f5269 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java @@ -635,11 +635,11 @@ public class CalculateService { return false; } - public static List queryRoutePathsOnDirection(Section start, Section end, Boolean right) { + public static List queryRoutePathsOnDirection(Section start, Section end, Boolean right, int iterTimes) { List list = new ArrayList<>(); List warnList = new ArrayList<>(); RoutePath routePath = new RoutePath(start, end, right); - queryRoutePaths(0, start, routePath, list, warnList); + queryRoutePaths(0, iterTimes, start, routePath, list, warnList); if (!CollectionUtils.isEmpty(list)) { for (RoutePath path : list) { path.calculateDistance(); @@ -659,7 +659,7 @@ public class CalculateService { * @param preferredSections 优先经过这些区段,可以为null */ public static RoutePath queryLeastSwitchRoutePath(Section startSection, Section endSection, Collection
preferredSections, boolean toRight) { - List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, toRight); + List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, toRight, 100); if (CollectionUtils.isEmpty(routePaths)) { return null; } else { @@ -695,14 +695,14 @@ public class CalculateService { } } - private static void queryRoutePaths(int iter, Section section, RoutePath routePath, + private static void queryRoutePaths(int iter, int iterTimes, Section section, RoutePath routePath, List list, List warnList) { if (section == null) { warnList.add(String.format("进路路径[%s]未找到,找到的最后区段为[%s],下一区段为null", routePath.debugStr(), routePath.getLastSection().debugStr())); return; } - if (iter > 100) { + if (iter > iterTimes) { warnList.add(String.format("进路路径[%s]未找到:迭代100次,最后区段为[%s]", routePath.debugStr(), routePath.getLastSection().debugStr())); return; @@ -721,20 +721,20 @@ public class CalculateService { } else { // 添加并进行迭代 routePath.addSection(next); - queryRoutePaths(iter + 1, next, routePath, list, warnList); + queryRoutePaths(iter + 1, iterTimes, next, routePath, list, warnList); } } else if (section.isSwitchTrack()) { // 道岔区段 Switch relSwitch = section.getRelSwitch(); if (relSwitch.isA(section)) { RoutePath path1 = routePath.cloneNew(); path1.addSection(relSwitch.getB()); - queryRoutePaths(iter + 1, relSwitch.getB(), path1, list, warnList); + queryRoutePaths(iter + 1, iterTimes, relSwitch.getB(), path1, list, warnList); RoutePath path2 = routePath.cloneNew(); path2.addSection(relSwitch.getC()); - queryRoutePaths(iter + 1, relSwitch.getC(), path2, list, warnList); + queryRoutePaths(iter + 1, iterTimes, relSwitch.getC(), path2, list, warnList); } else { routePath.addSection(relSwitch.getA()); - queryRoutePaths(iter + 1, relSwitch.getA(), routePath, list, warnList); + queryRoutePaths(iter + 1, iterTimes, relSwitch.getA(), routePath, list, warnList); } } else { warnList.add(String.format("区段[%s]的[%s]区段不存在", @@ -760,7 +760,7 @@ public class CalculateService { list.add(routePath); } else { routePath.addSections(sectionList); - queryRoutePaths(iter + 1, route.getLastRouteSection(), routePath, list, warnList); + queryRoutePaths(iter + 1, iterTimes, route.getLastRouteSection(), routePath, list, warnList); } return; } @@ -823,7 +823,7 @@ public class CalculateService { } else { for (RoutePath clone : iterList) { Section next = clone.getLastSection(); - queryRoutePaths(iter + 1, next, clone, list, warnList); + queryRoutePaths(iter + 1, iterTimes, next, clone, list, warnList); } } } else { @@ -845,7 +845,7 @@ public class CalculateService { for (Section next : sectionList) { routePath.addSection(next); if (next.getSignalOf(right) != null) { - queryRoutePaths(iter + 1, next, routePath, list, warnList); + queryRoutePaths(iter + 1, iterTimes, next, routePath, list, warnList); break; } } @@ -1113,7 +1113,7 @@ public class CalculateService { // if (distance == null) { // return null; // } - List routePaths = queryRoutePathsOnDirection(train.getHeadPosition().getSection(), target, right); + List routePaths = queryRoutePathsOnDirection(train.getHeadPosition().getSection(), target, right, 10); if (CollectionUtils.isEmpty(routePaths)) { return null; }