diff --git a/src/main/java/club/joylink/rtss/services/training/GenerateTask.java b/src/main/java/club/joylink/rtss/services/training/GenerateTask.java index 1ac37cf5a..13dc0a7aa 100644 --- a/src/main/java/club/joylink/rtss/services/training/GenerateTask.java +++ b/src/main/java/club/joylink/rtss/services/training/GenerateTask.java @@ -9,6 +9,7 @@ import club.joylink.rtss.services.training.generatornew.GeneratorNew; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; +import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.vo.client.CommandDefinitionVO; import club.joylink.rtss.vo.client.LessonChapterTrainingRelVO; import club.joylink.rtss.vo.client.LessonVO; @@ -77,6 +78,18 @@ public class GenerateTask { // 构造仿真数据 // 根据操作定义生成实训 definitionVOList.forEach(operateDefinitionVO -> { + if (operateDefinitionVO.useReplaceSignal()) { + mapVO.getGraphDataNew().getSignalList().stream() + .filter(signalVO -> Signal.SignalType.TRANSMISSION.equals(signalVO.getType())) + .forEach(signalVO -> { + Signal signal = new Signal(signalVO.getCode(), signalVO.getUniqueName()); + signal.setShowName(signalVO.getName()); + Signal linkSignal = simulation.getRepository().getByCode(signalVO.getLinkSignalCode(), Signal.class); + signal.setLinkSignal(linkSignal); + linkSignal.addReplaceSignal(signal); + simulation.getRepository().getSignalList().add(signal); + }); + } try { List trainingVOList = generator.generate(config, simulation, operateDefinitionVO); if (CollectionUtils.isEmpty(trainingVOList)) { diff --git a/src/main/java/club/joylink/rtss/services/training/constant/TrainingConsts.java b/src/main/java/club/joylink/rtss/services/training/constant/TrainingConsts.java index d73101a5e..67002f2d1 100644 --- a/src/main/java/club/joylink/rtss/services/training/constant/TrainingConsts.java +++ b/src/main/java/club/joylink/rtss/services/training/constant/TrainingConsts.java @@ -48,7 +48,10 @@ public interface TrainingConsts { /** 终端按钮信号机 */ END_BUTTON_SIGNAL, /** 终端按钮信号机 */ - BUTTON; + BUTTON, + /** 终端替代信号机 */ + END_REPLACE_SIGNAL, + ; } } diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java index 17d497154..906a1e10f 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java @@ -1,6 +1,7 @@ package club.joylink.rtss.services.training.generatornew; import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.services.training.constant.TrainingConsts; import club.joylink.rtss.services.training.data.GenerateConfig; import club.joylink.rtss.simulation.cbtc.Simulation; @@ -91,6 +92,23 @@ public interface GeneratorNew { case END_SIGNAL: s.setDeviceCode(((Route) mapDevice).getDestination().getCode()); break; + case END_REPLACE_SIGNAL: + Route route = (Route) mapDevice; + List replaceSignals = route.getDestination().getReplaceSignals(); + if (replaceSignals != null) { + Signal signal; + if (MapPrdTypeEnum.LOCAL.equals(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType()))) { + signal = replaceSignals.stream().filter(ss -> ss.getShowName().startsWith("F")).findFirst().orElse(null); + } else { + signal = replaceSignals.stream().filter(ss -> ss.getShowName().startsWith("T")).findFirst().orElse(null); + } + if (signal != null) { + s.setDeviceCode(signal.getCode()); + break; + } + } + s.setDeviceCode(route.getDestination().getCode()); + break; case END_BUTTON_SIGNAL: s.setDeviceCode(((Route) mapDevice).getDestinationButtonSignal().getCode()); break; 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 b7b609bd0..306319837 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 @@ -147,6 +147,11 @@ public class Signal extends DelayUnlockDevice { */ private Signal linkSignal; + /** + * 替代信号机 + */ + private List replaceSignals; + // ------------------状态属性--------------------- private int mode; @@ -615,6 +620,13 @@ public class Signal extends DelayUnlockDevice { return this.signalModel.getGuideAspect(); } + public void addReplaceSignal(Signal signal) { + if (replaceSignals == null) { + replaceSignals = new ArrayList<>(); + } + replaceSignals.add(signal); + } + public enum LightColor { RED, YELLOW, diff --git a/src/main/java/club/joylink/rtss/vo/client/training/definition/OperateDefinitionConfig.java b/src/main/java/club/joylink/rtss/vo/client/training/definition/OperateDefinitionConfig.java index ce17426b9..8d6dc7fae 100644 --- a/src/main/java/club/joylink/rtss/vo/client/training/definition/OperateDefinitionConfig.java +++ b/src/main/java/club/joylink/rtss/vo/client/training/definition/OperateDefinitionConfig.java @@ -26,6 +26,8 @@ public class OperateDefinitionConfig { private List sectionTypes;//区段生成指定类型 + public Boolean useReplaceSignal; + public boolean isAtp() { return RouteType.ATP.equals(this.routeType); } diff --git a/src/main/java/club/joylink/rtss/vo/client/training/definition/OperateDefinitionVO.java b/src/main/java/club/joylink/rtss/vo/client/training/definition/OperateDefinitionVO.java index 61a0d3f53..5d605bae7 100644 --- a/src/main/java/club/joylink/rtss/vo/client/training/definition/OperateDefinitionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/training/definition/OperateDefinitionVO.java @@ -198,4 +198,12 @@ public class OperateDefinitionVO { } return null; } + + public boolean useReplaceSignal() { + OperateDefinitionConfig routeSettingConfig = this.getRouteSettingConfig(); + if (Objects.nonNull(routeSettingConfig)) { + return routeSettingConfig.getUseReplaceSignal(); + } + return false; + } }