From c6a005c31f6d926552404fbbd9c5cced9b1a11a1 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 16 Jun 2022 10:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=BD=A6=E5=8A=A1=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=AB=AF=E7=94=9F=E6=95=88=E5=8C=BA=E7=9A=84=E7=94=9F=E6=95=88?= =?UTF-8?q?=E8=87=B3=E8=BD=A6=E7=AB=99=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/operation/Operation.java | 5 + .../CtcStationRunPlanOperateHandler.java | 12 ++ .../runplan/CtcStationRunPlanLogService.java | 149 +++++++----------- .../simulation/cbtc/CTC/CTCLogicLoop.java | 82 +++++++++- .../cbtc/CTC/data/CtcRepository.java | 8 + .../rtss/vo/client/WebSocketMessageType.java | 10 ++ .../client/factory/SocketMessageFactory.java | 4 +- 7 files changed, 170 insertions(+), 100 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index 6bb983ade..b90c13f2e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -958,6 +958,11 @@ public class Operation { * 将编辑区行车日志发布至仿真计划中 */ CTC_RELEASE_RUN_PLAN_TO_SIMULATION, + + /** + * 将CTC生效区发布至车站 + */ + CTC_RELEASE_EFFECT_AREA_TO_STATION, //---------------------------- 改方、辅助操作 ------------------------- /** * 改方按钮操作 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java index a6f758c9e..53cdc60cd 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java @@ -164,4 +164,16 @@ public class CtcStationRunPlanOperateHandler { public void agreeDepartureNotice(Simulation simulation, String stationCode, String runPlanCode) { ctcService.agreeDepartureNotice(simulation, stationCode, runPlanCode); } + + + /** + * 将CTC生效区发布至车站 + * + * @param simulation 仿真实体 + * @param stationCode 车站编码 + */ + @OperateHandlerMapping(type = Operation.Type.CTC_RELEASE_EFFECT_AREA_TO_STATION) + public void effectAreaToStation(Simulation simulation, String stationCode) { + ctcStationRunPlanLogService.effectAreaToStation(simulation, stationCode); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java index 2de504822..e30bd8273 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java @@ -10,16 +10,19 @@ import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -import club.joylink.rtss.util.RandomGenerator; import club.joylink.rtss.websocket.StompMessageService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalTime; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -75,27 +78,25 @@ public class CtcStationRunPlanLogService { } List runPlanLogList = new ArrayList<>(planParamList.size()); planParamList.stream().forEach(p -> { - CtcStationRunPlanLog changeRunPlanLog = null; // 要发的消息实体 - if (p.getStatus() <= 0) { // 修改、删除 - CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, p.getRunPlanCode()); - changeRunPlanLog = modifyRunPlanInfo(simulation, runPlanLog, p); - } else if (p.getStatus() == 1) { // 增加 - CtcStationRunPlanLog runPlanLog = createRunPlanLog(simulation, stationCode, p); + CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, p.getRunPlanCode()); + if (runPlanLog != null) { // 修改、删除 + if (modifyRunPlanInfo(simulation, runPlanLog, p)) { // 是否修改过股道 + runPlanLogList.add(runPlanLog); + } + } else { + runPlanLog = createRunPlanLog(simulation, stationCode, p); simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog); - changeRunPlanLog = runPlanLog; - } - if (changeRunPlanLog != null && !StringUtils.isEmpty(changeRunPlanLog.getCode())) { - runPlanLogList.add(changeRunPlanLog); + runPlanLogList.add(runPlanLog); } }); // 编辑过轨道的行车记录 - runPlanLogList.stream().filter(runPlanLog -> runPlanLog.getArriveRunPlan() != null || runPlanLog.getDepartRunPlan() != null) - .forEach(runPlanLog -> { - CtcStationRunPlanLog r = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanLog.getCode()); - if (runPlanLog.getArriveRunPlan() != null && runPlanLog.getArriveRunPlan().getTrackSection() != null) { + runPlanLogList.stream() + .filter(r -> r.getArriveRunPlan() != null || r.getDepartRunPlan() != null) + .forEach(r -> { + if (r.getArriveRunPlan() != null && r.getArriveRunPlan().getTrackSection() != null) { ctcService.runPlanItemUpdate(simulation, r.getStation(), r.getArriveRunPlan(), false); } - if (runPlanLog.getDepartRunPlan() != null && runPlanLog.getDepartRunPlan().getTrackSection() != null) { + if (r.getDepartRunPlan() != null && r.getDepartRunPlan().getTrackSection() != null) { ctcService.runPlanItemUpdate(simulation, r.getStation(), r.getDepartRunPlan(), true); } }); @@ -114,7 +115,7 @@ public class CtcStationRunPlanLogService { runPlanParamList.stream().forEach(p -> { String tripNumber = StringUtils.isEmpty(p.getArriveTripNumber()) ? p.getDepartTripNumber() : p.getArriveTripNumber(); p.setTripNumber(tripNumber); - String runPlanCode = p.generateId(); + String runPlanCode = tripNumber; if (stationRunPlanMap.containsKey(runPlanCode)) { modifyRunPlanParam(stationRunPlanMap.get(runPlanCode), p); } else { @@ -129,7 +130,7 @@ public class CtcStationRunPlanLogService { * * @param simulation 仿真实体 * @param stationCode 车站编码 - * @param tripNumber 车次 + * @param runPlanCode 车次 */ public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String runPlanCode) { Map stationRunLogTripNumberMap = simulation.getCtcRepository() @@ -161,7 +162,7 @@ public class CtcStationRunPlanLogService { runPlanParamList.forEach(p -> { String tripNumber = StringUtils.isEmpty(p.getArriveTripNumber()) ? p.getDepartTripNumber() : p.getArriveTripNumber(); p.setTripNumber(tripNumber); - p.setRunPlanCode(p.generateId()); + p.setRunPlanCode(tripNumber); }); Map planParamMap = runPlanParamList.stream().collect(Collectors.toMap(p -> p.getRunPlanCode(), (p) -> p)); simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().put(stationCode, planParamMap); @@ -175,29 +176,31 @@ public class CtcStationRunPlanLogService { */ public void releaseRunPlanToSimulation(Simulation simulation, String stationCode) { // 编辑区信息 - Map planParamMap = simulation.getCtcRepository() - .getSimulationRunPlanEditAreaMap().getOrDefault(stationCode, new ConcurrentHashMap<>()); - // 发布至生效区中 - simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap().put(stationCode, planParamMap); - + Map planParamMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap() + .getOrDefault(stationCode, new ConcurrentHashMap<>()); // 编辑区版本 + 1 AtomicInteger editVersion = simulation.getCtcRepository().getStationEditAreaVersion() .getOrDefault(stationCode, new AtomicInteger(0)); editVersion.decrementAndGet(); simulation.getCtcRepository().getStationEditAreaVersion().put(stationCode, editVersion); - + // 发布至生效区中 + simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap().put(stationCode, planParamMap); AtomicInteger effectVersion = new AtomicInteger(editVersion.get()); // 覆盖生效区版本 simulation.getCtcRepository().getStationEffectAreaVersion().put(stationCode, effectVersion); - //------------------ 下边这一步 --------- 后边需要移动到【生效至车站】操作中 - // 移除生效区中车站的所有计划(包括原始计划) - simulation.getCtcRepository().removeRunPlanByStationCode(stationCode); - // 添加至仿真CTC运行计划中 - List runPlanLogList = new LinkedList<>(); - planParamMap.forEach((k, p) -> { - CtcStationRunPlanLog runPlanLog = createRunPlanLog(simulation, stationCode, p); - simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog); - runPlanLogList.add(runPlanLog); - }); + } + + /** + * 【生效至车站】操作中 + * + * @param simulation 仿真实体 + * @param stationCode 车站编码 + */ + public void effectAreaToStation(Simulation simulation, String stationCode) { + Map runPlanParamMap = simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap().get(stationCode); + if (!CollectionUtils.isEmpty(runPlanParamMap)) { + List runPlanParamList = runPlanParamMap.values().stream().collect(Collectors.toList()); + modifyBatchRunPlan(simulation, stationCode, runPlanParamList, 1); + } } /** @@ -300,80 +303,53 @@ public class CtcStationRunPlanLogService { * @param planParam 修改参数 * @return */ - private CtcStationRunPlanLog modifyRunPlanInfo(Simulation simulation, CtcStationRunPlanLog runPlanLog, CtcRunPlanParam planParam) { - CtcStationRunPlanLog changeRunPlanLog = new CtcStationRunPlanLog(); + private boolean modifyRunPlanInfo(Simulation simulation, CtcStationRunPlanLog runPlanLog, CtcRunPlanParam planParam) { boolean change = false; if (planParam.getStatus() == -1) { runPlanLog.setDelete(Boolean.TRUE); - changeRunPlanLog.setDelete(Boolean.TRUE); - change = true; } - CtcStationRunPlanLog.RunPlanItem changeArriveItem = modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), planParam, true); - changeRunPlanLog.setArriveRunPlan(changeArriveItem); - change = change || changeArriveItem != null; - CtcStationRunPlanLog.RunPlanItem changeDepartItem = modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), planParam, false); - changeRunPlanLog.setDepartRunPlan(changeDepartItem); - change = change || changeDepartItem != null; + // 到达 + change = change || modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), planParam, true); + // 出发 + change = change || modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), planParam, false); // 存在不一样的选项 long modifyNum = planParam.getRunPlanTaskList().stream().filter(task -> !runPlanLog.getRunPlanTaskList().contains(task)).count(); if (modifyNum > 0 || (planParam.getRunPlanTaskList().size() != runPlanLog.getRunPlanTaskList().size())) { // 长度不一致直接赋值 runPlanLog.setRunPlanTaskList(planParam.getRunPlanTaskList()); - changeRunPlanLog.setRunPlanTaskList(planParam.getRunPlanTaskList()); - change = true; } // 是否客运 if (planParam.getPassenger() != null && !Objects.equals(planParam.getPassenger(), runPlanLog.getPassenger())) { runPlanLog.setPassenger(planParam.getPassenger()); - changeRunPlanLog.setPassenger(planParam.getPassenger()); - change = true; } // 重点列车 if (planParam.getKeyTrains() != null && !Objects.equals(planParam.getKeyTrains(), runPlanLog.getKeyTrains())) { runPlanLog.setKeyTrains(planParam.getKeyTrains()); - changeRunPlanLog.setKeyTrains(planParam.getKeyTrains()); - change = true; } // 是否军用 if (planParam.getMilitary() != null && !Objects.equals(planParam.getMilitary(), runPlanLog.getMilitary())) { runPlanLog.setMilitary(planParam.getMilitary()); - changeRunPlanLog.setMilitary(planParam.getMilitary()); - change = true; } // 运行股道与基本径路不一致 if (planParam.getTrackDiscordant() != null && !Objects.equals(planParam.getTrackDiscordant(), runPlanLog.getTrackDiscordant())) { runPlanLog.setTrackSectionCode(planParam.getTrackSectionCode()); - changeRunPlanLog.setTrackSectionCode(planParam.getTrackSectionCode()); - change = true; } // 出入口与基本径路不一致 if (planParam.getEntryOutDiscordant() != null && !Objects.equals(planParam.getEntryOutDiscordant(), runPlanLog.getEntryOutDiscordant())) { runPlanLog.setEntryOutDiscordant(planParam.getEntryOutDiscordant()); - changeRunPlanLog.setEntryOutDiscordant(planParam.getEntryOutDiscordant()); - change = true; } // 超限等级 if (planParam.getTransfinite() != null && !Objects.equals(planParam.getTransfinite(), runPlanLog.getTransfinite())) { runPlanLog.setTransfinite(planParam.getTransfinite()); - changeRunPlanLog.setTransfinite(planParam.getTransfinite()); - change = true; } // 记事 if (planParam.getRemark() != null && !Objects.equals(planParam.getRemark(), runPlanLog.getRemark())) { runPlanLog.setRemark(planParam.getRemark()); - changeRunPlanLog.setRemark(planParam.getRemark()); - change = true; } // 晚点原因 if (planParam.getLateReason() != null && !Objects.equals(planParam.getLateReason(), runPlanLog.getLateReason())) { runPlanLog.setLateReason(planParam.getLateReason()); - changeRunPlanLog.setLateReason(planParam.getLateReason()); - change = true; } - - if (change) { - changeRunPlanLog.setCode(planParam.getRunPlanCode()); - } - return changeRunPlanLog; + return change; } /** @@ -384,19 +360,12 @@ public class CtcStationRunPlanLogService { * @param paramInfo 参数 * @param arrive 是否到达 */ - private CtcStationRunPlanLog.RunPlanItem modifyRunPlanItemInfo(Simulation simulation, CtcStationRunPlanLog.RunPlanItem runPlanItem - , CtcRunPlanParam paramInfo, boolean arrive) { - CtcStationRunPlanLog.RunPlanItem changeItem = null; + private boolean modifyRunPlanItemInfo(Simulation simulation, CtcStationRunPlanLog.RunPlanItem runPlanItem, CtcRunPlanParam paramInfo, boolean arrive) { boolean change = false; if (runPlanItem != null) { - changeItem = new CtcStationRunPlanLog.RunPlanItem(); // 返回改变的实体 // 实际时间 LocalTime actualTime = arrive ? paramInfo.getArriveTime() : paramInfo.getDepartTime(); - if (actualTime != null) { - change = !Objects.equals(actualTime.toString(), runPlanItem.getActualTime()); - if (change) { - changeItem.setActualTime(actualTime.toString()); - } + if (actualTime != null && !Objects.equals(actualTime.toString(), runPlanItem.getActualTime())) { runPlanItem.setActualTime(actualTime.toString()); } // 股道编码 @@ -405,17 +374,12 @@ public class CtcStationRunPlanLogService { Section section = simulation.getRepository().getByCode(sectionCode, Section.class); change = !Objects.equals(section, runPlanItem.getTrackSection()); if (change) { - changeItem.setTrackSection(section); + runPlanItem.setTrackSection(section); } - runPlanItem.setTrackSection(section); } // 车次 String tripNumber = arrive ? paramInfo.getArriveTripNumber() : paramInfo.getDepartTripNumber(); - if (!StringUtils.isEmpty(tripNumber)) { - change = !Objects.equals(tripNumber, runPlanItem.getTripNumber()); - if (change) { - changeItem.setTripNumber(tripNumber); - } + if (!StringUtils.isEmpty(tripNumber) && !Objects.equals(tripNumber, runPlanItem.getTripNumber())) { runPlanItem.setTripNumber(tripNumber); } // 车站 @@ -424,12 +388,11 @@ public class CtcStationRunPlanLogService { Station station = simulation.getRepository().getByCode(stationCode, Station.class); change = !Objects.equals(station, runPlanItem.getStation()); if (change) { - changeItem.setStation(station); + runPlanItem.setStation(station); } - runPlanItem.setStation(station); } } - return change ? changeItem : null; + return change; } /** @@ -441,15 +404,15 @@ public class CtcStationRunPlanLogService { * @return */ private CtcStationRunPlanLog createRunPlanLog(Simulation simulation, String stationCode, CtcRunPlanParam paramInfo) { - CtcStationRunPlanLog ctcStationRunPlanLog = new CtcStationRunPlanLog(paramInfo); - ctcStationRunPlanLog.setCode(RandomGenerator.uuid()); - Station station = simulation.getRepository().getByCode(stationCode, Station.class); - ctcStationRunPlanLog.setStation(station); String tripNumber = paramInfo.getTripNumber(); if (StringUtils.isEmpty(tripNumber)) { tripNumber = StringUtils.isEmpty(paramInfo.getArriveTripNumber()) ? paramInfo.getDepartTripNumber() : paramInfo.getArriveTripNumber(); } - ctcStationRunPlanLog.setTripNumber(tripNumber); + paramInfo.setTripNumber(tripNumber); + CtcStationRunPlanLog ctcStationRunPlanLog = new CtcStationRunPlanLog(paramInfo); + ctcStationRunPlanLog.setCode(tripNumber); + Station station = simulation.getRepository().getByCode(stationCode, Station.class); + ctcStationRunPlanLog.setStation(station); ctcStationRunPlanLog.setArriveRunPlan(CtcStationRunPlanLog.createRunPlanItem(simulation, paramInfo, true)); ctcStationRunPlanLog.setDepartRunPlan(CtcStationRunPlanLog.createRunPlanItem(simulation, paramInfo, false)); return ctcStationRunPlanLog; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java index 985157289..5e82e4b4e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java @@ -46,9 +46,12 @@ public class CTCLogicLoop { // 发送运行计划变化消息 sendRunPlanChangeMessage(simulation); sendRunPlanRemoveMessage(simulation); - // 发送车务管理端消息 + // 发送车务管理端消息(编辑区) sendCtcManageChangeMessage(simulation); sendCtcManageRemoveMessage(simulation); + // 车务管理端消息(生效区) + sendCtcManageEffectChangeMessage(simulation); + sendCtcManageEffectRemoveMessage(simulation); } public void sendAllMessage(Simulation simulation) { @@ -249,7 +252,8 @@ public class CTCLogicLoop { } }); if (!CollectionUtils.isEmpty(messageList)) { - sendCtcMessage(simulation.getId(), messageList, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_CHANGE, simulation.getSimulationUserIds()); + sendCtcMessage(simulation.getId(), messageList + , WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_CHANGE, simulation.getSimulationUserIds()); } } @@ -267,7 +271,8 @@ public class CTCLogicLoop { if (!CollectionUtils.isEmpty(ctcRunPlanVOList)) { // 移除已删除的数据 ctcRunPlanVOList.forEach(vo -> ctcRunPlanVOMap.remove(vo.getStationCode() + "_" + vo.getCode())); - sendCtcMessage(simulation.getId(), ctcRunPlanVOList, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_REMOVE, simulation.getSimulationUserIds()); + sendCtcMessage(simulation.getId(), ctcRunPlanVOList + , WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_REMOVE, simulation.getSimulationUserIds()); } } @@ -291,7 +296,8 @@ public class CTCLogicLoop { allList.addAll(editAreaStatusVOMap.values()); } if (!CollectionUtils.isEmpty(allList)) { - sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT, userIds); + sendCtcMessage(simulation.getId(), allList + , WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT, userIds); } } } @@ -322,7 +328,8 @@ public class CTCLogicLoop { }); }); if (!CollectionUtils.isEmpty(allList)) { - sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE, simulation.getSimulationUserIds()); + sendCtcMessage(simulation.getId(), allList + , WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE, simulation.getSimulationUserIds()); } } @@ -332,7 +339,9 @@ public class CTCLogicLoop { * @param simulation 仿真实体 */ public void sendCtcManageRemoveMessage(Simulation simulation) { + // 状态,key:车站_车次 Map editAreaStatusVOMap = simulation.getCtcRepository().getEditAreaStatusVOMap(); + // 编辑区,key:车站 key:车次 Map> editeAreaMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap(); List messageInfo = editAreaStatusVOMap.values().stream().filter(vo -> { Map map = editeAreaMap.get(vo.getStationCode()); @@ -346,7 +355,68 @@ public class CTCLogicLoop { return false; }).map(vo -> vo.buildRemoveParam()).collect(Collectors.toList()); if (messageInfo != null && !messageInfo.isEmpty()) { - sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE, simulation.getSimulationUserIds()); + // 移除已删除状态 + messageInfo.forEach(vo -> editAreaStatusVOMap.remove(vo.getStationCode() + "_" + vo.getRunPlanCode())); + sendCtcMessage(simulation.getId(), messageInfo + , WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE, simulation.getSimulationUserIds()); + } + } + + /** + * 发送生效区变化消息 + * + * @param simulation 仿真实体 + */ + public void sendCtcManageEffectChangeMessage(Simulation simulation) { + Map editAreaStatusVOMap = simulation.getCtcRepository().getEffectAreaStatusVOMap(); + List allList = new ArrayList<>(); + simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap().forEach((k, v) -> { + v.values().stream().forEach(p -> { + String mapKey = p.getStationCode() + "_" + p.getRunPlanCode(); + CtcRunPlanParam param = editAreaStatusVOMap.get(mapKey); + CtcRunPlanParam changeCtcRunPlanVo = null; + if (param == null) { + changeCtcRunPlanVo = p.clone(); + editAreaStatusVOMap.put(mapKey, changeCtcRunPlanVo); + allList.add(editAreaStatusVOMap.get(mapKey)); + } else { + changeCtcRunPlanVo = param.compareAndChange(p); + if (changeCtcRunPlanVo != null) { + allList.add(changeCtcRunPlanVo); + } + } + }); + }); + if (!CollectionUtils.isEmpty(allList)) { + sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_CHANGE + , simulation.getSimulationUserIds()); + } + } + + /** + * 发送生效区移除消息 + * + * @param simulation 仿真实体 + */ + public void sendCtcManageEffectRemoveMessage(Simulation simulation) { + Map effectAreaStatusVOMap = simulation.getCtcRepository().getEffectAreaStatusVOMap(); + Map> effectAreaMap = simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap(); + List messageInfo = effectAreaStatusVOMap.values().stream().filter(vo -> { + Map map = effectAreaMap.get(vo.getStationCode()); + if (map == null) { + return true; + } + CtcRunPlanParam p = map.get(vo.getRunPlanCode()); + if (p == null) { + return true; + } + return false; + }).map(vo -> vo.buildRemoveParam()).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(messageInfo)) { + // 移除已删除状态 + messageInfo.forEach(vo -> effectAreaStatusVOMap.remove(vo.getStationCode() + "_" + vo.getRunPlanCode())); + sendCtcMessage(simulation.getId(), messageInfo + , WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_REMOVE, simulation.getSimulationUserIds()); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java index 29ed2c4c5..12daf0bd1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java @@ -78,6 +78,11 @@ public class CtcRepository { */ private final Map editAreaStatusVOMap = new HashMap<>(); + /** + * 车务管理端生效区运行计划状态 + */ + private final Map effectAreaStatusVOMap = new HashMap<>(); + public void reset() { routeSequenceMap.clear(); @@ -85,6 +90,8 @@ public class CtcRepository { trackViewVOMap.clear(); // 编辑区清空 this.simulationRunPlanEditAreaMap.clear(); + // 生效区清空 + this.simulationRunPlanEffectAreaMap.clear(); // 仿真运行数据直接清空 this.simulationRunPlanMap.clear(); this.allRunPlanList.clear(); @@ -96,6 +103,7 @@ public class CtcRepository { // 运行计划状态清除 this.runPlanStatusVOMap.clear(); this.editAreaStatusVOMap.clear(); + this.effectAreaStatusVOMap.clear(); } /** 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 c7066d97f..ef7d2f045 100644 --- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java +++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java @@ -391,6 +391,16 @@ public enum WebSocketMessageType { * 仿真编辑区运行计划变化 */ SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE, + + /** + * 仿真生效区运行计划变化 + */ + SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_CHANGE, + + /** + * 仿真CTC管理端生效区移除操作 + */ + SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_REMOVE, /** ------------ CTC消息信息 ----------- */ ; } 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 3f8c41521..b9e5fccad 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 @@ -115,7 +115,9 @@ public class SocketMessageFactory { } case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT: case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE: - case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE: { + case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE: + case SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_CHANGE: + case SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_REMOVE: { topicList.add(SimulationSubscribeTopic.Ctc_Manager.buildDestination(group)); break; }