【运行计划时间修改】

【连通错办提示等】
This commit is contained in:
weizhihong 2022-07-04 11:14:09 +08:00
parent 2e42eeea75
commit 69a3cc8eaa
4 changed files with 143 additions and 44 deletions

View File

@ -7,11 +7,16 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence;
import club.joylink.rtss.simulation.cbtc.CTC.data.TrackSection;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.map.StationDirection;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
@ -22,41 +27,39 @@ import java.util.stream.Collectors;
public class CtcRunPlanErrorMsgService {
/**
* 股道超限检查
* 创建计划时股道超限检查
*/
public RunPlanCheck transfiniteCheck = (simulation, stationCode, runPlanParam) -> {
CtcStationRunPlanLog.TransfiniteType transfinite = runPlanParam.getTransfinite();
if (CtcStationRunPlanLog.TransfiniteType.NO.equals(transfinite)) {
return;
}
/**
* 检验逻辑
*/
BiFunction<CtcStationRunPlanLog.TransfiniteType, TrackSection, Boolean> doCheck = (leveType, trackSection) -> {
if (trackSection == null) {
return false;
}
List<CtcStationRunPlanLog.TransfiniteType> typeList =
Arrays.stream(CtcStationRunPlanLog.TransfiniteType.values()).collect(Collectors.toList());
int runPlanIndex = typeList.indexOf(leveType);
int sectionIndex = typeList.indexOf(trackSection.getTransfinite());
return runPlanIndex > sectionIndex; // 运行等级 > 股道等级说明超限
arriveAndDepartSectionCheck(simulation, stationCode, runPlanParam, transfinite);
};
};
CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository();
// 发车是否存在
if (runPlanParam.departIsExist() && !StringUtils.isEmpty(runPlanParam.getDepartSectionCode())) {
TrackSection trackSection = effectRepository.queryTrackSection(stationCode, runPlanParam.getDepartSectionCode());
if (doCheck.apply(runPlanParam.getTransfinite(), trackSection)) {
BusinessExceptionAssertEnum.OPERATION_FAIL.exception(String.format("运行计划超限不符合【发车股道:%s】超限", runPlanParam.getDepartSectionCode()));
}
/**
* 在计划日志中股道超限检查
*/
public RunPlanCheck logTransfiniteCheck = (simulation, stationCode, runPlanParam) -> {
CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanParam.getRunPlanCode());
CtcStationRunPlanLog.TransfiniteType transfinite = runPlanLog.getTransfinite();
arriveAndDepartSectionCheck(simulation, stationCode, runPlanParam, transfinite);
};
/**
* 股道与计划不一致
*/
public RunPlanCheck sectionInconsistentCheck = (simulation, stationCode, runPlanParam) -> {
CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanParam.getRunPlanCode());
CtcRunPlanParam planParam = runPlanLog.getPlanParam();
// 接车股道
boolean isCheck = !StringUtils.isEmpty(planParam.getArriveSectionCode()) && !StringUtils.isEmpty(runPlanParam.getArriveSectionCode())
&& (!Objects.equals(runPlanParam.getArriveSectionCode(), planParam.getArriveSectionCode()));
if (isCheck) {
BusinessExceptionAssertEnum.OPERATION_FAIL.exception(String.format("接车股道与计划股道不一致【车次:%s】", runPlanLog.getTripNumber()));
}
// 接车是否存在
if (runPlanParam.arriveIsExist() && !StringUtils.isEmpty(runPlanParam.getArriveStationCode())) {
TrackSection trackSection = effectRepository.queryTrackSection(stationCode, runPlanParam.getArriveStationCode());
if (doCheck.apply(runPlanParam.getTransfinite(), trackSection)) {
BusinessExceptionAssertEnum.OPERATION_FAIL.exception(String.format("运行计划超限不符合【接车股道:%s】超限", runPlanParam.getArriveStationCode()));
}
// 发车股道
isCheck = !StringUtils.isEmpty(planParam.getDepartSectionCode()) && !StringUtils.isEmpty(runPlanParam.getDepartSectionCode())
&& (!Objects.equals(runPlanParam.getDepartSectionCode(), planParam.getDepartSectionCode()));
if (isCheck) {
BusinessExceptionAssertEnum.OPERATION_FAIL.exception(String.format("发车股道与计划股道不一致【车次:%s】", runPlanLog.getTripNumber()));
}
};
@ -81,19 +84,107 @@ public class CtcRunPlanErrorMsgService {
};
/**
* 发口连通检查
* 发口与计划不一致检查
*/
public RunPlanCheck directionCheck = (simulation, stationCode, runPlanParam) -> {
public RunPlanCheck directionInconsistentCheck = (simulation, stationCode, runPlanParam) -> {
CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanParam.getRunPlanCode());
CtcRunPlanParam planParam = runPlanLog.getPlanParam();
// 接车口
if (!StringUtils.isEmpty(runPlanParam.getArriveDirectionCode())) {
boolean isCheck = !StringUtils.isEmpty(planParam.getArriveDirectionCode()) && !StringUtils.isEmpty(runPlanParam.getArriveDirectionCode())
&& !Objects.equals(runPlanParam.getArriveDirectionCode(), planParam.getArriveDirectionCode());
if (isCheck) {
BusinessExceptionAssertEnum.OPERATION_FAIL.exception(String.format("接车口与计划不一致【车次:%s】", runPlanLog.getTripNumber()));
}
// 发车口
if (!StringUtils.isEmpty(runPlanParam.getDepartDirectionCode())) {
isCheck = !StringUtils.isEmpty(planParam.getDepartDirectionCode()) && !StringUtils.isEmpty(runPlanParam.getDepartDirectionCode())
&& !Objects.equals(runPlanParam.getDepartDirectionCode(), planParam.getDepartDirectionCode());
if (isCheck) {
BusinessExceptionAssertEnum.OPERATION_FAIL.exception(String.format("发车口与计划不一致【车次:%s】", runPlanLog.getTripNumber()));
}
};
/**
* 创建计划时道路连通检查
*/
public RunPlanCheck pathConnectedCheck = (simulation, stationCode, runPlanParam) -> {
// 到达连通检查
if (!StringUtils.isEmpty(runPlanParam.getArriveDirectionCode()) && !StringUtils.isEmpty(runPlanParam.getArriveSectionCode())) {
pathConnectedCheck(simulation, runPlanParam.getArriveDirectionCode(), runPlanParam.getArriveSectionCode(), true);
}
// 出发连通检查
if (!StringUtils.isEmpty(runPlanParam.getDepartDirectionCode()) && !StringUtils.isEmpty(runPlanParam.getDepartSectionCode())) {
pathConnectedCheck(simulation, runPlanParam.getDepartDirectionCode(), runPlanParam.getDepartSectionCode(), false);
}
};
/**
* 检验逻辑
*/
private BiFunction<CtcStationRunPlanLog.TransfiniteType, TrackSection, Boolean> doTransfiniteCheck = (leveType, trackSection) -> {
if (trackSection == null) {
return false;
}
List<CtcStationRunPlanLog.TransfiniteType> typeList =
Arrays.stream(CtcStationRunPlanLog.TransfiniteType.values()).collect(Collectors.toList());
int runPlanIndex = typeList.indexOf(leveType);
int sectionIndex = typeList.indexOf(trackSection.getTransfinite());
return runPlanIndex > sectionIndex; // 运行等级 > 股道等级说明超限
};
/**
* 接发股道超限检查
*
* @param simulation 仿真
* @param stationCode 车站
* @param runPlanParam 运行计划参数
* @param transfinite 超限等级
*/
private void arriveAndDepartSectionCheck(Simulation simulation, String stationCode, CtcRunPlanParam runPlanParam
, CtcStationRunPlanLog.TransfiniteType transfinite) {
if (CtcStationRunPlanLog.TransfiniteType.NO.equals(transfinite)) {
return;
}
CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository();
// 发车是否存在
if (runPlanParam.departIsExist() && !StringUtils.isEmpty(runPlanParam.getDepartSectionCode())) {
TrackSection trackSection = effectRepository.queryTrackSection(stationCode, runPlanParam.getDepartSectionCode());
if (doTransfiniteCheck.apply(transfinite, trackSection)) {
BusinessExceptionAssertEnum.OPERATION_FAIL.exception(String.format("运行计划超限不符合【发车股道:%s】超限"
, runPlanParam.getDepartSectionCode()));
}
}
// 接车是否存在
if (runPlanParam.arriveIsExist() && !StringUtils.isEmpty(runPlanParam.getArriveStationCode())) {
TrackSection trackSection = effectRepository.queryTrackSection(stationCode, runPlanParam.getArriveStationCode());
if (doTransfiniteCheck.apply(transfinite, trackSection)) {
BusinessExceptionAssertEnum.OPERATION_FAIL.exception(String.format("运行计划超限不符合【接车股道:%s】超限"
, runPlanParam.getArriveStationCode()));
}
}
}
/**
* 道路连通检查
*
* @param simulation 仿真
* @param directionCode 出入口
* @param sectionCode 停发车股道
*/
private void pathConnectedCheck(Simulation simulation, String directionCode, String sectionCode, boolean arrive) {
StationDirection stationDirection = simulation.getRepository().getByCode(directionCode, StationDirection.class);
Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
List<Route> routeList = arrive ? stationDirection.getReceiveRouteList() : stationDirection.getDeliverRouteList();
Signal signal = arrive ? section.getSignalToLeft() : section.getSignalToRight();
Signal routeSignal = null;
for (Route r : routeList) {
routeSignal = arrive ? r.getDestination() : r.getStart();
if (Objects.equals(routeSignal, signal)) {
return;
}
}
String strFormat = arrive ? "进路不连通【入口:%s,停车股道:%s】" : "进路不连通【出口:%s出发股道%s】";
BusinessExceptionAssertEnum.OPERATION_FAIL.exception(String.format(strFormat, stationDirection.getSignal().getShowName(), section.getName()));
}
@FunctionalInterface
public interface RunPlanCheck {

View File

@ -44,9 +44,18 @@ public class CtcStationRunPlanLogService {
*/
public void modifyBatchRunPlan(Simulation simulation, String stationCode, List<CtcRunPlanParam> planParamList, int force) {
if (force == 0) {
for (CtcRunPlanParam p : planParamList) {
planParamList.forEach(p -> {
// 进路接近检查
ctcRunPlanErrorMsgService.sectionRouteCheck.valid(simulation, stationCode, p);
}
// 股道超限检查
ctcRunPlanErrorMsgService.logTransfiniteCheck.valid(simulation, stationCode, p);
// 股道与计划不一致检查
ctcRunPlanErrorMsgService.sectionInconsistentCheck.valid(simulation, stationCode, p);
// 接发口不一致
ctcRunPlanErrorMsgService.directionInconsistentCheck.valid(simulation, stationCode, p);
// 连通性检查
});
}
List<CtcStationRunPlanLog> changeList = new LinkedList<>();
List<CtcStationRunPlanLog> createList = new LinkedList<>();
@ -244,7 +253,7 @@ public class CtcStationRunPlanLogService {
curRunPlanParam.setDepartSectionCode(sectionCode);
}
CtcRunPlanVO ctcRunPlanVO = CtcRunPlanVO.compareAndChange(curRunPlanParam, effectRunPlanParam);
ctcRunPlanVO.setCreateTime(simulation.getSystemTime());
ctcRunPlanVO.setCreateTime(simulation.getCorrectSystemTime());
simulation.getCtcRepository().saveApplyRunPlan(ctcRunPlanVO);
}
}

View File

@ -191,7 +191,7 @@ public class CtcZoneService {
CtcManageRepository.StationRunPlanRepository runPlanRepository
= zoneRepository.getStationRunPlanMap().get(station.getCode());
if (runPlanRepository != null) {
effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getSystemTime());
effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getCorrectSystemTime());
}
});
updateStageRunPlan(simulation, stationCodeSet);
@ -211,7 +211,7 @@ 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.getSystemTime());
effectRepository.releaseRunPlanByStationCode(runPlanRepository, simulation.getCorrectSystemTime());
updateStageRunPlan(simulation, stationCode);
return "success";
}
@ -226,7 +226,7 @@ public class CtcZoneService {
= simulation.getCtcRepository().getCtcZoneRepository().getStationRunPlanMap();
CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository();
stationRunPlanMap.forEach((k, v) -> {
effectRepository.releaseRunPlanByStationCode(v, simulation.getSystemTime());
effectRepository.releaseRunPlanByStationCode(v, simulation.getCorrectSystemTime());
updateStageRunPlan(simulation, k);
});
return "success";

View File

@ -1,6 +1,5 @@
package club.joylink.rtss.simulation.cbtc.CTC.service;
import club.joylink.rtss.exception.BaseException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
@ -125,7 +124,7 @@ public class CTCService {
CtcStationRunPlanLog previousStationPlan = getCtcStationRunPlanByRunPlanCode(simulation, previousStation.getCode(), runPlanCode);
currentStationPlan.finishReceivingNotice();
previousStationPlan.finishDepartureNotice();
String systemTime = simulation.getSystemTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:dd"));
String systemTime = simulation.getCorrectSystemTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:dd"));
currentStationPlan.getArriveRunPlan().setAdjacentMessageTime(systemTime);
previousStationPlan.getDepartRunPlan().setAdjacentMessageTime(systemTime);
}