diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index 2fac6fd61..97d5f19f3 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -523,6 +523,7 @@ public class Training2Service { throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "实训不存在"); } Simulation simulation = groupSimulationCache.getSimulationByGroup(group); + loadTrainingPre(simulation); // 重置仿真状态 // groupSimulationService.planOver(group); simulationService.reset(group); @@ -603,6 +604,7 @@ public class Training2Service { * 加载实训数据 */ private void loadTraining(Simulation simulation, DraftTraining2WithBLOBs draftTraining2, LoginUserInfoVO loginUserInfoVO) { + loadTrainingPre(simulation); // 没有背景不做加载,加载的时候不做背景加载,开始的时候重新加载背景即可 if (!StringUtils.isEmpty(draftTraining2.getBgSceneJson())) { groupSimulationService.loadScenes(simulation.getId(), draftTraining2.getBgSceneJson()); @@ -623,6 +625,17 @@ public class Training2Service { simulationLifeCycleService.pause(simulation); } + /** + * 仿真加载实训时前置清空方法 + * @param simulation 仿真 + */ + private void loadTrainingPre(Simulation simulation) { + if (simulation.getTraining2() != null) { // 如果仿真存在旧的实训 + removeTrainingJob(simulation); + clearJumpStep(simulation); + } + } + /** * 判断实训步骤是否完成 */ @@ -674,7 +687,7 @@ public class Training2Service { } } // 发送步骤提示信息,需要跳过步骤不发消息 - if (!step.isPrompt() && !simulation.getTraining2().isJumpStep(step)) { + if (!step.isPrompt() && !simulation.getTraining2().haveJumpStep()) { step.setPrompt(true); // 标识已发送过消息 applicationContext.publishEvent(new SimulationStepTipEvent(this, simulation, step)); } @@ -929,8 +942,10 @@ public class Training2Service { addTrainingJob(simulation, training2); // 启动仿真 simulationLifeCycleService.resume(simulation); - // 发送开始消息 - trainingStatusMessage(simulation, 1); + // 发送开始消息,跳转不发送消息 + if (!training2.haveJumpStep()) { + trainingStatusMessage(simulation, 1); + } } /** @@ -938,8 +953,10 @@ public class Training2Service { */ private void clearJumpStep(Simulation simulation) { simulation.updateSpeed(Simulation.MIN_SPEED); - simulation.getTraining2().setJumpToStep(null); - simulation.getTraining2().finish(); + if (simulation.getTraining2() != null) { + simulation.getTraining2().setJumpToStep(null); + simulation.getTraining2().finish(); + } } /** diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationManager.java b/src/main/java/club/joylink/rtss/simulation/SimulationManager.java index 507f4d58d..07674e7a0 100644 --- a/src/main/java/club/joylink/rtss/simulation/SimulationManager.java +++ b/src/main/java/club/joylink/rtss/simulation/SimulationManager.java @@ -185,8 +185,11 @@ public class SimulationManager { String oldMemberId = simulationUser.getMemberId(); if (oldMemberId != null) { SimulationMember old = simulation.getSimulationMemberById(oldMemberId); - this.memberPlayChange(simulation, old, null); + if (Objects.equals(old.getUserId(), userId)) { // 这里做同用户对比,防止角色替换时,置NULL问题 + this.memberPlayChange(simulation, old, null); + } } + log.info("memberId:" + memberId + ";userId:" + userId); this.memberPlayChange(simulation, simulationMember, simulationUser); } else { this.memberPlayChange(simulation, simulationMember, null); 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 5ec2421f2..8b22929d1 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 @@ -7,6 +7,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption; import club.joylink.rtss.simulation.cbtc.data.vr.*; +import club.joylink.rtss.vo.map.MapCISwitchVO; import club.joylink.rtss.vo.map.MapGraphDataNewVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.RealLineConfigVO; @@ -114,6 +115,8 @@ public class MapDeviceBuilder { MapDeviceBuilder.buildCatenary(graphData, elementMap, errMsgList, mapDataBuildResult.getCatenaryMap()); //应答器 MapDeviceBuilder.buildResponderDataRef(graphData, elementMap, errMsgList, mapDataBuildResult.getSectionRespondersMap()); + // 设置信号机引导关键道岔信息 + initSignalGuideKeySwitch(graphData, elementMap, errMsgList); if (mapDataBuildResult.getErrMsgList().isEmpty()) { Map> sectionArriveMap = MapDeviceBuilder.buildNormalStandTrackAdjoinSections(mapDataBuildResult.getDeviceMap()); mapDataBuildResult.setSectionArriveNearMap(sectionArriveMap); @@ -1568,4 +1571,26 @@ public class MapDeviceBuilder { private static boolean isCross(String type) { return Objects.equals(type, BusinessConsts.Section.SectionType.Type05); } + + /** + * 初始化信号机的引导关键道岔设置(作用于引导信号的开放) + * @param graphData 地图信息 + * @param elementMap 设备信息 + * @param errMsgList 错误提示信息 + */ + private static void initSignalGuideKeySwitch(MapGraphDataNewVO graphData, Map elementMap, List errMsgList) { + graphData.getSignalList().stream().filter(s -> !CollectionUtils.isEmpty(s.getGuideKeySwitchList())).forEach(s -> { + List switchElementList = new ArrayList<>(s.getGuideKeySwitchList().size()); + for (MapCISwitchVO ciSwitchVO : s.getGuideKeySwitchList()) { + Switch aSwitch = (Switch) elementMap.get(ciSwitchVO.getSwitchCode()); + if (Objects.isNull(aSwitch)) { + errMsgList.add(String.format("编码为[%s]的道岔不存在", ciSwitchVO.getSwitchCode())); + } else { + switchElementList.add(new SwitchElement(aSwitch, ciSwitchVO.isNormal())); + } + } + Signal signal = (Signal) elementMap.get(s.getCode()); + signal.setGuideKeySwitchList(switchElementList); + }); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java index 2c6ec407f..d283a9b87 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java @@ -159,6 +159,11 @@ public class Signal extends DelayUnlockDevice { */ private List replaceSignals; + /** + * 信号机引导关键道岔列表 + */ + private List guideKeySwitchList; + // ------------------状态属性--------------------- private int mode; diff --git a/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java index 824f523e4..5dc890d52 100644 --- a/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.map.graph; import club.joylink.rtss.simulation.cbtc.data.map.Signal; +import club.joylink.rtss.vo.map.MapCISwitchVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; @@ -202,6 +203,11 @@ public class MapSignalNewVO { */ private String srCode; + /** + * 引导关键道岔列表 + */ + private List guideKeySwitchList; + @JsonIgnore public boolean isShunting() { return Signal.SignalType.SHUNTING.equals(this.type);