CTC进路防错办
This commit is contained in:
parent
ba33bc6449
commit
92135e2717
@ -16,6 +16,7 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@ -285,10 +286,15 @@ public class CtcRepository {
|
|||||||
return routeSequence.getLine(tripNumber, departure);
|
return routeSequence.getLine(tripNumber, departure);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteSequence.Line getRouteSequenceLine(String stationCode, String tripNumber, String routeCode) {
|
public RouteSequence.Line findRouteSequenceLine(String stationCode, String tripNumber, String routeCode) {
|
||||||
RouteSequence routeSequence = routeSequenceMap.get(stationCode);
|
RouteSequence routeSequence = routeSequenceMap.get(stationCode);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(routeSequence);
|
return routeSequence.findLine(tripNumber, routeCode);
|
||||||
return routeSequence.getLine(tripNumber, routeCode);
|
}
|
||||||
|
|
||||||
|
public RouteSequence.Line getRouteSequenceLine(String stationCode, String tripNumber, String routeCode) {
|
||||||
|
RouteSequence.Line line = findRouteSequenceLine(stationCode, tripNumber, routeCode);
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(line);
|
||||||
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addDispatchCommand(RailDispatchCommand command) {
|
public synchronized void addDispatchCommand(RailDispatchCommand command) {
|
||||||
@ -337,4 +343,24 @@ public class CtcRepository {
|
|||||||
}
|
}
|
||||||
return tickets;
|
return tickets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询计划早于这个时间的进路序列
|
||||||
|
*/
|
||||||
|
public List<RouteSequence.Line> findRouteSequenceLineThatLessThan(String stationCode, LocalTime planTime) {
|
||||||
|
RouteSequence routeSequence = routeSequenceMap.get(stationCode);
|
||||||
|
if (routeSequence == null)
|
||||||
|
return new ArrayList<>();
|
||||||
|
return routeSequence.getLines().stream()
|
||||||
|
.filter(line -> line.getPlanTime().isBefore(planTime))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public RouteSequence getRouteSequence(String stationCode) {
|
||||||
|
return routeSequenceMap.get(stationCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrackView getTrackView(String stationCode) {
|
||||||
|
return trackViewMap.get(stationCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,16 @@ public class RouteSequence {
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Line findLine(String tripNumber, String routeCode) {
|
||||||
|
List<Line> lines = tripLineMap.get(tripNumber);
|
||||||
|
if (CollectionUtils.isEmpty(lines))
|
||||||
|
return null;
|
||||||
|
return lines.stream().filter(line -> Objects.equals(routeCode, line.getRoute().getCode()))
|
||||||
|
.findAny().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取进路序列中的一行(进路应该对每个车次只会办一次
|
* 获取进路序列中的一行
|
||||||
*/
|
*/
|
||||||
public Line getLine(String tripNumber, String routeCode) {
|
public Line getLine(String tripNumber, String routeCode) {
|
||||||
List<Line> lines = tripLineMap.get(tripNumber);
|
List<Line> lines = tripLineMap.get(tripNumber);
|
||||||
|
@ -104,8 +104,8 @@ public class RailCtcOperateHandler {
|
|||||||
* @param duration 办理调车进路时可以输入时间
|
* @param duration 办理调车进路时可以输入时间
|
||||||
*/
|
*/
|
||||||
@OperateHandlerMapping(type = Operation.Type.CTC_SET_ROUTE)
|
@OperateHandlerMapping(type = Operation.Type.CTC_SET_ROUTE)
|
||||||
public void setRoute(Simulation simulation, String routeCode, String tripNumber, Boolean force, Integer duration) {
|
public List<String> setRoute(Simulation simulation, String routeCode, String tripNumber, Boolean force, Integer duration) {
|
||||||
ctcService.setRoute(simulation, routeCode, tripNumber, force, duration);
|
return ctcService.setRoute(simulation, routeCode, tripNumber, force, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.CTC.service;
|
package club.joylink.rtss.simulation.cbtc.CTC.service;
|
||||||
|
|
||||||
|
import club.joylink.rtss.exception.BaseException;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
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.RouteSequence;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.data.TrackView;
|
||||||
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.*;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
|
||||||
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.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class CTCService {
|
public class CTCService {
|
||||||
@ -132,14 +139,59 @@ public class CTCService {
|
|||||||
line.setAutoTrigger(trigger);
|
line.setAutoTrigger(trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String setRoute(Simulation simulation, String routeCode, String tripNumber, Boolean force, Integer duration) {
|
public List<String> setRoute(Simulation simulation, String routeCode, String tripNumber, Boolean force, Integer duration) {
|
||||||
// if (StringUtils.hasText(tripNumber) && !Objects.equals(true, force)) {
|
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
||||||
// // CTC卡控功能
|
Station station = route.getStart().getStation();
|
||||||
// }
|
if (station == null)
|
||||||
|
station = route.getStart().getDeviceStation();
|
||||||
|
|
||||||
|
List<String> conflictInfo = new ArrayList<>();
|
||||||
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
|
if (StringUtils.hasText(tripNumber) && !Objects.equals(true, force)) { //列车进路防错办
|
||||||
|
RouteSequence.Line line = ctcRepository.findRouteSequenceLine(station.getCode(), tripNumber, routeCode);
|
||||||
|
if (line == null)
|
||||||
|
conflictInfo.add(String.format("车次[%s]的进路序列中不包含[name:%s]进路", tripNumber, route.getName()));
|
||||||
|
}
|
||||||
|
if (duration != null && !Objects.equals(true, force)) { //调车进路防错办
|
||||||
|
Set<Section> sections = new HashSet<>(route.getSectionList());
|
||||||
|
Map<Switch, SwitchElement> switchMap = new HashMap<>();
|
||||||
|
List<SwitchElement> switchList = route.getSwitchList();
|
||||||
|
if (!CollectionUtils.isEmpty(switchList)) {
|
||||||
|
switchMap = switchList.stream().collect(Collectors.toMap(SwitchElement::getASwitch, Function.identity()));
|
||||||
|
}
|
||||||
|
LocalTime endTime = simulation.getCorrectSystemTime().plusSeconds(duration).toLocalTime();
|
||||||
|
List<RouteSequence.Line> lines = ctcRepository.findRouteSequenceLineThatLessThan(station.getCode(), endTime);
|
||||||
|
out:
|
||||||
|
for (RouteSequence.Line line : lines) {
|
||||||
|
Route lineRoute = line.getRoute();
|
||||||
|
if (lineRoute == null)
|
||||||
|
continue;
|
||||||
|
for (Section section : lineRoute.getSectionList()) {
|
||||||
|
if (sections.contains(section)) {
|
||||||
|
conflictInfo.add(String.format("所选进路[name:%s]与车次[%s]的[name:%s]进路冲突",
|
||||||
|
route.getName(), line.getTripNumber(), lineRoute.getName()));
|
||||||
|
continue out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<SwitchElement> sl = lineRoute.getSwitchList();
|
||||||
|
if (!CollectionUtils.isEmpty(sl)) {
|
||||||
|
for (SwitchElement element : sl) {
|
||||||
|
SwitchElement e = switchMap.get(element.getASwitch());
|
||||||
|
if (e != null && !element.equals(e)) {
|
||||||
|
conflictInfo.add(String.format("所选进路[name:%s]与车次[%s]的[name:%s]进路冲突",
|
||||||
|
route.getName(), line.getTripNumber(), lineRoute.getName()));
|
||||||
|
continue out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!conflictInfo.isEmpty())
|
||||||
|
return conflictInfo;
|
||||||
|
|
||||||
Route.CheckFailMessage checkFailMessage = ciApiService.settingRoute(simulation, routeCode);
|
Route.CheckFailMessage checkFailMessage = ciApiService.settingRoute(simulation, routeCode);
|
||||||
if (checkFailMessage != null)
|
if (checkFailMessage != null)
|
||||||
throw BusinessExceptionAssertEnum.OPERATION_FAIL.exception(checkFailMessage.debugStr());
|
throw BusinessExceptionAssertEnum.OPERATION_FAIL.exception(checkFailMessage.debugStr());
|
||||||
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
route.setTripNumber(tripNumber);
|
route.setTripNumber(tripNumber);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user