From 7890dc9b7016a437f2ed7b450edb93c9da9f0167 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Wed, 15 Jun 2022 18:37:01 +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=E8=BF=90=E8=A1=8C=E8=AE=A1=E5=88=92=E5=8F=91=E9=80=81?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E3=80=91=EF=BC=88=E5=AD=98=E5=9C=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CtcStationRunPlanOperateHandler.java | 6 +- .../ATS/operation/vo/CtcRunPlanParam.java | 120 ++++++++++++- .../runplan/CtcStationRunPlanLogService.java | 163 +++++++----------- .../simulation/cbtc/CTC/CTCLogicLoop.java | 92 ++++++---- .../cbtc/CTC/data/CtcRepository.java | 8 +- .../message/SimulationUserWsListener.java | 6 +- .../rtss/vo/client/WebSocketMessageType.java | 5 - .../client/factory/SocketMessageFactory.java | 4 +- 8 files changed, 247 insertions(+), 157 deletions(-) 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 b69d7ee6b..a6f758c9e 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 @@ -131,11 +131,11 @@ public class CtcStationRunPlanOperateHandler { * * @param simulation 仿真实体 * @param stationCode 车站编码 - * @param tripNumber 车次 + * @param runPlanCode 车次 */ @OperateHandlerMapping(type = Operation.Type.CTC_REMOVE_RUN_PLAN_FROM_EDIT_AREA) - public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String tripNumber) { - ctcStationRunPlanLogService.removeRunPlanFromEditArea(simulation, stationCode, tripNumber); + public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String runPlanCode) { + ctcStationRunPlanLogService.removeRunPlanFromEditArea(simulation, stationCode, runPlanCode); } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java index 641e9b256..e2121ddf5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java @@ -4,15 +4,18 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.springframework.util.StringUtils; import java.time.LocalTime; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Objects; @Getter @Setter @NoArgsConstructor -public class CtcRunPlanParam { +public class CtcRunPlanParam implements Cloneable { /** * 运行计划编码 */ @@ -136,18 +139,108 @@ public class CtcRunPlanParam { /** * 删除时构造实体 * - * @param stationCode 车站 - * @param tripNumber 车次 * @return 实体 */ - public static CtcRunPlanParam buildRemoveParam(String stationCode, String tripNumber) { + public CtcRunPlanParam buildRemoveParam() { CtcRunPlanParam p = new CtcRunPlanParam(); - p.stationCode = stationCode; - p.tripNumber = tripNumber; - p.runPlanTaskList = null; + p.setRunPlanCode(this.runPlanCode); + p.setStationCode(this.stationCode); + p.setTripNumber(this.tripNumber); + p.setRunPlanTaskList(null); return p; } + /** + * 生成主键 + * + * @return 主键 + */ + public String generateId() { + return this.getTripNumber() + + (StringUtils.isEmpty(this.arriveDirectionCode) ? "_" : this.arriveDirectionCode) + + (StringUtils.isEmpty(this.departDirectionCode) ? "_" : this.departDirectionCode); + } + + public CtcRunPlanParam compareAndChange(CtcRunPlanParam modify) { + CtcRunPlanParam runPlanParam = new CtcRunPlanParam(); + runPlanParam.setRunPlanCode(modify.getRunPlanCode()); + boolean change = false; + if (!Objects.equals(this.stationCode, modify.getStationCode())) { + this.stationCode = modify.getStationCode(); + runPlanParam.setStationCode(modify.getStationCode()); + change = true; + } + if (!Objects.equals(this.tripNumber, modify.getTripNumber())) { + this.tripNumber = modify.getTripNumber(); + runPlanParam.setTripNumber(modify.getTripNumber()); + change = true; + } + if (!Objects.equals(this.trackSectionCode, modify.getTrackSectionCode())) { + this.trackSectionCode = modify.getTrackSectionCode(); + runPlanParam.setTrackSectionCode(modify.getTrackSectionCode()); + change = true; + } + if (!Objects.equals(this.arriveSectionCode, modify.getArriveSectionCode())) { + this.arriveSectionCode = modify.getArriveSectionCode(); + runPlanParam.setArriveSectionCode(modify.getArriveSectionCode()); + change = true; + } + if (!Objects.equals(this.departSectionCode, modify.getDepartSectionCode())) { + this.departSectionCode = modify.getDepartSectionCode(); + runPlanParam.setDepartSectionCode(modify.getDepartSectionCode()); + change = true; + } + if (!Objects.equals(this.arriveTime, modify.getArriveTime())) { + this.arriveTime = modify.getArriveTime(); + runPlanParam.setArriveTime(modify.getArriveTime()); + change = true; + } + if (!Objects.equals(this.departTime, modify.getDepartTime())) { + this.departTime = modify.getDepartTime(); + runPlanParam.setDepartTime(modify.getDepartTime()); + change = true; + } + if (!Objects.equals(this.arriveTripNumber, modify.getArriveTripNumber())) { + this.arriveTripNumber = modify.getArriveTripNumber(); + runPlanParam.setArriveTripNumber(modify.getArriveTripNumber()); + change = true; + } + if (!Objects.equals(this.departTripNumber, modify.getDepartTripNumber())) { + this.departTripNumber = modify.getDepartTripNumber(); + runPlanParam.setDepartTripNumber(modify.getDepartTripNumber()); + change = true; + } + if (!Objects.equals(this.arriveStationCode, modify.getArriveStationCode())) { + this.arriveStationCode = modify.getArriveStationCode(); + runPlanParam.setArriveStationCode(modify.getArriveStationCode()); + change = true; + } + if (!Objects.equals(this.departStationCode, modify.getDepartStationCode())) { + this.departStationCode = modify.getDepartStationCode(); + runPlanParam.setDepartStationCode(modify.getDepartStationCode()); + change = true; + } + + if (!Objects.equals(this.arriveDirectionCode, modify.getArriveDirectionCode())) { + this.arriveDirectionCode = modify.getArriveDirectionCode(); + runPlanParam.setArriveDirectionCode(modify.getArriveDirectionCode()); + change = true; + } + if (!Objects.equals(this.departDirectionCode, modify.getDepartDirectionCode())) { + this.departDirectionCode = modify.getDepartDirectionCode(); + runPlanParam.setDepartDirectionCode(modify.getDepartDirectionCode()); + change = true; + } + // 存在不一样的选项 + long modifyNum = modify.getRunPlanTaskList().stream().filter(task -> !this.runPlanTaskList.contains(task)).count(); + if (modifyNum > 0 || (this.runPlanTaskList.size() != modify.getRunPlanTaskList().size())) { // 长度不一致直接赋值 + this.runPlanTaskList = modify.getRunPlanTaskList(); + runPlanParam.setRunPlanTaskList(modify.getRunPlanTaskList()); + change = true; + } + return change ? runPlanParam : null; + } + @Override public String toString() { return "CtcRunPlanParam{" + @@ -168,4 +261,17 @@ public class CtcRunPlanParam { ", status=" + status + '}'; } + + @Override + public CtcRunPlanParam clone() { + try { + CtcRunPlanParam clone = (CtcRunPlanParam) super.clone(); + List list = new ArrayList<>(this.runPlanTaskList.size()); + Collections.copy(list, this.runPlanTaskList); + clone.setRunPlanTaskList(list); + return clone; + } catch (CloneNotSupportedException e) { + throw new AssertionError(); + } + } } 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 2cf68f12c..2de504822 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 @@ -109,24 +109,42 @@ public class CtcStationRunPlanLogService { * @param runPlanParamList 运行计划列表 */ public void addRunPlanListToEditArea(Simulation simulation, String stationCode, List runPlanParamList) { - List runPlanLogList = new ArrayList<>(runPlanParamList.size()); Map stationRunPlanMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap() .getOrDefault(stationCode, new ConcurrentHashMap<>(64)); runPlanParamList.stream().forEach(p -> { String tripNumber = StringUtils.isEmpty(p.getArriveTripNumber()) ? p.getDepartTripNumber() : p.getArriveTripNumber(); p.setTripNumber(tripNumber); - if (stationRunPlanMap.containsKey(tripNumber)) { - CtcRunPlanParam changeParam = modifyRunPlanParam(stationRunPlanMap.get(tripNumber), p); - if (changeParam != null) { - runPlanLogList.add(changeParam); - } + String runPlanCode = p.generateId(); + if (stationRunPlanMap.containsKey(runPlanCode)) { + modifyRunPlanParam(stationRunPlanMap.get(runPlanCode), p); } else { - stationRunPlanMap.put(tripNumber, p); - runPlanLogList.add(p); + p.setRunPlanCode(runPlanCode); + stationRunPlanMap.put(runPlanCode, p); } }); - // 发送消息 - ctcLogicLoop.sendCtcManageChangeMessage(simulation, runPlanLogList, simulation.getSimulationUserIds()); + } + + /** + * 将车站编辑区中删除车次内容 + * + * @param simulation 仿真实体 + * @param stationCode 车站编码 + * @param tripNumber 车次 + */ + public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String runPlanCode) { + Map stationRunLogTripNumberMap = simulation.getCtcRepository() + .getSimulationRunPlanEditAreaMap().getOrDefault(stationCode, new ConcurrentHashMap<>()); + stationRunLogTripNumberMap.remove(runPlanCode); + } + + /** + * 全部清空 + * + * @param simulation 仿真修改 + * @param stationCode 车站编码 + */ + public void clearRunPlanFromEditArea(Simulation simulation, String stationCode) { + simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().remove(stationCode); } /** @@ -140,45 +158,13 @@ public class CtcStationRunPlanLogService { // 移除车站所有运行计划 simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().remove(stationCode); // 运行计划 - Map planParamMap = runPlanParamList.stream().collect(Collectors.toMap(p -> { + runPlanParamList.forEach(p -> { String tripNumber = StringUtils.isEmpty(p.getArriveTripNumber()) ? p.getDepartTripNumber() : p.getArriveTripNumber(); p.setTripNumber(tripNumber); - return tripNumber; - }, (p) -> p)); + p.setRunPlanCode(p.generateId()); + }); + Map planParamMap = runPlanParamList.stream().collect(Collectors.toMap(p -> p.getRunPlanCode(), (p) -> p)); simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().put(stationCode, planParamMap); - // 发送消息 - ctcLogicLoop.sendCtcManageCoverMessage(simulation, runPlanParamList, simulation.getSimulationUserIds()); - } - - /** - * 将车站编辑区中删除车次内容 - * - * @param simulation 仿真实体 - * @param stationCode 车站编码 - * @param tripNumber 车次 - */ - public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String tripNumber) { - Map stationRunLogTripNumberMap = simulation.getCtcRepository() - .getSimulationRunPlanEditAreaMap().getOrDefault(stationCode, new ConcurrentHashMap<>()); - stationRunLogTripNumberMap.remove(tripNumber); - // 发送消息 - ctcLogicLoop.sendCtcManageRemoveMessage(simulation, Arrays.asList(CtcRunPlanParam.buildRemoveParam(stationCode, tripNumber)), simulation.getSimulationUserIds()); - } - - /** - * 全部清空 - * - * @param simulation 仿真修改 - * @param stationCode 车站编码 - */ - public void clearRunPlanFromEditArea(Simulation simulation, String stationCode) { - Map stationRunLogTripNumberMap = simulation.getCtcRepository() - .getSimulationRunPlanEditAreaMap().getOrDefault(stationCode, new ConcurrentHashMap<>()); - List removeParamList = stationRunLogTripNumberMap.values().stream() - .map(c -> CtcRunPlanParam.buildRemoveParam(c.getStationCode(), c.getTripNumber())) - .collect(Collectors.toList()); - // 发送消息 - ctcLogicLoop.sendCtcManageRemoveMessage(simulation, removeParamList, simulation.getSimulationUserIds()); } /** @@ -474,99 +460,68 @@ public class CtcStationRunPlanLogService { * * @param original 原始参数 * @param modify 修改参数 - * @return 修改过的属性 */ - private CtcRunPlanParam modifyRunPlanParam(CtcRunPlanParam original, CtcRunPlanParam modify) { - CtcRunPlanParam runPlanParam = new CtcRunPlanParam(); - boolean change = false; - if (!Objects.equals(original.getStationCode(), modify.getStationCode())) { + private void modifyRunPlanParam(CtcRunPlanParam original, CtcRunPlanParam modify) { + if (modify.getStationCode() != null + && !Objects.equals(original.getStationCode(), modify.getStationCode())) { original.setStationCode(modify.getStationCode()); - runPlanParam.setStationCode(modify.getStationCode()); - change = true; } - if (!Objects.equals(original.getTripNumber(), modify.getTripNumber())) { + if (modify.getTripNumber() != null + && !Objects.equals(original.getTripNumber(), modify.getTripNumber())) { original.setTripNumber(modify.getTripNumber()); - runPlanParam.setTripNumber(modify.getTripNumber()); - change = true; } - if (!Objects.equals(original.getTrackSectionCode(), modify.getTrackSectionCode())) { + if (modify.getTrackSectionCode() != null + && !Objects.equals(original.getTrackSectionCode(), modify.getTrackSectionCode())) { original.setTrackSectionCode(modify.getTrackSectionCode()); - runPlanParam.setTrackSectionCode(modify.getTrackSectionCode()); - change = true; } - if (!Objects.equals(original.getArriveSectionCode(), modify.getArriveSectionCode())) { + if (modify.getArriveSectionCode() != null + && !Objects.equals(original.getArriveSectionCode(), modify.getArriveSectionCode())) { original.setArriveSectionCode(modify.getArriveSectionCode()); - runPlanParam.setArriveSectionCode(modify.getArriveSectionCode()); - change = true; } - if (!Objects.equals(original.getDepartSectionCode(), modify.getDepartSectionCode())) { + if (modify.getDepartSectionCode() != null + && !Objects.equals(original.getDepartSectionCode(), modify.getDepartSectionCode())) { original.setDepartSectionCode(modify.getDepartSectionCode()); - runPlanParam.setDepartSectionCode(modify.getDepartSectionCode()); - change = true; } - if (!Objects.equals(original.getArriveTime(), modify.getArriveTime())) { + if (modify.getArriveTime() != null + && !Objects.equals(original.getArriveTime(), modify.getArriveTime())) { original.setArriveTime(modify.getArriveTime()); - runPlanParam.setArriveTime(modify.getArriveTime()); - change = true; } - if (!Objects.equals(original.getDepartTime(), modify.getDepartTime())) { + if (modify.getDepartTime() != null + && !Objects.equals(original.getDepartTime(), modify.getDepartTime())) { original.setDepartTime(modify.getDepartTime()); - runPlanParam.setDepartTime(modify.getDepartTime()); - change = true; } - if (!Objects.equals(original.getArriveTripNumber(), modify.getArriveTripNumber())) { + if (modify.getArriveTripNumber() != null + && !Objects.equals(original.getArriveTripNumber(), modify.getArriveTripNumber())) { original.setArriveTripNumber(modify.getArriveTripNumber()); - runPlanParam.setArriveTripNumber(modify.getArriveTripNumber()); - change = true; } - if (!Objects.equals(original.getDepartTripNumber(), modify.getDepartTripNumber())) { + if (modify.getDepartTripNumber() != null + && !Objects.equals(original.getDepartTripNumber(), modify.getDepartTripNumber())) { original.setDepartTripNumber(modify.getDepartTripNumber()); - runPlanParam.setDepartTripNumber(modify.getDepartTripNumber()); - change = true; } - if (!Objects.equals(original.getArriveStationCode(), modify.getArriveStationCode())) { + if (modify.getArriveStationCode() != null + && !Objects.equals(original.getArriveStationCode(), modify.getArriveStationCode())) { original.setArriveStationCode(modify.getArriveStationCode()); - runPlanParam.setArriveStationCode(modify.getArriveStationCode()); - change = true; } - if (!Objects.equals(original.getDepartStationCode(), modify.getDepartStationCode())) { + if (modify.getDepartStationCode() != null + && !Objects.equals(original.getDepartStationCode(), modify.getDepartStationCode())) { original.setDepartStationCode(modify.getDepartStationCode()); - runPlanParam.setDepartStationCode(modify.getDepartStationCode()); - change = true; } - if (!Objects.equals(original.getArriveDirectionCode(), modify.getArriveDirectionCode())) { + if (modify.getArriveDirectionCode() != null + && !Objects.equals(original.getArriveDirectionCode(), modify.getArriveDirectionCode())) { original.setArriveDirectionCode(modify.getArriveDirectionCode()); - runPlanParam.setArriveDirectionCode(modify.getArriveDirectionCode()); - change = true; } - if (!Objects.equals(original.getDepartDirectionCode(), modify.getDepartDirectionCode())) { + if (modify.getDepartDirectionCode() != null + && !Objects.equals(original.getDepartDirectionCode(), modify.getDepartDirectionCode())) { original.setDepartDirectionCode(modify.getDepartDirectionCode()); - runPlanParam.setDepartDirectionCode(modify.getDepartDirectionCode()); - change = true; } // 存在不一样的选项 long modifyNum = modify.getRunPlanTaskList().stream().filter(task -> !original.getRunPlanTaskList().contains(task)).count(); if (modifyNum > 0 || (original.getRunPlanTaskList().size() != modify.getRunPlanTaskList().size())) { // 长度不一致直接赋值 original.setRunPlanTaskList(modify.getRunPlanTaskList()); - runPlanParam.setRunPlanTaskList(modify.getRunPlanTaskList()); - change = true; - } else { - runPlanParam.setRunPlanTaskList(null); - } - if (!Objects.equals(original.getRunPlanTaskList(), modify.getRunPlanTaskList())) { - original.setRunPlanTaskList(modify.getRunPlanTaskList()); - runPlanParam.setRunPlanTaskList(modify.getRunPlanTaskList()); - change = true; } if (!Objects.equals(original.getStatus(), modify.getStatus())) { original.setStatus(modify.getStatus()); - runPlanParam.setStatus(modify.getStatus()); - change = true; } - if (!change) { - runPlanParam = null; - } - return runPlanParam; } } 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 a9038e796..985157289 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,6 +46,9 @@ public class CTCLogicLoop { // 发送运行计划变化消息 sendRunPlanChangeMessage(simulation); sendRunPlanRemoveMessage(simulation); + // 发送车务管理端消息 + sendCtcManageChangeMessage(simulation); + sendCtcManageRemoveMessage(simulation); } public void sendAllMessage(Simulation simulation) { @@ -269,52 +272,81 @@ public class CTCLogicLoop { } /** - * @param simulation - * @param messageInfo - * @param userIds + * @param simulation 仿真实体 + * @param userIds 用户ID */ - public void initCtcManageMessage(Simulation simulation, List messageInfo, Set userIds) { - if (!CollectionUtils.isEmpty(messageInfo)) { - sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT, userIds); + public void initCtcManageMessage(Simulation simulation, Set userIds) { + synchronized (this) { + Map editAreaStatusVOMap = simulation.getCtcRepository().getEditAreaStatusVOMap(); + List allList = new ArrayList<>(); + if (CollectionUtils.isEmpty(editAreaStatusVOMap)) { + simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().forEach((k, v) -> { + v.values().stream().forEach(p -> { + String mapKey = p.getStationCode() + "_" + p.getRunPlanCode(); + editAreaStatusVOMap.put(mapKey, p.clone()); + allList.add(p); + }); + }); + } else { + allList.addAll(editAreaStatusVOMap.values()); + } + if (!CollectionUtils.isEmpty(allList)) { + sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT, userIds); + } } } /** * 发送管理端信息变更消息 * - * @param simulation 仿真ID - * @param messageInfo 消息 - * @param userIds 用户ID + * @param simulation 仿真实体 */ - public void sendCtcManageChangeMessage(Simulation simulation, List messageInfo, Set userIds) { - if (messageInfo != null && !messageInfo.isEmpty()) { - sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE, userIds); - } - } - - /** - * 发送管理端信息覆盖消息 - * - * @param simulation 仿真ID - * @param messageInfo 消息 - * @param userIds 用户ID - */ - public void sendCtcManageCoverMessage(Simulation simulation, List messageInfo, Set userIds) { - if (messageInfo != null && !messageInfo.isEmpty()) { - sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_COVER, userIds); + public void sendCtcManageChangeMessage(Simulation simulation) { + Map editAreaStatusVOMap = simulation.getCtcRepository().getEditAreaStatusVOMap(); + List allList = new ArrayList<>(); + simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().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_EDIT_CHANGE, simulation.getSimulationUserIds()); } } /** * 发送管理端信息删除消息 * - * @param simulation 仿真ID - * @param messageInfo 消息 - * @param userIds 用户ID + * @param simulation 仿真实体 */ - public void sendCtcManageRemoveMessage(Simulation simulation, List messageInfo, Set userIds) { + public void sendCtcManageRemoveMessage(Simulation simulation) { + Map editAreaStatusVOMap = simulation.getCtcRepository().getEditAreaStatusVOMap(); + Map> editeAreaMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap(); + List messageInfo = editAreaStatusVOMap.values().stream().filter(vo -> { + Map map = editeAreaMap.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 (messageInfo != null && !messageInfo.isEmpty()) { - sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE, userIds); + sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_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 b32d281f3..29ed2c4c5 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 @@ -69,10 +69,15 @@ public class CtcRepository { private final Map> simulationRunPlanEffectAreaMap = new ConcurrentHashMap<>(); /** - * 消息状态 + * 运行日志消息状态 */ private final Map runPlanStatusVOMap = new HashMap<>(); + /** + * 车务管理端运行计划状态 + */ + private final Map editAreaStatusVOMap = new HashMap<>(); + public void reset() { routeSequenceMap.clear(); @@ -90,6 +95,7 @@ public class CtcRepository { })); // 运行计划状态清除 this.runPlanStatusVOMap.clear(); + this.editAreaStatusVOMap.clear(); } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationUserWsListener.java b/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationUserWsListener.java index 8c761e2ab..ecf1d6380 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationUserWsListener.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationUserWsListener.java @@ -2,7 +2,6 @@ package club.joylink.rtss.simulation.cbtc.message; import club.joylink.rtss.simulation.Simulation; import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; -import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam; import club.joylink.rtss.simulation.cbtc.CTC.CTCLogicLoop; import club.joylink.rtss.simulation.cbtc.data.plan.RealRun; import club.joylink.rtss.simulation.cbtc.data.status.DeviceStatus; @@ -26,7 +25,6 @@ import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -117,9 +115,7 @@ public class SimulationUserWsListener { } case Ctc_Manager: { // CTC运行管理端 // CTC管理端编辑区发送消息 - List allList = new ArrayList<>(); - simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().forEach((k, v) -> allList.addAll(v.values())); - ctcLogicLoop.initCtcManageMessage(simulation, allList, Stream.of(userId).collect(Collectors.toSet())); + ctcLogicLoop.initCtcManageMessage(simulation, Stream.of(userId).collect(Collectors.toSet())); break; } } 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 8c351834c..c7066d97f 100644 --- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java +++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java @@ -391,11 +391,6 @@ public enum WebSocketMessageType { * 仿真编辑区运行计划变化 */ SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE, - - /** - * 仿真编辑区运行计划覆盖 - */ - SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_COVER, /** ------------ 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 98355be43..3f8c41521 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 @@ -107,13 +107,13 @@ public class SocketMessageFactory { break; } case SIMULATION_CTC_RUN_PLAN_INIT: - case SIMULATION_CTC_RUN_PLAN_CHANGE: { + case SIMULATION_CTC_RUN_PLAN_CHANGE: + case SIMULATION_CTC_RUN_PLAN_REMOVE: { topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group)); topicList.add(SimulationSubscribeTopic.Ctc.buildDestination(group)); break; } case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT: - case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_COVER: case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE: case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE: { topicList.add(SimulationSubscribeTopic.Ctc_Manager.buildDestination(group));