From b15ec376fe5e37ea322815c254cbeba297c0bc3e Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 14 Jun 2022 17:13:07 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E3=80=91=20=E3=80=90=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=BD=A6=E5=8A=A1=E7=AE=A1=E7=90=86=E7=AB=AF=E6=B8=85=E7=A9=BA?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/operation/Operation.java | 15 +-- .../CtcStationRunPlanOperateHandler.java | 49 ++----- .../ATS/operation/vo/CtcRunPlanParam.java | 15 +++ .../runplan/CtcStationRunPlanLogService.java | 124 ++++-------------- .../simulation/cbtc/CTC/CTCLogicLoop.java | 2 +- 5 files changed, 58 insertions(+), 147 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 24d52e8d3..67a4200d9 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 @@ -915,16 +915,6 @@ public class Operation { */ CTC_BATCH_MODIFY_RUN_PLAN, - /** - * 修改股道 - */ - CTC_MODIFY_TRACK_SECTION, - - /** - * 修改实际到达时间 - */ - CTC_MODIFY_ACTUAL_TIME, - /** * 修改车次 */ @@ -950,6 +940,11 @@ public class Operation { */ CTC_REMOVE_RUN_PLAN_FROM_EDIT_AREA, + /** + * 清空编辑区中的运行计划 + */ + CTC_CLEAR_RUN_PLAN_FROM_EDIT_AREA, + /** * 导入覆盖运行计划到编辑区 */ 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 61e9ab477..247537051 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 @@ -9,7 +9,6 @@ import club.joylink.rtss.simulation.cbtc.Simulation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import java.time.LocalTime; import java.util.List; @OperateHandler @@ -30,38 +29,7 @@ public class CtcStationRunPlanOperateHandler { public void modifyBatchRunPlan(Simulation simulation, String stationCode, List planParamList, int force) { ctcStationRunPlanLogService.modifyBatchRunPlan(simulation, stationCode, planParamList, force); } - - /** - * 修改行车计划股道信息 - * - * @param simulation 仿真实体 - * @param stationCode 车站编码 - * @param runPlanCode 运行编码 - * @param arriveSectionCode 到达股道编码 - * @param departSectionCode 出发股道编码 - * @param force 是否强制 0:不强制。1:强制 - */ - @OperateHandlerMapping(type = Operation.Type.CTC_MODIFY_TRACK_SECTION) - public void modifyRunPlanTrackSection(Simulation simulation, String stationCode, String runPlanCode - , String arriveSectionCode, String departSectionCode, int force) { - ctcStationRunPlanLogService.modifyRunPlanTrackSection(simulation, stationCode, runPlanCode, arriveSectionCode, departSectionCode, force); - } - - /** - * 人工上报行车日志的到点时间 - * - * @param simulation 仿真实体 - * @param stationCode 车站编码 - * @param runPlanCode 运行编码 - * @param arriveTime 到点时间 - * @param departTime 发车时间 - */ - @OperateHandlerMapping(type = Operation.Type.CTC_MODIFY_ACTUAL_TIME) - public void artificialReportRunPlanActualTime(Simulation simulation, String stationCode, String runPlanCode - , LocalTime arriveTime, LocalTime departTime) { - ctcStationRunPlanLogService.artificialReportRunPlanActualTime(simulation, stationCode, runPlanCode, arriveTime, departTime); - } - + /** * 修改车次号 * @@ -146,7 +114,18 @@ public class CtcStationRunPlanOperateHandler { * @param tripNumberList 车次 */ @OperateHandlerMapping(type = Operation.Type.CTC_REMOVE_RUN_PLAN_FROM_EDIT_AREA) - public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, List tripNumberList) { - ctcStationRunPlanLogService.removeRunPlanFromEditArea(simulation, stationCode, tripNumberList); + public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String tripNumber) { + ctcStationRunPlanLogService.removeRunPlanFromEditArea(simulation, stationCode, tripNumber); + } + + /** + * 清空车站编辑区内容 + * + * @param simulation 仿真实体 + * @param stationCode 车站编码 + */ + @OperateHandlerMapping(type = Operation.Type.CTC_CLEAR_RUN_PLAN_FROM_EDIT_AREA) + public void clearRunPlanFromEditArea(Simulation simulation, String stationCode) { + ctcStationRunPlanLogService.clearRunPlanFromEditArea(simulation, stationCode); } } 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 154056756..80f21c23f 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 @@ -93,6 +93,21 @@ public class CtcRunPlanParam { */ private List runPlanTaskList = new ArrayList<>(); + /** + * 删除时构造实体 + * + * @param stationCode 车站 + * @param tripNumber 车次 + * @return 实体 + */ + public static CtcRunPlanParam buildRemoveParam(String stationCode, String tripNumber) { + CtcRunPlanParam p = new CtcRunPlanParam(); + p.stationCode = stationCode; + p.tripNumber = tripNumber; + p.runPlanTaskList = null; + return p; + } + @Override public String toString() { return "CtcRunPlanParam{" + 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 14b2e0cb2..a66ecd549 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 @@ -145,16 +145,32 @@ public class CtcStationRunPlanLogService { /** * 将车站编辑区中删除车次内容 * - * @param simulation 仿真实体 - * @param stationCode 车站编码 - * @param tripNumberList 车次 + * @param simulation 仿真实体 + * @param stationCode 车站编码 + * @param tripNumber 车次 */ - public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, List tripNumberList) { + public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String tripNumber) { Map stationRunLogTripNumberMap = simulation.getCtcRepository() .getSimulationRunPlanEditAreaMap().getOrDefault(stationCode, new ConcurrentHashMap<>()); - tripNumberList.forEach(tripNumber -> stationRunLogTripNumberMap.remove(tripNumber)); + stationRunLogTripNumberMap.remove(tripNumber); // 发送消息 - ctcLogicLoop.sendCtcManageRemoveMessage(simulation, tripNumberList, simulation.getSimulationUserIds()); + 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()); } /** @@ -190,101 +206,7 @@ public class CtcStationRunPlanLogService { }); ctcLogicLoop.coverRunPlanMessage(simulation, runPlanLogList, simulation.getSimulationUserIds()); } - - /** - * 修改运行股道 - * - * @param simulation 仿真实体 - * @param stationCode 车站编码 - * @param runPlanCode 运行编码 - * @param arriveSectionCode 到达区段 - * @param departSectionCode 出发区段 - * @param force 是否强制 0:不强制。1:强制 - */ - public void modifyRunPlanTrackSection(Simulation simulation, String stationCode, String runPlanCode - , String arriveSectionCode, String departSectionCode, int force) { - CtcStationRunPlanLog ctcStationRunPlanLog = - simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanCode); - // 如果不强制则需要判断区段进路占用 - if (force == 0) { - if (!StringUtils.isEmpty(arriveSectionCode)) { - RouteSequence.Line arriveLine = simulation.getCtcRepository() - .getRouteSequenceLine(stationCode, ctcStationRunPlanLog.getTripNumber(), false); - if ((arriveLine != null && arriveLine.getRoute().isLock())) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "到达进路状态不允许修改到达股道"); - } - } - if (!StringUtils.isEmpty(departSectionCode)) { - RouteSequence.Line departLine = simulation.getCtcRepository() - .getRouteSequenceLine(stationCode, ctcStationRunPlanLog.getTripNumber(), true); - if ((departLine != null && departLine.getRoute().isLock())) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "出发进路状态不允许修改到达股道"); - } - } - } - if (ctcStationRunPlanLog != null) { - CtcStationRunPlanLog changeRunPlanLog = new CtcStationRunPlanLog(); - changeRunPlanLog.setCode(runPlanCode); - if (!StringUtils.isEmpty(arriveSectionCode)) { - Section arriveSection = simulation.getRepository().getByCode(arriveSectionCode, Section.class); - if (ctcStationRunPlanLog.getArriveRunPlan() != null - && arriveSection.equals(ctcStationRunPlanLog.getArriveRunPlan().getTrackSection())) { - ctcStationRunPlanLog.getArriveRunPlan().setTrackSection(arriveSection); - changeRunPlanLog.setArriveRunPlan(new CtcStationRunPlanLog.RunPlanItem()); - changeRunPlanLog.getArriveRunPlan().setTrackSection(arriveSection); - } - } - if (!StringUtils.isEmpty(departSectionCode)) { - Section departSection = simulation.getRepository().getByCode(departSectionCode, Section.class); - if (ctcStationRunPlanLog.getDepartRunPlan() != null - && departSection.equals(ctcStationRunPlanLog.getDepartRunPlan().getTrackSection())) { - ctcStationRunPlanLog.getDepartRunPlan().setTrackSection(departSection); - changeRunPlanLog.setDepartRunPlan(new CtcStationRunPlanLog.RunPlanItem()); - changeRunPlanLog.getDepartRunPlan().setTrackSection(departSection); - } - } - if (changeRunPlanLog.getArriveRunPlan() != null || changeRunPlanLog.getDepartRunPlan() != null) { - ctcLogicLoop.sendRunPlanChangeMessage(simulation, Arrays.asList(changeRunPlanLog), simulation.getSimulationUserIds()); - } - } - } - - /** - * 人工上报行车日志的到点时间 - * - * @param simulation 仿真实体 - * @param stationCode 车站编码 - * @param runPlanCode 运行编码 - * @param arriveTime 到点时间 - * @param departTime 发车时间 - */ - public void artificialReportRunPlanActualTime(Simulation simulation, String stationCode, String runPlanCode - , LocalTime arriveTime, LocalTime departTime) { - CtcStationRunPlanLog ctcStationRunPlanLog = - simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanCode); - CtcStationRunPlanLog changeRunPlanLog = new CtcStationRunPlanLog(); - changeRunPlanLog.setCode(runPlanCode); - if (ctcStationRunPlanLog.getArriveRunPlan() != null) { - String arriveTimeStr = arriveTime != null ? "" : arriveTime.toString(); - if (!Objects.equals(arriveTimeStr, changeRunPlanLog.getArriveRunPlan().getActualTime())) { - changeRunPlanLog.setArriveRunPlan(new CtcStationRunPlanLog.RunPlanItem()); - changeRunPlanLog.getArriveRunPlan().setActualTime(arriveTimeStr); - ctcStationRunPlanLog.getArriveRunPlan().setActualTime(arriveTimeStr); - } - } - if (ctcStationRunPlanLog.getDepartRunPlan() != null) { - String departTimeStr = departTime != null ? "" : departTime.toString(); - if (!Objects.equals(departTimeStr, changeRunPlanLog.getArriveRunPlan().getActualTime())) { - changeRunPlanLog.setDepartRunPlan(new CtcStationRunPlanLog.RunPlanItem()); - changeRunPlanLog.getDepartRunPlan().setActualTime(departTimeStr); - ctcStationRunPlanLog.getDepartRunPlan().setActualTime(departTimeStr); - } - } - if (changeRunPlanLog.getArriveRunPlan() != null || changeRunPlanLog.getDepartRunPlan() != null) { - ctcLogicLoop.sendRunPlanChangeMessage(simulation, Arrays.asList(changeRunPlanLog), simulation.getSimulationUserIds()); - } - } - + /** * 修改本站到发车次 (这里存在问题,这里会不会引起后续车次的到发变化) * 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 9022d9349..f1a424606 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 @@ -183,7 +183,7 @@ public class CTCLogicLoop { * @param messageInfo 消息 * @param userIds 用户ID */ - public void sendCtcManageRemoveMessage(Simulation simulation, List messageInfo, Set userIds) { + public void sendCtcManageRemoveMessage(Simulation simulation, List messageInfo, Set userIds) { if (messageInfo != null && !messageInfo.isEmpty()) { sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE, userIds); }