diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsPlanTrainRouteSelectServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsPlanTrainRouteSelectServiceImpl.java index eb7ac4fa5..bc4c0055f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsPlanTrainRouteSelectServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsPlanTrainRouteSelectServiceImpl.java @@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import java.time.LocalDateTime; import java.time.LocalTime; import java.util.ArrayList; import java.util.List; @@ -32,22 +33,24 @@ public class AtsPlanTrainRouteSelectServiceImpl implements AtsRouteSelectService } SimulationDataRepository repository = simulation.getRepository(); TripPlan tripPlan = repository.getTripPlan(trainInfo.getServiceNumber(), trainInfo.getTripNumber()); + LocalDateTime systemTime = simulation.getSystemTime(); // 根据车次计划查找可触发进路列表 - Object[] results = this.queryByStationPlan(repository, trainInfo, tripPlan); + Object[] results = this.queryByStationPlan(repository, systemTime, trainInfo, tripPlan); // 根据计划筛选需触发进路 - Route route = filterRoutes(repository, trainInfo, tripPlan, results); + Route route = filterRoutes(repository, systemTime, trainInfo, tripPlan, results); return route; } /** * 先选取需要征用的进路,再根据计划判断是否存在冲突的未完成计划 * @param repository + * @param systemTime * @param trainInfo * @param tripPlan * @param results * @return */ - private Route filterRoutes(SimulationDataRepository repository, + private Route filterRoutes(SimulationDataRepository repository, LocalDateTime systemTime, TrainInfo trainInfo, TripPlan tripPlan, Object[] results) { if (results == null) { return null; @@ -64,11 +67,28 @@ public class AtsPlanTrainRouteSelectServiceImpl implements AtsRouteSelectService } log.debug(String.format("列车[%s]筛选出的进路为:[%s]", trainInfo.getGroupNumber(), route.getName())); boolean conflict = this.checkConflict(repository, trainInfo, tripPlan, route, turnBack); - if (conflict) { - route.setConflict(true); - } else { - route.setConflict(false); + if (route.isCheckConflict()) { + if (conflict) { + route.setConflict(true); + } else { + route.setConflict(false); + } } +// else { +// // 进路冲突,看计划时间 +// List planList = tripPlan.getPlanList(); +// LocalTime startTime = tripPlan.getStartTime(); +// for (StationPlan stationPlan : planList) { +// if (stationPlan.getSection().getCode().equals(trainInfo.getPlanStandTrack())) { +// break; +// } +// startTime = stationPlan.getLeaveTime(); +// } +// if (!systemTime.toLocalTime().plusSeconds(60).isAfter(startTime)) { +// log.debug(String.format("列车[%s]未到发车时间,不触发进路", trainInfo.getGroupNumber())); +// return null; +// } +// } return route; } @@ -252,7 +272,7 @@ public class AtsPlanTrainRouteSelectServiceImpl implements AtsRouteSelectService /** * @return (List)[0]: 可触发的进路;(Boolean)[1]:是否需要折返 */ - private Object[] queryByStationPlan(SimulationDataRepository repository, TrainInfo trainInfo, TripPlan tripPlan) { + private Object[] queryByStationPlan(SimulationDataRepository repository, LocalDateTime systemTime, TrainInfo trainInfo, TripPlan tripPlan) { Route route = null; Object[] result = new Object[3]; result[1] = false; @@ -262,6 +282,19 @@ public class AtsPlanTrainRouteSelectServiceImpl implements AtsRouteSelectService if (trainInfo.getPlanStandTrack() == null) { // 列车下一计划存在 return null; } + // 计划时间 + List planList = tripPlan.getPlanList(); + LocalTime startTime = tripPlan.getStartTime(); + for (StationPlan stationPlan : planList) { + if (stationPlan.getSection().getCode().equals(trainInfo.getPlanStandTrack())) { + break; + } + startTime = stationPlan.getLeaveTime(); + } + if (!systemTime.toLocalTime().plusSeconds(50).isAfter(startTime)) { + log.debug(String.format("列车[%s]未到发车时间,不触发进路", trainInfo.getGroupNumber())); + return null; + } Section planTrack = repository.getByCode(trainInfo.getPlanStandTrack(), Section.class);//下一计划 Section section = repository.getByCode(trainInfo.getPhysicalSection(), Section.class); // 列车所在区段 if (!planTrack.isSamePhysical(section.getCode())) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsTriggerRouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsTriggerRouteService.java index 4c655c449..a6c6e3cff 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsTriggerRouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsTriggerRouteService.java @@ -53,7 +53,7 @@ public class AtsTriggerRouteService { if (!route.isAtsControl()) { return; } - if (route.isConflict()) { + if (route.isConflict() && route.isCheckConflict()) { return; } this.ciApiService.settingRoute(simulation, route.getCode()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/command/VoiceCommandBO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/command/VoiceCommandBO.java index d6034b292..c7769fdb7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/command/VoiceCommandBO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/command/VoiceCommandBO.java @@ -261,7 +261,7 @@ public class VoiceCommandBO { return null; } List params = replyParamIndexes.stream().map(matcher::group).collect(Collectors.toList()); - String[] strings = params.toArray(new String[]{}); + Object[] strings = params.toArray(new Object[]{}); return String.format(reply, strings); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java index 52ef86037..6a7cd1583 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java @@ -995,7 +995,7 @@ public class SimulationDataRepository { if (route.isConflict()) { continue; } - if (route.getStart().equals(theRoute.getStart()) || route.isConflictWith(theRoute)) { + if (route.getStart().equals(theRoute.getStart())) { return true; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java index 3313e86f7..95e4dff3f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java @@ -130,7 +130,9 @@ public class Route extends MapNamedElement { /** 进路将要或上一次为哪辆列车排列 */ private TrainInfo train; - /** */ + /** 检查冲突功能是否开启 */ + private boolean checkConflict; + /** 是否冲突 */ private boolean conflict; @Override @@ -148,6 +150,7 @@ public class Route extends MapNamedElement { this.normalUnlock = false; this.unlockedSection = null; this.train = null; + this.checkConflict = false; this.conflict = false; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java index 104e210cd..af581c2a1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data.support; +import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement; import club.joylink.rtss.simulation.cbtc.data.map.Section;