From 6372892cdb6843a324cab64dfec4d6a766866956 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 8 Dec 2021 15:31:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=8D=E8=AE=BE=E8=BD=A6?= =?UTF-8?q?=E6=AC=A1=E5=8F=B7=E9=80=BB=E8=BE=91=E7=9A=84=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E4=BB=A5=E8=A6=86=E7=9B=96=E7=94=9F=E6=88=90=E5=8D=95=E6=9D=A1?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/services/RunPlanDraftService.java | 36 ++++++++++++++++++- .../services/runplan/RunPlanGenerator.java | 36 ------------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 86c441540..c6e65a52f 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -441,17 +441,18 @@ public class RunPlanDraftService implements IRunPlanDraftService { public void generateRunPlanService(Long userId, Long planId, RunPlanInputData inputData) { RunPlanVO planVO = getRunPlanById(planId); MapVO mapVO = this.iMapService.getMapDetail(planVO.getMapId()); + RealLineConfigVO configVO = mapVO.getConfigVO(); if (Objects.nonNull(inputData.getDepartureInterval())) { String max = planVO.getTripList().stream().map(RunPlanTripVO::getServiceNumber).max(Comparator.comparingInt(Integer::parseInt)).orElse("0"); // 当前已有最大服务号 int maxServiceNumber = Integer.parseInt(max); - RealLineConfigVO configVO = mapVO.getConfigVO(); String serviceFormat = String.format("%%0%sd", configVO.getFiguresOfServiceNumber()); inputData.setServiceNumber(String.format(serviceFormat, ++maxServiceNumber)); Integer departureInterval = inputData.getDepartureInterval() < 60 ? 180 : inputData.getDepartureInterval(); inputData.setDepartureInterval(departureInterval); } List newTripList = runPlanGenerator.generatorTrips(userId, inputData, mapVO); + rearrangeTripNumber(configVO, newTripList); BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(CollectionUtils.isEmpty(newTripList), String.format("生成服务号%s运行图数据失败", inputData.getServiceNumber())); planVO.getTripList().addAll(newTripList); RunPlanDraft planDraft = planVO.convert2Draft(); @@ -460,6 +461,39 @@ public class RunPlanDraftService implements IRunPlanDraftService { runPlanDraftDAO.updateByPrimaryKeySelective(planDraft); } + /** + * 根据线路配置,重排车次号 + */ + private void rearrangeTripNumber(RealLineConfigVO mapConfigVO, List tripList) { + //重排车次号 + if (mapConfigVO.isTripNumberIsUnique()) { + //上下行车次号 + int upTn = 1; + int downTn = 1; + //上下行方向编号 + String upDirection; + String downDirection; + String tripFormat; + if (mapConfigVO.getFiguresOfTripNumber() == 2) { + throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("两位车次号暂不支持车次号唯一"); +// upDirection = ""; +// downDirection = ""; +// tripFormat = "%02d"; + } else { + upDirection = "2"; + downDirection = "1"; + tripFormat = String.format("%%0%sd", mapConfigVO.getFiguresOfTripNumber() - 1); + } + for (RunPlanTripVO tripVO : tripList.stream().sorted(Comparator.comparing(RunPlanTripVO::getStartTime)).collect(Collectors.toList())) { + if (mapConfigVO.isUp(tripVO.getRight())) { + tripVO.setTripNumber(upDirection + String.format(tripFormat, upTn++)); + } else { + tripVO.setTripNumber(downDirection + String.format(tripFormat, downTn++)); + } + } + } + } + @Override @Transactional public void updateRunPlanService(Long planId, String serviceNumber, RunPlanServiceConfigVO serviceConfig, AccountVO accountVO) { 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 abffb76cd..89c4e7e77 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java @@ -83,7 +83,6 @@ public class RunPlanGenerator { inputData.setServiceNumber(String.format(serviceFormat, startServiceNumber + 2)); departEndTime1 = serviceTripList1.get(2).getTimeList().get(0).getArrivalTime(); generateServices(inputData, mapVO, running1Routing, running2Routing, inboundRoutings, outBoundRouting1, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime1); - rearrangeTripNumber(mapConfigVO, tripList); return tripList; } else if (Objects.nonNull(outBoundRouting2)) { tripList.removeAll(serviceTripList1); @@ -91,7 +90,6 @@ public class RunPlanGenerator { inputData.setServiceNumber(String.format(serviceFormat, startServiceNumber + 3)); departEndTime2 = serviceTripList2.get(2).getTimeList().get(0).getArrivalTime(); generateServices(inputData, mapVO, running2Routing, running1Routing, inboundRoutings, outBoundRouting2, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime2); - rearrangeTripNumber(mapConfigVO, tripList); return tripList; } } @@ -101,7 +99,6 @@ public class RunPlanGenerator { inputData.setServiceNumber(String.format(serviceFormat, startServiceNumber + 3)); generateServices(inputData, mapVO, running2Routing, running1Routing, inboundRoutings, outBoundRouting2, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime2); - rearrangeTripNumber(mapConfigVO, tripList); } else { Routing2BoundInfo outBoundRouting = null; @@ -129,39 +126,6 @@ public class RunPlanGenerator { return tripList; } - /** - * 根据线路配置,重排车次号 - */ - private void rearrangeTripNumber(RealLineConfigVO mapConfigVO, List tripList) { - //重排车次号 - if (mapConfigVO.isTripNumberIsUnique()) { - //上下行车次号 - int upTn = 1; - int downTn = 1; - //上下行方向编号 - String upDirection; - String downDirection; - String tripFormat; - if (mapConfigVO.getFiguresOfTripNumber() == 2) { - throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("两位车次号暂不支持车次号唯一"); -// upDirection = ""; -// downDirection = ""; -// tripFormat = "%02d"; - } else { - upDirection = "2"; - downDirection = "1"; - tripFormat = String.format("%%0%sd", mapConfigVO.getFiguresOfTripNumber() - 1); - } - for (RunPlanTripVO tripVO : tripList.stream().sorted(Comparator.comparing(RunPlanTripVO::getStartTime)).collect(Collectors.toList())) { - if (mapConfigVO.isUp(tripVO.getRight())) { - tripVO.setTripNumber(upDirection + String.format(tripFormat, upTn++)); - } else { - tripVO.setTripNumber(downDirection + String.format(tripFormat, downTn++)); - } - } - } - } - private void checkInputTime(RunPlanInputData inputData) { BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(inputData.getOverTime().isAfter(inputData.getBeginTime()), "输入参数错误:发车时间应早于结束时间"); LocalTime beginTimeOffset = inputData.getBeginTime().minusHours(OFFSET_TIME_HOURS);