From 382d28ca314a1d6cee0b5f8c87d9b63dd2da5a1c Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 10 Feb 2023 18:26:44 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=AE=9E=E8=AE=AD=E9=81=93=E5=B2=94?= =?UTF-8?q?=E5=AE=9A=E5=8F=8D=E3=80=81=E5=8D=95=E9=94=81=E8=A7=A3=E3=80=81?= =?UTF-8?q?=E8=BD=AC=E5=8A=A8=E8=81=94=E5=8A=A8=E9=AA=8C=E8=AF=81=E5=A4=84?= =?UTF-8?q?=E7=90=86=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/training2/Training2Service.java | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) 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 63bb25804..92f968f5f 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -12,6 +12,7 @@ import club.joylink.rtss.simulation.cbtc.*; import club.joylink.rtss.simulation.cbtc.conversation.Conversation; import club.joylink.rtss.simulation.cbtc.conversation.ConversationManagerService; import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage; +import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.vo.ConversationMessageVO; import club.joylink.rtss.simulation.cbtc.data.vo.Training2MessageVO; import club.joylink.rtss.simulation.cbtc.event.SimulationOperationEvent; @@ -70,6 +71,15 @@ public class Training2Service { Operation.Type.Conversation_Chat_Audio_Base64.name() ); + /** + * 实训步骤执行道岔联动元素存在当前步骤元素 + */ + private static final List CHECK_SWITCH_STATUS_LIST = Arrays.asList( + Operation.Type.Switch_Turn.name(), + Operation.Type.Switch_Normal_Position.name(), Operation.Type.Switch_Reverse_Position.name(), + Operation.Type.Switch_Single_Lock.name(), Operation.Type.Switch_Single_Unlock.name() + ); + @Autowired private AtsOperationDispatcher atsOperationDispatcher; @@ -392,11 +402,14 @@ public class Training2Service { if (CONVERSATION_LIST.contains(simCommand2.getOperationType().name()) && CONVERSATION_LIST.contains(event.getOperate())) { checkSimOperationConversation(simCommand2, simulation, step, event.getOperate()); startFlag = Boolean.TRUE; - } else if (simCommand2.getOperationType().name().equals(event.getOperate()) && compareParams(event.getParams(), simCommand2.getParams())) { simCommand2.doOperated(); // 标识已操作过 simCommand2.doCompletion(); startFlag = Boolean.TRUE; + } else if (checkSwitchLinkOperation(simulation, simCommand2, event)) { + simCommand2.doOperated(); // 标识已操作过 + simCommand2.doCompletion(); + startFlag = Boolean.TRUE; } // 指令执行后启动仿真 if (simulation.isPause() && startFlag) { @@ -757,6 +770,30 @@ public class Training2Service { } } + /** + * 检查是否是道岔联动操作 + * @param simulation + * @param event + * @return + */ + private boolean checkSwitchLinkOperation(Simulation simulation, Operation2.SimCommand2 simCommand2, SimulationOperationEvent event) { + boolean flag = CHECK_SWITCH_STATUS_LIST.contains(simCommand2.getOperationType().name()) && CHECK_SWITCH_STATUS_LIST.contains(event.getOperate()); + if (flag) { + flag = simCommand2.getParams() != null && event.getParams() != null; + } + if (flag) { + String eventSwitchCode = event.getParams().getOrDefault("switchCode", "").toString(); + Switch aSwitch = simulation.getRepository().getByCode(eventSwitchCode, Switch.class); + Switch linkedSwitch = aSwitch.queryLinkedSwitch(); + flag = Objects.nonNull(linkedSwitch); + if (flag) { + String simComSwitchCode = simCommand2.getParams().getOrDefault("switchCode", "").toString(); + flag = Objects.equals(simComSwitchCode, linkedSwitch.getCode()); + } + } + return flag; + } + /** * 对比事件与操作参数 */