修改设置计划车时,下一车站计划的筛选逻辑
This commit is contained in:
parent
57209785ad
commit
618c8dc33c
@ -11,7 +11,14 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.TrainType;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.DestinationCodeDefinition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Routing;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.SectionRunPath;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
|
||||
@ -24,16 +31,20 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService;
|
||||
import club.joylink.rtss.vo.client.operation.DriveParamVO;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* ATS列车服务
|
||||
*/
|
||||
@ -98,7 +109,8 @@ public class AtsTrainService {
|
||||
if (tripPlan != null) {
|
||||
//车次计划检查
|
||||
boolean tripRepeat = repository.getTrainInfoMap().values().stream()
|
||||
.anyMatch(info -> Objects.equals(info.getServiceNumber(), sn) && Objects.equals(info.getTripNumber(), tn));
|
||||
.anyMatch(info -> Objects.equals(info.getServiceNumber(), sn) && Objects.equals(
|
||||
info.getTripNumber(), tn));
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotTrue(tripRepeat, "车次计划已在运行");
|
||||
ti = new TrainInfo(groupNumber, TrainType.PLAN);
|
||||
ti.init(section, tripPlan, dn, cn);
|
||||
@ -152,14 +164,16 @@ public class AtsTrainService {
|
||||
}
|
||||
Section target = repository.getByCode(sectionCode, Section.class);
|
||||
if (!trainInfo.isCtcLevel()) {
|
||||
trainInfo.init(target, trainInfo.getDestinationCode(), trainInfo.getServiceNumber(), trainInfo.getTripNumber(), trainInfo.getCrewNumber());
|
||||
trainInfo.init(target, trainInfo.getDestinationCode(), trainInfo.getServiceNumber(),
|
||||
trainInfo.getTripNumber(), trainInfo.getCrewNumber());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置计划车
|
||||
*/
|
||||
public void setPlanTrain(Simulation simulation, String groupNumber, String serviceNumber, String tripNumber) {
|
||||
public void setPlanTrain(Simulation simulation, String groupNumber, String serviceNumber,
|
||||
String tripNumber) {
|
||||
Objects.requireNonNull(groupNumber);
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
TrainInfo supervisedTrain = repository.findSupervisedTrainByGroup(groupNumber);
|
||||
@ -174,21 +188,22 @@ public class AtsTrainService {
|
||||
setPlanTrain(simulation, repository, supervisedTrain, tripPlan);
|
||||
}
|
||||
|
||||
private void setPlanTrain(Simulation simulation, SimulationDataRepository repository, TrainInfo supervisedTrain, TripPlan tripPlan) {
|
||||
private void setPlanTrain(Simulation simulation, SimulationDataRepository repository,
|
||||
TrainInfo supervisedTrain, TripPlan tripPlan) {
|
||||
if (supervisedTrain.hasPositionAndDirection()) {
|
||||
Section phySection = repository.getByCode(supervisedTrain.getPhysicalSection(), Section.class);
|
||||
Section phySection = repository.getByCode(supervisedTrain.getPhysicalSection(),
|
||||
Section.class);
|
||||
StationPlan nextPlan = null;
|
||||
List<StationPlan> planList = tripPlan.getPlanList();
|
||||
for (int i = planList.size() - 1; i >= 0; i--) {
|
||||
StationPlan stationPlan = planList.get(i);
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(stationPlan.getSection(), phySection);
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(
|
||||
stationPlan.getSection(), phySection);
|
||||
if (!CollectionUtils.isEmpty(routePaths)) {
|
||||
nextPlan = stationPlan;
|
||||
if (routePaths.get(0).isRight() != tripPlan.isRight()) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
nextPlan = stationPlan;
|
||||
}
|
||||
}
|
||||
if (Objects.isNull(nextPlan)) {
|
||||
@ -201,7 +216,8 @@ public class AtsTrainService {
|
||||
}
|
||||
// 更新列车计划和下一站
|
||||
supervisedTrain.initPlan(tripPlan, nextPlan, repository.getConfig());
|
||||
this.onboardAtpApiService.updateTripPlan(simulation, supervisedTrain.getGroupNumber(), tripPlan);
|
||||
this.onboardAtpApiService.updateTripPlan(simulation, supervisedTrain.getGroupNumber(),
|
||||
tripPlan);
|
||||
atsPlanTrainStageService.updateNextPlan(simulation, supervisedTrain, tripPlan, nextPlan);
|
||||
// long runningTime = ChronoUnit.SECONDS.between(tripPlan.getStartTime(), nextPlan.getArriveTime());
|
||||
// this.onboardAtpApiService.updateNextStation(simulation, supervisedTrain.getGroupNumber(),
|
||||
@ -209,7 +225,8 @@ public class AtsTrainService {
|
||||
}
|
||||
}
|
||||
|
||||
public void setHeadTrain(Simulation simulation, String groupNumber, String serviceNumber, String tripNumber, String destinationCode) {
|
||||
public void setHeadTrain(Simulation simulation, String groupNumber, String serviceNumber,
|
||||
String tripNumber, String destinationCode) {
|
||||
Objects.requireNonNull(groupNumber);
|
||||
Objects.requireNonNull(destinationCode);
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
@ -231,24 +248,29 @@ public class AtsTrainService {
|
||||
default:
|
||||
throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("车次号不正确");
|
||||
}
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(tripRight, supervisedTrain.getRight(), "方向不正确");
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(tripRight,
|
||||
supervisedTrain.getRight(), "方向不正确");
|
||||
}
|
||||
setDestinationCode(simulation, groupNumber, serviceNumber, tripNumber, destinationCode, repository, supervisedTrain);
|
||||
setDestinationCode(simulation, groupNumber, serviceNumber, tripNumber, destinationCode,
|
||||
repository, supervisedTrain);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置目的地码
|
||||
*/
|
||||
private void setDestinationCode(Simulation simulation, String groupNumber, String serviceNumber, String tripNumber,
|
||||
private void setDestinationCode(Simulation simulation, String groupNumber, String serviceNumber,
|
||||
String tripNumber,
|
||||
String destinationCode, SimulationDataRepository repository, TrainInfo supervisedTrain) {
|
||||
Boolean right = supervisedTrain.getRight();
|
||||
Section headSection = repository.getByCode(supervisedTrain.getNotNullPhysicalSection(), Section.class);
|
||||
Section headSection = repository.getByCode(supervisedTrain.getNotNullPhysicalSection(),
|
||||
Section.class);
|
||||
Map<String, DestinationCodeDefinition> destinationMap = repository.getDestinationMap();
|
||||
|
||||
if (!CollectionUtils.isEmpty(destinationMap)) { //有新版目的地码数据
|
||||
DestinationCodeDefinition destinationCodeDefinition = destinationMap.get(destinationCode);
|
||||
if (destinationCodeDefinition == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("目的地码[%s]不存在", destinationCode));
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument,
|
||||
String.format("目的地码[%s]不存在", destinationCode));
|
||||
}
|
||||
Section destinationSection = destinationCodeDefinition.getSection();
|
||||
Section targetSection = null;
|
||||
@ -272,8 +294,10 @@ public class AtsTrainService {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument,
|
||||
String.format("列车[%s]方向未知", groupNumber));
|
||||
}
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(destinationCodeDefinition.containsSection(startSection, right),
|
||||
String.format("%s超出%s范围", String.format("列车[%s]", groupNumber), destinationCodeDefinition.logStr()));
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
||||
destinationCodeDefinition.containsSection(startSection, right),
|
||||
String.format("%s超出%s范围", String.format("列车[%s]", groupNumber),
|
||||
destinationCodeDefinition.logStr()));
|
||||
break;
|
||||
}
|
||||
case OTHER:
|
||||
@ -281,16 +305,19 @@ public class AtsTrainService {
|
||||
Section fromSection = headSection;
|
||||
List<Routing> routings = repository.queryRoutingByDestCode(destinationCode);
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(routings,
|
||||
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
||||
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber,
|
||||
destinationCode, destinationSection.getCode()));
|
||||
for (Routing routing : routings) {
|
||||
if (headSection.isTurnBackTrack()) { //是折返轨,不限制方向
|
||||
if (routing.containsSection(headSection)) {
|
||||
selectRouting = routing;
|
||||
}
|
||||
for (Section section : routing.getAllSections()) {
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(section, headSection);
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(
|
||||
section, headSection);
|
||||
if (!CollectionUtils.isEmpty(routePaths)) {
|
||||
if (routePaths.stream().anyMatch(routePath -> routePath.isRight() == routing.isRight())) {
|
||||
if (routePaths.stream()
|
||||
.anyMatch(routePath -> routePath.isRight() == routing.isRight())) {
|
||||
fromSection = section;
|
||||
selectRouting = routing;
|
||||
}
|
||||
@ -302,7 +329,8 @@ public class AtsTrainService {
|
||||
selectRouting = routing;
|
||||
} else {
|
||||
for (Section section : routing.getAllSections()) {
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(section, headSection);
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(
|
||||
section, headSection);
|
||||
if (routePaths.stream().anyMatch(routePath -> routePath.isRight() == right)) {
|
||||
fromSection = section;
|
||||
selectRouting = routing;
|
||||
@ -322,9 +350,11 @@ public class AtsTrainService {
|
||||
}
|
||||
supervisedTrain.setHctPath(new SectionRunPath(sections, selectRouting.isRight()));
|
||||
} else {
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(destinationSection, headSection);
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(
|
||||
destinationSection, headSection);
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(routePaths,
|
||||
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
||||
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber,
|
||||
destinationCode, destinationSection.getCode()));
|
||||
RoutePath routePath = routePaths.stream()
|
||||
.min(Comparator.comparingDouble(RoutePath::getReverseSwitchQuantity))
|
||||
.get();
|
||||
@ -335,7 +365,8 @@ public class AtsTrainService {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault, String.format("无法识别的目的地码类型[%s]", destinationCodeDefinition.getType()));
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault,
|
||||
String.format("无法识别的目的地码类型[%s]", destinationCodeDefinition.getType()));
|
||||
}
|
||||
//默认
|
||||
} else { //没有新版目的地码数据
|
||||
@ -353,7 +384,8 @@ public class AtsTrainService {
|
||||
}
|
||||
supervisedTrain.change2HeadCode(destinationCode, serviceNumber, tripNumber);
|
||||
atsHeadTrainStageService.updatePlanSection(simulation, supervisedTrain);
|
||||
this.onboardAtpApiService.update2HeadTrainServiceNumber(simulation, groupNumber, serviceNumber, tripNumber, destinationCode, needParking);
|
||||
this.onboardAtpApiService.update2HeadTrainServiceNumber(simulation, groupNumber, serviceNumber,
|
||||
tripNumber, destinationCode, needParking);
|
||||
supervisedTrain.updateEstimatedArriveInfo(null, null);
|
||||
}
|
||||
|
||||
@ -399,9 +431,11 @@ public class AtsTrainService {
|
||||
*/
|
||||
public void changeTripNumber(Simulation simulation, String groupNumber, String serviceNumber) {
|
||||
TrainInfo trainInfo = simulation.getRepository().getSupervisedTrainByGroup(groupNumber);
|
||||
TripPlan tripPlan = simulation.getRepository().findTripPlan(serviceNumber, trainInfo.getTripNumber());
|
||||
TripPlan tripPlan = simulation.getRepository()
|
||||
.findTripPlan(serviceNumber, trainInfo.getTripNumber());
|
||||
if (tripPlan == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("[%s : %s]车次计划未找到", serviceNumber, trainInfo.getTripNumber()));
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument,
|
||||
String.format("[%s : %s]车次计划未找到", serviceNumber, trainInfo.getTripNumber()));
|
||||
}
|
||||
onboardAtpApiService.updateTripPlan(simulation, groupNumber, tripPlan);
|
||||
trainInfo.applyNewTripPlan(tripPlan);
|
||||
@ -434,17 +468,21 @@ public class AtsTrainService {
|
||||
}
|
||||
Section section = (Section) element;
|
||||
Section targetSection = section.getNextRunningSectionOf(right);
|
||||
SectionPosition trainTargetPosition = new SectionPosition(targetSection, targetSection.getStopPointByDirection(right));
|
||||
Float distance = CalculateService.calculateDistance(train.getHeadPosition(), trainTargetPosition, right, false);
|
||||
SectionPosition trainTargetPosition = new SectionPosition(targetSection,
|
||||
targetSection.getStopPointByDirection(right));
|
||||
Float distance = CalculateService.calculateDistance(train.getHeadPosition(),
|
||||
trainTargetPosition, right, false);
|
||||
if (distance == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "无法到达的位置");
|
||||
}
|
||||
tempTargetPosition = new SectionPosition(section, section.getStopPointByDirection(right));
|
||||
} else {
|
||||
VirtualRealityTrain targetTrain = repository.getVRByCode(targetDeviceCode, VirtualRealityTrain.class);
|
||||
VirtualRealityTrain targetTrain = repository.getVRByCode(targetDeviceCode,
|
||||
VirtualRealityTrain.class);
|
||||
SectionPosition targetTrainTailPosition = targetTrain.calculateTailPosition();
|
||||
boolean targetIsRight = targetTrain.isRight();
|
||||
tempTargetPosition = CalculateService.calculateNextPositionByStartAndLen(targetTrainTailPosition, !targetIsRight, 2, false);
|
||||
tempTargetPosition = CalculateService.calculateNextPositionByStartAndLen(
|
||||
targetTrainTailPosition, !targetIsRight, 2, false);
|
||||
}
|
||||
targetPosition = tempTargetPosition.convert2PhysicalSectionPosition();
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotNull(targetPosition, "无法抵达所选位置");
|
||||
@ -458,7 +496,8 @@ public class AtsTrainService {
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
b = vrSignal != null && vrSignal.getModel().getDefaultAspect().equals(vrSignal.getAspect());
|
||||
}
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且为禁止信号");
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b,
|
||||
"需要车头所在区段前方有同向信号机,且为禁止信号");
|
||||
param.setThroughSignal(signal);
|
||||
param.setThroughSignalAspect(signal.getDefaultAspect());
|
||||
} else if (param.isThroughGuideSignal()) { // 越引导行驶
|
||||
@ -468,19 +507,23 @@ public class AtsTrainService {
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
b = vrSignal != null && vrSignal.getModel().getGuideAspect().equals(vrSignal.getAspect());
|
||||
}
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且为引导信号");
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b,
|
||||
"需要车头所在区段前方有同向信号机,且为引导信号");
|
||||
param.setThroughSignal(signal);
|
||||
param.setThroughSignalAspect(signal.getGuideAspect());
|
||||
} else if (param.isDriverNextStand()){ // 行驶至前方车站
|
||||
} else if (param.isDriverNextStand()) { // 行驶至前方车站
|
||||
// 停车目的区段
|
||||
if (section.isStandTrack()) {
|
||||
targetPosition = new SectionPosition(section, section.getStopPointByDirection(train.isRight()));
|
||||
targetPosition = new SectionPosition(section,
|
||||
section.getStopPointByDirection(train.isRight()));
|
||||
} else {
|
||||
targetPosition = train.calculateNextStandStopPosition();
|
||||
if (targetPosition == null && train.getTarget() != null) {
|
||||
targetPosition = new SectionPosition(train.getTarget(), train.getTarget().getStopPointByDirection(train.isRight()));
|
||||
targetPosition = new SectionPosition(train.getTarget(),
|
||||
train.getTarget().getStopPointByDirection(train.isRight()));
|
||||
}
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(targetPosition, train.debugStr() + "找不到下一个停车点");
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(targetPosition,
|
||||
train.debugStr() + "找不到下一个停车点");
|
||||
param.setThroughSignal(section.getSignalOf(right));
|
||||
}
|
||||
} else {
|
||||
@ -495,7 +538,8 @@ public class AtsTrainService {
|
||||
float offset = targetSection.getStopPointByDirection(train.isRight());
|
||||
SectionPosition linkTargetSectionPosition = new SectionPosition(targetSection, offset);
|
||||
linkParamVO.setTargetPosition(linkTargetSectionPosition);
|
||||
Float distance = CalculateService.calculateDistance(headPosition, linkTrain.calculateTailPosition(), right, false);
|
||||
Float distance = CalculateService.calculateDistance(headPosition,
|
||||
linkTrain.calculateTailPosition(), right, false);
|
||||
float len = linkTrain.getLen() + (distance == null ? 0 : distance);
|
||||
targetPosition = new SectionPosition(targetSection, offset + (len * (right ? -1 : 1)));
|
||||
}
|
||||
@ -514,13 +558,16 @@ public class AtsTrainService {
|
||||
VirtualRealityTrain activeTrain = repository.getOnlineTrainBy(groupNumber);
|
||||
VirtualRealityTrain passiveTrain = repository.getOnlineTrainBy(groupNumber2);
|
||||
if (activeTrain.isRight() != passiveTrain.isRight()) {
|
||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation, String.format("列车[%s][%s]方向不同", groupNumber, groupNumber2));
|
||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation,
|
||||
String.format("列车[%s][%s]方向不同", groupNumber, groupNumber2));
|
||||
}
|
||||
SectionPosition headPosition = activeTrain.getHeadPosition();
|
||||
SectionPosition tailPosition = passiveTrain.calculateTailPosition();
|
||||
Float distance = CalculateService.calculateDistance(headPosition, tailPosition, activeTrain.isRight(), false);
|
||||
Float distance = CalculateService.calculateDistance(headPosition, tailPosition,
|
||||
activeTrain.isRight(), false);
|
||||
if (distance == null || distance > 3) {
|
||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation, String.format("列车[%s][%s]距离过远", groupNumber, groupNumber2));
|
||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation,
|
||||
String.format("列车[%s][%s]距离过远", groupNumber, groupNumber2));
|
||||
}
|
||||
activeTrain.setLinkTrain(passiveTrain);
|
||||
}
|
||||
@ -529,7 +576,8 @@ public class AtsTrainService {
|
||||
* 排列进路到(站台/信号机)
|
||||
*/
|
||||
public void setRouteTo(Simulation simulation, String groupNumber, List<String> routeCodes) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeCodes, "所选进路不能为空");
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeCodes,
|
||||
"所选进路不能为空");
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
TrainInfo trainInfo = repository.getSupervisedTrainByGroup(groupNumber);
|
||||
routeCodes.forEach(code -> {
|
||||
@ -542,7 +590,8 @@ public class AtsTrainService {
|
||||
/**
|
||||
* 设置列车运行类型
|
||||
*/
|
||||
public void setRunType(Simulation simulation, String groupNumber, VirtualRealityTrain.RunType runType) {
|
||||
public void setRunType(Simulation simulation, String groupNumber,
|
||||
VirtualRealityTrain.RunType runType) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
train.setRunType(runType);
|
||||
}
|
||||
@ -600,9 +649,11 @@ public class AtsTrainService {
|
||||
/**
|
||||
* 列车跳停
|
||||
*/
|
||||
public void skipStop(Simulation simulation, String groupNumber, String destinationCode, List<String> standCodes) {
|
||||
public void skipStop(Simulation simulation, String groupNumber, String destinationCode,
|
||||
List<String> standCodes) {
|
||||
// TODO: 2021/4/6 目前计划车没有运行线,所以运行线的跳停在计划车上不生效。并且<查询列车经过的站台>接口,计划车的站台是根据车次计划而不是运行线筛选的。
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(standCodes, "所选站台列表不能为空");
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(standCodes,
|
||||
"所选站台列表不能为空");
|
||||
//2021-04-09 16:26:21 为了简化逻辑,对运行线的跳停先改为对站台设置所有列车跳停。所以可以直接调用站台的跳停方法
|
||||
standCodes.forEach(code -> atsStandService.setJumpStop(simulation, code, groupNumber));
|
||||
|
||||
@ -626,10 +677,13 @@ public class AtsTrainService {
|
||||
|
||||
public void distribute(Simulation simulation, String groupNumber, String serviceNumber) {
|
||||
// TODO: 2021/4/7 如果给某列车分配一个已经有列车在跑的班次,该列车在停车点会分配上班次,该班次原来那辆车会被分配一条和班次相关的运行线。(就类似脱离班次操作)
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(simulation.getRepository().isVrTrainOnline(groupNumber));
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
||||
simulation.getRepository().isVrTrainOnline(groupNumber));
|
||||
LocalTime now = LocalTime.now();
|
||||
Optional<TripPlan> tripPlanOptional = simulation.getRepository().getTripPlanList(serviceNumber).stream()
|
||||
.filter(tripPlan -> tripPlan.getStartTime().isBefore(now) && tripPlan.getEndTime().isAfter(now))
|
||||
Optional<TripPlan> tripPlanOptional = simulation.getRepository().getTripPlanList(serviceNumber)
|
||||
.stream()
|
||||
.filter(
|
||||
tripPlan -> tripPlan.getStartTime().isBefore(now) && tripPlan.getEndTime().isAfter(now))
|
||||
.findAny();
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(tripPlanOptional.isPresent(),
|
||||
String.format("当前时间不能分配该服务号[%s]", serviceNumber));
|
||||
@ -642,7 +696,8 @@ public class AtsTrainService {
|
||||
public void cancelCBTCRoute(Simulation simulation, List<String> routeCodes) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
Map<String, Route> settingRouteMap = repository.getSettingRouteMap();
|
||||
List<Route> collect = routeCodes.stream().map(settingRouteMap::get).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
List<Route> collect = routeCodes.stream().map(settingRouteMap::get).filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(collect)) {
|
||||
TrainInfo trainInfo = collect.get(0).getTrain();
|
||||
if (trainInfo != null) {
|
||||
@ -657,8 +712,10 @@ public class AtsTrainService {
|
||||
/**
|
||||
* 取消跳停【泰雷兹】
|
||||
*/
|
||||
public void cancelSkipStop(Simulation simulation, String groupNumber, String destinationCode, List<String> standCodes) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(standCodes, "所选站台列表不能为空");
|
||||
public void cancelSkipStop(Simulation simulation, String groupNumber, String destinationCode,
|
||||
List<String> standCodes) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(standCodes,
|
||||
"所选站台列表不能为空");
|
||||
standCodes.forEach(code -> atsStandService.cancelJumpStop(simulation, code, groupNumber));
|
||||
}
|
||||
|
||||
@ -667,7 +724,8 @@ public class AtsTrainService {
|
||||
trainInfo.setAtsAutoTrigger(autoTrigger);
|
||||
}
|
||||
|
||||
public void regulation(Simulation simulation, String groupNumber, BusinessConsts.Regulation regulation, RegulationParam regulationParam) {
|
||||
public void regulation(Simulation simulation, String groupNumber,
|
||||
BusinessConsts.Regulation regulation, RegulationParam regulationParam) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
switch (regulation) {
|
||||
case TIME_TABLE_REGULATION:
|
||||
@ -693,7 +751,8 @@ public class AtsTrainService {
|
||||
repository.setIntervalTime(null);
|
||||
}
|
||||
|
||||
public IntervalCalculateResult calculateInterval(Simulation simulation, Integer trainNumber, Integer interval) {
|
||||
public IntervalCalculateResult calculateInterval(Simulation simulation, Integer trainNumber,
|
||||
Integer interval) {
|
||||
IntervalCalculateResult result = new IntervalCalculateResult();
|
||||
if (trainNumber != null) {
|
||||
result.setTrainNumber(trainNumber);
|
||||
|
Loading…
Reference in New Issue
Block a user