【去除多余代码】
This commit is contained in:
parent
5525b8413e
commit
526b0972c9
@ -2,7 +2,7 @@ package club.joylink.rtss.simulation.cbtc.ATS.service.runplan;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationStagePlan;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcManageRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcZoneRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -53,9 +53,12 @@ public class CtcZoneService {
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(railwayRepository);
|
||||
Map<String, List<CtcRunPlanParam>> stationRunPlanMap = railwayRepository.getZoneRunPlanMap().values().stream()
|
||||
.collect(Collectors.groupingBy(CtcRunPlanParam::getStationCode));
|
||||
simulation.getCtcRepository().getStationStagePlan().forEach((k, v) -> {
|
||||
if (stationRunPlanMap.containsKey(k)) {
|
||||
v.updateStageRunPlanList(simulation.getCorrectSystemTime(), stationRunPlanMap.get(k));
|
||||
// 找到生效区数据
|
||||
stationRunPlanMap.forEach((k, v) -> {
|
||||
CtcManageRepository manageRepository = simulation.getCtcRepository().getManageRepositoryMap().get(k);
|
||||
if (manageRepository != null) {
|
||||
manageRepository.releaseEffectArea(simulation.getCorrectSystemTime(), null,
|
||||
v.stream().collect(Collectors.toMap(CtcRunPlanParam::getRunPlanCode, CtcRunPlanParam::clone)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -67,14 +70,15 @@ public class CtcZoneService {
|
||||
* @param stationCode 车站编码
|
||||
*/
|
||||
public void releaseStationRunPlan(Simulation simulation, String stationCode) {
|
||||
CtcStationStagePlan stagePlan = simulation.getCtcRepository().getStationStagePlan().get(stationCode);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(stagePlan);
|
||||
CtcZoneRepository railwayRepository = simulation.getCtcRepository().getZoneRepository().values().stream()
|
||||
.filter(r -> r.getStationMap().containsKey(stationCode)).findFirst().orElse(null);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(railwayRepository);
|
||||
List<CtcRunPlanParam> ctcRunPlanParamList = railwayRepository.getZoneRunPlanMap().values().stream()
|
||||
.filter(r -> r.getStationCode().equals(stationCode)).collect(Collectors.toList());
|
||||
stagePlan.updateStageRunPlanList(simulation.getCorrectSystemTime(), ctcRunPlanParamList);
|
||||
CtcManageRepository manageRepository = simulation.getCtcRepository().getManageRepositoryMap().get(stationCode);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(manageRepository);
|
||||
Map<String, CtcRunPlanParam> ctcRunPlanParamMap = railwayRepository.getZoneRunPlanMap().values().stream()
|
||||
.filter(r -> r.getStationCode().equals(stationCode))
|
||||
.collect(Collectors.toMap(CtcRunPlanParam::getRunPlanCode, CtcRunPlanParam::clone));
|
||||
manageRepository.releaseEffectArea(simulation.getCorrectSystemTime(), null, ctcRunPlanParamMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,13 +87,14 @@ public class CtcZoneService {
|
||||
* @param simulation 仿真
|
||||
*/
|
||||
public void releaseAllRunPlan(Simulation simulation) {
|
||||
Map<String, CtcStationStagePlan> stagePlanMap = simulation.getCtcRepository().getStationStagePlan();
|
||||
Map<String, CtcManageRepository> stagePlanMap = simulation.getCtcRepository().getManageRepositoryMap();
|
||||
simulation.getCtcRepository().getZoneRepository().forEach((zoneCode, railwayRepository) -> {
|
||||
Map<String, List<CtcRunPlanParam>> stationRunPlanMap = railwayRepository.getZoneRunPlanMap().values().stream()
|
||||
.collect(Collectors.groupingBy(CtcRunPlanParam::getStationCode));
|
||||
Map<String, Map<String, CtcRunPlanParam>> stationRunPlanMap =
|
||||
railwayRepository.getZoneRunPlanMap().values().stream().collect(Collectors.groupingBy(
|
||||
CtcRunPlanParam::getStationCode, Collectors.toMap(CtcRunPlanParam::getRunPlanCode, CtcRunPlanParam::clone)));
|
||||
stationRunPlanMap.forEach((k, v) -> {
|
||||
if (stagePlanMap.containsKey(k)) {
|
||||
stagePlanMap.get(k).updateStageRunPlanList(simulation.getCorrectSystemTime(), v);
|
||||
stagePlanMap.get(k).releaseEffectArea(simulation.getCorrectSystemTime(), null, v);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -5,6 +5,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.StationDirection;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -64,6 +65,24 @@ public class CtcManageRepository {
|
||||
return isEdit ? this.editAreaMap.getRunPlanRepository() : this.effectAreaMap.getRunPlanRepository();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布运行计划数据至生效区
|
||||
*
|
||||
* @param updateDateTime 发布时间
|
||||
* @param version 版本
|
||||
* @param runPlanParamMap 发布内容
|
||||
*/
|
||||
public void releaseEffectArea(LocalDateTime updateDateTime, Integer version, Map<String, CtcRunPlanParam> runPlanParamMap) {
|
||||
StationRunPlanRepository effectRepository = this.getEffectAreaMap().getRunPlanRepository();
|
||||
if (version == null) {
|
||||
effectRepository.getVersion().incrementAndGet(); // 生效区版本 +1
|
||||
} else {
|
||||
effectRepository.getVersion().set(version);
|
||||
}
|
||||
effectRepository.getRunPlanParamMap().clear(); // 计划清空
|
||||
effectRepository.setUpdateTime(updateDateTime); // 更新时间
|
||||
effectRepository.getRunPlanParamMap().putAll(runPlanParamMap);
|
||||
}
|
||||
|
||||
public void rest() {
|
||||
|
||||
@ -114,9 +133,20 @@ public class CtcManageRepository {
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract static class AbstractWorkspaceRepository {
|
||||
/**
|
||||
* 车站编码
|
||||
*/
|
||||
protected String stationCode;
|
||||
|
||||
/**
|
||||
* 当前数据版本
|
||||
*/
|
||||
protected AtomicInteger version;
|
||||
|
||||
/**
|
||||
* 最近变更时间
|
||||
*/
|
||||
protected LocalDateTime updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,9 +13,10 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 铁路局CTC 车务管理终端
|
||||
* |
|
||||
* |下发计划至更新区
|
||||
* |下发计划至生效区
|
||||
* |
|
||||
* 更新区
|
||||
* 生效区
|
||||
* 【manageRepositoryMap.CtcManageRepository.effectAreaMap】
|
||||
* |
|
||||
* | 拉取计划至车站终端
|
||||
* |
|
||||
@ -44,12 +45,6 @@ public class CtcRepository {
|
||||
*/
|
||||
private final CtcManageRepositoryVO ctcManageRepositoryVO = new CtcManageRepositoryVO();
|
||||
|
||||
/**
|
||||
* 各车站的阶段计划
|
||||
* 车站为key
|
||||
*/
|
||||
private final Map<String, CtcStationStagePlan> stationStagePlan = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 车站-进路序列。每个车站都应该有
|
||||
* k - stationCode
|
||||
@ -77,12 +72,6 @@ public class CtcRepository {
|
||||
*/
|
||||
private List<CtcStationRunPlanLog> allRunPlanList = new LinkedList<>();
|
||||
|
||||
/**
|
||||
* 车站的阶段计划
|
||||
* 车站key
|
||||
*/
|
||||
private Map<String, CtcStationStagePlan> stationStagePlanMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 原始数据中行车计划:原始行驶计划数据
|
||||
* 编码为key
|
||||
|
@ -1,58 +0,0 @@
|
||||
package club.joylink.rtss.simulation.cbtc.CTC.data;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 阶段计划
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class CtcStationStagePlan {
|
||||
/**
|
||||
* 车站编码
|
||||
*/
|
||||
private Station station;
|
||||
|
||||
/**
|
||||
* 最近接受时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 运行计划列表
|
||||
*/
|
||||
private List<CtcRunPlanParam> ctcRunPlanParamList;
|
||||
|
||||
public CtcStationStagePlan(Station station) {
|
||||
this.station = station;
|
||||
this.ctcRunPlanParamList = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新运行计划列表
|
||||
*
|
||||
* @param updateTime 更新时间
|
||||
* @param runPlanParamList 运行计划列表
|
||||
*/
|
||||
public void updateStageRunPlanList(LocalDateTime updateTime, List<CtcRunPlanParam> runPlanParamList) {
|
||||
this.updateTime = updateTime;
|
||||
this.ctcRunPlanParamList = runPlanParamList.stream().map(CtcRunPlanParam::clone).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 车站编码
|
||||
*
|
||||
* @return 车站编码
|
||||
*/
|
||||
public String getStationCode() {
|
||||
return this.station.getCode();
|
||||
}
|
||||
}
|
@ -372,8 +372,6 @@ public class SimulationBuilder {
|
||||
CtcZoneRepository ctcZoneRepository = new CtcZoneRepository(ctcZone);
|
||||
ctcZone.getStationList().forEach(s -> {
|
||||
ctcZoneRepository.getStationMap().put(s.getCode(), s);
|
||||
// 各车站的阶段计划
|
||||
simulation.getCtcRepository().getStationStagePlan().put(s.getCode(), new CtcStationStagePlan(s));
|
||||
// 车务管理终端数据
|
||||
simulation.getCtcRepository().getManageRepositoryMap().put(s.getCode(), new CtcManageRepository(s.getCode()));
|
||||
});
|
||||
@ -435,11 +433,6 @@ public class SimulationBuilder {
|
||||
CtcManageRepository ctcManageRepository = simulation.getCtcRepository().getManageRepositoryMap().get(param.getStationCode());
|
||||
ctcManageRepository.saveRunPlanToEditArea(param.clone());
|
||||
ctcManageRepository.saveRunPlanToEffectArea(param.clone());
|
||||
// 各站阶段计划一份
|
||||
CtcStationStagePlan ctcStationStagePlan = simulation.getCtcRepository().getStationStagePlan().get(param.getStationCode());
|
||||
if (ctcStationStagePlan != null) {
|
||||
ctcStationStagePlan.getCtcRunPlanParamList().add(param.clone());
|
||||
}
|
||||
CtcStationRunPlanLog runPlanLog = new CtcStationRunPlanLog(param);
|
||||
runPlanLog.setCode(param.getRunPlanCode());
|
||||
runPlanLog.setTripNumber(param.getTripNumber());
|
||||
|
Loading…
Reference in New Issue
Block a user