diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 52c1a32f3..2ae56ecfe 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -453,6 +453,12 @@ public class RunPlanDraftService implements IRunPlanDraftService { List arriveConfigList = tripConfigVO.getArriveConfigList(); arriveConfigList.stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO)); + if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getLast().getSectionCode())) { + tripVO.setEndTime(tripConfigVO.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME)); + } + if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getFirst().getSectionCode())) { + tripVO.setStartTime(tripConfigVO.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME)); + } newTripList.add(tripVO); } } else { @@ -753,6 +759,9 @@ public class RunPlanDraftService implements IRunPlanDraftService { if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getLast().getSectionCode())) { tripVO.setEndTime(tripConfig.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME)); } + if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getFirst().getSectionCode())) { + tripVO.setStartTime(tripConfig.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME)); + } if (CollectionUtils.isEmpty(runPlanVO.getTripList())) { runPlanVO.setTripList(new ArrayList<>()); diff --git a/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java b/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java index 30d93d99b..b2769e56c 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java @@ -429,7 +429,7 @@ public class RunPlanGenerator { } } - private void setTripTerminalTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList, int reentryTime) { + public void setTripTerminalTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList, int reentryTime) { setTripStartTime(runPlanTripVO, tripTimeList, reentryTime); setTripEndTime(runPlanTripVO, tripTimeList, reentryTime); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java b/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java index 8e33ee40a..92828cd08 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java @@ -12,6 +12,7 @@ import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; +import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapVO; import club.joylink.rtss.vo.client.map.newmap.MapRunLevelQueryVO; @@ -82,7 +83,17 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService { list.forEach(l -> { Section startSection = (Section) deviceMap.get(l.getStartSectionCode()); Section endSection = (Section) deviceMap.get(l.getEndSectionCode()); - Float distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); + Float distance; + if((startSection.isStandTrack() && endSection.isTransferTrack()) || (endSection.isStandTrack() && startSection.isTransferTrack())){ + try{ + distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); + }catch (SimulationException e){ + distance = CalculateService.calculateDistance(startSection, endSection, !l.getRight()); + } + }else{ + + distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); + } RunPlanRunlevel entity = new RunPlanRunlevel(); entity.setId(l.getId()); entity.setMapId(l.getMapId()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java index 3eaaa928d..592fba715 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java @@ -157,6 +157,10 @@ public class AtsPlanService { hold = this.atsStandService.isHoldTrain(target); } // 更新跳停状态 + if (jump && Objects.equals(tripPlan.getLastStationPlan().getStation(), target.getStation())) { + // 最后一站,不跳停 + jump = false; + } if (!Objects.equals(train.isJump(), jump)) { if (jump) { this.onboardAtpApiService.setJump(simulation, train.getGroupNumber()); @@ -365,7 +369,8 @@ public class AtsPlanService { } LocalTime arriveTime = systemTime.plusSeconds(intervalRunTime); train.updateEstimatedArriveInfo(nextStationPlan.getSection(), arriveTime); - if (this.atsStandService.isJump(nextStationPlan.getSection(), train.getGroupNumber())) { + if (!tripPlan.isLastPlan(nextStationPlan) && + this.atsStandService.isJump(nextStationPlan.getSection(), train.getGroupNumber())) { this.onboardAtpApiService.setJump(simulation, train.getGroupNumber()); } } else { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java index 32a03e1c7..1153f056d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java @@ -205,10 +205,15 @@ public class AtsTrainLoadService { RoutePath routePath = this.selectDefaultRoutePath(repository, stationPlan.getSection(), nextStationPlan.getSection()); right = routePath.isRight(); int t = current.toSecondOfDay() - stationPlan.getLeaveTime().toSecondOfDay(); - float s = routePath.getLength(); + float s = routePath.getLenFromSection(stationPlan.getSection()); + //右:-最后区段+后右停车点 + 前区段-前右停车点 左:-左停车点+前左停车点 + s= right? + s-nextStationPlan.getSection().getLen()+nextStationPlan.getSection().getStopPointByDirection(right)+stationPlan.getSection().getLen()-stationPlan.getSection().getStopPointByDirection(right) + : + s-nextStationPlan.getSection().getStopPointByDirection(right)+stationPlan.getSection().getStopPointByDirection(right); int totalTime = nextStationPlan.getArriveTime().toSecondOfDay() - stationPlan.getLeaveTime().toSecondOfDay(); float moveDistance = s / totalTime * t; // 移动的距离 - headPosition = routePath.getSectionPositionOfLen(moveDistance); + headPosition = routePath.getSectionPositionOfLen(moveDistance,stationPlan.getSection()); SectionPosition nextTargetPosition = new SectionPosition(nextStationPlan.getSection(), nextStationPlan.getSection().getStopPointByDirection(right)); if (headPosition.isAheadOf(nextTargetPosition, right)) { @@ -426,6 +431,8 @@ public class AtsTrainLoadService { trainInfo.updateEstimatedArriveInfo(endStationPlan.getSection(), endStationPlan.getArriveTime()); train.updateNextStationPlan(endStationPlan.getStation(), endStationPlan.getSection(), tripPlan.isPlanParking(endStationPlan)); break; + } else if (passedSectionStopPoint(headPosition, endStationPlan.getSection(), right)) { + continue; } else { RoutePath routePath = this.selectDefaultRoutePath(repository, startStationPlan.getSection(), endStationPlan.getSection()); if (routePath.containsSection(headPosition.getSection())) { @@ -454,6 +461,16 @@ public class AtsTrainLoadService { return false; } + + private boolean passedSectionStopPoint(SectionPosition headPosition, Section funSection, boolean right) { + float d = headPosition.getOffset() - funSection.getStopPointByDirection(right); + if (Objects.equals(headPosition.getSection(), funSection) + && d > SimulationConstants.PARK_POINT_MAX_OFFSET) { + return true; + } + return false; + } + /** * 处理碰撞逻辑 * @param simulation diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java index d24dd8e44..8b5a45526 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java @@ -358,6 +358,7 @@ public class RouteService { if (simulation.getSystemTime().isAfter(route.getSettingStartTime().plusSeconds(10))) { route.settingFailed(); simulation.getRepository().removeSettingRoute(route); + route.setLock(false); log.info(String.format("进路[%s]办理失败,取消办理2", route.debugStr())); return; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java index dadf8ba98..c78eb813a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java @@ -110,36 +110,79 @@ public class RoutePath { this.end.getStation().getName(), this.end.getName()); } - public SectionPosition getSectionPositionOfLen(float runLen) { + public float getLenFromSection(Section fromSection){ + List
list = new ArrayList<>(); + if(sectionList.contains(fromSection)){ + int i = sectionList.indexOf(fromSection); + list.addAll(sectionList.subList(i,sectionList.size())); + }else{ + list.add(start); + list.addAll(this.sectionList); + } + float len = 0; + for (Section section : list) { + if(Objects.equals(section,fromSection)){ + continue; + } + len += section.getLen(); + } + return len; + } + public SectionPosition getSectionPositionOfLen(float runLen,Section fromSection) { float remain = runLen; Section target = null; Float offset = null; - if (remain < this.length) { +// if (remain < this.length) { List
list = new ArrayList<>(); + if(sectionList.contains(fromSection)){ + int i = sectionList.indexOf(fromSection); + list.addAll(sectionList.subList(i,sectionList.size())); + }else{ + list.add(start); list.addAll(this.sectionList); + } + float len = 0; + for (Section section : list) { + len += section.getLen(); + } + float addLen; for (Section section : list) { - float addLen = section.getLen(); + if (start == section) { + addLen = right ? section.getLen() - section.getStopPointByDirection(right) : section.getStopPointByDirection(right); + if (runLen < addLen) { + target = section; + offset = right ? section.getStopPointByDirection(right) + remain : section.getStopPointByDirection(right) - remain; + break; + } + } +// else if (this.end == section) { +// addLen = right?section.getStopPointByDirection(right):section.getLen() - section.getStopPointByDirection(right); +// } + else { + addLen = section.getLen(); + } + if (remain < addLen) { // 在此区段上 target = section; - if (Objects.equals(this.start, section)) { - if (this.right) { - offset = section.getLen() - (addLen - remain); - } else { - offset = (addLen - remain); - } - } else { +// if (Objects.equals(this.start, section)) { +// if (this.right) { +// offset = section.getLen() - (addLen - remain); +// } else { +// offset = (addLen - remain); +// } +// } else { if (this.right) { offset = remain; } else { - offset = section.getLen() - remain; + offset = addLen - remain; } - } +// } break; } else { remain -= addLen; } } - } +// } if (Objects.isNull(target) || Objects.isNull(offset)) { throw new SimulationException(SimulationExceptionType.System_Fault, String.format("路径[%s]的总距离[%s],未找到距离[%s]对应的区段位置", diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java index 2fedd158d..79ec60070 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java @@ -164,7 +164,7 @@ public class ATOService { SectionPosition targetStopPoint = new SectionPosition(target, target.getStopPointByDirection(right)); Float targetDistance = CalculateService.calculateDistance(headPosition, targetStopPoint, right); - if (Objects.nonNull(targetDistance) && targetDistance < distance) { + if (Objects.nonNull(targetDistance)&& targetDistance >= 0 && targetDistance < distance) { return targetDistance; } } else { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowSimulateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowSimulateService.java index ef8a4647f..c34633a1a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowSimulateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowSimulateService.java @@ -296,7 +296,6 @@ public class PassengerFlowSimulateService { StandTimePassengerFlowData flowData = standTimePassengerFlowDataMap.get(stand.getCode()); StandTimePassengerFlowData preData = preTimePassengerFlowDataMap.get(stand.getCode()); int add = flowData.getNum() - preData.getNum(); - log.debug(String.format("站台[%s]增加乘客: %s", stand.debugStr(), add)); if (add < 0) { // 列车拉走了站台上的人 if (flowData.getNum() != 0 && preData.getNum() > 1000) { @@ -305,6 +304,7 @@ public class PassengerFlowSimulateService { add = flowData.getNum(); } } + log.debug(String.format("站台[%s]增加乘客: %s", stand.debugStr(), add)); int total = standPassengerFlow.plus(add); sendData.put("standCode", stand.getCode()); sendData.put("num", total); @@ -392,7 +392,7 @@ public class PassengerFlowSimulateService { // 如果没有数据,默认下车5%的人 down = (int) (trainPassengerFlow.getPassengerQuantity() * 0.05); } - trainPassengerFlow.minus(down); + down = trainPassengerFlow.minus(down); } sendData.put("out", down); // 上车 @@ -406,6 +406,7 @@ public class PassengerFlowSimulateService { } trainPassengerFlow.plus(up); sendData.put("in", up); + sendData.put("remain", trainPassengerFlow.getPassengerQuantity()); String json = JsonUtils.writeValueNullableFieldAsString(sendData); SocketMessageVO message = SocketMessageFactory.build( diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/data/TrainPassengerFlow.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/data/TrainPassengerFlow.java index fdd4cdd48..88bf2846a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/data/TrainPassengerFlow.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/data/TrainPassengerFlow.java @@ -24,13 +24,15 @@ public class TrainPassengerFlow { this.off = false; } - public void minus(int num) { + public int minus(int num) { + this.off = true; if (this.passengerQuantity < num) { + num = this.passengerQuantity; this.passengerQuantity = 0; } else { this.passengerQuantity -= num; } - this.off = true; + return num; } public void plus(int up) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/JumpStrategyServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/JumpStrategyServiceImpl.java new file mode 100644 index 000000000..45a9b516b --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/JumpStrategyServiceImpl.java @@ -0,0 +1,158 @@ +package club.joylink.rtss.simulation.cbtc.passenger.strategy; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.data.map.Stand; +import club.joylink.rtss.simulation.cbtc.data.plan.RealRun; +import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan; +import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; +import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.JumpStrategy; +import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.StandPassenger; +import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.StrategyCalculateData; +import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.TrainPassenger; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.time.LocalTime; +import java.util.*; + +@Slf4j +@Component +public class JumpStrategyServiceImpl implements StrategyService { + + @Override + public List generateStrategy(StrategyCalculateData data) { + List list = new ArrayList<>(); + Stand stand = null; + // 暂时按一个站大客流处理 + List standPassengerList = data.getAllStandPassengerList(); + for (StandPassenger standPassenger : standPassengerList) { + if (standPassenger.isLpf()) { + stand = standPassenger.getStand(); + break; + } + } + if (stand == null) { + return null; + } + List leftStandList = data.getLeftStandList(); + List rightStandList = data.getRightStandList(); + boolean right = false; + int index = leftStandList.indexOf(stand); + if (index < 0) { + // 不是左向站台 + right = true; + index = rightStandList.indexOf(stand); + } + BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(index >= 0, String.format("未找到站台[%s]", stand.debugStr())); + + log.debug(String.format("生成跳停策略[%s]个", list.size())); + return list; + } + + @Override + public void calculate(StrategyCalculateData data, JumpStrategy strategy) { + // 系统时间 + LocalTime systemTime = data.getSystemTime().toLocalTime();// 系统当前时间 + LocalTime endTime = systemTime.plusMinutes(Config.STRATEGY_CAL_TIME);// 预测计算终点 + List trainPassengerList = data.getTrainPassengerList(); + Map trainPreviousMap = new HashMap<>(); // 列车上一个到站/发车数据 + int i = 0; + while (systemTime.isBefore(endTime) && i<1000) { // 在计算时间内 + ++i; + if (i > 999) { + log.error("死循环--------------------------"); + } + LocalTime nextTime = null; + for (TrainPassenger trainPassenger : trainPassengerList) { + String groupNumber = trainPassenger.getGroupNumber(); + TripPlan tripPlan = data.queryTripPlan(trainPassenger.getServiceNumber(), trainPassenger.getTripNumber()); + if (tripPlan == null) { // 未找到计划,跳过 + log.warn(String.format("列车[%s-%s|%s]没有找到车次计划", + groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber())); + continue; + } + if (tripPlan.isBackup()) { + continue; + } + // 上一实际到发 + RealRun realRun = trainPreviousMap.get(groupNumber); + if (realRun == null) { + realRun = data.queryPreviousRealRunData(groupNumber); + if (realRun != null) { + trainPreviousMap.put(groupNumber, realRun); + } + } + List planList = tripPlan.getPlanList(); + int offsetTime = 0; + StationPlan nextStationPlan = null; + if (realRun != null && + Objects.equals(tripPlan.getServiceNumber(), realRun.getServiceNumber()) && + Objects.equals(tripPlan.getTripNumber(), realRun.getTripNumber())) { + // 上一实际运行数据存在且在当前计划中 + // 查询实际运行到的车站计划 + StationPlan stationPlan = tripPlan.queryStationPlanByStationCode(realRun.getStationCode()); + BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(stationPlan); + LocalTime leaveTime = stationPlan.getLeaveTime(); + if (realRun.isArrive()) { + // 是到达车站的计划,预测离站 + LocalTime arriveTime = stationPlan.getArriveTime(); + if (!tripPlan.isFirstPlan(stationPlan)) { + offsetTime = realRun.getTime().toLocalTime().toSecondOfDay() - arriveTime.toSecondOfDay(); + } + RealRun leave = this.handleTrainLeave(data, strategy, trainPassenger, tripPlan, stationPlan, offsetTime); + + trainPreviousMap.put(groupNumber, leave); + } else { + offsetTime = realRun.getTime().toLocalTime().toSecondOfDay() - leaveTime.toSecondOfDay(); + } + if (tripPlan.isLastPlan(stationPlan)) { + // 最后一个到发计划,获取下一个折返后车次计划 + TripPlan nextTripPlan = data.queryNextTripPlan(tripPlan); + if (nextTripPlan != null) { + tripPlan = nextTripPlan; + nextStationPlan = nextTripPlan.getFirstStationPlan(); + } + } else { + nextStationPlan = tripPlan.queryNextStationPlanByStationCode(realRun.getStationCode()); + } + } else { + for (StationPlan stationPlan : planList) { + if (stationPlan.getArriveTime().compareTo(systemTime) >= 0) { + nextStationPlan = stationPlan; + break; + } + } + } + if (nextStationPlan != null) { + LocalTime arriveTime = nextStationPlan.getArriveTime(); + RealRun arrive = this.buildRealRun(groupNumber, tripPlan, nextStationPlan, true, arriveTime, offsetTime, data.getSystemTime()); + data.addRealRun(arrive); + RealRun leave = this.handleTrainLeave(data, strategy, trainPassenger, tripPlan, nextStationPlan, offsetTime); + data.addRealRun(leave); + trainPreviousMap.put(groupNumber, leave); + if (nextTime == null || leave.getTime().toLocalTime().isBefore(nextTime)) { + nextTime = leave.getTime().toLocalTime(); + } + } + } + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(nextTime); + systemTime = nextTime; + } + strategy.setCoTarget(strategy.getTarget1()*strategy.getW1()+strategy.getTarget2()*strategy.getW2()); + } + + private RealRun handleTrainLeave(StrategyCalculateData data, JumpStrategy strategy, TrainPassenger trainPassenger, + TripPlan tripPlan, StationPlan stationPlan, int offsetTime) { + Stand stand = strategy.getStand(); + LocalTime arriveTime = stationPlan.getArriveTime(); + LocalTime leaveTime = stationPlan.getLeaveTime(); + // 生成预测实际运行图 + RealRun leave = this.buildRealRun(trainPassenger.getGroupNumber(), tripPlan, stationPlan, false, leaveTime, offsetTime, data.getSystemTime()); + data.addRealRun(leave); + // 大客流站计算指标 + if (Objects.equals(stationPlan.getSection(), stand.getSection())) { + + } + return leave; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/LargePassengerFlowStrategyService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/LargePassengerFlowStrategyService.java index c1b3e6830..80d6d165a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/LargePassengerFlowStrategyService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/LargePassengerFlowStrategyService.java @@ -58,6 +58,7 @@ public class LargePassengerFlowStrategyService { for (ParkTimeStrategy parkTimeStrategy : parkTimeStrategies) { this.parkTimeStrategyService.calculate(strategyCalculateData.clone(), parkTimeStrategy); parkTimeStrategy.buildDescription(); + parkTimeStrategy.handleTarget(); log.info(String.format("停站时间策略[%s]计算指标为:%s", parkTimeStrategy.getDescription(), parkTimeStrategy.targetDebugStr())); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/ParkTimeStrategyServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/ParkTimeStrategyServiceImpl.java index e83f3ed17..cf27c6496 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/ParkTimeStrategyServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/ParkTimeStrategyServiceImpl.java @@ -79,15 +79,6 @@ public class ParkTimeStrategyServiceImpl implements StrategyService planList = tripPlan.getPlanList(); int offsetTime = 0; StationPlan nextStationPlan = null; @@ -114,7 +119,6 @@ public class ParkTimeStrategyServiceImpl implements StrategyService standPassengerMap = new ConcurrentHashMap<>(); + List leftStandList; + + List rightStandList; + List trainPassengerList; private StrategyCalculateData() { @@ -56,6 +60,21 @@ public class StrategyCalculateData { StandPassenger standPassenger = new StandPassenger(standPassengerFlow); this.standPassengerMap.put(standPassenger.getStand().getCode(), standPassenger); } + List leftList = new ArrayList<>(); + List rightList = new ArrayList<>(); + for (StandPassengerFlow standPassengerFlow : allStandPassengerFlow) { + Stand stand = standPassengerFlow.getStand(); + if (stand.isRight()) { + rightList.add(stand); + } else { + leftList.add(stand); + } + } + leftList.sort(Comparator.comparing((stand) -> stand.getStation().getSn())); + rightList.sort(Comparator.comparing((stand) -> stand.getStation().getSn())); + Collections.reverse(leftList); + this.leftStandList = leftList; + this.rightStandList = rightList; List tpList = new ArrayList<>(); for (TrainPassengerFlow trainPassengerFlow : allTrainPassengerFlow) { if (!StringUtils.hasText(trainPassengerFlow.getTrain().getServiceNumber())) { @@ -85,6 +104,8 @@ public class StrategyCalculateData { standPassengerMap.put(code, standPassenger.clone()); }); obj.standPassengerMap = standPassengerMap; + obj.leftStandList = this.leftStandList; + obj.rightStandList = this.rightStandList; List tpList = new ArrayList<>(); for (TrainPassenger trainPassenger : this.trainPassengerList) { tpList.add(trainPassenger.clone());