From cd344bc3f033ce97b30189e7980a0509f7d5691e Mon Sep 17 00:00:00 2001 From: weizhihong Date: Wed, 7 Dec 2022 10:12:02 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=AE=9E=E8=AE=AD=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BF=AE=E6=94=B9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/training2/Training2RuleService.java | 4 ++-- .../vo/training2/rule/BgSceneStatusRule.java | 16 ++++++++++++++++ .../rtss/vo/training2/rule/MapDeviceRule.java | 16 +++++++++++++--- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2RuleService.java b/src/main/java/club/joylink/rtss/services/training2/Training2RuleService.java index 5512d485e..5a783fb18 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2RuleService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2RuleService.java @@ -68,7 +68,7 @@ public class Training2RuleService { publishedTraining2Example.createCriteria().andMapIdEqualTo(mapId).andCreatorIdEqualTo(0L); publishedTraining2DAO.deleteByExample(publishedTraining2Example); // 生成新数据 - ruleList.forEach(rule -> { + for (RtsTraining2RuleWithBLOBs rule : ruleList) { Training2Rule training2Rule = new Training2Rule(rule); List deviceList = training2Rule.getDeviceRule().filterMapDeviceList(simulation); List training2WithBLOBs = new ArrayList<>(deviceList.size()); @@ -79,7 +79,7 @@ public class Training2RuleService { } // 新数据入库 publishedTraining2DAO.insertList(training2WithBLOBs); - }); + } } } } finally { diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java index 058b1ea2c..3f5cac265 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java @@ -35,6 +35,14 @@ public enum BgSceneStatusRule { /** * 设置进路背景blockade */ + ROUTE_SET_BG_SCENE("排列进路背景") { + @Override + public String doHandle(Simulation simulation, MapElement mapElement) { + Route route = (Route) mapElement; + route.getSwitchList().forEach(switchElement -> switchElement.getASwitch().setSingleLock(false)); + return getBgScene(simulation); + } + }, ROUTE_CANCEL_BG_SCENE("取消进路背景") { @Override public String doHandle(Simulation simulation, MapElement mapElement) { @@ -91,6 +99,14 @@ public enum BgSceneStatusRule { /** * 道岔单解背景:将道岔设置为封锁 */ + SWITCH_SINGLE_BLOCK_BG_SCENE("道岔单锁背景") { + @Override + public String doHandle(Simulation simulation, MapElement mapElement) { + Switch iSwitch = (Switch) mapElement; + iSwitch.setSingleLock(false); + return getBgScene(simulation); + } + }, SWITCH_SINGLE_UNBLOCK_BG_SCENE("道岔单解背景") { @Override public String doHandle(Simulation simulation, MapElement mapElement) { diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java index 5808f8e29..8141aa7e5 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java @@ -70,6 +70,10 @@ public enum MapDeviceRule { if (route.isGuide()) { // 引导进路跳过 return false; } + // 排除道岔默认单锁的进路 + if (route.getSwitchList().stream().anyMatch(switchElement -> switchElement.getASwitch().isSingleLock())) { + return false; + } if (railway) { if (route.isPassRoute() || route.isLongShuntingRoute() || !(Route.Type.RECEIVING.equals(route.getType()) || Route.Type.DEPARTURE.equals(route.getType()))) { @@ -84,10 +88,16 @@ public enum MapDeviceRule { SWITCH_LIST("道岔列表") { @Override public List filterMapDeviceList(Simulation simulation) { - List stationList = STATION_LIST.filterMapDeviceList(simulation); - Station station = stationList.get(0); List switchList = simulation.getRepository().getSwitchList().stream() - .filter(aSwitch -> station.equals(aSwitch.getDeviceStation())).collect(Collectors.toList()); + .filter(aSwitch -> { + if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot()) + return false; + if (aSwitch.isSingleLock()) { + return false; + } + aSwitch.setSingleLock(false); + return true; + }).collect(Collectors.toList()); return generateRandomElement(switchList, 1); } },