From 0296d007ab681f458fd1b9e78e1b05966d2a156b Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 3 Aug 2021 13:58:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BA=BA=E5=B7=A5=E8=BD=A6?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=88=97=E8=BD=A6=E5=9C=A8=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E6=89=8D=E6=B8=85=E9=99=A4target?= =?UTF-8?q?=EF=BC=9B=E6=B7=BB=E5=8A=A0=E5=88=9B=E5=BB=BA=E8=BF=9B=E8=B7=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=9B=E5=88=97=E8=BD=A6=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=E9=99=8D=E4=BD=8E=E8=87=B380km/h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draft/DraftMapRouteController.java | 5 ++ .../draftData/DraftMapRouteService.java | 2 + .../draftData/DraftMapRouteServiceImpl.java | 39 ++++++++++----- .../ATS/service/AtsRouteSettingService.java | 49 ------------------- .../cbtc/ATS/service/AtsTrainService.java | 4 +- .../cbtc/data/vr/VirtualRealityTrain.java | 2 +- 6 files changed, 39 insertions(+), 62 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapRouteController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapRouteController.java index b330bd3de..5ebb0a392 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapRouteController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapRouteController.java @@ -52,4 +52,9 @@ public class DraftMapRouteController { public void setSetOverlapInCtcFalse(@PathVariable Long id) { this.draftMapRouteService.setSetOverlapInCtcFalse(id); } + + @PostMapping("") + public void createRoute(@PathVariable Long id, @RequestBody MapRouteNewVO routeNewVO) { + this.draftMapRouteService.createRoute(id, routeNewVO); + } } diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteService.java index 4bbcee0e8..4c12848ef 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteService.java @@ -20,4 +20,6 @@ public interface DraftMapRouteService { void deleteStandHoldList(Long mapId); void setSetOverlapInCtcFalse(Long mapId); + + void createRoute(long draftMapId, MapRouteNewVO routeNewVO); } diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java index dfd4957b3..d87a4ce5f 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java @@ -39,10 +39,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { @Override public MapRouteNewVO createRailwayRoute(Long id, MapRouteNewVO routeNewVO) { - DraftMapRouteExample example = new DraftMapRouteExample(); - example.createCriteria() - .andMapIdEqualTo(id); - List routeList = this.draftMapRouteDAO.selectByExampleWithBLOBs(example); + List routeList = findEntitiesByMapId(id); Map routeVOMap = routeList.stream() .map(draftMapRoute -> MapRouteNewVO.convert2VO(draftMapRoute)) .collect(Collectors.toMap(MapRouteNewVO::getCode, Function.identity())); @@ -97,11 +94,15 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { @Override public List queryAllRoutes(Long id) { + List routeList = findEntitiesByMapId(id); + return MapRouteNewVO.convertDraft2VOList(routeList); + } + + private List findEntitiesByMapId(Long mapId) { DraftMapRouteExample example = new DraftMapRouteExample(); example.createCriteria() - .andMapIdEqualTo(id); - List routeList = this.draftMapRouteDAO.selectByExampleWithBLOBs(example); - return MapRouteNewVO.convertDraft2VOList(routeList); + .andMapIdEqualTo(mapId); + return this.draftMapRouteDAO.selectByExampleWithBLOBs(example); } @Override @@ -131,10 +132,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { public void deleteRoute(Long id, String code) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(code, String.format("code不能为空")); - DraftMapRouteExample example = new DraftMapRouteExample(); - example.createCriteria() - .andMapIdEqualTo(id); - List routeList = this.draftMapRouteDAO.selectByExampleWithBLOBs(example); + List routeList = findEntitiesByMapId(id); Map routeVOMap = routeList.stream() .map(draftMapRoute -> MapRouteNewVO.convert2VO(draftMapRoute)) .collect(Collectors.toMap(MapRouteNewVO::getCode, Function.identity())); @@ -172,4 +170,23 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { update(mapId, route.getCode(), route); }); } + + @Override + public void createRoute(long draftMapId, MapRouteNewVO routeNewVO) { + List routes = findEntitiesByMapId(draftMapId); + String prefix_route = DraftMapCiDataGeneratorImpl.CodeGenerator.Prefix_Route; + DraftMapCiDataGeneratorImpl.CodeGenerator routeCodeGenerator; + if (CollectionUtils.isEmpty(routes)) { + routeCodeGenerator = DraftMapCiDataGeneratorImpl.CodeGenerator.getRouteCodeGenerator(0); + } else { + Integer sn = routes.stream() + .map(DraftMapRoute::getCode) + .map(c -> Integer.parseInt(c.replace(prefix_route, ""))) + .max(Integer::compareTo).get(); + routeCodeGenerator = DraftMapCiDataGeneratorImpl.CodeGenerator.getRouteCodeGenerator(sn); + } + String code = routeCodeGenerator.next(); + routeNewVO.setCode(code); + draftMapRouteDAO.insert(routeNewVO.convert2Draft()); + } } 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 c91716e78..a39f71e09 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 @@ -146,55 +146,6 @@ public class AtsRouteSettingService { } } } - -// // 如果已经到达目的地,返回 -// if (Objects.equals(headSection, destDefinition.getSection())) { -// return null; -// } -// // 目的地定义存在,根据目的地定义查询路径,办理进路 -// // 判断是否终点站折返办理 -// if (train.isParking() && destDefinition.isLoop()) { // 列车停车,且目的地为环路运营 -// Section section = destDefinition.getEndStationParkSection(right); -// if (Objects.equals(section, headSection)) { // 列车停靠终点站对应站台 -// Station station = destDefinition.getStationOf(right); -// if (destDefinition.isFrontTurnBack(station)) { // 站前折返 -// neededSignal = section.getSignalOf(!right); -// List paths = repository.queryRoutePathsByStart(section); -// for (RoutePath path : paths) { // 筛选方向一致且终端区段是站台轨的 -// if (Objects.equals(path.isRight(), !right) && path.getEnd().isNormalStandTrack()) { -// routePaths.add(path); -// } -// } -// } else { // 站后折返 -// train.startTurnBack(null); -// StationTurnBackStrategyOption strategy = null; -// if (Objects.nonNull(station.getTbStrategyId())) { -// strategy = station.getCurrentTurnBackStrategy(); -// } -// return this.selectTbRouteByStrategy(simulation, train, signal, null, strategy, trainList); -// } -// } -// } -// // 非终点折返办理,根据列车预计到站查询 -// if (Objects.nonNull(train.getEstimatedArriveStandTrack())) { -// // 查询到达预计到站的路径 -// Section eaStandSection = repository.getByCode(train.getEstimatedArriveStandTrack(), Section.class); -// List paths = repository.queryRoutePathsByEnd(eaStandSection); -// for (RoutePath path : paths) { -// if (path.containsSection(headSection) && path.isRight() == right) { -// routePaths.add(path); -// } -// } -// // 如果预计到达不是终点,尝试查询从预计到达开始的路径 -// if (!destDefinition.isEndSection(eaStandSection, right)) { -// List pathList = repository.queryRoutePathsByStart(eaStandSection); -// for (RoutePath routePath : pathList) { -// if (destDefinition.containsSection(routePath.getEnd(), right)) { -// routePaths.add(routePath); -// } -// } -// } -// } } else { // 按交路查询办理,如果找到才办理 Routing routing = train.getRouting(); 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 c6425d677..a197cfb4f 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 @@ -345,7 +345,9 @@ public class AtsTrainService { // this.onboardAtpApiService.change2Manual(simulation, groupNumber); supervisedTrain.change2Manual(); VirtualRealityTrain train = repository.getOnlineTrainBy(groupNumber); - train.setTarget(null); + if (train.isStop()) { + train.setTarget(null); + } } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index c55eed5b7..df9583652 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -73,7 +73,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 列车前进最大速度 */ - private float speedMax = (float) (100 / 3.6); + private float speedMax = (float) (80 / 3.6); /** * 列车倒车最大速度