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:
commit
383aa6edd1
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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,28 @@ public class CtcStationRunPlanLogService {
|
||||
if (CollectionUtils.isEmpty(ctcRunPlanVOList)) {
|
||||
return;
|
||||
}
|
||||
List<CtcStationRunPlanLog> 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 +260,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 +297,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 +389,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
@ -303,7 +302,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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -133,9 +133,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();
|
||||
@ -144,7 +144,6 @@ public class CtcRepository {
|
||||
dispatchCommandIdGenerator = new AtomicInteger(0);
|
||||
dispatchCommandMap.clear();
|
||||
stationRegisterMap.clear();
|
||||
SimulationBuilder.buildCtcRailwayInfo(simulation);
|
||||
SimulationBuilder.buildCtcStationRunPlanLog(simulation);
|
||||
SimulationBuilder.generateRouteSequence(simulation);
|
||||
buildTrackViewData(simulation);
|
||||
|
@ -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(); // 是否军用
|
||||
@ -154,6 +156,7 @@ public class CtcStationRunPlanLog {
|
||||
} else {
|
||||
this.runPlanTaskItemMap = new HashMap<>(0);
|
||||
}
|
||||
this.delete = paramInfo.getStatus() == -1;
|
||||
}
|
||||
|
||||
public void finishReceivingNotice() {
|
||||
@ -321,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);
|
||||
}
|
||||
@ -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();
|
||||
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 +395,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 +468,7 @@ public class CtcStationRunPlanLog {
|
||||
// 站务
|
||||
Train_Depot_Operation("站务");
|
||||
|
||||
private String optionName;
|
||||
private final String optionName;
|
||||
|
||||
RunPlanTask(String optionName) {
|
||||
this.optionName = optionName;
|
||||
@ -535,7 +564,7 @@ public class CtcStationRunPlanLog {
|
||||
GOODS_TRAIN("货运"), // 货运
|
||||
ELECTRICAL("电力");// 电力
|
||||
|
||||
private String optionName;
|
||||
private final String optionName;
|
||||
|
||||
PlanPropertiesType(String optionName) {
|
||||
this.optionName = optionName;
|
||||
|
@ -93,7 +93,6 @@ public class CtcZoneRepository {
|
||||
* 重置
|
||||
*/
|
||||
public void reset() {
|
||||
this.ctcZoneList.clear();
|
||||
this.stationRunPlanMap.clear();
|
||||
}
|
||||
}
|
||||
|
@ -73,9 +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 && status == -1) { // 删除
|
||||
return runPlanVO;
|
||||
}
|
||||
// 编辑信息
|
||||
CtcRunPlanParam changeRunPlan = new CtcRunPlanParam().compareAndChange(oldRunPlanLog, runPlanParam);
|
||||
runPlanVO.setChangeRunPlan(changeRunPlan);
|
||||
return changeRunPlan != null ? runPlanVO : null;
|
||||
|
@ -314,7 +314,7 @@ public class CtcStationRunPlanLogVO {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class RunPlanItem {
|
||||
public static class RunPlanItem {
|
||||
/**
|
||||
* 车次
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
@ -100,7 +97,6 @@ public class SimulationBuilder {
|
||||
loadDepotInOutRoutePath(simulation);
|
||||
// CTC行车日志数据结构构建
|
||||
if (simulation.getRepository().getConfig().isHasCTC()) {
|
||||
buildCtcRailwayInfo(simulation);
|
||||
buildCtcStationRunPlanLog(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 仿真实体
|
||||
*/
|
||||
public static void buildCtcStationRunPlanLog(Simulation simulation) {
|
||||
Map<String, List<TripPlan>> serverTripMap = simulation.getRepository().getServiceTripsMap();
|
||||
if (CollectionUtils.isEmpty(serverTripMap)) {
|
||||
return;
|
||||
}
|
||||
List<CtcRunPlanParam> 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<Station> 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<String> checkRunPlanAndBuildLostRoutePaths(Map<String, List<TripPlan>> serverTripMap,
|
||||
Map<String, List<RoutePath>> routePathMap) {
|
||||
Map<String, String> errMsgMap = new HashMap<>();
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
* 预备状态
|
||||
|
Loading…
Reference in New Issue
Block a user