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 648fb90d3..4ed9a668d 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 @@ -11,13 +11,9 @@ import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.status.StationStatus; import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption; import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO; -import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferResultVO; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; -import club.joylink.rtss.vo.client.SocketMessageVO; -import club.joylink.rtss.vo.client.WebSocketMessageType; -import club.joylink.rtss.vo.client.factory.SocketMessageFactory; import club.joylink.rtss.websocket.StompMessageService; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; @@ -186,19 +182,27 @@ public class AtsStationService { if (CollectionUtils.isEmpty(replyVOList)) { throw new SimulationException(SimulationExceptionType.Invalid_Operation, "回复结果列表不能为空"); } - List resultVOList = new ArrayList<>(replyVOList.size()); + List stationCodes = new ArrayList<>(replyVOList.size()); + SimulationMember simulationMember = null; + boolean replyResult = false; for (ControlTransferReplyVO reply : replyVOList) { Station station = simulation.getRepository().getByCode(reply.getStationCode(), Station.class); if (station.isControlTransferApplying()) { if (reply.isAgree()) { station.setControlMode(controlMode); } - resultVOList.add(new ControlTransferResultVO(station, reply.isAgree())); + if (!Station.ControlMode.Center.equals(controlMode)) { + simulationMember = station.getApplicant(); + replyResult = reply.isAgree(); + stationCodes.add(station.getCode()); + } station.cancelControlTransferApplication(); } } - if (!CollectionUtils.isEmpty(resultVOList)) { - resultVOList.forEach(vo -> sendHandlerMessage(simulation.getId(), vo)); + if (!CollectionUtils.isEmpty(stationCodes)) { + atsMessageCollectAndDispatcher.handlerOperateMessage(simulation, + new OperationMessage(simulationMember.getId(), new HashSet<>(Collections.singleton(simulationMember)), + Operation.Type.CM_Reply_Station_Control, null, replyResult, stationCodes)); } } @@ -560,16 +564,4 @@ public class AtsStationService { new OperationMessage(fromMember.getId(), new HashSet<>(Collections.singleton(fromMember)), operationType, null, true, Arrays.asList(stationCode))); } - - /** - * 发送车站转换结果 - * - * @param group 仿真 - * @param vo 转换结果 - */ - private void sendHandlerMessage(String group, ControlTransferResultVO vo) { - SocketMessageVO> messageVO = - SocketMessageFactory.build(WebSocketMessageType.Simulation_Control_Transfer_Result, group, vo.getData()); - stompMessageService.sendToUser(Set.of(vo.getUserId()), messageVO); - } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java index a47bff2af..f10555792 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java @@ -543,7 +543,7 @@ public class CiApiServiceImpl2 implements CiApiService { station = station.getDeviceStation(); } Station deviceStation = station; - boolean restartFlag = Objects.nonNull(deviceStation.getRestartTime()) && deviceStation.getRestartTime().isBefore(LocalTime.now()); + boolean restartFlag = Objects.nonNull(deviceStation.getRestartTime()) && deviceStation.getRestartTime().isBefore(simulation.getCorrectSystemTime().toLocalTime()); // 是否大铁设备 boolean hasCTCFlag = simulation.getRepository().getConfig().isRailway(); // 大铁异常提示语 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java index 5ac473614..985c46bc6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java @@ -5,6 +5,8 @@ import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement; import club.joylink.rtss.simulation.cbtc.data.storage.ato.StorageSpeedCurve; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; +import club.joylink.rtss.simulation.cbtc.exception.SimulationException; +import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.NonNull; @@ -44,7 +46,15 @@ public class StorageMa { public MaService.Ma convert2SimulationObj(SimulationDataRepository repository) { VirtualRealityTrain train = repository.getVRByCode(trainCode, VirtualRealityTrain.class); - MapNamedElement device = repository.getByCode(deviceCode, MapNamedElement.class); + MapNamedElement device = null; + if (repository.getDeviceMap().containsKey(deviceCode)) { + device = repository.getByCode(deviceCode, MapNamedElement.class); + } else if (repository.getVrDeviceMap().containsKey(deviceCode)) { + device = repository.getVrDeviceMap().get(deviceCode); + } else { + throw new SimulationException(SimulationExceptionType.System_Fault, + String.format("地图数据异常:不存在code为[%s]的数据", deviceCode)); + } MaService.Ma ma = new MaService.Ma(train, device, type); if (eoaPosition != null) { ma.setEoaPosition(eoaPosition.convert2SimulationObj(repository)); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ControlTransferResultVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ControlTransferResultVO.java deleted file mode 100644 index 6898982c9..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ControlTransferResultVO.java +++ /dev/null @@ -1,46 +0,0 @@ -package club.joylink.rtss.simulation.cbtc.data.vo; - -import club.joylink.rtss.simulation.cbtc.data.map.Station; -import club.joylink.rtss.simulation.cbtc.member.SimulationMember; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.HashMap; -import java.util.Map; - -/** - * 控制权转换结果信息 - */ -@Getter -@Setter -@NoArgsConstructor -public class ControlTransferResultVO { - - private String stationCode; - - private String applicantId; - - private String userId; - - private Station.ControlMode apply2TheControlMode; - - private boolean status; - - public ControlTransferResultVO(Station station, boolean agree) { - this.status = agree; - this.stationCode = station.getCode(); - this.applicantId = station.getApplicantId(); - this.userId = station.getApplicant().getUserId(); - this.apply2TheControlMode = station.getApply2TheControlMode(); - } - - public Map getData() { - Map resultMap = new HashMap<>(); - resultMap.put("stationCode", stationCode); - resultMap.put("applicantId", applicantId); - resultMap.put("apply2TheControlMode", apply2TheControlMode); - resultMap.put("status", status); - return resultMap; - } -} diff --git a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java index a21d26428..5589c3f88 100644 --- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java +++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java @@ -162,10 +162,6 @@ public enum WebSocketMessageType { * 仿真-报警 */ Simulation_Alarm, - /** - * 仿真-控制模式转换结果 - */ - Simulation_Control_Transfer_Result, //------------------ 仿真剧本 ------------------ /** diff --git a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java index e3039b2eb..9788a7295 100644 --- a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java +++ b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java @@ -102,7 +102,6 @@ public class SocketMessageFactory { topicList.add(SimulationSubscribeTopic.Main.buildDestination(group)); break; } - case Simulation_Control_Transfer_Result: case Simulation_DeviceStatus: { topicList.add(SimulationSubscribeTopic.DeviceStatus.buildDestination(group)); break; 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 5ddf61bbc..6ad489cc8 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 @@ -314,6 +314,17 @@ public enum BgSceneStatusRule { return getBgScene(simulation); } }, + SIGNAL_HUMAN_RELEASE_NB_BG_SCENE("宁波信号机总人解背景"){ + @Override + public String doHandle(Simulation simulation, MapElement mapElement) { + Signal signal = (Signal) mapElement; + Route route = signal.getRouteList().get(0); + openRouteDirect(simulation, route); + closeSignalDirectly(route.getStart()); + Section.AxleFault.FAULT.apply(route.getStart().getSection()); + return getBgScene(simulation); + } + }, /** * 区段区故解背景 */ @@ -694,7 +705,7 @@ public enum BgSceneStatusRule { station = station.getDeviceStation(); } station.setInterlockMachineStarting(true); - station.setRestartTime(LocalTime.now()); + station.setRestartTime(simulation.getCorrectSystemTime().toLocalTime()); Station.Fault.INTERLOCK_FAULT.fix(station); //恢复联锁机故障 SimulationDataRepository repository = simulation.getRepository(); //该站范围内区段故障锁闭 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 95ceb6dab..b228d550f 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 @@ -2,6 +2,7 @@ package club.joylink.rtss.vo.training2.rule; import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; @@ -393,7 +394,7 @@ public enum MapDeviceRule { SECTION_SWITCH_AXLE_TRACK_LIST("道岔计轴区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - return generateRandomElement(querySectionListByFunction(simulation,s -> s.isAxleCounter() && !s.isSwitchAxleCounterSection()), NUMBER); + return generateRandomElement(querySectionListByFunction(simulation,s -> s.isAxleCounter() && s.isSwitchAxleCounterSection()), NUMBER); } }, SECTION_CROSS_LIST("岔心区段列表") { @@ -423,7 +424,28 @@ public enum MapDeviceRule { if (section.isSwitchTrack() || section.isSwitchAxleCounterSection() || section.isLogicSection() || section.isCross()) { return false; } - return section.getDeviceStation().isCentralized(); + if (section.getStation() != null) { + return section.getStation().isCentralized(); + } else { + return section.getDeviceStation().isCentralized(); + } + }); + return generateRandomElement(sectionList, NUMBER); + } + }, + SECTION_CONTROL_LIST("控制模式车站区段列表") { + @Override + public List
filterMapDeviceList(Simulation simulation) { + List
sectionList = queryNormalSectionList(simulation, section -> { + // 普通区段排除道岔区段 + if (section.isSwitchTrack() || section.isSwitchAxleCounterSection() || section.isLogicSection() || section.isCross()) { + return false; + } + if (section.getStation() != null) { + return section.getStation().isHasControlMode(); + } else { + return section.getDeviceStation().isHasControlMode(); + } }); return generateRandomElement(sectionList, NUMBER); } @@ -564,11 +586,22 @@ public enum MapDeviceRule { }), NUMBER); } }, + ROUTE_CENTRALIZED_LIST("集中站本站进路列表"){ + @Override + public List filterMapDeviceList(Simulation simulation) { + return generateRandomElement(queryNormalRouteList(simulation, route -> { + if (!route.getInterlockStation().isCentralized()) { + return false; + } + return Objects.equals( route.getStart().getDeviceStation(), route.getDestination().getDeviceStation()); + }), NUMBER); + } + }, ROUTE_CONTROL_LIST("控制模式车站进路列表") { @Override public List filterMapDeviceList(Simulation simulation) { return generateRandomElement(queryNormalRouteList(simulation, route ->{ - return route.getInterlockStation().isHasControlMode() && !route.isGuide(); + return route.getInterlockStation().isHasControlMode() && !route.isGuide() && !route.isTurnBack(); }), NUMBER); } }, @@ -583,7 +616,20 @@ public enum MapDeviceRule { ROUTE_DEPARTURE_LIST("发车进路列表") { @Override public List filterMapDeviceList(Simulation simulation) { - return generateRandomElement(queryNormalRouteList(simulation, route -> Objects.equals(Route.Type.DEPARTURE, route.getType())), NUMBER); + List routeList = new ArrayList<>(); + simulation.getRepository().getStationList().forEach(station -> { + station.getStationDirectionMap().forEach((k, v) -> { + if (StationDirection.DirectionRunModel.A.equals(v.getRunModel())) { + if (StationDirection.ReceiveAndDeliverModel.D.equals(v.getDefaultRunStatus())) { + List list = v.getDeliverRouteList().stream() + .filter(route -> !CollectionUtils.isEmpty(route.getSectionList())) + .collect(Collectors.toList()); + routeList.addAll(list); + } + } + }); + }); + return generateRandomElement(routeList, NUMBER); } }, ROUTE_FIRST_STATION_LIST("获取第一个站进路列表") { diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java index ce25fc10a..755e0b613 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java @@ -1,9 +1,12 @@ package club.joylink.rtss.vo.training2.rule; +import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; +import java.util.Objects; + /** * 实训获取元素属性的公共代码,生成实训时使用 */ @@ -33,7 +36,12 @@ public abstract class MapElementRule { } else if (mapElement instanceof Switch) { return ((Switch) mapElement).getDeviceStation(); } else if (mapElement instanceof Route) { - return ((Route) mapElement).getInterlockStation(); + Route route = ((Route) mapElement); + if (route.getInterlockStation() != null) { + return route.getInterlockStation(); + } else { + return route.getStart().getStation() != null ? route.getStart().getStation() : route.getStart().getDeviceStation(); + } } throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error); } @@ -56,6 +64,32 @@ public abstract class MapElementRule { throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error); } + /** + * 获取终端信号机 + * + * @param simulation + * @param route + * @return + */ + public static Signal queryEndSignal(Simulation simulation, Route route) { + Signal startSignal = route.getStart(); + Signal endSignal = route.getDestination(); + Signal resultSignal = null; + if (!Objects.equals(startSignal.getDeviceStation(), endSignal.getDeviceStation())) { + resultSignal = simulation.getRepository().getSignalList().stream().filter(signal -> Signal.SignalType.TRANSMISSION.equals(signal.getType()) + && signal.getLinkSignal() != null && signal.getLinkSignal().getCode().equals(endSignal.getCode())) + .findFirst().orElse(null); + } + if (resultSignal != null) { + return resultSignal; + } + if (route.getDestinationButtonSignal() != null) { + return route.getDestinationButtonSignal(); + } else { + return route.getDestination(); + } + } + private static Signal querySectionSignal(Section section) { boolean flag = true; do { 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 1a8a0710d..445cf5a79 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 @@ -1,5 +1,6 @@ package club.joylink.rtss.vo.training2.rule; +import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; @@ -69,7 +70,15 @@ public enum MapLocationRule { return calcMapLocation(simulation, () -> { MapGraphDataNewVO mapGraphDataNewVO = simulation.getBuildParams().getMap().getGraphDataNew(); MapSectionNewVO sectionNewVO = mapGraphDataNewVO.getSectionList().stream() - .filter(s -> s.getCode().equals(mapElement.getCode())).findFirst().get(); + .filter(s -> Objects.equals(s.getCode(), mapElement.getCode())).findFirst().get(); + // 道岔区段 + if (Objects.equals(sectionNewVO.getType(), BusinessConsts.Section.SectionType.Type04) + && !CollectionUtils.isEmpty(sectionNewVO.getRelevanceSectionList())) { + String pointCode = sectionNewVO.getRelevanceSectionList().get(0); + MapSectionNewVO pointSectionNew = mapGraphDataNewVO.getSectionList().stream() + .filter(s -> Objects.equals(s.getCode(), pointCode)).findFirst().get(); + return pointSectionNew.getPoints().get(0); + } return sectionNewVO.getPoints().get(0); }); } @@ -110,7 +119,7 @@ public enum MapLocationRule { MapStationNewVO stationNewVO = simulation.getBuildParams().getMap().getGraphDataNew().getStationList().stream() .filter(mapStationNewVO -> !mapStationNewVO.isDepot()).findFirst().get(); // 横向偏差 - int x = point.getX() - 960; // 屏幕一般宽度 + int x = (int) ((point.getX() - 960) * Double.valueOf(s)); // 屏幕一般宽度 // 纵向偏差 Point origin = simulation.getBuildParams().getMap().getGraphDataNew().getOrigin(); int y = (origin == null) ? stationNewVO.getPosition().getY() - 200 : origin.getY(); 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 71a298438..ac9f40f74 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 @@ -5,6 +5,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.vo.map.graph.MapSignalButtonVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.Getter; import java.util.*; @@ -48,6 +49,15 @@ public enum PropertyValueRule { return MapElementRule.queryStation(mapElement).getCode(); } }, + STATION_JP("地图设备所属车站简拼"){ + @Override + public Object resolve(Simulation simulation, Object mapElement) { + String stationCode = MapElementRule.queryStation(mapElement).getCode(); + MapStationNewVO stationNewVO = simulation.getBuildParams().getMap().getGraphDataNew().getStationList().stream() + .filter(s -> Objects.equals(stationCode, s.getCode())).findFirst().orElse(null); + return stationNewVO.getJp(); + } + }, ROUTE_START_SIGNAL_NAME("进路起始名称") { @Override public String resolve(Simulation simulation, Object mapElement) { @@ -89,23 +99,13 @@ public enum PropertyValueRule { ROUTE_END_SIGNAL_NAME("进路末端名称") { @Override public String resolve(Simulation simulation, Object mapElement) { - Route route = (Route) mapElement; - if (route.getDestinationButtonSignal() != null) { - return route.getDestinationButtonSignal().getShowName(); - } else { - return route.getDestination().getShowName(); - } + return MapElementRule.queryEndSignal(simulation, (Route) mapElement).getShowName(); } }, ROUTE_END_SIGNAL_CODE("进路末端信号机编码") { @Override public String resolve(Simulation simulation, Object mapElement) { - Route route = (Route) mapElement; - if (route.getDestinationButtonSignal() != null) { - return route.getDestinationButtonSignal().getCode(); - } else { - return route.getDestination().getCode(); - } + return MapElementRule.queryEndSignal(simulation, (Route) mapElement).getCode(); } }, ROUTE_END_BUTTON_SIGNAL_NAME("进路终端按钮信号机名称") { @@ -114,6 +114,25 @@ public enum PropertyValueRule { return ((Route) mapElement).getDestinationButtonSignal().getShowName(); } }, + ROUTE_END_BUTTON_SIGNAL_CODE("进路终端按钮信号机编码") { + @Override + public Object resolve(Simulation simulation, Object mapElement) { + return ((Route) mapElement).getDestinationButtonSignal().getCode(); + } + }, + ROUTE_END_PICK_BUTTON_CODE("进路终端接车按钮编码") { + @Override + public String resolve(Simulation simulation, Object mapElement) { + Route route = (Route) mapElement; + List signalButtonList = simulation.getBuildParams().getMap().getGraphDataNew().getSignalButtonList(); + MapSignalButtonVO buttonVO = signalButtonList.stream().filter(button -> MapSignalButtonVO.Type.PICK.equals(button.getType()) + && Objects.equals(button.getSignalCode(), route.getDestination().getCode())).findFirst().orElse(null); + if (buttonVO == null) { + throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "错误数据"); + } + return buttonVO.getCode(); + } + }, SIGNAL_BUTTON_CODE("信号机按钮编码") { @Override public String resolve(Simulation simulation, Object mapElement) {