Merge remote-tracking branch 'origin/test' into test

# Conflicts:
#	src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java
This commit is contained in:
joylink_zhangsai 2022-07-01 09:31:38 +08:00
commit 383aa6edd1
13 changed files with 72 additions and 215 deletions

View File

@ -499,11 +499,6 @@ public class CtcRunPlanParam implements Cloneable {
this.transfinite = origin.getTransfinite(); this.transfinite = origin.getTransfinite();
change = true; change = true;
} }
// 状态
if (!Objects.equals(origin.getStatus(), modify.getStatus())) {
this.status = origin.getStatus();
change = true;
}
return change ? this : null; return change ? this : null;
} }

View File

@ -73,7 +73,7 @@ public class CtcStationRunPlanLogService {
runPlanLogList.add(runPlanLog); runPlanLogList.add(runPlanLog);
} }
} else { } else {
runPlanLog = createRunPlanLog(simulation, stationCode, p); runPlanLog = CtcStationRunPlanLog.createRunPlanLog(simulation, stationCode, p);
simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog); simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog);
runPlanLogList.add(runPlanLog); runPlanLogList.add(runPlanLog);
} }
@ -215,46 +215,28 @@ public class CtcStationRunPlanLogService {
if (CollectionUtils.isEmpty(ctcRunPlanVOList)) { if (CollectionUtils.isEmpty(ctcRunPlanVOList)) {
return; return;
} }
List<CtcStationRunPlanLog> runPlanLogList = new ArrayList<>();
ctcRunPlanVOList.forEach(ctcRunPlanVO -> { ctcRunPlanVOList.forEach(ctcRunPlanVO -> {
CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository() CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository()
.getRunPlanByRunPlanCodeAndStationCode(stationCode, ctcRunPlanVO.getRunPlanCode()); .getRunPlanByRunPlanCodeAndStationCode(stationCode, ctcRunPlanVO.getRunPlanCode());
boolean change = false;
if (runPlanLog != null) { if (runPlanLog != null) {
runPlanLog.setBaseAttribute(ctcRunPlanVO.getRunPlan()); runPlanLog.setBaseAttribute(ctcRunPlanVO.getRunPlan());
runPlanLog.setDelete(ctcRunPlanVO.getStatus() == -1);
// 到达 // 到达
if (ctcRunPlanVO.getRunPlan().arriveIsExist()) { // 不存在到达信息则直接浮空 if (ctcRunPlanVO.getRunPlan().arriveIsExist()) { // 不存在到达信息则直接浮空
change = modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), ctcRunPlanVO.getRunPlan(), true); modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), ctcRunPlanVO.getRunPlan(), true);
} else { } else {
runPlanLog.setArriveRunPlan(null); runPlanLog.setArriveRunPlan(null);
} }
// 出发 // 出发
if (ctcRunPlanVO.getRunPlan().departIsExist()) { if (ctcRunPlanVO.getRunPlan().departIsExist()) {
change = change || modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), ctcRunPlanVO.getRunPlan(), false); modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), ctcRunPlanVO.getRunPlan(), false);
} else { } else {
runPlanLog.setDepartRunPlan(null); runPlanLog.setDepartRunPlan(null);
} }
} else { } else {
change = true; runPlanLog = CtcStationRunPlanLog.createRunPlanLog(simulation, stationCode, ctcRunPlanVO.getRunPlan());
runPlanLog = createRunPlanLog(simulation, stationCode, ctcRunPlanVO.getRunPlan());
simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog); 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 +260,7 @@ public class CtcStationRunPlanLogService {
curRunPlanParam.setDepartSectionCode(sectionCode); curRunPlanParam.setDepartSectionCode(sectionCode);
} }
CtcRunPlanVO ctcRunPlanVO = CtcRunPlanVO.compareAndChange(curRunPlanParam, effectRunPlanParam); CtcRunPlanVO ctcRunPlanVO = CtcRunPlanVO.compareAndChange(curRunPlanParam, effectRunPlanParam);
ctcRunPlanVO.setCreateTime(simulation.getCorrectSystemTime()); ctcRunPlanVO.setCreateTime(simulation.getSystemTime());
simulation.getCtcRepository().saveApplyRunPlan(ctcRunPlanVO); simulation.getCtcRepository().saveApplyRunPlan(ctcRunPlanVO);
} }
} }
@ -315,7 +297,7 @@ public class CtcStationRunPlanLogService {
if (planParam.getPassenger() != null) { if (planParam.getPassenger() != null) {
CtcStationRunPlanLog.PlanPropertiesType planPropertiesType = planParam.getPassenger() ? CtcStationRunPlanLog.PlanPropertiesType planPropertiesType = planParam.getPassenger() ?
CtcStationRunPlanLog.PlanPropertiesType.PASSENGER : null; CtcStationRunPlanLog.PlanPropertiesType.PASSENGER : null;
if (!Objects.equals(planParam.getPassenger(), runPlanLog.getPassenger())) { if (!Objects.equals(planPropertiesType, runPlanLog.getPassenger())) {
runPlanLog.setPassenger(planPropertiesType); runPlanLog.setPassenger(planPropertiesType);
} }
} }
@ -407,23 +389,5 @@ public class CtcStationRunPlanLogService {
return change; 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;
}
} }

View File

@ -195,7 +195,7 @@ public class CtcZoneService {
CtcManageRepository.StationRunPlanRepository runPlanRepository CtcManageRepository.StationRunPlanRepository runPlanRepository
= zoneRepository.getStationRunPlanMap().get(station.getCode()); = zoneRepository.getStationRunPlanMap().get(station.getCode());
if (runPlanRepository != null) { if (runPlanRepository != null) {
effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getCorrectSystemTime()); effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getSystemTime());
} }
}); });
updateStageRunPlan(simulation, stationCodeSet); updateStageRunPlan(simulation, stationCodeSet);
@ -215,10 +215,8 @@ public class CtcZoneService {
CtcManageRepository.StationRunPlanRepository runPlanRepository = zoneRepository.getStationRunPlanMap().get(stationCode); CtcManageRepository.StationRunPlanRepository runPlanRepository = zoneRepository.getStationRunPlanMap().get(stationCode);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanRepository); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanRepository);
CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository(); CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository();
effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getCorrectSystemTime()); effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getSystemTime());
updateStageRunPlan(simulation, stationCode); updateStageRunPlan(simulation, stationCode);
// 发送消息
// ctcLogicLoop.sendZoneRunPlanSend(simulation);
return "success"; return "success";
} }
@ -232,7 +230,7 @@ public class CtcZoneService {
= simulation.getCtcRepository().getCtcZoneRepository().getStationRunPlanMap(); = simulation.getCtcRepository().getCtcZoneRepository().getStationRunPlanMap();
CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository(); CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository();
stationRunPlanMap.forEach((k, v) -> { stationRunPlanMap.forEach((k, v) -> {
effectRepository.releaseRunPlanByStationCode(v, simulation.getCorrectSystemTime()); effectRepository.releaseRunPlanByStationCode(v, simulation.getSystemTime());
updateStageRunPlan(simulation, k); updateStageRunPlan(simulation, k);
}); });
return "success"; return "success";

View File

@ -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.CtcStationRunPlanLogVO;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RouteSequenceVO; 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.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.CTC.service.CTCService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
@ -303,7 +302,7 @@ public class CTCLogicLoop {
messageList.add(ctcStationRunPlanLogVO); messageList.add(ctcStationRunPlanLogVO);
} }
} else { } else {
messageList = ctcRunPlanVOMap.values().stream().collect(Collectors.toList()); messageList = new ArrayList<>(ctcRunPlanVOMap.values());
} }
sendCtcMessage(simulation.getId(), messageList, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_INIT, userIds); sendCtcMessage(simulation.getId(), messageList, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_INIT, userIds);
} }

View File

@ -293,7 +293,8 @@ public class CtcEffectRepository {
} }
public void reset() { public void reset() {
this.stationRunPlanMap.clear(); // 去除运行计划清空
// this.stationRunPlanMap.clear();
this.stationStageRunPlanMap.clear(); this.stationStageRunPlanMap.clear();
this.stageRunPlanVersionMap.clear(); this.stageRunPlanVersionMap.clear();
this.stationApplyRunPlanMap.clear(); this.stationApplyRunPlanMap.clear();

View File

@ -133,9 +133,9 @@ public class CtcRepository {
this.ctcZoneRepository.reset(); this.ctcZoneRepository.reset();
this.ctcEffectRepository.reset(); this.ctcEffectRepository.reset();
this.manageRepositoryMap.clear(); this.manageRepositoryMap.clear();
// this.runPlanStatusVOMap.clear();
this.allRunPlanList.clear(); this.allRunPlanList.clear();
this.simulationRunPlanMap.clear(); this.simulationRunPlanMap.clear();
this.runPlanStatusVOMap.clear(); // 运行计划状态清除
routeSequenceIdGenerator = new AtomicInteger(0); routeSequenceIdGenerator = new AtomicInteger(0);
routeSequenceMap.clear(); routeSequenceMap.clear();
routeSequenceVOMap.clear(); routeSequenceVOMap.clear();
@ -144,7 +144,6 @@ public class CtcRepository {
dispatchCommandIdGenerator = new AtomicInteger(0); dispatchCommandIdGenerator = new AtomicInteger(0);
dispatchCommandMap.clear(); dispatchCommandMap.clear();
stationRegisterMap.clear(); stationRegisterMap.clear();
SimulationBuilder.buildCtcRailwayInfo(simulation);
SimulationBuilder.buildCtcStationRunPlanLog(simulation); SimulationBuilder.buildCtcStationRunPlanLog(simulation);
SimulationBuilder.generateRouteSequence(simulation); SimulationBuilder.generateRouteSequence(simulation);
buildTrackViewData(simulation); buildTrackViewData(simulation);

View File

@ -140,8 +140,10 @@ public class CtcStationRunPlanLog {
public void setBaseAttribute(CtcRunPlanParam paramInfo) { public void setBaseAttribute(CtcRunPlanParam paramInfo) {
this.tripNumber = paramInfo.getTripNumber(); this.tripNumber = paramInfo.getTripNumber();
this.trackSectionCode = paramInfo.getTrackSectionCode(); this.trackSectionCode = paramInfo.getTrackSectionCode();
if (paramInfo.getPassenger() != null && paramInfo.getPassenger()) { if (paramInfo.getPassenger() != null && paramInfo.getPassenger()) { // 没办理客运就先默认为货运
this.passenger = PlanPropertiesType.PASSENGER; // 是否客运 this.passenger = PlanPropertiesType.PASSENGER; // 是否客运
} else {
this.passenger = PlanPropertiesType.GOODS_TRAIN; // 货运
} }
this.keyTrains = paramInfo.getKeyTrains(); // 重点列车 this.keyTrains = paramInfo.getKeyTrains(); // 重点列车
this.military = paramInfo.getMilitary(); // 是否军用 this.military = paramInfo.getMilitary(); // 是否军用
@ -154,6 +156,7 @@ public class CtcStationRunPlanLog {
} else { } else {
this.runPlanTaskItemMap = new HashMap<>(0); this.runPlanTaskItemMap = new HashMap<>(0);
} }
this.delete = paramInfo.getStatus() == -1;
} }
public void finishReceivingNotice() { public void finishReceivingNotice() {
@ -321,6 +324,12 @@ public class CtcStationRunPlanLog {
public RunPlanItem(CtcRunPlanParam paramInfo) { public RunPlanItem(CtcRunPlanParam paramInfo) {
this.paramInfo = 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.trainTypeMap = new HashMap<>(TrainType.values().length);
this.processTypeMap = new HashMap<>(ProcessType.values().length); this.processTypeMap = new HashMap<>(ProcessType.values().length);
} }
@ -336,6 +345,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 +379,7 @@ public class CtcStationRunPlanLog {
// 运行方向 // 运行方向
String directionCode = arrive ? paramInfo.getArriveDirectionCode() : paramInfo.getDepartDirectionCode(); String directionCode = arrive ? paramInfo.getArriveDirectionCode() : paramInfo.getDepartDirectionCode();
RunPlanItem runPlanItem = null; 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); runPlanItem = new RunPlanItem(paramInfo);
Station adjacentStation = null; Station adjacentStation = null;
if (!StringUtils.isEmpty(directionCode)) { if (!StringUtils.isEmpty(directionCode)) {
@ -368,7 +395,9 @@ public class CtcStationRunPlanLog {
} }
runPlanItem.setRunModel(stationDirection.getDefaultRunStatus()); runPlanItem.setRunModel(stationDirection.getDefaultRunStatus());
runPlanItem.initAccessName(); 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); adjacentStation = StringUtils.isEmpty(stationCode) ? adjacentStation : simulation.getRepository().getByCode(stationCode, Station.class);
@ -439,7 +468,7 @@ public class CtcStationRunPlanLog {
// 站务 // 站务
Train_Depot_Operation("站务"); Train_Depot_Operation("站务");
private String optionName; private final String optionName;
RunPlanTask(String optionName) { RunPlanTask(String optionName) {
this.optionName = optionName; this.optionName = optionName;
@ -535,7 +564,7 @@ public class CtcStationRunPlanLog {
GOODS_TRAIN("货运"), // 货运 GOODS_TRAIN("货运"), // 货运
ELECTRICAL("电力");// 电力 ELECTRICAL("电力");// 电力
private String optionName; private final String optionName;
PlanPropertiesType(String optionName) { PlanPropertiesType(String optionName) {
this.optionName = optionName; this.optionName = optionName;

View File

@ -93,7 +93,6 @@ public class CtcZoneRepository {
* 重置 * 重置
*/ */
public void reset() { public void reset() {
this.ctcZoneList.clear();
this.stationRunPlanMap.clear(); this.stationRunPlanMap.clear();
} }
} }

View File

@ -73,9 +73,13 @@ public class CtcRunPlanVO {
CtcRunPlanVO runPlanVO = new CtcRunPlanVO(runPlanParam); CtcRunPlanVO runPlanVO = new CtcRunPlanVO(runPlanParam);
runPlanVO.setStatus(status); runPlanVO.setStatus(status);
runPlanVO.getRunPlan().setStatus(status); runPlanVO.getRunPlan().setStatus(status);
if (oldRunPlanLog == null) { if (oldRunPlanLog == null) { // 新增
return runPlanVO; return runPlanVO;
} }
if (oldRunPlanLog.getStatus() != status && status == -1) { // 删除
return runPlanVO;
}
// 编辑信息
CtcRunPlanParam changeRunPlan = new CtcRunPlanParam().compareAndChange(oldRunPlanLog, runPlanParam); CtcRunPlanParam changeRunPlan = new CtcRunPlanParam().compareAndChange(oldRunPlanLog, runPlanParam);
runPlanVO.setChangeRunPlan(changeRunPlan); runPlanVO.setChangeRunPlan(changeRunPlan);
return changeRunPlan != null ? runPlanVO : null; return changeRunPlan != null ? runPlanVO : null;

View File

@ -314,7 +314,7 @@ public class CtcStationRunPlanLogVO {
@Getter @Getter
@Setter @Setter
public class RunPlanItem { public static class RunPlanItem {
/** /**
* 车次 * 车次
*/ */

View File

@ -4,28 +4,15 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService; 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.CtcRepository;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; 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.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.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Route; import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Station; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; 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.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@Component @Component
public class CTCService { public class CTCService {
@ -109,7 +96,7 @@ public class CTCService {
CtcStationRunPlanLog previousStationPlan = getCtcStationRunPlanByRunPlanCode(simulation, previousStation.getCode(), runPlanCode); CtcStationRunPlanLog previousStationPlan = getCtcStationRunPlanByRunPlanCode(simulation, previousStation.getCode(), runPlanCode);
currentStationPlan.finishReceivingNotice(); currentStationPlan.finishReceivingNotice();
previousStationPlan.finishDepartureNotice(); 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); currentStationPlan.getArriveRunPlan().setAdjacentMessageTime(systemTime);
previousStationPlan.getDepartRunPlan().setAdjacentMessageTime(systemTime); previousStationPlan.getDepartRunPlan().setAdjacentMessageTime(systemTime);
} }

View File

@ -1,14 +1,12 @@
package club.joylink.rtss.simulation.cbtc.build; package club.joylink.rtss.simulation.cbtc.build;
import club.joylink.rtss.entity.Ibp; 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.CTC.data.*;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.*; 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.TerminalDeparturePlan;
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
@ -30,7 +28,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -100,7 +97,6 @@ public class SimulationBuilder {
loadDepotInOutRoutePath(simulation); loadDepotInOutRoutePath(simulation);
// CTC行车日志数据结构构建 // CTC行车日志数据结构构建
if (simulation.getRepository().getConfig().isHasCTC()) { if (simulation.getRepository().getConfig().isHasCTC()) {
buildCtcRailwayInfo(simulation);
buildCtcStationRunPlanLog(simulation); buildCtcStationRunPlanLog(simulation);
generateRouteSequence(simulation); generateRouteSequence(simulation);
} }
@ -355,143 +351,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 仿真实体 * @param simulation 仿真实体
*/ */
public static void buildCtcStationRunPlanLog(Simulation simulation) { public static void buildCtcStationRunPlanLog(Simulation simulation) {
Map<String, List<TripPlan>> serverTripMap = simulation.getRepository().getServiceTripsMap(); List<Station> stationList = simulation.getRepository().getStationList();
if (CollectionUtils.isEmpty(serverTripMap)) { // 调度台
return; CtcZoneRepository ctcZoneRepository = simulation.getCtcRepository().getCtcZoneRepository();
} // 生效区
List<CtcRunPlanParam> ctcRunPlanParamList = new ArrayList<>(); CtcEffectRepository ctcEffectRepository = simulation.getCtcRepository().getCtcEffectRepository();
LocalDate nowLocalDate = simulation.getCorrectSystemTime().toLocalDate(); ctcEffectRepository.getStationRunPlanMap().forEach((k, v) -> {
// 由于车次号是唯一标识地铁车次不适用这里只去一车次组的车次信息 v.getRunPlanParamMap().forEach((c, r) -> {
serverTripMap.values().stream().findFirst().stream().forEach(tripPlanList -> { // 调度台放入
tripPlanList.forEach(tripPlan -> { ctcZoneRepository.saveRunPlan(r.clone());
StationPlan stationPlan, adjacentStationPlan; // 重新构造运行日志
CtcRunPlanParam ctcRunPlanParam; CtcStationRunPlanLog runPlanLog = CtcStationRunPlanLog.createRunPlanLog(simulation, k, r);
StationDirection stationDirection; runPlanLog.setOrigin(true);
String codePrefix = tripPlan.getServiceNumber().concat(tripPlan.getTripNumber()); simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog);
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);
}
}); });
}); });
// 集中中心一份
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<String> checkRunPlanAndBuildLostRoutePaths(Map<String, List<TripPlan>> serverTripMap, public static List<String> checkRunPlanAndBuildLostRoutePaths(Map<String, List<TripPlan>> serverTripMap,
Map<String, List<RoutePath>> routePathMap) { Map<String, List<RoutePath>> routePathMap) {
Map<String, String> errMsgMap = new HashMap<>(); Map<String, String> errMsgMap = new HashMap<>();

View File

@ -15,11 +15,11 @@ import java.util.concurrent.atomic.AtomicInteger;
*/ */
@Getter @Getter
public class StationDirectionStatus extends DeviceStatus { 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;
/** /**
* 预备状态 * 预备状态