diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java index b9fa63222..b8dfa0675 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java @@ -279,8 +279,15 @@ public class AtsStationService { * @param station */ public void surrenderControl(Simulation simulation, SimulationMember member, Station station) { - Station controlModeStation = station.getControlModeStation(); - controlModeStation.surrenderControl(); + Station deviceStation; + if (station.isCentralized()) { + deviceStation = station; + } else { + deviceStation = station.getDeviceStation(); + } + SimulationDataRepository repository = simulation.getRepository(); + Set stations = repository.getStationsByDeviceStations(deviceStation); + stations.forEach(Station::surrenderControl); } /** @@ -291,13 +298,18 @@ public class AtsStationService { * @param station */ public void receiveControl(Simulation simulation, SimulationMember member, Station station) { - Station controlModeStation = station.getControlModeStation(); + Station deviceStation; + if (station.isCentralized()) { + deviceStation = station; + } else { + deviceStation = station.getDeviceStation(); + } + SimulationDataRepository repository = simulation.getRepository(); + Set stations = repository.getStationsByDeviceStations(deviceStation); if (member.isDispatcher()) { - // 行调 - controlModeStation.occControl(); + stations.forEach(Station::occControl); } else if (member.isStationSupervisor()) { - // 车站 - controlModeStation.localControl(); + stations.forEach(Station::localControl); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java index 77f129a15..161381f0e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java @@ -23,9 +23,6 @@ public class MapDeviceBuilder { /** * 校验并构建设备数据 - * - * @param graphData - * @param mapDataBuildResult */ static void checkAndBuildMapDeviceData(MapGraphDataNewVO graphData, SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult) { Map elementMap = mapDataBuildResult.getDeviceMap(); @@ -41,65 +38,7 @@ public class MapDeviceBuilder { elementMap.put(zc.getCode(), zc); }); // 车站 - List stationList = graphData.getStationList(); - stationList.forEach(stationVO -> { - Station station = new Station(stationVO.getCode(), stationVO.getName()); - if (Objects.nonNull(elementMap.get(station.getCode()))) { - errMsgList.add(String.format("编码为[%s]的车站不唯一", station.getCode())); - } - elementMap.put(station.getCode(), station); - station.setCentralized(stationVO.isCentralized()); - if (station.isCentralized()) { - ZC zc = (ZC) elementMap.get(stationVO.getZcCode()); - if (Objects.isNull(zc)) { - errMsgList.add(String.format("车站[%s(%s)]未关联ZC或ZC不存在,请在ZC设备处选择管理的集中站列表", station.getName(), station.getCode())); - } else { - station.setZc(zc); - } - } - if (Objects.isNull(stationVO.getKmRange())) { - errMsgList.add(String.format("车站[%s(%s)]未设置距离", stationVO.getName(), stationVO.getCode())); - } else { - station.setKmPostVal(stationVO.getKmRange()); - } - if (Objects.isNull(stationVO.getSn())) { - errMsgList.add(String.format("车站[%s(%s)]序号未设置", stationVO.getName(), stationVO.getCode())); - } else { - station.setSn(stationVO.getSn()); - } - station.setInterlock(stationVO.isCiStation()); - station.setHasControlMode(stationVO.isCreateControlMode()); - station.setDepot(stationVO.isDepot()); - station.setRoutingStationList(stationVO.getRoutingStationList()); - station.setTurnBack(stationVO.isReentry()); - station.setSmallRouting(stationVO.isSmallRouting()); - if (station.isDepot() && station.isTurnBack()) { - errMsgList.add(String.format("车站[%s(%s)]不能既是停车场,又是折返车站", - stationVO.getName(), stationVO.getCode())); - } - if (station.isHasControlMode()) { // 有控制模式,初始化为中控 - station.setControlMode(Station.ControlMode.Center); - } - }); - // 设备集中站下的车站关联ZC - stationList.forEach(stationVO -> { - Station station = (Station) elementMap.get(stationVO.getCode()); - if (station.isCentralized()) { // 如果是设备集中站 - List stationCodeList = stationVO.getChargeStationCodeList(); - if (!CollectionUtils.isEmpty(stationCodeList)) { - stationCodeList.forEach(code -> { - Station normal = (Station) elementMap.get(code); - if (Objects.isNull(normal)) { - errMsgList.add(String.format("设备集中站车站[%s(%s)]管理车站数据异常:编码为[%s]的车站不存在", - station.getName(), station.getCode(), code)); - } else { - normal.setDeviceStation(station); - normal.setZc(station.getZc()); - } - }); - } - } - }); + buildStation(graphData, elementMap, errMsgList); // 区段 List sectionList = graphData.getSectionList(); Map desCodeSectionMap = new HashMap<>(); @@ -930,6 +869,72 @@ public class MapDeviceBuilder { buildCatenary(graphData, elementMap, errMsgList, mapDataBuildResult.getCatenaryMap()); } + /** + * 构建车站数据 + */ + private static void buildStation(MapGraphDataNewVO graphData, Map elementMap, List errMsgList) { + // 车站 + List stationList = graphData.getStationList(); + stationList.forEach(stationVO -> { + Station station = new Station(stationVO.getCode(), stationVO.getName()); + if (Objects.nonNull(elementMap.get(station.getCode()))) { + errMsgList.add(String.format("编码为[%s]的车站不唯一", station.getCode())); + } + elementMap.put(station.getCode(), station); + station.setCentralized(stationVO.isCentralized()); + if (station.isCentralized()) { + ZC zc = (ZC) elementMap.get(stationVO.getZcCode()); + if (Objects.isNull(zc)) { + errMsgList.add(String.format("车站[%s(%s)]未关联ZC或ZC不存在,请在ZC设备处选择管理的集中站列表", station.getName(), station.getCode())); + } else { + station.setZc(zc); + } + } + if (Objects.isNull(stationVO.getKmRange())) { + errMsgList.add(String.format("车站[%s(%s)]未设置距离", stationVO.getName(), stationVO.getCode())); + } else { + station.setKmPostVal(stationVO.getKmRange()); + } + if (Objects.isNull(stationVO.getSn())) { + errMsgList.add(String.format("车站[%s(%s)]序号未设置", stationVO.getName(), stationVO.getCode())); + } else { + station.setSn(stationVO.getSn()); + } + station.setInterlock(stationVO.isCiStation()); + station.setHasControlMode(stationVO.isCreateControlMode()); + station.setDepot(stationVO.isDepot()); + station.setRoutingStationList(stationVO.getRoutingStationList()); + station.setTurnBack(stationVO.isReentry()); + station.setSmallRouting(stationVO.isSmallRouting()); + if (station.isDepot() && station.isTurnBack()) { + errMsgList.add(String.format("车站[%s(%s)]不能既是停车场,又是折返车站", + stationVO.getName(), stationVO.getCode())); + } + if (station.isHasControlMode()) { // 有控制模式,初始化为中控 + station.setControlMode(Station.ControlMode.Center); + } + }); + // 设备集中站下的车站关联ZC,联锁站下的车站关联联锁站 + stationList.forEach(stationVO -> { + Station station = (Station) elementMap.get(stationVO.getCode()); + if (station.isCentralized()) { // 如果是设备集中站 + List stationCodeList = stationVO.getChargeStationCodeList(); + if (!CollectionUtils.isEmpty(stationCodeList)) { + stationCodeList.forEach(code -> { + Station normal = (Station) elementMap.get(code); + if (Objects.isNull(normal)) { + errMsgList.add(String.format("设备集中站车站[%s(%s)]管理车站数据异常:编码为[%s]的车站不存在", + station.getName(), station.getCode(), code)); + } else { + normal.setDeviceStation(station); + normal.setZc(station.getZc()); + } + }); + } + } + }); + } + /** * 构建接触网数据 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java index e0c0a2766..f3a0bf5ab 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java @@ -373,14 +373,6 @@ public class Station extends MapNamedElement { } - public Station getControlModeStation() { - if (Objects.nonNull(this.hasControlMode)) { - return this; - } else { - return this.deviceStation; - } - } - /** * 是否中控 */ diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapStationNewVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapStationNewVO.java index dec2050d4..9ce25424c 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapStationNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapStationNewVO.java @@ -1,7 +1,7 @@ package club.joylink.rtss.vo.client.map.newmap; -import com.fasterxml.jackson.annotation.JsonIgnore; import club.joylink.rtss.vo.client.Point; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; @@ -155,7 +155,7 @@ public class MapStationNewVO { private boolean centralized; /** - * 是否连锁站 + * 是否联锁站 */ private boolean ciStation;