From 1fbe684487d9165938b4a0e9ab4780f0ffa22a11 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 8 Dec 2022 10:17:59 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=AE=9E=E8=AE=AD=E7=94=9F=E6=88=90?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AD=9B=E9=80=89=E3=80=81=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/training2/rule/BgSceneStatusRule.java | 8 ++-- .../rtss/vo/training2/rule/MapDeviceRule.java | 46 +++++++++++++++++++ .../vo/training2/rule/MapLocationRule.java | 16 +++++-- .../vo/training2/rule/PropertyValueRule.java | 2 +- 4 files changed, 63 insertions(+), 9 deletions(-) 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 3f5cac265..a9f560a63 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 @@ -386,7 +386,7 @@ public enum BgSceneStatusRule { STATION_POWER_ON_UNLOCK("车站上电解锁背景") { @Override public String doHandle(Simulation simulation, MapElement mapElement) { - Station station = (Station) mapElement; + Station station = MapElementRule.queryStation(mapElement); restartInterlock(simulation, station); return getBgScene(simulation); } @@ -394,7 +394,7 @@ public enum BgSceneStatusRule { STATION_OPEN_AUTO_SETTING_BG_SCENE("全站进路交ATS自动控背景") { @Override public String doHandle(Simulation simulation, MapElement mapElement) { - Station station = (Station) mapElement; + Station station = MapElementRule.queryStation(mapElement); if(!station.isInterlock()) { throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error); } @@ -419,7 +419,7 @@ public enum BgSceneStatusRule { STATION_CENTER_CONTROL_BG_SCENE ("车站设置中控背景") { @Override public String doHandle(Simulation simulation, MapElement mapElement) { - Station station = (Station) mapElement; + Station station = MapElementRule.queryStation(mapElement); station.setControlMode(Station.ControlMode.Local); return getBgScene(simulation); } @@ -427,7 +427,7 @@ public enum BgSceneStatusRule { STATION_STATION_CONTROL_BG_SCENE("车站转为站控背景") { @Override public String doHandle(Simulation simulation, MapElement mapElement) { - Station station = (Station) mapElement; + Station station = MapElementRule.queryStation(mapElement); station.setControlMode(Station.ControlMode.Center); return getBgScene(simulation); } 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 b1e22404c..20721956d 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 @@ -53,6 +53,33 @@ public enum MapDeviceRule { return MapDeviceRule.generateRandomElement(standList, NUMBER); } }, + CONTROL_STATION_STAND_LIST("控制模式车站的站台列表") { + @Override + public List filterMapDeviceList(Simulation simulation) { + // 车站列表 + List stationList = simulation.getRepository().getStationList().stream() + .filter(station -> !station.isDepot()).sorted(Comparator.comparingInt(Station::getSn)) + .collect(Collectors.toList()); + Station firstStation = stationList.get(0); + Station lastStation = stationList.get(stationList.size() - 1); + List standList = simulation.getRepository().getStandList().stream().filter(stand -> { + if (stand.getStation() != null && stand.getStation().isDepot()) + return false; + // 去除第一个与最后一个站的站台 + if (firstStation.equals(stand.getStation()) || lastStation.equals(stand.getStation())) { + return false; + } + if (!stand.isVisible() || !stand.hasDoor() || stand.isSmall()) { // 特殊站台 + return false; + } + if (!stand.getStation().isHasControlMode()) { + return false; + } + return true; + }).sorted(Comparator.comparingInt(stand -> stand.getStation().getSn())).collect(Collectors.toList()); + return MapDeviceRule.generateRandomElement(standList, NUMBER); + } + }, ROUTE_LIST("进路列表") { @Override public List filterMapDeviceList(Simulation simulation) { @@ -104,6 +131,25 @@ public enum MapDeviceRule { return generateRandomElement(switchList, 1); } }, + CONTROL_STATION_SWITCH_LIST("控制模式车站的道岔列表") { + @Override + public List filterMapDeviceList(Simulation simulation) { + List switchList = simulation.getRepository().getSwitchList().stream() + .filter(aSwitch -> { + if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot()) + return false; + if (!aSwitch.getDeviceStation().isHasControlMode()) { + return false; + } + if (aSwitch.isSingleLock()) { + return false; + } + aSwitch.setSingleLock(false); + return true; + }).collect(Collectors.toList()); + return generateRandomElement(switchList, 1); + } + }, SIGNAL_LIST("信号机列表") { @Override public List filterMapDeviceList(Simulation simulation) { diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MapLocationRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MapLocationRule.java index 93f1af729..00e48c1f7 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MapLocationRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MapLocationRule.java @@ -11,10 +11,7 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.map.MapGraphDataNewVO; -import club.joylink.rtss.vo.map.graph.MapSignalNewVO; -import club.joylink.rtss.vo.map.graph.MapStationNewVO; -import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; -import club.joylink.rtss.vo.map.graph.Point; +import club.joylink.rtss.vo.map.graph.*; import lombok.Getter; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -65,6 +62,17 @@ public enum MapLocationRule { return stationStandNewVO.getPosition(); }); } + }, + SECTION_MAP_LOCATION("使用区段定位") { + @Override + public String doHandle(Simulation simulation, MapElement mapElement) { + return calcMapLocation(simulation, () -> { + MapGraphDataNewVO mapGraphDataNewVO = simulation.getBuildParams().getMap().getGraphDataNew(); + MapSectionNewVO sectionNewVO = mapGraphDataNewVO.getSectionList().stream() + .filter(s -> s.getCode().equals(mapElement.getCode())).findFirst().get(); + return sectionNewVO.getPoints().get(0); + }); + } } ; diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/PropertyValueRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/PropertyValueRule.java index 94979b50e..54dc81a45 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/PropertyValueRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/PropertyValueRule.java @@ -132,7 +132,7 @@ public enum PropertyValueRule { CENTER_CONTROL_STATION_CODE_LIST("站控转中控时车站列表") { @Override public Object resolve(Simulation simulation, Object mapElement) { - Station station = (Station) mapElement; + Station station = MapElementRule.queryStation(mapElement); return List.of(station.getCode()); } },