diff --git a/src/main/java/club/joylink/rtss/controller/runplan/RunPlanUserDataController.java b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanUserDataController.java index 9afcc1333..278d1280d 100644 --- a/src/main/java/club/joylink/rtss/controller/runplan/RunPlanUserDataController.java +++ b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanUserDataController.java @@ -95,9 +95,9 @@ public class RunPlanUserDataController { iRunPlanRunlevelService.updateRefLevels(user.getId(), mapId, list); } - @ApiOperation(value = "用于区段数据变化时更新站间距离") + @ApiOperation(value = "用于区段数据变化时更新站间距离且重新计算运行等级数据") @PutMapping(path = "/{mapId}/runlevelDistance") - public Map updateRunlevelDistance(@PathVariable Long mapId, @RequestAttribute UserVO user) { + public List updateRunlevelDistance(@PathVariable Long mapId, @RequestAttribute UserVO user) { return iRunPlanRunlevelService.updateRunlevelDistance(user.getId(), mapId); } diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 7d1dea9ab..33973e4c2 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -745,22 +745,22 @@ public class RunPlanDraftService implements IRunPlanDraftService { tripVO.setTripNumber(tripVO.getDirectionCode() + String.format("%03d", ++downTripNumber)); } if (i == 0) { - tripVO.setIsOutbound(true); - tripVO.setIsInbound(true); +// tripVO.setIsOutbound(true); +// tripVO.setIsInbound(true); tripVO.setIsReentry(false); } if (newTripList.size() > 1) { if (i == newTripList.size() - 1) { - tripVO.setIsInbound(true); +// tripVO.setIsInbound(true); tripVO.setIsReentry(false); - tripVO.setIsOutbound(false); +// tripVO.setIsOutbound(false); } else if (i == 0) { tripVO.setIsReentry(true); - tripVO.setIsInbound(false); +// tripVO.setIsInbound(false); } else { - tripVO.setIsInbound(false); +// tripVO.setIsInbound(false); tripVO.setIsReentry(true); - tripVO.setIsOutbound(false); +// tripVO.setIsOutbound(false); } } //是否为备用车 @@ -787,12 +787,19 @@ public class RunPlanDraftService implements IRunPlanDraftService { Map> serviceMap = planVO.getTripList().stream().collect(Collectors.groupingBy(RunPlanTripVO::getServiceNumber)); serviceMap.forEach((s, trips) -> { trips.sort(Comparator.comparing(RunPlanTripVO::getStartTime)); + if(Objects.isNull(trips.get(0).getIsOutbound()) || !trips.get(0).getIsOutbound()){ + errorList.add(String.format("服务号[%s]首班车次[%s]不是出库", s, trips.get(0).getTripNumber())); + } LocalTime departTime = trips.get(0).getStartTime().plusHours(OFFSET_TIME_HOURS); //服务首班车次时间 >2:00 if (departTime.isBefore(LocalTime.of(2, 0))) { errorList.add(String.format("服务号[%s]首班车次发车时间[%s]过早,应不早于02:00", s, departTime)); } - LocalTime overTime = trips.get(trips.size() - 1).getEndTime(); + + if(Objects.isNull(trips.get(trips.size() - 1).getIsInbound()) || !trips.get(trips.size() - 1).getIsInbound()){ + errorList.add(String.format("服务号[%s]最后一班车次[%s]不是回库", s, trips.get(trips.size() - 1).getTripNumber())); + } + LocalTime overTime = trips.get(trips.size() - 1).getEndTime().plusHours(OFFSET_TIME_HOURS); //服务最后一班车次时间 <2:00 if (overTime.isAfter(LocalTime.of(2, 0)) && overTime.isBefore(LocalTime.of(4, 0))) { errorList.add(String.format("服务号[%s]最后一班车次结束时间[%s]太晚,应不晚于次日02:00", s, overTime)); @@ -881,6 +888,10 @@ public class RunPlanDraftService implements IRunPlanDraftService { continue; } Float distance = stationSpacingMap.get(tripTime.getSectionCode() + "-" + nextTripTime.getSectionCode()); + MapSectionNewVO startSection = map.findSection(tripTime.getSectionCode()); + if (startSection.isReentryTrack() && !startSection.isStandTrack()){ + continue; + } if (Objects.isNull(distance)) { errorList.add(String.format("服务号[%s]车次号[%s]从车站[%s]至车站[%s]缺少站间距离数据", s, trip.getTripNumber(), map.findStation(tripTime.getStationCode()).getName(), map.findStation(nextTripTime.getStationCode()).getName())); continue; @@ -976,8 +987,8 @@ public class RunPlanDraftService implements IRunPlanDraftService { cur.getServiceNumber(), cur.getTripNumber(), map.findStation(cur.getStationCode()).getName())); return; } - if (ChronoUnit.SECONDS.between(pre.getDepartureTime(), cur.getArrivalTime()) < 60) { - errorList.add(String.format("相邻车次[%s-%s] 与 车次[%s-%s]行车至车站[%s]时运行间隔太小不安全,应不小于1分钟", + if (ChronoUnit.SECONDS.between(pre.getDepartureTime(), cur.getArrivalTime()) < 45) { + errorList.add(String.format("相邻车次[%s-%s] 与 车次[%s-%s]行车至车站[%s]时运行间隔太小不安全,应不小于45秒", pre.getServiceNumber(), pre.getTripNumber(), cur.getServiceNumber(), cur.getTripNumber(),map.findStation(cur.getStationCode()).getName())); return; diff --git a/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRunlevelService.java b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRunlevelService.java index 0d5bd644d..86b90a6b5 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRunlevelService.java +++ b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRunlevelService.java @@ -14,7 +14,7 @@ public interface IRunPlanRunlevelService { void updateRefLevels(Long userId, Long mapId, List list); - Map updateRunlevelDistance(Long userId, Long mapId); + List updateRunlevelDistance(Long userId, Long mapId); PageVO queryUserRunLevels(Long userId, Long mapId, RunPlanRunLevelQueryVO queryVO); 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 9c19f7ea5..7342ae08d 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java @@ -3,11 +3,12 @@ package club.joylink.rtss.services.runplan; import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.client.map.MapVO; -import club.joylink.rtss.vo.client.map.newmap.MapSectionNewVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; import club.joylink.rtss.vo.client.runplan.user.*; import club.joylink.rtss.vo.runplan.RunPlanInputData; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -56,35 +57,35 @@ public class RunPlanGenerator { int startServiceNumber = Integer.parseInt(inputData.getServiceNumber()); LocalTime initBeginTime = inputData.getBeginTime(); - LinkedList serviceTripList1 = generateService(inputData, mapVO,inboundRoutings, running1Routing, running2Routing, runLevelMap, parkTimeMap, reentryData); + LinkedList serviceTripList1 = generateService(inputData, mapVO, inboundRoutings, running1Routing, running2Routing, runLevelMap, parkTimeMap, reentryData); tripList.addAll(serviceTripList1); - LocalTime departEndTime2 = serviceTripList1.get(1).getStartTime(); + LocalTime departEndTime2 = serviceTripList1.get(1).getTimeList().get(0).getArrivalTime(); inputData.setServiceNumber(String.format("%03d", startServiceNumber + 1)); - LinkedList serviceTripList2 = generateService(inputData, mapVO,inboundRoutings, running2Routing, running1Routing, runLevelMap, parkTimeMap, reentryData); + LinkedList serviceTripList2 = generateService(inputData, mapVO, inboundRoutings, running2Routing, running1Routing, runLevelMap, parkTimeMap, reentryData); tripList.addAll(serviceTripList2); - LocalTime departEndTime1 = serviceTripList2.get(1).getStartTime(); + LocalTime departEndTime1 = serviceTripList2.get(1).getTimeList().get(0).getArrivalTime(); - RunPlanRoutingVO outBoundRouting2 = null; - RunPlanRoutingVO outBoundRouting1 = null; + Routing2BoundInfo outBoundRouting2 = null; + Routing2BoundInfo outBoundRouting1 = null; if (inputData.hasOutAndInBound()) { - outBoundRouting1 = getOutboundRouting(running1Routing, outboundRoutings); - outBoundRouting2 = getOutboundRouting(running2Routing, outboundRoutings); + outBoundRouting1 = getOutboundRouting(running1Routing, outboundRoutings,runLevelMap); + outBoundRouting2 = getOutboundRouting(running2Routing, outboundRoutings,runLevelMap); if (Objects.nonNull(outBoundRouting1) && Objects.nonNull(outBoundRouting2)) { - setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList1, outBoundRouting1); - setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList2, outBoundRouting2); + setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList1, outBoundRouting1); + setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList2, outBoundRouting2); } else if (Objects.nonNull(outBoundRouting1)) { tripList.removeAll(serviceTripList2); - setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList1, outBoundRouting1); + setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList1, outBoundRouting1); inputData.setServiceNumber(String.format("%03d", startServiceNumber + 2)); - departEndTime1 = serviceTripList1.get(2).getStartTime(); + departEndTime1 = serviceTripList1.get(2).getTimeList().get(0).getArrivalTime(); generateServices(inputData, mapVO, running1Routing, running2Routing, inboundRoutings, outBoundRouting1, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime1); return tripList; - } else if(Objects.nonNull(outBoundRouting2)){ + } else if (Objects.nonNull(outBoundRouting2)) { tripList.removeAll(serviceTripList1); - setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList2, outBoundRouting2); + setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList2, outBoundRouting2); inputData.setServiceNumber(String.format("%03d", startServiceNumber + 3)); - departEndTime2 = serviceTripList2.get(2).getStartTime(); + departEndTime2 = serviceTripList2.get(2).getTimeList().get(0).getArrivalTime(); generateServices(inputData, mapVO, running2Routing, running1Routing, inboundRoutings, outBoundRouting2, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime2); return tripList; } @@ -97,17 +98,17 @@ public class RunPlanGenerator { generateServices(inputData, mapVO, running2Routing, running1Routing, inboundRoutings, outBoundRouting2, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime2); } else { - RunPlanRoutingVO outBoundRouting = null; + Routing2BoundInfo outBoundRouting = null; //出库的衔接环路 RunPlanRoutingVO outRefLoop = running1Routing; //另一个交路 RunPlanRoutingVO otherLoop = running2Routing; if (inputData.hasOutAndInBound()) { - outBoundRouting = getOutboundRouting(running1Routing, outboundRoutings); + outBoundRouting = getOutboundRouting(running1Routing, outboundRoutings,runLevelMap); outRefLoop = running1Routing; otherLoop = running2Routing; if (Objects.isNull(outBoundRouting)) { - outBoundRouting = getOutboundRouting(running2Routing, outboundRoutings); + outBoundRouting = getOutboundRouting(running2Routing, outboundRoutings,runLevelMap); outRefLoop = running2Routing; otherLoop = running1Routing; } @@ -115,34 +116,13 @@ public class RunPlanGenerator { LinkedList serviceTripList = generateService(inputData, mapVO, inboundRoutings, outRefLoop, otherLoop, runLevelMap, parkTimeMap, reentryData); //构建出库车次时刻 if (inputData.hasOutAndInBound() && Objects.nonNull(outBoundRouting)) { - setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList, outBoundRouting); + setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList, outBoundRouting); } tripList.addAll(serviceTripList); } return tripList; } - private void setOutBoundTripTimes(Map runLevelMap, Map parkTimeMap, - LinkedList serviceTripList, RunPlanRoutingVO outBoundRouting) { - //首趟车次连接车辆段或停车场 - RunPlanTripVO firstTrip = serviceTripList.getFirst(); - firstTrip.setStartSectionCode(outBoundRouting.getStartSectionCode()); - List timeList = firstTrip.getTimeList(); - RunPlanTripTimeVO runPlanTripTime = timeList.get(0); - if(Objects.equals(runPlanTripTime.getSectionCode(),firstTrip.getStartSectionCode())){ - runPlanTripTime.setArrivalTime(runPlanTripTime.getDepartureTime().minusSeconds(parkTimeMap.get(runPlanTripTime.getSectionCode()))); - } - LocalTime arrivalTime = runPlanTripTime.getArrivalTime(); - String sectionCode = runPlanTripTime.getSectionCode(); - RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); - runPlanTripTimeVO.setStationCode(outBoundRouting.getStartStationCode()); - runPlanTripTimeVO.setSectionCode(outBoundRouting.getStartSectionCode()); - runPlanTripTimeVO.setDepartureTime(arrivalTime.minusSeconds(runLevelMap.get(runPlanTripTimeVO.getSectionCode() + "-" + sectionCode))); - runPlanTripTimeVO.setArrivalTime(runPlanTripTimeVO.getDepartureTime()); - timeList.add(0, runPlanTripTimeVO); - firstTrip.setStartTime(timeList.get(0).getArrivalTime()); - } - private void checkInputTime(RunPlanInputData inputData) { BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(inputData.getOverTime().isAfter(inputData.getBeginTime()), "输入参数错误:发车时间应早于结束时间"); LocalTime beginTimeOffset = inputData.getBeginTime().minusHours(OFFSET_TIME_HOURS); @@ -151,7 +131,11 @@ public class RunPlanGenerator { inputData.setOverTime(inputData.getOverTime().minusHours(OFFSET_TIME_HOURS)); } - private void generateServices(RunPlanInputData inputData, MapVO mapVO, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, List inboundRoutings, RunPlanRoutingVO outBoundRouting, Map runLevelMap, Map parkTimeMap, Map reentryData, List tripList, LocalTime initBeginTime, LocalTime departEndTime) { + private void generateServices(RunPlanInputData inputData, MapVO mapVO, + RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, List inboundRoutings, Routing2BoundInfo outBoundRouting, + Map runLevelMap, Map parkTimeMap, Map reentryData, + List tripList, + LocalTime initBeginTime, LocalTime departEndTime) { LinkedList serviceTripList; inputData.setBeginTime(initBeginTime); LocalTime preServiceDepartTime = inputData.getBeginTime(); @@ -161,8 +145,8 @@ public class RunPlanGenerator { inputData.setServiceNumber(String.format("%03d", Integer.parseInt(inputData.getServiceNumber()) + 2)); preServiceDepartTime = serviceTripList.getFirst().getStartTime(); //构建出库车次时刻 - if (inputData.hasOutAndInBound() && Objects.nonNull(outBoundRouting)) { - setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList, outBoundRouting); + if (inputData.hasOutAndInBound() && Objects.nonNull(outBoundRouting)) { + setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList, outBoundRouting); } tripList.addAll(serviceTripList); } @@ -180,11 +164,9 @@ public class RunPlanGenerator { if (Objects.isNull(reentryData.get(endStationCode))) { throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception(String.format("车站[%s]缺少折返数据", mapVO.findStation(endStationCode).getName())); } - Boolean startTBIsFront = startTBIsFront(running1Routing, mapVO); - checkStationReentryData(mapVO, reentryData, startStationCode, startTBIsFront); + checkStationReentryData(mapVO, reentryData, startStationCode, running1Routing.getStartTbFront()); - Boolean endTBIsFront = endTBIsFront(running1Routing, mapVO); - checkStationReentryData(mapVO, reentryData, endStationCode, endTBIsFront); + checkStationReentryData(mapVO, reentryData, endStationCode, running1Routing.getEndTbFront()); return reentryData; } @@ -203,15 +185,11 @@ public class RunPlanGenerator { LinkedList serviceTripList = new LinkedList<>(); int nextTripNumber = 1; - int outRefTripRunTime = getLoopTripRunTime(mapVO, outRefLoop, runLevelMap, parkTimeMap, reentryData); - - int otherTripRunTime = getLoopTripRunTime(mapVO, otherLoop, runLevelMap, parkTimeMap, reentryData); - //构建环路车次 boolean loop = false; while (CollectionUtils.isEmpty(serviceTripList) || - (loop ? serviceTripList.getLast().getEndTime().plusSeconds(otherTripRunTime).isBefore(inputData.getOverTime()) - : serviceTripList.getLast().getEndTime().plusSeconds(outRefTripRunTime).isBefore(inputData.getOverTime()))) { + (loop ? serviceTripList.getLast().getEndTime().isBefore(inputData.getOverTime()) + : serviceTripList.getLast().getEndTime().isBefore(inputData.getOverTime()))) { if (loop) { nextTripNumber = buildServiceTrip(inputData, mapVO, otherLoop, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber); @@ -223,110 +201,78 @@ public class RunPlanGenerator { } if (inputData.hasOutAndInBound()) { - RunPlanRoutingVO inboundRouting = getInboundRouting(inboundRoutings, outRefLoop, otherLoop, serviceTripList, loop); + Routing2BoundInfo inboundRouting = getInboundRouting(loop ? outRefLoop : otherLoop, inboundRoutings,runLevelMap); + if (Objects.isNull(inboundRouting)) { + serviceTripList.removeLast(); + inboundRouting = getInboundRouting(!loop ? outRefLoop : otherLoop, inboundRoutings,runLevelMap); + } if (Objects.nonNull(inboundRouting)) { - if (Objects.equals(serviceTripList.getLast().getRight(), inboundRouting.getRight()) || (inboundRouting.getParkSectionCodeList().size() == 2 && inboundRouting.getStartTbFront())) { - - //末班车次与连接车辆段或停车场 - RunPlanTripVO lastTrip = serviceTripList.getLast(); - lastTrip.setEndSectionCode(inboundRouting.getEndSectionCode()); - List timeList = lastTrip.getTimeList(); - RunPlanTripTimeVO runPlanTripTime = timeList.get(timeList.size() - 1); - if (!Objects.equals(serviceTripList.getLast().getRight(), inboundRouting.getRight())) { - runPlanTripTime.setDepartureTime(runPlanTripTime.getArrivalTime().plusSeconds(reentryData.get(runPlanTripTime.getStationCode()).getTbFront())); - } - - LocalTime departureTime = runPlanTripTime.getDepartureTime(); - String sectionCode = runPlanTripTime.getSectionCode(); - List parkSectionList = inboundRouting.getParkSectionCodeList(); - for (int i = 1; i < parkSectionList.size(); i++) { - RunPlanRoutingSection routingSection = parkSectionList.get(i); - RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); - runPlanTripTimeVO.setStationCode(routingSection.getStationCode()); - runPlanTripTimeVO.setSectionCode(routingSection.getSectionCode()); - runPlanTripTimeVO.setArrivalTime(departureTime.plusSeconds(runLevelMap.get(sectionCode + "-" + runPlanTripTimeVO.getSectionCode()))); - runPlanTripTimeVO.setDepartureTime(i == parkSectionList.size() - 1 ? runPlanTripTimeVO.getArrivalTime() : runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode()))); - timeList.add(runPlanTripTimeVO); - departureTime = runPlanTripTimeVO.getDepartureTime(); - sectionCode = runPlanTripTimeVO.getSectionCode(); - } - lastTrip.setEndTime(timeList.get(timeList.size() - 1).getArrivalTime()); - } else { - //构建回库车次 - buildServiceTrip(inputData, mapVO, inboundRouting, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber); - } + setInBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList, inboundRouting); } } - serviceTripList.getFirst().setIsOutbound(true); - serviceTripList.getLast().setIsInbound(true); - serviceTripList.getLast().setIsReentry(false); return serviceTripList; } - private RunPlanRoutingVO getInboundRouting(List inboundRoutings, RunPlanRoutingVO outRefLoop, RunPlanRoutingVO otherLoop, LinkedList serviceTripList, boolean loop) { - RunPlanRoutingVO inboundRouting = getRunPlanRouting(inboundRoutings, outRefLoop, otherLoop, loop); - if (Objects.isNull(inboundRouting)) { - serviceTripList.removeLast(); - inboundRouting = getRunPlanRouting(inboundRoutings, otherLoop, outRefLoop, loop); - } - return inboundRouting; - } - private RunPlanRoutingVO getRunPlanRouting(List inboundRoutings, RunPlanRoutingVO outRefLoop, RunPlanRoutingVO otherLoop, boolean loop) { - RunPlanRoutingVO inboundRouting; - if (loop) { - inboundRouting = getRunPlanRouting(inboundRoutings, outRefLoop, otherLoop); - } else { - inboundRouting = getRunPlanRouting(inboundRoutings, otherLoop, outRefLoop); - } - return inboundRouting; - } + private Routing2BoundInfo getInboundRouting(RunPlanRoutingVO runningRouting, List inboundRoutings, Map runLevelMap) { + //找入库 + RunPlanRoutingVO inboundRouting = null; + List parkSectionCodeList = runningRouting.getParkSectionCodeList(); + int r = 0; + t: + for (int index = runningRouting.getStartTbFront() ? 0 : 1, i = parkSectionCodeList.size() - (runningRouting.getEndTbFront() ? 1 : 2); i > index; i--) { + RunPlanRoutingSection parkSection = parkSectionCodeList.get(i); - private RunPlanRoutingVO getRunPlanRouting(List inboundRoutings, RunPlanRoutingVO outRefLoop, RunPlanRoutingVO otherLoop) { - RunPlanRoutingVO inboundRouting; - RunPlanRoutingSection routingSection = outRefLoop.getParkSectionCodeList().get(outRefLoop.getParkSectionCodeList().size()-2); - inboundRouting = inboundRoutings.stream().filter(inRouting -> - Objects.equals(inRouting.getStartSectionCode(), otherLoop.getStartSectionCode()) - && !inRouting.getParkSectionCodeList().contains(routingSection)) - .sorted(Comparator.comparingInt(o -> o.getParkSectionCodeList().size())) - .findFirst().orElse(null); - return inboundRouting; - } + inboundRouting = inboundRoutings.stream().filter(inRouting -> { - - private int getLoopTripRunTime(MapVO mapVO, RunPlanRoutingVO loop, Map runLevelMap, Map parkTimeMap, Map reentryData) { - int parkTime = 0; - int runTime; - - //计算出库对接环路运行所需时间 - int oNum = loop.getParkSectionCodeList().size() - 1; - int outRefTripRunTime = 0; - for (int i = 0; i < oNum; i++) { - RunPlanRoutingSection routingSection = loop.getParkSectionCodeList().get(i); - RunPlanRoutingSection nextRoutingSection = loop.getParkSectionCodeList().get(i + 1); - if (i == 0) { - if (startTBIsFront(loop, mapVO)) { - parkTime = reentryData.get(routingSection.getStationCode()).getTbFront() - parkTimeMap.get(routingSection.getSectionCode()); - runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode()); - } else { - runTime = reentryData.get(routingSection.getStationCode()).getTbBack() - reentryData.get(routingSection.getStationCode()).getTbFrom(); - } - } else if (i == oNum - 1) { - if (endTBIsFront(loop, mapVO)) { - parkTime = parkTimeMap.get(routingSection.getSectionCode()) + parkTimeMap.get(routingSection.getSectionCode()); - runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode()); - } else { - parkTime = parkTimeMap.get(routingSection.getSectionCode()); - runTime = reentryData.get(nextRoutingSection.getStationCode()).getTbFrom(); - } - } else { - parkTime = parkTimeMap.get(routingSection.getSectionCode()); - runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode()); + List inSectionList = inRouting.getParkSectionCodeList(); + RunPlanRoutingSection inSection = inSectionList.get(inSectionList.size() - 2); + return Objects.equals(parkSection.getSectionCode(), inSection.getSectionCode()); + }).sorted(Comparator.comparing(routingVO -> runLevelMap.get(parkSection.getSectionCode() + "-" + routingVO.getEndSectionCode()))).findFirst().orElse(null); + if (Objects.nonNull(inboundRouting)) { + r = runningRouting.getStartTbFront() ? i + 1 : i; + break t; } - outRefTripRunTime = outRefTripRunTime + parkTime + runTime; - parkTime = 0; + +// for (int x = 0, y = inboundRoutings.size(); x < y; x++) { +// RunPlanRoutingVO inRouting = inboundRoutings.get(x); +// List inSectionList = inRouting.getParkSectionCodeList(); +// RunPlanRoutingSection inSection = inSectionList.get(inSectionList.size() - 2); +// if (Objects.equals(parkSection.getSectionCode(), inSection.getSectionCode())) { +// inboundRouting = inRouting; +// r = runningRouting.getStartTbFront() ? i + 1 : i; +// break t; +// } +// } } - return outRefTripRunTime; + if (Objects.isNull(inboundRouting)) return null; + return new Routing2BoundInfo(inboundRouting, r); + } + + private void setInBoundTripTimes(Map runLevelMap, Map parkTimeMap, Map reentryData, + LinkedList serviceTripList, Routing2BoundInfo inBoundInfo) { + //末班车次连接车辆段或停车场 + RunPlanTripVO lastTrip = serviceTripList.getLast(); + lastTrip.setEndSectionCode(inBoundInfo.getBoundRouting().getEndSectionCode()); + List timeList = lastTrip.getTimeList(); + timeList = timeList.subList(0, inBoundInfo.getR()); + lastTrip.setTimeList(timeList); + RunPlanTripTimeVO runPlanTripTime = timeList.get(timeList.size() - 1); + if (!Objects.equals(lastTrip.getRight(), inBoundInfo.getBoundRouting().getRight())) { + runPlanTripTime.setDepartureTime(runPlanTripTime.getArrivalTime().plusSeconds(reentryData.get(runPlanTripTime.getStationCode()).getTbFront())); + } else if (Objects.equals(runPlanTripTime.getSectionCode(), lastTrip.getEndSectionCode())) { + runPlanTripTime.setDepartureTime(runPlanTripTime.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTime.getSectionCode()))); + } + + RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); + runPlanTripTimeVO.setStationCode(inBoundInfo.getBoundRouting().getEndStationCode()); + runPlanTripTimeVO.setSectionCode(inBoundInfo.getBoundRouting().getEndSectionCode()); + runPlanTripTimeVO.setArrivalTime(runPlanTripTime.getDepartureTime().plusSeconds(runLevelMap.get(runPlanTripTime.getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode()))); + runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime()); + timeList.add(runPlanTripTimeVO); + lastTrip.setEndTime(runPlanTripTimeVO.getArrivalTime()); + lastTrip.setIsInbound(true); + lastTrip.setIsReentry(false); } private int buildServiceTrip(RunPlanInputData inputData, MapVO mapVO, RunPlanRoutingVO routing, @@ -337,14 +283,15 @@ public class RunPlanGenerator { tripVO.setServiceNumber(inputData.getServiceNumber()); tripVO.setTripNumber(tripVO.getDirectionCode() + String.format("%03d", tripNumber)); tripVO.setIsReentry(true); - if (routing.isOutBoundRoute()) { - tripVO.setIsOutbound(true); - } - if (routing.isInBoundRoute()) { - tripVO.setIsInbound(true); - tripVO.setIsReentry(false); - } - Boolean startTBIsFront = startTBIsFront(routing, mapVO); + tripVO.setIsInbound(false); + tripVO.setIsOutbound(false); +// if (routing.isOutBoundRoute()) { +// tripVO.setIsOutbound(true); +// } +// if (routing.isInBoundRoute()) { +// tripVO.setIsInbound(true); +// tripVO.setIsReentry(false); +// } LinkedList tripTimeList = new LinkedList<>(); int size = routing.getParkSectionCodeList().size(); for (int i = 0; i < size; i++) { @@ -353,8 +300,8 @@ public class RunPlanGenerator { runPlanTripTimeVO.setStationCode(routingSection.getStationCode()); runPlanTripTimeVO.setSectionCode(routingSection.getSectionCode()); if (CollectionUtils.isEmpty(tripList) && i == 0) {//首发车次 - if (Objects.nonNull(startTBIsFront)) { - if (!startTBIsFront) continue; + if (Objects.nonNull(routing.getStartTbFront())) { + if (!routing.getStartTbFront()) continue; runPlanTripTimeVO.setArrivalTime(inputData.getBeginTime()); runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode()))); } else { @@ -362,26 +309,26 @@ public class RunPlanGenerator { runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime()); } } else if (i == 0) { //其它车次发车 - if (!startTBIsFront) { + if (!routing.getStartTbFront()) { continue; } - RunPlanTripTimeVO lastTripTime = tripList.getLast().getTimeList().get(tripList.getLast().getTimeList().size()-1); + RunPlanTripTimeVO lastTripTime = tripList.getLast().getTimeList().get(tripList.getLast().getTimeList().size() - 1); runPlanTripTimeVO.setArrivalTime( lastTripTime.getDepartureTime()); runPlanTripTimeVO.setDepartureTime(lastTripTime.getDepartureTime()); } else if (i == size - 1) { - Boolean endTBIsFront = endTBIsFront(routing, mapVO); - if (Objects.nonNull(endTBIsFront) && !endTBIsFront) { + if (Objects.nonNull(routing.getEndTbFront()) && !routing.getEndTbFront()) { continue; } RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get(routingSection.getStationCode()); - runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripTimeList) ? tripList.getLast().getEndTime().plusSeconds(45) + runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripTimeList) ? + CollectionUtils.isEmpty(tripList) ? inputData.getBeginTime().plusSeconds(reentryData.get(routing.getStartStationCode()).getTbTo()): tripList.getLast().getEndTime().plusSeconds(reentryData.get(routing.getStartStationCode()).getTbBack()-reentryData.get(routing.getStartStationCode()).getTbFrom()) : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelMap.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode()))); - runPlanTripTimeVO.setDepartureTime(Objects.isNull(endTBIsFront) + runPlanTripTimeVO.setDepartureTime(Objects.isNull(routing.getEndTbFront()) ? runPlanTripTimeVO.getArrivalTime() : runPlanTripTimeVO.getArrivalTime().plusSeconds(reentryTime.getTbFront())); } else { - if (i == 1 && Objects.nonNull(startTBIsFront) && !startTBIsFront) { + if (i == 1 && Objects.nonNull(routing.getStartTbFront()) && !routing.getStartTbFront()) { RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get(routing.getStartStationCode()); runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripList) ? inputData.getBeginTime() : tripList.getLast().getEndTime().plusSeconds(reentryTime.getTbBack() - reentryTime.getTbFrom())); runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode()))); @@ -439,42 +386,72 @@ public class RunPlanGenerator { } } - public Boolean startTBIsFront(RunPlanRoutingVO runningRouting, MapVO mapVO) { - MapSectionNewVO startReentrySection = mapVO.findSection(runningRouting.getStartSectionCode()); - if (startReentrySection.isReentryTrack()) { - if (startReentrySection.isStandTrack()) { - return true; - } - return false; - } - return null; - } - - public Boolean endTBIsFront(RunPlanRoutingVO runningRouting, MapVO mapVO) { - MapSectionNewVO endReentrySection = mapVO.findSection(runningRouting.getEndSectionCode()); - if (endReentrySection.isReentryTrack()) { - if (endReentrySection.isStandTrack()) { - return true; - } - return false; - } - return null; - } - - private RunPlanRoutingVO getOutboundRouting(RunPlanRoutingVO runningRouting, List outboundRoutings) { - RunPlanRoutingVO outboundRouting = null; + private Routing2BoundInfo getOutboundRouting(RunPlanRoutingVO runningRouting, List outboundRoutings,Map runLevelMap) { //找出库 + RunPlanRoutingVO outboundRouting = null; List parkSectionCodeList = runningRouting.getParkSectionCodeList(); - RunPlanRoutingSection parkSection = parkSectionCodeList.get(runningRouting.getStartTbFront() ? 0 : 1); - for (int x = 0; x < outboundRoutings.size(); x++) { - RunPlanRoutingVO outRouting = outboundRoutings.get(x); - List outSectionList = outRouting.getParkSectionCodeList(); - RunPlanRoutingSection outSection = outSectionList.get(1); - if (Objects.equals(parkSection.getSectionCode(), outSection.getSectionCode())) { - outboundRouting = outRouting; - break; + int r = 0; + t: + for (int i = runningRouting.getStartTbFront() ? 0 : 1, index = parkSectionCodeList.size() - (runningRouting.getEndTbFront() ? 1 : 2); i < index; i++) { + RunPlanRoutingSection parkSection = parkSectionCodeList.get(i); + + outboundRouting = outboundRoutings.stream().filter(outRouting -> { + RunPlanRoutingSection outSection = outRouting.getParkSectionCodeList().get(1); + return Objects.equals(parkSection.getSectionCode(), outSection.getSectionCode()); + }).sorted(Comparator.comparing(routingVO -> runLevelMap.get(routingVO.getStartSectionCode() + "-" + parkSection.getSectionCode()))).findFirst().orElse(null); + if (Objects.nonNull(outboundRouting)) { + r = runningRouting.getStartTbFront() ? i : i - 1; + break t; } + + +// for (int x = 0, y = outboundRoutings.size(); x < y; x++) { +// RunPlanRoutingVO outRouting = outboundRoutings.get(x); +// RunPlanRoutingSection outSection = outRouting.getParkSectionCodeList().get(1); +// if (Objects.equals(parkSection.getSectionCode(), outSection.getSectionCode())) { +// outboundRouting = outRouting; +// r = runningRouting.getStartTbFront() ? i : i - 1; +// break t; +// } +// } } - return outboundRouting; + if (Objects.isNull(outboundRouting)) return null; + return new Routing2BoundInfo(outboundRouting, r); + } + + private void setOutBoundTripTimes(Map runLevelMap, Map parkTimeMap, Map reentryData, + LinkedList serviceTripList, Routing2BoundInfo outBoundInfo) { + //首趟车次连接车辆段或停车场 + RunPlanTripVO firstTrip = serviceTripList.getFirst(); + firstTrip.setStartSectionCode(outBoundInfo.getBoundRouting().getStartSectionCode()); + List timeList = firstTrip.getTimeList(); + //倒推从第二站开始 + if (outBoundInfo.getR() != 0) { + timeList = timeList.subList(outBoundInfo.getR(), timeList.size()); + firstTrip.setTimeList(timeList); + } + RunPlanTripTimeVO runPlanTripTime = timeList.get(0); + if (!Objects.equals(firstTrip.getRight(), outBoundInfo.getBoundRouting().getRight())) { + runPlanTripTime.setArrivalTime(runPlanTripTime.getDepartureTime().minusSeconds(reentryData.get(runPlanTripTime.getStationCode()).getTbFront())); + } else if (Objects.equals(runPlanTripTime.getSectionCode(), firstTrip.getStartSectionCode())) { + runPlanTripTime.setArrivalTime(runPlanTripTime.getDepartureTime().minusSeconds(parkTimeMap.get(runPlanTripTime.getSectionCode()))); + } + + RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); + runPlanTripTimeVO.setStationCode(outBoundInfo.getBoundRouting().getStartStationCode()); + runPlanTripTimeVO.setSectionCode(outBoundInfo.getBoundRouting().getStartSectionCode()); + runPlanTripTimeVO.setDepartureTime(runPlanTripTime.getArrivalTime().minusSeconds(runLevelMap.get(runPlanTripTimeVO.getSectionCode() + "-" + runPlanTripTime.getSectionCode()))); + runPlanTripTimeVO.setArrivalTime(runPlanTripTimeVO.getDepartureTime()); + timeList.add(0, runPlanTripTimeVO); + firstTrip.setStartTime(timeList.get(0).getArrivalTime()); + firstTrip.setIsOutbound(true); + } + + @Getter + @AllArgsConstructor + private class Routing2BoundInfo { + + private RunPlanRoutingVO boundRouting; + private int r; } } 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 176beb56e..b56b8f2e5 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java @@ -23,7 +23,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -68,7 +67,7 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService { @Override @Transactional - public Map updateRunlevelDistance(Long userId, Long mapId) { + public List updateRunlevelDistance(Long userId, Long mapId) { MapVO map = this.iMapService.getMapDetail(mapId); SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), @@ -76,7 +75,6 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService { Map deviceMap = buildResult.getDeviceMap(); List list = queryUserRunLevels(userId, mapId); BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(CollectionUtils.isEmpty(list), "操作失败,运行等级数据为空"); - Map r = new LinkedHashMap<>(); list.forEach(l -> { Section startSection = (Section) deviceMap.get(l.getStartSectionCode()); Section endSection = (Section) deviceMap.get(l.getEndSectionCode()); @@ -91,14 +89,20 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService { distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); } + l.setDistance(distance); + l.generateDefaultRunLevel(); RunPlanRunlevel entity = new RunPlanRunlevel(); entity.setId(l.getId()); entity.setMapId(l.getMapId()); entity.setDistance(distance); + entity.setLevel1(l.getL1()); + entity.setLevel2(l.getL2()); + entity.setLevel3(l.getL3()); + entity.setLevel4(l.getL4()); + entity.setLevel5(l.getL5()); this.runPlanRunlevelDAO.updateByPrimaryKeySelective(entity); - r.put(l.getId(),distance); }); - return r; + return list; } @Override diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java index b70c360f1..c1baf6f4a 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java @@ -10,6 +10,8 @@ import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; +import java.time.LocalTime; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -30,11 +32,31 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew { public void importDataCheckAndPreHandle(List runPlanImportList, List stationList, String upDirection) { Map stationMap = stationList.stream().collect( Collectors.toMap(MapStationNewVO::getRunPlanName, Function.identity())); + //增加36203回库到奉化22:00 + RunPlanImport newTrip = new RunPlanImport(); + newTrip.setCode("36401"); + newTrip.setDestinationCode(""); + List newArrivalList = new ArrayList<>(); + newTrip.setArrivalList(newArrivalList); + RunPlanArrivalTime tripTime = new RunPlanArrivalTime(); + tripTime.setStationName("金海路"); + tripTime.setArriveTime(LocalTime.of(5,5,43)); + tripTime.setDepartureTime(LocalTime.of(21,59,30)); + RunPlanArrivalTime tripTime2 = new RunPlanArrivalTime(); + tripTime2.setStationName("奉化停车场"); + tripTime2.setArriveTime(LocalTime.of(22,0)); + tripTime2.setDepartureTime(LocalTime.of(22,0)); + newArrivalList.add(tripTime); + newArrivalList.add(tripTime2); + runPlanImportList.add(newTrip); runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport, upDirection); List arrivalList = runPlanImport.getArrivalList(); + if(runPlanImport.getCode().equals("36301")){ + arrivalList.remove(0); + } handleStationAndTime(stationMap, arrivalList); - if(Arrays.asList("36102", "36203","36301").contains(runPlanImport.getCode())){ + if(Arrays.asList("36102", "36203","36401","36301").contains(runPlanImport.getCode())){ runPlanImport.setBackup(true); } }); @@ -59,75 +81,12 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew { @Override public void handleTrip(RunPlanImport runPlanImport, RunPlanTripVO tripVO, String startStationName, String endStationName, boolean isFirst, boolean isLast, String firstStationName , String finalStationName) { - // Y315工作日 - switch (endStationName) { - case "奉化停车场": - if(runPlanImport.isBackup()){ - tripVO.setEndSectionCode("T60"); //T2101 - }else if(Arrays.asList("32403","32503","32603","31215","30119","30819","31119").contains(runPlanImport.getCode())){ - tripVO.setEndSectionCode("T62"); //T2102 - } - break; - case "金海路": - if (runPlanImport.isBackup()) { - tripVO.setEndSectionCode("T4");//T2107 - } else { - tripVO.setEndSectionCode("T9");//T2108 - } - break; - case "首南车辆段": - if(Arrays.asList("30518","30618","30918","31718","31818","31918","32018").contains(runPlanImport.getCode())){ - tripVO.setEndSectionCode("T238"); //T3002 - }else{ - tripVO.setEndSectionCode("T237");//T3001 - } - break; - case "南部商务区": - tripVO.setEndSectionCode("T313");//T3307 - break; - case "大通桥": - tripVO.setEndSectionCode("T545");//T4407 - break; - case "体育馆": - tripVO.setEndSectionCode("T442");//T4107 - break; - } - - switch (startStationName) { - case "奉化停车场": - tripVO.setStartSectionCode("T62"); //T2102 - break; - case "金海路": - if (runPlanImport.isBackup()) { - tripVO.setStartSectionCode("T4");//T2107 - } else { - tripVO.setStartSectionCode("T9");//T2108 - } - break; - case "首南车辆段": - if(Arrays.asList("30102","30202","30402","32402","32502","32602","30702","31002","31302","30602","30902","31202").contains(runPlanImport.getCode())){ - tripVO.setStartSectionCode("T238");//T3002 - }else{ - tripVO.setStartSectionCode("T237"); //T3001 - } - break; - case "南部商务区": - tripVO.setStartSectionCode("T313");//T3307 - break; - case "大通桥": - tripVO.setStartSectionCode("T545");//T4407 - break; - case "体育馆": - tripVO.setStartSectionCode("T442");//T4107 - break; - } - - //Y316双休日 +// // Y315工作日 // switch (endStationName) { // case "奉化停车场": // if(runPlanImport.isBackup()){ // tripVO.setEndSectionCode("T60"); //T2101 -// }else if(Arrays.asList("30915","31115","30117","30219","31417","30419").contains(runPlanImport.getCode())){ +// }else if(Arrays.asList("32403","32503","32603","31215","30119","30819","31119").contains(runPlanImport.getCode())){ // tripVO.setEndSectionCode("T62"); //T2102 // } // break; @@ -139,7 +98,7 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew { // } // break; // case "首南车辆段": -// if(Arrays.asList("31616","31716","31018","31816","31218","31916","30820").contains(runPlanImport.getCode())){ +// if(Arrays.asList("30518","30618","30918","31718","31818","31918","32018").contains(runPlanImport.getCode())){ // tripVO.setEndSectionCode("T238"); //T3002 // }else{ // tripVO.setEndSectionCode("T237");//T3001 @@ -168,7 +127,7 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew { // } // break; // case "首南车辆段": -// if(Arrays.asList("30102","30202","30402","31302","31502","30502","30702","30902").contains(runPlanImport.getCode())){ +// if(Arrays.asList("30102","30202","30402","32402","32502","32602","30702","31002","31302","30602","30902","31202").contains(runPlanImport.getCode())){ // tripVO.setStartSectionCode("T238");//T3002 // }else{ // tripVO.setStartSectionCode("T237"); //T3001 @@ -183,54 +142,127 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew { // case "体育馆": // tripVO.setStartSectionCode("T442");//T4107 // break; +// case "樱花公园": +// tripVO.setStartSectionCode("T442");//T4107 +// break; // } + + //Y316双休日 + switch (endStationName) { + case "奉化停车场": + if(runPlanImport.isBackup()){ + tripVO.setEndSectionCode("T60"); //T2101 + }else if(Arrays.asList("30915","31115","30117","30219","31417","30419").contains(runPlanImport.getCode())){ + tripVO.setEndSectionCode("T62"); //T2102 + } + break; + case "金海路": + if (runPlanImport.isBackup()) { + tripVO.setEndSectionCode("T4");//T2107 + } else { + tripVO.setEndSectionCode("T9");//T2108 + } + break; + case "首南车辆段": + if(Arrays.asList("31616","31716","31018","31816","31218","31916","30820").contains(runPlanImport.getCode())){ + tripVO.setEndSectionCode("T238"); //T3002 + }else{ + tripVO.setEndSectionCode("T237");//T3001 + } + break; + case "南部商务区": + tripVO.setEndSectionCode("T313");//T3307 + break; + case "大通桥": + tripVO.setEndSectionCode("T545");//T4407 + break; + case "体育馆": + tripVO.setEndSectionCode("T442");//T4107 + break; + } + + switch (startStationName) { + case "奉化停车场": + tripVO.setStartSectionCode("T62"); //T2102 + break; + case "金海路": + if (runPlanImport.isBackup()) { + tripVO.setStartSectionCode("T4");//T2107 + } else { + tripVO.setStartSectionCode("T9");//T2108 + } + break; + case "首南车辆段": + if(Arrays.asList("30102","30202","30402","31302","31502","30502","30702","30902").contains(runPlanImport.getCode())){ + tripVO.setStartSectionCode("T238");//T3002 + }else{ + tripVO.setStartSectionCode("T237"); //T3001 + } + break; + case "南部商务区": + tripVO.setStartSectionCode("T313");//T3307 + break; + case "大通桥": + tripVO.setStartSectionCode("T545");//T4407 + break; + case "体育馆": + tripVO.setStartSectionCode("T442");//T4107 + break; + case "樱花公园": + tripVO.setStartSectionCode("T442");//T4107 + break; + } } @Override public void handleTripTime(RunPlanTripTimeVO timeVO, RunPlanImport runPlanImport, MapStationNewVO stationVO, String startStationName, String endStationName) { - // Y315工作日 - if("高塘桥".equals(stationVO.getRunPlanName())){ - if(Arrays.asList("36203","30803","31103").contains(runPlanImport.getCode())){ - timeVO.setSectionCode("T273");//T3015 - } - return; - } - if("首南车辆段".equals(stationVO.getRunPlanName())){ - if(Arrays.asList("30518","30618","30918","31718","31818","31918","32018","30102","30202","30402","32402","32502","32602","30702","31002","31302","30602","30902","31202").contains(runPlanImport.getCode())){ - timeVO.setSectionCode("T238");//T3002 - }else{ - timeVO.setSectionCode("T237"); //T3001 - } - return; - } - - //通用 - if("奉化停车场".equals(stationVO.getRunPlanName())){ - if(runPlanImport.isBackup() && runPlanImport.getCode().equals("36203")){ - timeVO.setSectionCode("T60"); //T2101 - }else{ - timeVO.setSectionCode("T62"); //T2102 - } - return; - } - -// // Y316工作日 +// // Y315工作日 // if("高塘桥".equals(stationVO.getRunPlanName())){ -// if(Arrays.asList("36203","30603","30803").contains(runPlanImport.getCode())){ +// if(Arrays.asList("36203","30803","31103").contains(runPlanImport.getCode())){ // timeVO.setSectionCode("T273");//T3015 // } // return; // } -// // if("首南车辆段".equals(stationVO.getRunPlanName())){ -// if(Arrays.asList("31616","31716","31018","31816","31218","31916","30820","30102","30202","30402","31302","31502","30502","30702","30902").contains(runPlanImport.getCode())){ +// if(Arrays.asList("30518","30618","30918","31718","31818","31918","32018","30102","30202","30402","32402","32502","32602","30702","31002","31302","30602","30902","31202").contains(runPlanImport.getCode())){ // timeVO.setSectionCode("T238");//T3002 // }else{ // timeVO.setSectionCode("T237"); //T3001 // } // return; // } + + //通用 + if("奉化停车场".equals(stationVO.getRunPlanName())){ + if(runPlanImport.isBackup() && (runPlanImport.getCode().equals("36203") ||runPlanImport.getCode().equals("36401"))){ + timeVO.setSectionCode("T60"); //T2101 + }else{ + timeVO.setSectionCode("T62"); //T2102 + } + return; + } + if("金海路".equals(stationVO.getRunPlanName()) && runPlanImport.getCode().equals("36401")){ + timeVO.setSectionCode("T4"); //T2101 + return; + } + + // Y316工作日 + if("高塘桥".equals(stationVO.getRunPlanName())){ + if(Arrays.asList("36203","30603","30803").contains(runPlanImport.getCode())){ + timeVO.setSectionCode("T273");//T3015 + } + return; + } + + if("首南车辆段".equals(stationVO.getRunPlanName())){ + if(Arrays.asList("31616","31716","31018","31816","31218","31916","30820","30102","30202","30402","31302","31502","30502","30702","30902").contains(runPlanImport.getCode())){ + timeVO.setSectionCode("T238");//T3002 + }else{ + timeVO.setSectionCode("T237"); //T3001 + } + return; + } } } diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanImport.java b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanImport.java index f337f07a2..f2abbd319 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanImport.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanImport.java @@ -2,6 +2,7 @@ package club.joylink.rtss.vo.client.runplan; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanTripVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanTripVO.java index 7c8a5a761..facc2936d 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanTripVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanTripVO.java @@ -117,6 +117,8 @@ public class RunPlanTripVO { public RunPlanTripVO(RunPlanRoutingVO routingVO) { this.right = routingVO.getRight(); + this.isOutbound = routingVO.isInBoundRoute(); + this.isInbound = routingVO.isOutBoundRoute(); this.destinationCode = Objects.isNull(routingVO.getDestinationCode()) ? "" : routingVO.getDestinationCode(); this.startSectionCode = routingVO.getStartSectionCode(); this.endSectionCode = routingVO.getEndSectionCode(); diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java index 3393beecb..baf629333 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java @@ -159,19 +159,6 @@ public class RunPlanRoutingVO { routingVO.setParkSectionCodeList(JsonUtils.readCollection(JsonUtils.writeValueAsString(mapRoutingDataVO.getParkSectionCodeList()), List.class, RunPlanRoutingSection.class)); return routingVO; } -// public RunPlanRoutingVO generateLoopRoutingBasicData(){ -// RunPlanRoutingVO routing = new RunPlanRoutingVO(); -// routing.setMapId(mapId); -// routing.setName(name+LOOP_MARK); -// routing.setCode(code+LOOP_MARK); -// routing.setStartStationCode(endStationCode); -// routing.setStartSectionCode(endSectionCode); -// routing.setEndStationCode(startStationCode); -// routing.setEndSectionCode(startSectionCode); -// routing.setRight(!right); -// routing.setDescription(description+LOOP_MARK); -// return routing; -// } public static List convert2VOList(List runPlanRoutings){ return runPlanRoutings.stream().map(RunPlanRoutingVO::convert2VO).collect(Collectors.toList());