From 8ab7b568698d177c652297004e2b4ca673db4e11 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Wed, 8 Jun 2022 14:04:23 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=89=B9=E9=87=8F=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=A1=8C=E8=BD=A6=E6=97=A5=E5=BF=97=E5=8A=9F=E8=83=BD=E3=80=91?= =?UTF-8?q?=20=E3=80=90PLC=E4=BF=A1=E5=8F=B7=E6=9D=BF=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E3=80=81=E6=8C=87=E7=A4=BA=E7=81=AF=E7=BD=91=E5=85=B3=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E9=85=8D=E7=BD=AE=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 | 16 +- .../ATS/operation/vo/CtcRunPlanParam.java | 72 +++++++ .../runplan/CtcStationRunPlanLogService.java | 195 +++++++++++++++++- .../cbtc/CTC/data/CtcRepository.java | 10 + .../client/project/hhcj/HhcjIbpConfigVO.java | 77 +++++++ 6 files changed, 364 insertions(+), 11 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java 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 b84a52180..3e1b2e3b3 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 @@ -910,6 +910,11 @@ public class Operation { // */ // CTC_PASS, + /** + * 批量修改运行计划 + */ + CTC_BATCH_MODIFY_RUN_PLAN, + /** * 修改股道 */ 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 1b45b370b..d6949f14f 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 @@ -3,12 +3,14 @@ package club.joylink.rtss.simulation.cbtc.ATS.operation.handler; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping; +import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam; import club.joylink.rtss.simulation.cbtc.ATS.service.runplan.CtcStationRunPlanLogService; 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 @Slf4j @@ -16,6 +18,19 @@ public class CtcStationRunPlanOperateHandler { @Autowired private CtcStationRunPlanLogService ctcStationRunPlanLogService; + /** + * 修改行车计划信息 + * + * @param simulation 仿真实体 + * @param stationCode 车站编码 + * @param planParamList 修改行车参数 + * @param force 是否强制 0:不强制。1:强制 + */ + @OperateHandlerMapping(type = Operation.Type.CTC_BATCH_MODIFY_RUN_PLAN) + public void modifyBatchRunPlan(Simulation simulation, String stationCode, List planParamList, int force) { + ctcStationRunPlanLogService.modifyBatchRunPlan(simulation, stationCode, planParamList, force); + } + /** * 修改行车计划股道信息 * @@ -32,7 +47,6 @@ public class CtcStationRunPlanOperateHandler { ctcStationRunPlanLogService.modifyRunPlanTrackSection(simulation, stationCode, runPlanCode, arriveSectionCode, departSectionCode, force); } - /** * 人工上报行车日志的到点时间 * 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 new file mode 100644 index 000000000..d5ea14cf2 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java @@ -0,0 +1,72 @@ +package club.joylink.rtss.simulation.cbtc.ATS.operation.vo; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.time.LocalTime; + +@Getter +@Setter +@NoArgsConstructor +public class CtcRunPlanParam { + /** + * 运行计划编码 + */ + private String runPlanCode; + + /** + * 到达股道 + */ + private String arriveSectionCode; + + /** + * 发车股道 + */ + private String departSectionCode; + + /** + * 到达时间 + */ + private LocalTime arriveTime; + + /** + * 发车时间 + */ + private LocalTime departTime; + + /** + * 到达车次 + */ + private String arriveTripNumber; + + /** + * 发车车次 + */ + private String departTripNumber; + + /** + * 到达车站 + */ + private String arriveStationCode; + + /** + * 发车车站 + */ + private String departStationCode; + + /** + * 到达口 + */ + private String arriveSignalCode; + + /** + * 发车口 + */ + private String departSignalCode; + + /** + * 状态:-1:删除,0:修改,1:添加 + */ + private int status; +} 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 03f1921d4..310fd7398 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 @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.ATS.service.runplan; +import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam; import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence; import club.joylink.rtss.simulation.cbtc.Simulation; @@ -19,6 +20,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import java.time.LocalTime; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -32,6 +34,167 @@ public class CtcStationRunPlanLogService { @Autowired private ApplicationContext applicationContext; + /** + * 批量修改运行计划 + * + * @param simulation 仿真实体 + * @param stationCode 车站编码 + * @param planParamList 参数信息 + * @param force 是否强制 + */ + public void modifyBatchRunPlan(Simulation simulation, String stationCode, List planParamList, int force) { + if (force == 0) { + boolean isNormal = planParamList.stream().filter(param -> param.getStatus() == 0) + .anyMatch(p -> { + CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getCtcStationRunPlanLog(stationCode, p.getRunPlanCode()); + if (!StringUtils.isEmpty(p.getArriveSectionCode())) { + RouteSequence.Line arriveLine = simulation.getCtcRepository() + .getRouteSequenceLine(stationCode, runPlanLog.getTripNumber(), false); + if ((arriveLine != null && arriveLine.getRoute().isLock())) { + return true; + } + } + if (!StringUtils.isEmpty(p.getDepartSectionCode())) { + RouteSequence.Line departLine = simulation.getCtcRepository() + .getRouteSequenceLine(stationCode, runPlanLog.getTripNumber(), true); + if ((departLine != null && departLine.getRoute().isLock())) { + return true; + } + } + return false; + }); + if (isNormal) { + throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "进路状态不允许修改到达股道"); + } + } + List runPlanLogList = new ArrayList<>(planParamList.size()); + planParamList.stream().forEach(p -> { + if (p.getStatus() <= 0) { + CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getCtcStationRunPlanLog(stationCode, p.getRunPlanCode()); + if (p.getStatus() == 0) { + modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), p, true); + modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), p, false); + runPlanLogList.add(runPlanLog); + } else if (p.getStatus() == -1) { + runPlanLog.setDelete(true); + runPlanLogList.add(runPlanLog); + } + } else if (p.getStatus() == 1) { + CtcStationRunPlanLog runPlanLog = addRunPlanLog(simulation, stationCode, p); + simulation.getCtcRepository().addCtcStationRunPlan(runPlanLog); + runPlanLogList.add(runPlanLog); + } + }); + websocketMessageSend(simulation, runPlanLogList); + } + + /** + * 修改行车计划属性信息 + * + * @param simulation 仿真实体 + * @param runPlanItem 接发条目 + * @param paramInfo 参数 + * @param arrive 是否到达 + */ + private void modifyRunPlanItemInfo(Simulation simulation, CtcStationRunPlanLog.RunPlanItem runPlanItem + , CtcRunPlanParam paramInfo, boolean arrive) { + if (runPlanItem != null) { + // 实际时间 + LocalTime actualTime = arrive ? paramInfo.getArriveTime() : paramInfo.getDepartTime(); + if (actualTime != null) { + runPlanItem.setActualTime(actualTime.toString()); + } + // 股道编码 + String sectionCode = arrive ? paramInfo.getArriveSectionCode() : paramInfo.getDepartSectionCode(); + if (!StringUtils.isEmpty(sectionCode)) { + Section section = simulation.getRepository().getByCode(sectionCode, Section.class); + runPlanItem.setTrackSection(section); + } + // 车次 + String tripNumber = arrive ? paramInfo.getArriveTripNumber() : paramInfo.getDepartTripNumber(); + if (!StringUtils.isEmpty(tripNumber)) { + runPlanItem.setTripNumber(tripNumber); + } + // 车站 + String stationCode = arrive ? paramInfo.getArriveStationCode() : paramInfo.getDepartStationCode(); + if (!StringUtils.isEmpty(stationCode)) { + Station station = simulation.getRepository().getByCode(stationCode, Station.class); + runPlanItem.setStation(station); + } + } + } + + /** + * 增加行车日志 + * + * @param simulation + * @param stationCode + * @param paramInfo + * @return + */ + private CtcStationRunPlanLog addRunPlanLog(Simulation simulation, String stationCode, CtcRunPlanParam paramInfo) { + CtcStationRunPlanLog ctcStationRunPlanLog = new CtcStationRunPlanLog(); + Station station = simulation.getRepository().getByCode(stationCode, Station.class); + String tripNumber = StringUtils.isEmpty(paramInfo.getArriveTripNumber()) ? + paramInfo.getDepartTripNumber() : paramInfo.getArriveTripNumber(); + ctcStationRunPlanLog.setCode(RandomGenerator.uuid()); + ctcStationRunPlanLog.setStation(station); + ctcStationRunPlanLog.setTripNumber(tripNumber); + if (!StringUtils.isEmpty(paramInfo.getArriveTripNumber())) { + CtcStationRunPlanLog.RunPlanItem arriveRunPlanItem = createRunPlanItem(simulation, paramInfo, true); + ctcStationRunPlanLog.setArriveRunPlan(arriveRunPlanItem); + } + if (!StringUtils.isEmpty(paramInfo.getDepartTripNumber())) { + CtcStationRunPlanLog.RunPlanItem departRunPlanItem = createRunPlanItem(simulation, paramInfo, false); + ctcStationRunPlanLog.setDepartRunPlan(departRunPlanItem); + } + return ctcStationRunPlanLog; + } + + /** + * 创建运行计划实体 + * + * @param simulation 仿真实体 + * @param paramInfo 参数信息 + * @param arrive 是否到达 + * @return 运行计划实体 + */ + private CtcStationRunPlanLog.RunPlanItem createRunPlanItem(Simulation simulation, CtcRunPlanParam paramInfo, boolean arrive) { + CtcStationRunPlanLog.RunPlanItem runPlanItem = new CtcStationRunPlanLog.RunPlanItem(); + // 车次 + String tripNumber = arrive ? paramInfo.getArriveTripNumber() : paramInfo.getDepartTripNumber(); + runPlanItem.setTripNumber(tripNumber); + // 实际时间 + LocalTime planTime = arrive ? paramInfo.getArriveTime() : paramInfo.getDepartTime(); + runPlanItem.setPlanTime(planTime); + // 股道编码 + String sectionCode = arrive ? paramInfo.getArriveSectionCode() : paramInfo.getDepartSectionCode(); + // 股道 + Section section = simulation.getRepository().getByCode(sectionCode, Section.class); + runPlanItem.setTrackSection(section); + // 车站\邻站 + String stationCode = arrive ? paramInfo.getArriveStationCode() : paramInfo.getDepartStationCode(); + Station adjacentStation = simulation.getRepository().getByCode(stationCode, Station.class); + runPlanItem.setStation(adjacentStation); + // 运行方向 + String signalCode = arrive ? paramInfo.getArriveSignalCode() : paramInfo.getDepartSignalCode(); + Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); + runPlanItem.setPlanLineName(signal.getShowName()); + StationDirection stationDirection = adjacentStation.getStationDirectionMap().values().stream() + .filter(s -> s.getSignal().equals(signal)) + .findFirst().orElse(null); + if (stationDirection != null) { + runPlanItem.setStationDirection(stationDirection); + runPlanItem.setRight(stationDirection.getRight()); + runPlanItem.initPlanLineName(); + } + // 接发状态 + StationDirection.ReceiveAndDeliverModel runModel = arrive ? + StationDirection.ReceiveAndDeliverModel.R : StationDirection.ReceiveAndDeliverModel.D; + runPlanItem.setRunModel(runModel); + return null; + } + /** * 修改运行股道 * @@ -64,15 +227,19 @@ public class CtcStationRunPlanLogService { } } if (ctcStationRunPlanLog != null) { - Section arriveSection = simulation.getRepository().getByCode(arriveSectionCode, Section.class); - if (ctcStationRunPlanLog.getArriveRunPlan() != null - && ctcStationRunPlanLog.getArriveRunPlan().getStationPlan() != null) { - ctcStationRunPlanLog.getArriveRunPlan().setTrackSection(arriveSection); + if (!StringUtils.isEmpty(arriveSectionCode)) { + Section arriveSection = simulation.getRepository().getByCode(arriveSectionCode, Section.class); + if (ctcStationRunPlanLog.getArriveRunPlan() != null + && ctcStationRunPlanLog.getArriveRunPlan().getStationPlan() != null) { + ctcStationRunPlanLog.getArriveRunPlan().setTrackSection(arriveSection); + } } - Section departSection = simulation.getRepository().getByCode(departSectionCode, Section.class); - if (ctcStationRunPlanLog.getDepartRunPlan() != null - && ctcStationRunPlanLog.getDepartRunPlan().getStationPlan() != null) { - ctcStationRunPlanLog.getDepartRunPlan().setTrackSection(departSection); + if (!StringUtils.isEmpty(departSectionCode)) { + Section departSection = simulation.getRepository().getByCode(departSectionCode, Section.class); + if (ctcStationRunPlanLog.getDepartRunPlan() != null + && ctcStationRunPlanLog.getDepartRunPlan().getStationPlan() != null) { + ctcStationRunPlanLog.getDepartRunPlan().setTrackSection(departSection); + } } websocketMessageSend(simulation, Arrays.asList(ctcStationRunPlanLog)); } @@ -92,10 +259,18 @@ public class CtcStationRunPlanLogService { CtcStationRunPlanLog ctcStationRunPlanLog = simulation.getCtcRepository().getCtcStationRunPlanLog(stationCode, runPlanCode); if (ctcStationRunPlanLog.getArriveRunPlan() != null) { - ctcStationRunPlanLog.getArriveRunPlan().setActualTime(arriveTime.toString()); + if (arriveTime != null) { + ctcStationRunPlanLog.getArriveRunPlan().setActualTime(arriveTime.toString()); + } else { + ctcStationRunPlanLog.getArriveRunPlan().setActualTime(null); + } } if (ctcStationRunPlanLog.getDepartRunPlan() != null) { - ctcStationRunPlanLog.getDepartRunPlan().setActualTime(departTime.toString()); + if (departTime != null) { + ctcStationRunPlanLog.getDepartRunPlan().setActualTime(departTime.toString()); + } else { + ctcStationRunPlanLog.getDepartRunPlan().setActualTime(null); + } } websocketMessageSend(simulation, Arrays.asList(ctcStationRunPlanLog)); } 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 f2798ec34..792607d61 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 @@ -29,6 +29,16 @@ public class CtcRepository { // generateRouteSequence(); } + /** + * 增加单个行车日志 + * + * @param ctcStationRunPlanLog 日志信息 + */ + public void addCtcStationRunPlan(CtcStationRunPlanLog ctcStationRunPlanLog) { + this.ctcStationRunPlanLogList.add(ctcStationRunPlanLog); + // generateRouteSequence(); + } + /** * 获取ctc 行车日志 * diff --git a/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjIbpConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjIbpConfigVO.java index 1f950ee39..e239906dc 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjIbpConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjIbpConfigVO.java @@ -65,6 +65,83 @@ public class HhcjIbpConfigVO extends RealConfigVO { */ private Integer r_sx_hsjc = 21; + /***************************** 信号盘 ************************************/ + /** + * 下行扣车按钮 + */ + private Integer r_xx_kc = 0; + + /** + * 下行扣车指示灯 + */ + private Integer w_xx_kc_light = 0; + + /** + * 下行终止扣车 + */ + private Integer r_xx_zzkc = 1; + + /** + * 下行取消紧急停车 + */ + private Integer r_xx_qxjjtc = 2; + + /** + * 下行紧急停车按钮 + */ + private Integer r_xx_jjtc = 3; + + /** + * 下行紧急停车灯 + */ + private Integer w_xx_jjtc_light = 1; + + /** + * 下行蜂鸣器 + */ + private Integer w_xx_alarm = 2; + + /** + * 上行扣车按钮 + */ + private Integer r_sx_kc = 4; + + /** + * 上行扣车指示灯 + */ + private Integer w_sx_kc_light = 3; + + /** + * 上行终止扣车 + */ + private Integer r_sx_zzkc = 5; + + /** + * 上行取消紧急停车 + */ + private Integer r_sx_qxjjtc = 6; + + /** + * 上行紧急停车 + */ + private Integer r_sx_jjtc = 7; + + /** + * 上行紧急停车灯 + */ + private Integer w_sx_jjtc_light = 4; + + /** + * 上行报警切除 + */ + private Integer r_sx_bjqc = 8; + + /** + * 上行试灯按钮 + */ + private Integer r_sx_sd = 9; + + /***************************** 信号 ************************************/ public HhcjIbpConfigVO() { super(0, 304); }