From 5ffb79605544a240e8fc84ebcd6de3941c5c5e9e Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 30 Jun 2022 15:48:44 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E3=80=90=E5=8F=91=E9=80=81=E9=A2=84?= =?UTF-8?q?=E5=91=8ABUG=E3=80=91=20=E3=80=90=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E8=AE=A1=E5=88=92=E3=80=91=20=E3=80=90?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=9C=B0=E9=93=81=E8=BF=90=E8=A1=8C=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ATS/operation/vo/CtcRunPlanParam.java | 5 - .../runplan/CtcStationRunPlanLogService.java | 49 +----- .../ATS/service/runplan/CtcZoneService.java | 8 +- .../simulation/cbtc/CTC/CTCLogicLoop.java | 3 +- .../cbtc/CTC/data/CtcEffectRepository.java | 3 +- .../cbtc/CTC/data/CtcRepository.java | 3 +- .../cbtc/CTC/data/CtcStationRunPlanLog.java | 32 +++- .../cbtc/CTC/data/CtcZoneRepository.java | 1 - .../CTC/data/vo/CtcStationRunPlanLogVO.java | 2 +- .../cbtc/CTC/service/CTCService.java | 15 +- .../cbtc/build/SimulationBuilder.java | 144 ++---------------- .../data/status/StationDirectionStatus.java | 8 +- 12 files changed, 60 insertions(+), 213 deletions(-) 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 de60fd004..2306562a8 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 @@ -499,11 +499,6 @@ public class CtcRunPlanParam implements Cloneable { this.transfinite = origin.getTransfinite(); change = true; } - // 状态 - if (!Objects.equals(origin.getStatus(), modify.getStatus())) { - this.status = origin.getStatus(); - change = true; - } return change ? this : null; } 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 b396d9ac4..c45d3922e 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 @@ -73,7 +73,7 @@ public class CtcStationRunPlanLogService { runPlanLogList.add(runPlanLog); } } else { - runPlanLog = createRunPlanLog(simulation, stationCode, p); + runPlanLog = CtcStationRunPlanLog.createRunPlanLog(simulation, stationCode, p); simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog); runPlanLogList.add(runPlanLog); } @@ -215,46 +215,29 @@ public class CtcStationRunPlanLogService { if (CollectionUtils.isEmpty(ctcRunPlanVOList)) { return; } - List runPlanLogList = new ArrayList<>(); ctcRunPlanVOList.forEach(ctcRunPlanVO -> { CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository() .getRunPlanByRunPlanCodeAndStationCode(stationCode, ctcRunPlanVO.getRunPlanCode()); - boolean change = false; if (runPlanLog != null) { runPlanLog.setBaseAttribute(ctcRunPlanVO.getRunPlan()); runPlanLog.setDelete(ctcRunPlanVO.getStatus() == -1); // 到达 if (ctcRunPlanVO.getRunPlan().arriveIsExist()) { // 不存在到达信息则直接浮空 - change = modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), ctcRunPlanVO.getRunPlan(), true); + modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), ctcRunPlanVO.getRunPlan(), true); } else { runPlanLog.setArriveRunPlan(null); } // 出发 if (ctcRunPlanVO.getRunPlan().departIsExist()) { - change = change || modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), ctcRunPlanVO.getRunPlan(), false); + modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), ctcRunPlanVO.getRunPlan(), false); } else { runPlanLog.setDepartRunPlan(null); } } else { - change = true; - runPlanLog = createRunPlanLog(simulation, stationCode, ctcRunPlanVO.getRunPlan()); + runPlanLog = CtcStationRunPlanLog.createRunPlanLog(simulation, stationCode, ctcRunPlanVO.getRunPlan()); simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog); } - if (change) { - runPlanLogList.add(runPlanLog); - } }); - // 编辑过轨道的行车记录 ,暂时注释 -// 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 (r.getDepartRunPlan() != null && r.getDepartRunPlan().getTrackSection() != null) { -// ctcService.runPlanItemUpdate(simulation, r.getStation(), r.getDepartRunPlan(), true); -// } -// }); } /** @@ -278,7 +261,7 @@ public class CtcStationRunPlanLogService { curRunPlanParam.setDepartSectionCode(sectionCode); } CtcRunPlanVO ctcRunPlanVO = CtcRunPlanVO.compareAndChange(curRunPlanParam, effectRunPlanParam); - ctcRunPlanVO.setCreateTime(simulation.getCorrectSystemTime()); + ctcRunPlanVO.setCreateTime(simulation.getSystemTime()); simulation.getCtcRepository().saveApplyRunPlan(ctcRunPlanVO); } } @@ -315,7 +298,7 @@ public class CtcStationRunPlanLogService { if (planParam.getPassenger() != null) { CtcStationRunPlanLog.PlanPropertiesType planPropertiesType = planParam.getPassenger() ? CtcStationRunPlanLog.PlanPropertiesType.PASSENGER : null; - if (!Objects.equals(planParam.getPassenger(), runPlanLog.getPassenger())) { + if (!Objects.equals(planPropertiesType, runPlanLog.getPassenger())) { runPlanLog.setPassenger(planPropertiesType); } } @@ -407,23 +390,5 @@ public class CtcStationRunPlanLogService { return change; } - /** - * 增加行车日志 - * - * @param simulation 仿真实体 - * @param stationCode 车站编码 - * @param paramInfo 参数 - * @return 行车日志 - */ - private CtcStationRunPlanLog createRunPlanLog(Simulation simulation, String stationCode, CtcRunPlanParam paramInfo) { - paramInfo.generateRunPlanCodeAndTripNumber(); - String tripNumber = paramInfo.getTripNumber(); - 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/ATS/service/runplan/CtcZoneService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java index 512fdbc9b..797f095d1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java @@ -195,7 +195,7 @@ public class CtcZoneService { CtcManageRepository.StationRunPlanRepository runPlanRepository = zoneRepository.getStationRunPlanMap().get(station.getCode()); if (runPlanRepository != null) { - effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getCorrectSystemTime()); + effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getSystemTime()); } }); updateStageRunPlan(simulation, stationCodeSet); @@ -215,10 +215,8 @@ public class CtcZoneService { CtcManageRepository.StationRunPlanRepository runPlanRepository = zoneRepository.getStationRunPlanMap().get(stationCode); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanRepository); CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository(); - effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getCorrectSystemTime()); + effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getSystemTime()); updateStageRunPlan(simulation, stationCode); - // 发送消息 - // ctcLogicLoop.sendZoneRunPlanSend(simulation); return "success"; } @@ -232,7 +230,7 @@ public class CtcZoneService { = simulation.getCtcRepository().getCtcZoneRepository().getStationRunPlanMap(); CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository(); stationRunPlanMap.forEach((k, v) -> { - effectRepository.releaseRunPlanByStationCode(v, simulation.getCorrectSystemTime()); + effectRepository.releaseRunPlanByStationCode(v, simulation.getSystemTime()); updateStageRunPlan(simulation, k); }); return "success"; 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 306c7c084..fb1a35329 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 @@ -4,7 +4,6 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.*; import club.joylink.rtss.simulation.cbtc.CTC.data.vo.CtcStationRunPlanLogVO; import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RouteSequenceVO; import club.joylink.rtss.simulation.cbtc.CTC.data.vo.TrackViewVO; -import club.joylink.rtss.simulation.cbtc.CTC.data.vo.*; import club.joylink.rtss.simulation.cbtc.CTC.service.CTCService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; @@ -271,7 +270,7 @@ public class CTCLogicLoop { messageList.add(ctcStationRunPlanLogVO); } } else { - messageList = ctcRunPlanVOMap.values().stream().collect(Collectors.toList()); + messageList = new ArrayList<>(ctcRunPlanVOMap.values()); } sendCtcMessage(simulation.getId(), messageList, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_INIT, userIds); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java index 4f18ddd78..e1c141492 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java @@ -293,7 +293,8 @@ public class CtcEffectRepository { } public void reset() { - this.stationRunPlanMap.clear(); + // 去除运行计划清空 + // this.stationRunPlanMap.clear(); this.stationStageRunPlanMap.clear(); this.stageRunPlanVersionMap.clear(); this.stationApplyRunPlanMap.clear(); 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 5abbde117..74f4fef91 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 @@ -130,9 +130,9 @@ public class CtcRepository { this.ctcZoneRepository.reset(); this.ctcEffectRepository.reset(); this.manageRepositoryMap.clear(); + // this.runPlanStatusVOMap.clear(); this.allRunPlanList.clear(); this.simulationRunPlanMap.clear(); - this.runPlanStatusVOMap.clear(); // 运行计划状态清除 routeSequenceIdGenerator = new AtomicInteger(0); routeSequenceMap.clear(); routeSequenceVOMap.clear(); @@ -141,7 +141,6 @@ public class CtcRepository { dispatchCommandIdGenerator = new AtomicInteger(0); dispatchCommandMap.clear(); stationRegisterMap.clear(); - SimulationBuilder.buildCtcRailwayInfo(simulation); SimulationBuilder.buildCtcStationRunPlanLog(simulation); SimulationBuilder.generateRouteSequence(simulation); stationTicketMap.clear(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java index e20cff77d..055a35bea 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java @@ -140,8 +140,10 @@ public class CtcStationRunPlanLog { public void setBaseAttribute(CtcRunPlanParam paramInfo) { this.tripNumber = paramInfo.getTripNumber(); this.trackSectionCode = paramInfo.getTrackSectionCode(); - if (paramInfo.getPassenger() != null && paramInfo.getPassenger()) { + if (paramInfo.getPassenger() != null && paramInfo.getPassenger()) { // 没办理客运,就先默认为货运 this.passenger = PlanPropertiesType.PASSENGER; // 是否客运 + } else { + this.passenger = PlanPropertiesType.GOODS_TRAIN; // 货运 } this.keyTrains = paramInfo.getKeyTrains(); // 重点列车 this.military = paramInfo.getMilitary(); // 是否军用 @@ -336,6 +338,24 @@ public class CtcStationRunPlanLog { } } + /** + * 增加行车日志 + * + * @param simulation 仿真实体 + * @param stationCode 车站编码 + * @param paramInfo 参数 + * @return 行车日志 + */ + public static CtcStationRunPlanLog createRunPlanLog(Simulation simulation, String stationCode, CtcRunPlanParam paramInfo) { + paramInfo.generateRunPlanCodeAndTripNumber(); + CtcStationRunPlanLog ctcStationRunPlanLog = new CtcStationRunPlanLog(paramInfo); + 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; + } + /** * 初始化到、发运行计划条目 * @@ -352,7 +372,7 @@ public class CtcStationRunPlanLog { // 运行方向 String directionCode = arrive ? paramInfo.getArriveDirectionCode() : paramInfo.getDepartDirectionCode(); RunPlanItem runPlanItem = null; - if ((!StringUtils.isEmpty(stationCode) && !StringUtils.isEmpty(tripNumber)) || !StringUtils.isEmpty(directionCode)) { + if ((!StringUtils.isEmpty(stationCode) || !StringUtils.isEmpty(directionCode)) && !StringUtils.isEmpty(tripNumber)) { runPlanItem = new RunPlanItem(paramInfo); Station adjacentStation = null; if (!StringUtils.isEmpty(directionCode)) { @@ -368,7 +388,9 @@ public class CtcStationRunPlanLog { } runPlanItem.setRunModel(stationDirection.getDefaultRunStatus()); runPlanItem.initAccessName(); - adjacentStation = stationDirection.getRelativeStationDirection().getStation(); + if (stationDirection.getRelativeStationDirection() != null) { + adjacentStation = stationDirection.getRelativeStationDirection().getStation(); + } } // 如果车站信息不为空则用指定车站信息 adjacentStation = StringUtils.isEmpty(stationCode) ? adjacentStation : simulation.getRepository().getByCode(stationCode, Station.class); @@ -439,7 +461,7 @@ public class CtcStationRunPlanLog { // 站务 Train_Depot_Operation("站务"); - private String optionName; + private final String optionName; RunPlanTask(String optionName) { this.optionName = optionName; @@ -535,7 +557,7 @@ public class CtcStationRunPlanLog { GOODS_TRAIN("货运"), // 货运 ELECTRICAL("电力");// 电力 - private String optionName; + private final String optionName; PlanPropertiesType(String optionName) { this.optionName = optionName; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcZoneRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcZoneRepository.java index 4995ca8df..6aed29d3c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcZoneRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcZoneRepository.java @@ -93,7 +93,6 @@ public class CtcZoneRepository { * 重置 */ public void reset() { - this.ctcZoneList.clear(); this.stationRunPlanMap.clear(); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcStationRunPlanLogVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcStationRunPlanLogVO.java index 2938e8fd4..619a0a307 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcStationRunPlanLogVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcStationRunPlanLogVO.java @@ -314,7 +314,7 @@ public class CtcStationRunPlanLogVO { @Getter @Setter - public class RunPlanItem { + public static class RunPlanItem { /** * 车次 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java index 47778ce6b..af98ee629 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java @@ -4,28 +4,15 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository; import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; -import club.joylink.rtss.simulation.cbtc.CTC.data.RailDispatchCommand; import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence; -import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RailDispatchCommandSignVO; -import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RailDispatchCommandVO; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.Route; import club.joylink.rtss.simulation.cbtc.data.map.Station; -import club.joylink.rtss.simulation.cbtc.member.SimulationMember; -import club.joylink.rtss.vo.client.SocketMessageVO; -import club.joylink.rtss.vo.client.factory.SocketMessageFactory; -import club.joylink.rtss.websocket.StompMessageService; -import club.joylink.rtss.websocket.WebSocketMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; -import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Collectors; @Component public class CTCService { @@ -109,7 +96,7 @@ public class CTCService { CtcStationRunPlanLog previousStationPlan = getCtcStationRunPlanByRunPlanCode(simulation, previousStation.getCode(), runPlanCode); currentStationPlan.finishReceivingNotice(); previousStationPlan.finishDepartureNotice(); - String systemTime = simulation.getCorrectSystemTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:dd")); + String systemTime = simulation.getSystemTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:dd")); currentStationPlan.getArriveRunPlan().setAdjacentMessageTime(systemTime); previousStationPlan.getDepartRunPlan().setAdjacentMessageTime(systemTime); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java index 47db31510..bae9c4cff 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java @@ -1,14 +1,12 @@ package club.joylink.rtss.simulation.cbtc.build; import club.joylink.rtss.entity.Ibp; -import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam; import club.joylink.rtss.simulation.cbtc.CTC.data.*; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.*; -import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan; import club.joylink.rtss.simulation.cbtc.data.plan.TerminalDeparturePlan; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; @@ -30,7 +28,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.util.CollectionUtils; import java.time.Duration; -import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -102,7 +99,6 @@ public class SimulationBuilder { if (simulation.getRepository().getConfig().isHasCTC()) { LocalDateTime now = LocalDateTime.now(); System.out.println("CTC行车日志耗时:" + Duration.between(now, LocalDateTime.now()).getSeconds()); - buildCtcRailwayInfo(simulation); buildCtcStationRunPlanLog(simulation); now = LocalDateTime.now(); generateRouteSequence(simulation); @@ -359,143 +355,29 @@ public class SimulationBuilder { } } - /** - * 构建铁路局(调度台、区段)等数据 - * - * @param simulation 仿真 - */ - public static void buildCtcRailwayInfo(Simulation simulation) { - String code = "Station32295_Station58852_Station47980"; // 后期数据录入 - // 铁路局(调度台、区段) - CtcZone ctcZone = new CtcZone(); - ctcZone.setCode(code); - ctcZone.setName("标准线"); - ctcZone.setStationList(simulation.getRepository().getStationList()); - // 铁路局(调度台、区段)数据 - simulation.getCtcRepository().getCtcZoneRepository().getCtcZoneList().add(ctcZone); - ctcZone.getStationList().forEach(s -> { - // 车务管理终端数据 - simulation.getCtcRepository().getManageRepositoryMap().put(s.getCode(), new CtcManageRepository(s.getCode())); - }); - } - /** * 根据行车计划构建行车日志 * * @param simulation 仿真实体 */ public static void buildCtcStationRunPlanLog(Simulation simulation) { - Map> serverTripMap = simulation.getRepository().getServiceTripsMap(); - if (CollectionUtils.isEmpty(serverTripMap)) { - return; - } - List ctcRunPlanParamList = new ArrayList<>(); - LocalDate nowLocalDate = simulation.getCorrectSystemTime().toLocalDate(); - // 由于车次号是唯一标识,地铁车次不适用,这里只去一车次组的车次信息 - serverTripMap.values().stream().findFirst().stream().forEach(tripPlanList -> { - tripPlanList.forEach(tripPlan -> { - StationPlan stationPlan, adjacentStationPlan; - CtcRunPlanParam ctcRunPlanParam; - StationDirection stationDirection; - String codePrefix = tripPlan.getServiceNumber().concat(tripPlan.getTripNumber()); - for (int index = 0, len = tripPlan.getPlanList().size(); index < len; index++) { - ctcRunPlanParam = new CtcRunPlanParam(); - stationPlan = tripPlan.getPlanList().get(index); - ctcRunPlanParam.setRunPlanCode(codePrefix); - // 目前将到达、出发车次一直 - ctcRunPlanParam.setTripNumber(tripPlan.getTripNumber()); - ctcRunPlanParam.setGroupNumber(tripPlan.getServiceNumber()); - ctcRunPlanParam.generateRunPlanCodeAndTripNumber(); - ctcRunPlanParam.setArriveTripNumber(tripPlan.getTripNumber()); - ctcRunPlanParam.setDepartTripNumber(tripPlan.getTripNumber()); - ctcRunPlanParam.setStationCode(stationPlan.getStation().getCode()); - ctcRunPlanParam.setTrackSectionCode(stationPlan.getSection().getCode()); - ctcRunPlanParam.setPassenger(Boolean.TRUE); - // 到达计划,始发站没有到达计划 - if (index > 0) { - adjacentStationPlan = tripPlan.getPlanList().get(index - 1); - initRunPlanParam(true, stationPlan, ctcRunPlanParam, adjacentStationPlan.getStation(), nowLocalDate); - } - // 发车计划,终点站没有发车计划 - if (index + 1 < len) { - adjacentStationPlan = tripPlan.getPlanList().get(index + 1); - initRunPlanParam(false, stationPlan, ctcRunPlanParam, adjacentStationPlan.getStation(), nowLocalDate); - } - ctcRunPlanParamList.add(ctcRunPlanParam); - } + List stationList = simulation.getRepository().getStationList(); + // 调度台 + CtcZoneRepository ctcZoneRepository = simulation.getCtcRepository().getCtcZoneRepository(); + // 生效区 + CtcEffectRepository ctcEffectRepository = simulation.getCtcRepository().getCtcEffectRepository(); + ctcEffectRepository.getStationRunPlanMap().forEach((k, v) -> { + v.getRunPlanParamMap().forEach((c, r) -> { + // 调度台放入 + ctcZoneRepository.saveRunPlan(r.clone()); + // 重新构造运行日志 + CtcStationRunPlanLog runPlanLog = CtcStationRunPlanLog.createRunPlanLog(simulation, k, r); + runPlanLog.setOrigin(true); + simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog); }); }); - // 集中中心一份 - CtcZoneRepository ctcZoneRepository = simulation.getCtcRepository().getCtcZoneRepository(); - // 生效区一份 - CtcEffectRepository ctcEffectRepository = simulation.getCtcRepository().getCtcEffectRepository(); - ctcRunPlanParamList.forEach(param -> { - // 集中中心增加 - ctcZoneRepository.saveRunPlan(param.clone()); - // 生效区 - ctcEffectRepository.saveRunPlan(param.clone()); - // 车务管理终端一份 - CtcManageRepository ctcManageRepository = simulation.getCtcRepository().getManageRepositoryMap().get(param.getStationCode()); - ctcManageRepository.saveRunPlanToEditArea(param.clone()); - ctcManageRepository.saveRunPlanToEffectArea(param.clone()); - CtcStationRunPlanLog runPlanLog = new CtcStationRunPlanLog(param); - runPlanLog.setCode(param.getRunPlanCode()); - runPlanLog.setTripNumber(param.getTripNumber()); - runPlanLog.setStation(simulation.getRepository().getByCode(param.getStationCode(), Station.class)); - runPlanLog.setOrigin(true); - runPlanLog.setArriveRunPlan(CtcStationRunPlanLog.createRunPlanItem(simulation, param, true)); - runPlanLog.setDepartRunPlan(CtcStationRunPlanLog.createRunPlanItem(simulation, param, false)); - simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog); - }); } - /** - * 根据原有的大铁运行计划生成运行参数实体 - * - * @param arriveFlag 到达 - * @param stationPlan 运行计划 - * @param ctcRunPlanParam 参数实体 - */ - private static void initRunPlanParam(boolean arriveFlag, StationPlan stationPlan, CtcRunPlanParam ctcRunPlanParam, Station adjacentStation, LocalDate nowLocalDate) { - StationDirection.ReceiveAndDeliverModel defaultRunStatus; - if (arriveFlag) { - defaultRunStatus = StationDirection.ReceiveAndDeliverModel.R; - ctcRunPlanParam.setArrivePlanTime(LocalDateTime.of(nowLocalDate, stationPlan.getArriveTime())); - // ctcRunPlanParam.setArriveTime(stationPlan.getArriveTime()); - ctcRunPlanParam.setArriveStationCode(adjacentStation.getCode()); - ctcRunPlanParam.setArriveSectionCode(stationPlan.getSection().getCode()); // 停靠股道 - } else { - defaultRunStatus = StationDirection.ReceiveAndDeliverModel.D; - ctcRunPlanParam.setDepartPlanTime(LocalDateTime.of(nowLocalDate, stationPlan.getLeaveTime())); - // ctcRunPlanParam.setDepartTime(stationPlan.getLeaveTime()); - ctcRunPlanParam.setDepartStationCode(adjacentStation.getCode()); - ctcRunPlanParam.setDepartSectionCode(stationPlan.getSection().getCode()); // 停靠股道 - } - // 确定方向条件:相对方向存在、相对方向与运行计划的邻站一致、符合接发状态、线路方向一致 - StationDirection stationDirection = stationPlan.getStation().getStationDirectionMap().values().stream() - .filter(direction -> direction.getRelativeStationDirection() != null - && direction.getRelativeStationDirection().getStation().getCode().equals(adjacentStation.getCode()) - && defaultRunStatus.equals(direction.getDefaultRunStatus())) - .findFirst().orElse(null); - if (stationDirection == null) { - // 获取接进路的方向 - stationDirection = stationPlan.getStation().getStationDirectionMap().values().stream() - .filter(direction -> defaultRunStatus.equals(direction.getDefaultRunStatus())) - .filter(direction -> { - boolean right = direction.getReceiveRouteList().stream().anyMatch(Route::isRight); - return (direction.getStation().getSn() + (right ? -1 : 1)) == adjacentStation.getSn(); - }).findFirst().orElse(null); - } - if (stationDirection != null) { - if (arriveFlag) { - ctcRunPlanParam.setArriveDirectionCode(stationDirection.getCode()); - } else { - ctcRunPlanParam.setDepartDirectionCode(stationDirection.getCode()); - } - } - } - - public static List checkRunPlanAndBuildLostRoutePaths(Map> serverTripMap, Map> routePathMap) { Map errMsgMap = new HashMap<>(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationDirectionStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationDirectionStatus.java index 23f28ccbe..faad89610 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationDirectionStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationDirectionStatus.java @@ -15,11 +15,11 @@ import java.util.concurrent.atomic.AtomicInteger; */ @Getter public class StationDirectionStatus extends DeviceStatus { - private String stationCode; + private final String stationCode; - private StationDirection.DirectionRunModel runModel; + private final StationDirection.DirectionRunModel runModel; - private DirectionLabelEnum labelEnum; + private final DirectionLabelEnum labelEnum; /** * 接车、发车模式 @@ -69,7 +69,7 @@ public class StationDirectionStatus extends DeviceStatus { /** * 倒计时 */ - private AtomicInteger remain; + private final AtomicInteger remain; /** * 预备状态 From bc5207b6a780d17e773e2583e40d183ed63d2813 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 30 Jun 2022 16:48:39 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=85=88=E5=8F=91=E5=B8=83=E5=86=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=EF=BC=8C=E8=BD=A6=E5=8A=A1=E7=AB=AF=E9=98=B6=E6=AE=B5=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=97=A0=E5=8F=98=E5=8C=96=E6=93=8D=E4=BD=9C=E3=80=91?= =?UTF-8?q?=20=E3=80=90=E5=88=9D=E5=A7=8B=E5=8C=96=E9=82=BB=E7=AB=99?= =?UTF-8?q?=E5=90=8C=E6=84=8F=E7=AD=89=E5=86=85=E5=AE=B9=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=97=AE=E9=A2=98=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java | 1 - 1 file changed, 1 deletion(-) 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 c45d3922e..7a7e833b1 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 @@ -220,7 +220,6 @@ public class CtcStationRunPlanLogService { .getRunPlanByRunPlanCodeAndStationCode(stationCode, ctcRunPlanVO.getRunPlanCode()); if (runPlanLog != null) { runPlanLog.setBaseAttribute(ctcRunPlanVO.getRunPlan()); - runPlanLog.setDelete(ctcRunPlanVO.getStatus() == -1); // 到达 if (ctcRunPlanVO.getRunPlan().arriveIsExist()) { // 不存在到达信息则直接浮空 modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), ctcRunPlanVO.getRunPlan(), true); From 20339c9237c3e197b1a5001cf6d87f53f416fac0 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 30 Jun 2022 16:49:14 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=85=88=E5=8F=91=E5=B8=83=E5=86=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=EF=BC=8C=E8=BD=A6=E5=8A=A1=E7=AB=AF=E9=98=B6=E6=AE=B5=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=97=A0=E5=8F=98=E5=8C=96=E6=93=8D=E4=BD=9C=E3=80=91?= =?UTF-8?q?=20=E3=80=90=E5=88=9D=E5=A7=8B=E5=8C=96=E9=82=BB=E7=AB=99?= =?UTF-8?q?=E5=90=8C=E6=84=8F=E7=AD=89=E5=86=85=E5=AE=B9=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=97=AE=E9=A2=98=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/CTC/data/CtcStationRunPlanLog.java | 7 +++++++ .../rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java index 055a35bea..d3750cd45 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java @@ -156,6 +156,7 @@ public class CtcStationRunPlanLog { } else { this.runPlanTaskItemMap = new HashMap<>(0); } + this.delete = paramInfo.getStatus() == -1; } public void finishReceivingNotice() { @@ -323,6 +324,12 @@ public class CtcStationRunPlanLog { public RunPlanItem(CtcRunPlanParam paramInfo) { this.paramInfo = paramInfo; + this.actualTime = ""; + this.adjacentStatus = ""; + this.adjacentMessage = NO; + this.adjacentDepart = ""; + this.occupiedCode = ""; + this.adjacentMessageTime = ""; this.trainTypeMap = new HashMap<>(TrainType.values().length); this.processTypeMap = new HashMap<>(ProcessType.values().length); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java index aa8f5ce09..d15a088ef 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java @@ -76,6 +76,9 @@ public class CtcRunPlanVO { if (oldRunPlanLog == null) { return runPlanVO; } + if (oldRunPlanLog.getStatus() != status) { + return runPlanVO; + } CtcRunPlanParam changeRunPlan = new CtcRunPlanParam().compareAndChange(oldRunPlanLog, runPlanParam); runPlanVO.setChangeRunPlan(changeRunPlan); return changeRunPlan != null ? runPlanVO : null; From 56389d00b01398c257f33093a4050210e100e201 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 30 Jun 2022 17:24:55 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E3=80=90=E4=B8=8B=E5=8F=91=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=88=A0=E9=99=A4=E6=97=B6=E5=8F=91=E9=80=81=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E9=97=AE=E9=A2=98=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java index d15a088ef..3e3784119 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcRunPlanVO.java @@ -73,12 +73,13 @@ public class CtcRunPlanVO { CtcRunPlanVO runPlanVO = new CtcRunPlanVO(runPlanParam); runPlanVO.setStatus(status); runPlanVO.getRunPlan().setStatus(status); - if (oldRunPlanLog == null) { + if (oldRunPlanLog == null) { // 新增 return runPlanVO; } - if (oldRunPlanLog.getStatus() != status) { + if (oldRunPlanLog.getStatus() != status && status == -1) { // 删除 return runPlanVO; } + // 编辑信息 CtcRunPlanParam changeRunPlan = new CtcRunPlanParam().compareAndChange(oldRunPlanLog, runPlanParam); runPlanVO.setChangeRunPlan(changeRunPlan); return changeRunPlan != null ? runPlanVO : null;