From 7fcf48be3543f10fef29d611f683b74129a604d7 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 8 Dec 2021 15:01:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BA=BF=E8=B7=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E3=80=90=E8=BF=90=E8=A1=8C=E5=9B=BE=E4=B8=AD?= =?UTF-8?q?=E8=BD=A6=E6=AC=A1=E5=8F=B7=E5=94=AF=E4=B8=80=E3=80=91=EF=BC=88?= =?UTF-8?q?=E5=BD=B1=E5=93=8D=E7=94=9F=E6=88=90=E8=AE=A1=E5=88=92=E7=9A=84?= =?UTF-8?q?=E8=BD=A6=E6=AC=A1=E5=8F=B7=EF=BC=89=E4=B8=8E=E7=9B=B8=E5=BA=94?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/services/RunPlanDraftService.java | 7 +++- .../services/runplan/RunPlanGenerator.java | 40 ++++++++++++++++++- .../simulation/cbtc/data/map/MapConfig.java | 3 ++ .../joylink/rtss/vo/map/RealLineConfigVO.java | 3 ++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 0c0b574f2..86c441540 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -21,7 +21,8 @@ import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.runplan.*; import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO; import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; -import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.MapVO; +import club.joylink.rtss.vo.map.RealLineConfigVO; import club.joylink.rtss.vo.map.graph.MapSectionNewVO; import club.joylink.rtss.vo.map.graph.MapStationNewVO; import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; @@ -444,7 +445,9 @@ public class RunPlanDraftService implements IRunPlanDraftService { String max = planVO.getTripList().stream().map(RunPlanTripVO::getServiceNumber).max(Comparator.comparingInt(Integer::parseInt)).orElse("0"); // 当前已有最大服务号 int maxServiceNumber = Integer.parseInt(max); - inputData.setServiceNumber(String.format("%03d", ++maxServiceNumber)); + 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); } 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 fe25f3f90..abffb76cd 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java @@ -33,8 +33,8 @@ public class RunPlanGenerator { private IRunPlanUserConfigService runPlanUserConfigService; public List generatorTrips(Long userId, RunPlanInputData inputData, MapVO mapVO) { - RealLineConfigVO configVO = mapVO.getConfigVO(); - String serviceFormat = String.format("%%0%sd", configVO.getFiguresOfServiceNumber()); + RealLineConfigVO mapConfigVO = mapVO.getConfigVO(); + String serviceFormat = String.format("%%0%sd", mapConfigVO.getFiguresOfServiceNumber()); //校验时间 checkInputTime(inputData); RunPlanRoutingVO running1Routing = runPlanRoutingService.queryUserRoutingById(userId, mapVO.getId(), inputData.getRunningRouting1()); @@ -83,6 +83,7 @@ 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); @@ -90,6 +91,7 @@ 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; } } @@ -99,6 +101,7 @@ 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; @@ -126,6 +129,39 @@ 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); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java index 2fa1e63df..ae1f49e55 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java @@ -216,6 +216,9 @@ public class MapConfig { /** 进路默认开启冲突检测 */ private boolean routeDefaultCheckConflict; + /** 运行图中车次号是否唯一 */ + private boolean tripNumberIsUnique; + private Set needConfirmConnectMembers = Stream.of(DISPATCHER, STATION_SUPERVISOR, MAINTAINER, ELECTRIC_DISPATCHER).collect(Collectors.toSet()); diff --git a/src/main/java/club/joylink/rtss/vo/map/RealLineConfigVO.java b/src/main/java/club/joylink/rtss/vo/map/RealLineConfigVO.java index d3ac26e3d..0da236445 100644 --- a/src/main/java/club/joylink/rtss/vo/map/RealLineConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/RealLineConfigVO.java @@ -206,6 +206,9 @@ public class RealLineConfigVO { /** 进路默认开启冲突检测 */ private boolean routeDefaultCheckConflict; + /** 运行图中车次号是否唯一 */ + private boolean tripNumberIsUnique; + public static RealLineConfigVO parseJsonStr(String configData) { if (StringUtils.hasText(configData)) { return JsonUtils.read(configData, RealLineConfigVO.class); From 13a11337dd5317fd80d6381f794560bddfd2721f Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 8 Dec 2021 15:31:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=8D=E8=AE=BE?= =?UTF-8?q?=E8=BD=A6=E6=AC=A1=E5=8F=B7=E9=80=BB=E8=BE=91=E7=9A=84=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E4=BB=A5=E8=A6=86=E7=9B=96=E7=94=9F=E6=88=90=E5=8D=95?= =?UTF-8?q?=E6=9D=A1=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);