From 9cb57676b0ba8e63178865d17a61a63169d512b8 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Wed, 19 May 2021 15:07:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6=E5=81=9C=E7=AB=99=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=AE=A1=E7=AE=97=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E7=BC=A9=E5=87=8F=E5=81=9C=E7=AB=99=E6=97=B6=E9=97=B4?= =?UTF-8?q?=20=E4=BB=BF=E7=9C=9F=E6=95=B0=E6=8D=AE=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=90=E8=A1=8C=E7=AD=89=E7=BA=A7=E3=80=81?= =?UTF-8?q?=E5=81=9C=E7=AB=99=E6=97=B6=E9=97=B4=E3=80=81=E7=AB=99=E5=8F=B0?= =?UTF-8?q?=E5=8C=BA=E6=AE=B5=E5=8F=AF=E5=88=B0=E8=BE=BE=E7=9A=84=E4=B8=B4?= =?UTF-8?q?=E8=BF=91=E7=AB=99=E5=8F=B0=E5=8C=BA=E6=AE=B5=E7=AD=89=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9E=84=E5=BB=BA=EF=BC=88=E6=9C=AA=E5=AE=8C=EF=BC=89?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE=EF=BC=9AATS=E6=98=AF=E5=90=A6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=A4=84=E7=90=86=E4=BA=BA=E5=B7=A5=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E7=AB=99=E5=89=8D=E6=8A=98=E8=BF=94=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BD=A6=E6=AC=A1=E6=9E=84=E5=BB=BA=E6=9C=AA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/services/MapService.java | 15 ++- .../services/draftData/RoutingGenerator.java | 2 +- .../cbtc/ATS/service/AtsPlanService.java | 29 +++-- .../cbtc/GroupSimulationServiceImpl.java | 85 +++++++------ .../cbtc/build/MapDeviceBuilder.java | 115 ++++++++++++++++++ .../cbtc/build/SimulationBuildParams.java | 7 +- .../cbtc/build/SimulationBuilder.java | 7 +- .../cbtc/build/UserConfigDataBuilder.java | 44 +++++++ .../cbtc/data/SimulationDataRepository.java | 12 +- .../simulation/cbtc/data/map/MapConfig.java | 1 + .../cbtc/data/map/StationParkTime.java | 7 ++ .../cbtc/data/map/StationRunLevel.java | 4 + .../simulation/job/SimulationFixedJob.java | 2 +- .../job/SimulationScheduledJob.java | 2 +- .../client/map/newmap/MapLogicDataNewVO.java | 19 +++ .../map/newmap/MapStationRunLevelVO.java | 28 ++++- .../runplan/user/RunPlanRunlevelVO.java | 16 ++- 17 files changed, 321 insertions(+), 74 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/build/UserConfigDataBuilder.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationParkTime.java diff --git a/src/main/java/club/joylink/rtss/services/MapService.java b/src/main/java/club/joylink/rtss/services/MapService.java index 8f6750321..f990fc983 100644 --- a/src/main/java/club/joylink/rtss/services/MapService.java +++ b/src/main/java/club/joylink/rtss/services/MapService.java @@ -244,17 +244,16 @@ public class MapService implements IMapService { MapDataVO mapDataVO = this.getMapData(mapVO.getId(), mapVO.getVersion()); mapVO.setMapData(mapDataVO); // mapVO.setMap3dData(this.findMap3dDataByMapId(mapVO.getId())); - // todo 后面可以设置为永不过期缓存 this.iCacheService.put(BusinessConsts.CachePrefix.Map + mapVO.getId(), mapVO); } } - if (Objects.nonNull(mapVO)) { - // 查询线路数据,保证每次都获取最新的线路配置 - RealLineVO realLineVO = this.iRealLineService.getLineDetailByCode(mapVO.getLineCode()); - mapVO.setConfigVO(realLineVO.getConfigVO()); - realLineVO.setConfigVO(null); - mapVO.getGraphDataNew().setSkinVO(realLineVO); - } + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mapVO, + String.format("不存在id为[%s]的地图数据", id)); + // 查询线路数据,保证每次都获取最新的线路配置 + RealLineVO realLineVO = this.iRealLineService.getLineDetailByCode(mapVO.getLineCode()); + mapVO.setConfigVO(realLineVO.getConfigVO()); + realLineVO.setConfigVO(null); + mapVO.getGraphDataNew().setSkinVO(realLineVO); return mapVO; } diff --git a/src/main/java/club/joylink/rtss/services/draftData/RoutingGenerator.java b/src/main/java/club/joylink/rtss/services/draftData/RoutingGenerator.java index ed63169de..0de769b4d 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/RoutingGenerator.java +++ b/src/main/java/club/joylink/rtss/services/draftData/RoutingGenerator.java @@ -17,7 +17,7 @@ import java.util.stream.Collectors; public class RoutingGenerator { /** - * 生成所有交路(此处生成的交流为一个方向能到达的,且路径中只包含同向站台,不能包含反向站台或其他非正常站台轨) + * 生成所有交路(此处生成的交路为一个方向能到达的,且路径中只包含同向站台,不能包含反向站台或其他非正常站台轨) * 生成逻辑: * 1,首先构建每一个站台轨、折返轨、转换轨能到达的最近的站台轨、折返轨、转换轨(站台轨和转换轨为查找的终点) * 2,遍历车站,取折返轨、转换轨开始生成(外循环从前往后遍历车站,内循环从后往前遍历车站) 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 9d4732ba8..09008298e 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 @@ -663,29 +663,34 @@ public class AtsPlanService { LocalTime systemTime = simulation.getSystemTime().toLocalTime(); int parkTime = this.atsStandService.trainParkingAndGetParkTime(simulation, section); train.updateArriveInfo(systemTime, station, section); - if (train.isPlanTrain()) { - SimulationDataRepository repository = simulation.getRepository(); - TripPlan tripPlan = repository.getTripPlan(train.getServiceNumber(), train.getTripNumber()); - // 更新追踪列车到站状态 - StationPlan stationPlan = tripPlan.queryStationPlanByStation(station); - if (parkTime < 0) { + if (parkTime < 0) { + if (train.isPlanTrain()) { + SimulationDataRepository repository = simulation.getRepository(); + TripPlan tripPlan = repository.getTripPlan(train.getServiceNumber(), train.getTripNumber()); + // 更新追踪列车到站状态 + StationPlan stationPlan = tripPlan.queryStationPlanByStation(station); parkTime = stationPlan.getParkTime(); if (tripPlan.isFirstPlan(stationPlan)) { // 第一个计划 - parkTime = stationPlan.getLeaveTime().toSecondOfDay() - systemTime.toSecondOfDay(); + int actualParkTime = stationPlan.getLeaveTime().toSecondOfDay() - systemTime.toSecondOfDay(); + if (actualParkTime > parkTime) { + parkTime = actualParkTime; + } } if (this.checkIfFrontTurnBack(simulation, train, section, tripPlan, stationPlan)) { //是站台折返车 //如果停车时间为0 ,则取后一个车次计划的首站发车时间 TripPlan nextTripPlan = repository.queryServiceNextTripPlan(tripPlan.getServiceNumber(), tripPlan.getTripNumber()); StationPlan nextFirstStationPlan = nextTripPlan.queryStationPlanByStation(station); - parkTime = nextFirstStationPlan.getLeaveTime().toSecondOfDay() - systemTime.toSecondOfDay(); + int actual = nextFirstStationPlan.getLeaveTime().toSecondOfDay() - systemTime.toSecondOfDay(); + if (actual > parkTime) { + parkTime = actual; + } } + } else { + // 头码车和人工车,取默认站台停站时间 + parkTime = 30; } } - if (parkTime < 10) { - // 头码车和人工车默认给25s - parkTime = 25; - } LocalTime leaveTime = systemTime.plusSeconds(parkTime); train.updateEstimatedLeaveInfo(section, leaveTime); this.atsStandService.updateStandParkTime(section, parkTime); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java index faddc50f8..b2f56b4ba 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -10,6 +10,8 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.*; import club.joylink.rtss.services.org.IOrgService; import club.joylink.rtss.services.org.IOrgUserService; +import club.joylink.rtss.services.runplan.IRunPlanParktimeService; +import club.joylink.rtss.services.runplan.IRunPlanRunlevelService; import club.joylink.rtss.services.script.IScriptService; import club.joylink.rtss.services.script.IScriptSimulationService; import club.joylink.rtss.services.simulation.SchedulingService; @@ -54,6 +56,8 @@ import club.joylink.rtss.vo.client.map.MapVO; import club.joylink.rtss.vo.client.map.newmap.MapStationNewVO; import club.joylink.rtss.vo.client.project.ProjectDeviceVO; import club.joylink.rtss.vo.client.runplan.*; +import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; import club.joylink.rtss.vo.client.script.ScriptVO; import club.joylink.rtss.vo.client.simulationv1.*; @@ -80,82 +84,60 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { @Autowired private ApplicationContext applicationContext; - @Autowired private IMapService iMapService; - @Autowired private ICommandService iCommandService; - @Autowired private ILoadPlanService iLoadPlanService; - @Autowired private IRunPlanTemplateService iRunPlanTemplateService; - @Autowired private SchedulingService schedulingService; - @Autowired private GroupSimulationCache groupSimulationCache; - @Autowired private SimulationLifeCycleService simulationLifeCycleService; - @Autowired private AtsOperationDispatcher atsOperationDispatcher; - @Autowired private AtsTrainLoadService atsTrainLoadService; - @Autowired private ATSMessageCollectAndDispatcher atsMessageCollectAndDispatcher; - @Autowired private MemberManager memberManager; - @Autowired private ITrainingV1Service iTrainingV1Service; - @Autowired private IExamService iExamService; - @Autowired private ILessonService iLessonService; - @Autowired private StompMessageService stompMessageService; - @Autowired private IScriptService iScriptService; - @Autowired private OtherConfig otherConfig; - @Autowired private WeChatConfig weChatConfig; - @Autowired private IScriptSimulationService iScriptSimulationService; - @Autowired private SimulationRealDeviceConnectManager simulationRealDeviceConnectManager; - @Autowired private PassengerFlowSimulateService passengerFlowSimulateService; - @Autowired private IOrgUserService iOrgUserService; - @Autowired private IUserPermissionService iUserPermissionService; - @Autowired private IOrgService iOrgService; - @Autowired private SimulationManager simulationManager; - + @Autowired + private IRunPlanRunlevelService iRunPlanRunlevelService; + @Autowired + private IRunPlanParktimeService iRunPlanParktimeService; // /** // * 创建仿真并进行缓存 // * @@ -223,8 +205,26 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { Simulation.FunctionalType functionalType) { Objects.requireNonNull(mapId, "地图id不能为空"); Objects.requireNonNull(functionalType, "仿真功能类型不能为空"); + SimulationBuildParams params = this.prepareSimulationParams(loginUserInfoVO, mapId, + prdType, functionalType); + String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getUserVO().getId(), mapId); + Simulation simulation = this.simulationLifeCycleService.create(params, group); + // 添加仿真成员 + SimulationUser simulationUser = new SimulationUser(simulation, loginUserInfoVO); + simulation.addSimulationUser(simulationUser); + // 根据仿真产品类型,设置用户扮演角色 + memberManager.playRoleBySimulationType(simulation, loginUserInfoVO.getUserVO().getId()); + // 仿真开始运行 + this.simulationManager.start(simulation.getId()); + return simulation; + } + + private SimulationBuildParams prepareSimulationParams(LoginUserInfoVO loginUserInfoVO, Long mapId, + MapPrdTypeEnum prdType, Simulation.FunctionalType functionalType) { // 获取地图数据 MapVO mapVO = this.iMapService.getMapDetail(mapId); + List runLevelList = this.prepareRunLevelData(mapVO, loginUserInfoVO, mapId); + List parkTimeList = this.prepareParkTimeData(mapVO, loginUserInfoVO, mapId); // 获取操作定义数据 List operationDefinitionList = this.iCommandService .queryDefinitionsByLineCode(mapVO.getLineCode()); @@ -233,6 +233,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { builder.loginUserInfo(loginUserInfoVO) .createTime(LocalDateTime.now()) .map(mapVO) + .userRunLevelList(runLevelList) + .userParkTimeList(parkTimeList) .operationDefinitionList(operationDefinitionList) .prodType(prdType) .functionalType(functionalType); @@ -252,16 +254,27 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { builder.schedulingPlan(schedulingPlanNewVO); } SimulationBuildParams params = builder.build(); - String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getUserVO().getId(), mapId); - Simulation simulation = this.simulationLifeCycleService.create(params, group); - // 添加仿真成员 - SimulationUser simulationUser = new SimulationUser(simulation, loginUserInfoVO); - simulation.addSimulationUser(simulationUser); - // 根据仿真产品类型,设置用户扮演角色 - memberManager.playRoleBySimulationType(simulation, loginUserInfoVO.getUserVO().getId()); - // 仿真开始运行 - this.simulationManager.start(simulation.getId()); - return simulation; + return params; + } + + private List prepareParkTimeData(MapVO mapVO, LoginUserInfoVO loginUserInfoVO, Long mapId) { + List runPlanParkingTimeVOList = this.iRunPlanParktimeService.queryUserParktimes(loginUserInfoVO.getUserVO().getId(), mapId); + return runPlanParkingTimeVOList; + } + + private List prepareRunLevelData(MapVO mapVO, LoginUserInfoVO loginUserInfoVO, Long mapId) { + List runLevelList = this.iRunPlanRunlevelService.queryUserRunLevels(loginUserInfoVO.getUserVO().getId(), mapId); + return runLevelList; +// List stationRunLevelVOList = RunPlanRunlevelVO.convert2StationRunPlanVOList(runLevelList); +// List defaultRunLevelList = mapVO.getLogicDataNew().getRunLevelList(); +// Map runLevelVOMap = new HashMap<>(); +// for (MapStationRunLevelVO vo : stationRunLevelVOList) { +// runLevelVOMap.put(vo.buildCode(), vo); +// } +// for (MapStationRunLevelVO vo : defaultRunLevelList) { +// runLevelVOMap.putIfAbsent(vo.buildCode(), vo); +// } +// mapVO.getLogicDataNew().setRunLevelList(new ArrayList<>(runLevelVOMap.values())); } @Override diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java index 8d3642fea..a6573efc2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java @@ -10,6 +10,7 @@ import club.joylink.rtss.vo.client.map.MapTrainModelVO; import club.joylink.rtss.vo.client.map.MapTrainVO; import club.joylink.rtss.vo.client.map.MapZcVO; import club.joylink.rtss.vo.client.map.newmap.*; +import lombok.extern.slf4j.Slf4j; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -20,6 +21,7 @@ import java.util.stream.Collectors; /** * 地图设备校验/构建器 */ +@Slf4j public class MapDeviceBuilder { /** @@ -744,6 +746,119 @@ public class MapDeviceBuilder { buildCatenary(graphData, elementMap, errMsgList, mapDataBuildResult.getCatenaryMap()); //应答器 buildResponderDataRef(graphData, elementMap, errMsgList, mapDataBuildResult.getSectionRespondersMap()); + if (mapDataBuildResult.getErrMsgList().isEmpty()) { + Map> sectionArriveMap = buildNormalStandTrackAdjoinSections(mapDataBuildResult.getDeviceMap()); + mapDataBuildResult.setSectionArriveNearMap(sectionArriveMap); + } + } + + public static Map> buildNormalStandTrackAdjoinSections(Map deviceMap) { + List
standTrackList = deviceMap.values().stream() + .filter(mapElement -> mapElement.getDeviceType().equals(MapElement.DeviceType.SECTION)) + .map(mapElement -> ((Section) mapElement)) + .filter(section -> section.isNormalStandTrack() || section.isTransferTrack() || section.isTurnBackTrack()) + .collect(Collectors.toList()); + Map> sectionDirectionSectionsMap = new HashMap<>(); + for (Section section : standTrackList) { + Set
rightDirectionList = new HashSet<>(); + sectionDirectionSectionsMap.put(buildSectionDirectionKey(section, true), rightDirectionList); + queryAdjoinSections(section, true, rightDirectionList); + Set
leftDirectionList = new HashSet<>(); + sectionDirectionSectionsMap.put(buildSectionDirectionKey(section, false), leftDirectionList); + queryAdjoinSections(section, false, leftDirectionList); + log.debug(String.format("区段[%s][右向]邻接区段为[%s],[左向]邻接区段为[%s]", + section.debugStr(), + String.join(",",rightDirectionList.stream().map(Section::debugStr).collect(Collectors.toList())), + String.join(",", leftDirectionList.stream().map(Section::debugStr).collect(Collectors.toList())))); + } + return sectionDirectionSectionsMap; + } + + private static String buildSectionDirectionKey(Section section, boolean right) { + return String.format("%s-%s", section.getCode(), right?"R":"L"); + } + + /** + * 查找区段临近的功能区段(站台轨、转换轨、折返轨) + * @param section + * @param right + * @param rightDirectionList + */ + private static void queryAdjoinSections(Section section, boolean right, Set
rightDirectionList) { + Signal signal = section.getSignalOf(right); + if (signal == null) { + Section base = section; + for (int i = 0; i < 10; i++) { + Section next = base.getSectionOf(right); + if (next == null) { // 可能到尽头了 + return; + } + if (checkAdjoinSectionAndAdd(next, rightDirectionList)) { + return; + } + signal = next.getSignalOf(right); + if (signal != null) { + break; + } + base = next; + } + } + if (signal == null) { + return; + } + queryAdjoinSections(signal, rightDirectionList); + } + + private static void queryAdjoinSections(Signal signal, Set
rightDirectionList) { + boolean right = signal.isRight(); + List routeList = signal.getRouteList(); + if (CollectionUtils.isEmpty(routeList)) { // 没有进路,找自动信号 + AutoSignal autoSignal = signal.getAutoSignal(); + if (autoSignal == null) { + return; + } + List
sectionList = autoSignal.getSectionList(); + for (Section temp : sectionList) { + if (checkAdjoinSectionAndAdd(temp, rightDirectionList)) { + return; + } + signal = temp.getSignalOf(right); + if (signal != null) { + queryAdjoinSections(signal, rightDirectionList); + } + } + } else { + Set queryList = new HashSet<>(); + for (Route route : routeList) { + if (route.isAtp() || route.isGuide()) { + continue; + } + List
sectionList = route.getSectionList(); + boolean finish = false; + for (Section section : sectionList) { + if (checkAdjoinSectionAndAdd(section, rightDirectionList)) { + finish = true; + break; + } + } + if (!finish) { + queryList.add(route.getDestination()); + } + } + for (Signal next : queryList) { + queryAdjoinSections(next, rightDirectionList); + } + } + } + + private static boolean checkAdjoinSectionAndAdd(Section temp, Set
rightDirectionList) { + if (temp.isStandTrack() || temp.isTransferTrack()) { + rightDirectionList.add(temp); + return true; + } else if (temp.isTurnBackTrack()) { + rightDirectionList.add(temp); + } + return false; } private static void checkSectionFunctionType(Map deviceMap, List errMsgList) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuildParams.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuildParams.java index aa9a527fc..0595fd9e3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuildParams.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuildParams.java @@ -1,15 +1,17 @@ package club.joylink.rtss.simulation.cbtc.build; +import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.CommandDefinitionVO; import club.joylink.rtss.vo.client.LessonVO; import club.joylink.rtss.vo.client.map.MapVO; import club.joylink.rtss.vo.client.runplan.RunPlanVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; import lombok.Builder; import lombok.Getter; @@ -34,7 +36,8 @@ public class SimulationBuildParams { /** 地图数据 */ private MapVO map; - + private List userRunLevelList; + private List userParkTimeList; /** 仿真产品类型 */ private MapPrdTypeEnum prodType; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java index 6e1770037..abe0ee7e6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java @@ -52,14 +52,17 @@ public class SimulationBuilder { simulation.addDataErrMsgs(mapDataBuildResult.getErrMsgList()); } simulation.getRepository().setDeviceMap(mapDataBuildResult.getDeviceMap()); + simulation.getRepository().setSectionArriveNearMap(mapDataBuildResult.sectionArriveNearMap); simulation.getRepository().setVrDeviceMap(mapDataBuildResult.getVrDeviceMap()); // simulation.getRepository().setRouteUnitMap(mapDataBuildResult.getRouteUnitMap()); simulation.getRepository().setRoutePathMap(mapDataBuildResult.getRoutePathMap()); simulation.getRepository().setDestinationMap(mapDataBuildResult.getDestinationMap()); simulation.getRepository().setRoutingList(mapDataBuildResult.getRoutingList()); - simulation.getRepository().setRunLevelList(mapDataBuildResult.getRunLevelList()); +// simulation.getRepository().setRunLevelList(mapDataBuildResult.getRunLevelList()); simulation.getRepository().getCatenaryMap().putAll(mapDataBuildResult.getCatenaryMap()); simulation.getRepository().getSectionRespondersMap().putAll(mapDataBuildResult.getSectionRespondersMap()); + UserConfigDataBuilder.buildUserRunLevel(simulation.getRepository(), buildParams.getUserRunLevelList()); + UserConfigDataBuilder.buildUserParkTime(simulation.getRepository(), buildParams.getUserParkTimeList()); // 加载运行图 checkAndLoadRunPlan(simulation, buildParams.getRunPlan()); // 加载派班计划 @@ -348,6 +351,8 @@ public class SimulationBuilder { private Map> sectionRespondersMap; + @Setter + Map> sectionArriveNearMap; /** * 数据错误信息列表 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/UserConfigDataBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/UserConfigDataBuilder.java new file mode 100644 index 000000000..36b93591f --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/UserConfigDataBuilder.java @@ -0,0 +1,44 @@ +package club.joylink.rtss.simulation.cbtc.build; + +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.Section; +import club.joylink.rtss.simulation.cbtc.data.map.Station; +import club.joylink.rtss.simulation.cbtc.data.map.StationParkTime; +import club.joylink.rtss.simulation.cbtc.data.map.StationRunLevel; +import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class UserConfigDataBuilder { + public static void buildUserRunLevel(SimulationDataRepository repository, List userRunLevelList) { + Map runLevelMap = new HashMap<>(); + for (RunPlanRunlevelVO vo : userRunLevelList) { + Station startStation = repository.getByCode(vo.getStartStationCode(), Station.class); + Section startSection = repository.getByCode(vo.getStartSectionCode(), Section.class); + Station endStation = repository.getByCode(vo.getEndStationCode(), Station.class); + Section endSection = repository.getByCode(vo.getEndSectionCode(), Section.class); + StationRunLevel stationRunLevel = new StationRunLevel(); + stationRunLevel.setStartStation(startStation); + stationRunLevel.setStartSection(startSection); + stationRunLevel.setEndStation(endStation); + stationRunLevel.setEndSection(endSection); + stationRunLevel.setRight(vo.getRight()); + stationRunLevel.setDistance(vo.getDistance()); + stationRunLevel.setL1(vo.getL1()); + stationRunLevel.setL2(vo.getL2()); + stationRunLevel.setL3(vo.getL3()); + stationRunLevel.setL4(vo.getL4()); + stationRunLevel.setL5(vo.getL5()); + runLevelMap.putIfAbsent(stationRunLevel.buildKey(), stationRunLevel); + } + repository.setRunLevelMap(runLevelMap); + } + + public static void buildUserParkTime(SimulationDataRepository repository, List userParkTimeList) { + Map parkTimeMap = new HashMap<>(); + + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java index 0c0ec9639..5e621bbbf 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java @@ -139,8 +139,18 @@ public class SimulationDataRepository { /** * 站间运行等级列表 + * key-startSectionCode-endSectionCode + * val-runLevel */ - private List runLevelList; + private Map runLevelMap; + /** + * key-sectionCode + */ + private Map parkTimeMap; + /** + * key-sectionCode-(R/L) R:右向,L:左向 + */ + Map> sectionArriveNearMap; /** * 终端/折返车站-终端发车计划map 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 6531015b2..71c051b2c 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 @@ -231,6 +231,7 @@ public class MapConfig { setRouteSettingNoFail(configVO.isRouteSettingNoFail()); setSignalOpenAfterParking(configVO.isSignalOpenAfterParking()); this.setStandHoldCloseLogicLight(configVO.isStandHoldCloseLogicLight()); + this.setAtsAutoHandleManualFrontTurnBack(configVO.isAtsAutoHandleManualFrontTurnBack()); setCtcOverlapOnlyTurnBackStationLock(configVO.isCtcOverlapOnlyTurnBackStationLock()); this.setGuideNeedRouteSettingFirst(configVO.isGuideNeedRouteSettingFirst()); setSwitchSingleHandle(configVO.getSwitchSingleHandle()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationParkTime.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationParkTime.java new file mode 100644 index 000000000..86d1f3c10 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationParkTime.java @@ -0,0 +1,7 @@ +package club.joylink.rtss.simulation.cbtc.data.map; + +import lombok.Getter; + +@Getter +public class StationParkTime { +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationRunLevel.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationRunLevel.java index 1a07f16b3..3dabdb3b5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationRunLevel.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationRunLevel.java @@ -50,4 +50,8 @@ public class StationRunLevel { startStation.getName(), startSection.getName(), endStation.getName(), endSection.getName()); } + + public String buildKey() { + return String.format("%s-%s", this.startSection.getCode(), this.endSection.getCode()); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/job/SimulationFixedJob.java b/src/main/java/club/joylink/rtss/simulation/job/SimulationFixedJob.java index 2195c884d..29d224c18 100644 --- a/src/main/java/club/joylink/rtss/simulation/job/SimulationFixedJob.java +++ b/src/main/java/club/joylink/rtss/simulation/job/SimulationFixedJob.java @@ -19,7 +19,7 @@ public final class SimulationFixedJob extends SimulationScheduledJob { LocalDateTime systemTime = simulation.getSystemTime(); // 实际运行间隔,单位ns long runPeriod = TimeUnit.MILLISECONDS.toNanos(this.rate) * simulation.getSpeed(); - // 弥补非整数倍的情况 + // 弥补非整数倍的情况.PS:只能弥补运行频率大于仿真基础运行频率的情况 long l = Duration.between(this.runtime, systemTime).toNanos(); long l1 = l % runPeriod; long add = runPeriod - l1; diff --git a/src/main/java/club/joylink/rtss/simulation/job/SimulationScheduledJob.java b/src/main/java/club/joylink/rtss/simulation/job/SimulationScheduledJob.java index d32ba444a..8c801cf82 100644 --- a/src/main/java/club/joylink/rtss/simulation/job/SimulationScheduledJob.java +++ b/src/main/java/club/joylink/rtss/simulation/job/SimulationScheduledJob.java @@ -39,7 +39,7 @@ public class SimulationScheduledJob extends SimulationJob { LocalDateTime systemTime = simulation.getSystemTime(); // 实际运行间隔,单位ns long runPeriod = TimeUnit.MILLISECONDS.toNanos(this.rate); - // 弥补非整数倍的情况 + // 弥补非整数倍的情况.PS:只能弥补运行频率大于仿真基础运行频率的情况 long l = Duration.between(this.runtime, systemTime).toNanos(); long l1 = l % runPeriod; long add = runPeriod - l1; diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapLogicDataNewVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapLogicDataNewVO.java index c2af8b2d6..d950bbe63 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapLogicDataNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapLogicDataNewVO.java @@ -1,10 +1,15 @@ package club.joylink.rtss.vo.client.map.newmap; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; @Getter @@ -26,6 +31,12 @@ public class MapLogicDataNewVO { @ApiModelProperty(value = "站间运行等级列表") private List runLevelList; + /** + * 停站时间列表 + */ + private List parkTimeList; + + @Deprecated @ApiModelProperty(value = "车站区段停站时间列表") private List parkingTimeList; @@ -53,4 +64,12 @@ public class MapLogicDataNewVO { this.overlapList = new ArrayList<>(); this.autoReentryList = new ArrayList<>(); } + + @JsonIgnore + public MapRoutingDataVO getLongestRouting() { + BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(this.routingList); + this.routingList.sort(Comparator.comparing(routingVO -> routingVO.getParkSectionCodeList().size())); + Collections.reverse(this.routingList); + return routingList.get(0); + } } diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapStationRunLevelVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapStationRunLevelVO.java index b76bbd952..d12b4b5a3 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapStationRunLevelVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapStationRunLevelVO.java @@ -1,11 +1,12 @@ package club.joylink.rtss.vo.client.map.newmap; -import com.fasterxml.jackson.annotation.JsonIgnore; import club.joylink.rtss.entity.DraftMapRunLevel; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.client.map.newmap.validate.RunLevelCreateCheck; import club.joylink.rtss.vo.client.map.newmap.validate.RunLevelGenerateCheck; import club.joylink.rtss.vo.client.map.newmap.validate.RunLevelUpdateCheck; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; @@ -80,6 +81,21 @@ public class MapStationRunLevelVO { @PositiveOrZero private Integer l5; + public MapStationRunLevelVO(RunPlanRunlevelVO runPlanRunlevelVO) { + this.mapId = runPlanRunlevelVO.getMapId(); + this.startStationCode = runPlanRunlevelVO.getStartStationCode(); + this.startSectionCode = runPlanRunlevelVO.getStartSectionCode(); + this.endStationCode = runPlanRunlevelVO.getEndStationCode(); + this.endSectionCode = runPlanRunlevelVO.getEndSectionCode(); + this.right = runPlanRunlevelVO.getRight(); + this.distance = runPlanRunlevelVO.getDistance(); + this.l1 = runPlanRunlevelVO.getL1(); + this.l2 = runPlanRunlevelVO.getL2(); + this.l3 = runPlanRunlevelVO.getL3(); + this.l4 = runPlanRunlevelVO.getL4(); + this.l5 = runPlanRunlevelVO.getL5(); + } + public static List convert2VOList(List list) { List voList = new ArrayList<>(); if (!CollectionUtils.isEmpty(list)) { @@ -134,11 +150,11 @@ public class MapStationRunLevelVO { public void generateDefaultRunLevel() { Objects.requireNonNull(this.distance, "站间距离不能为空"); - this.l1 = Math.round(this.distance / 12f); - this.l2 = Math.round(this.distance / 10.5f); - this.l3 = Math.round(this.distance / 9f); - this.l4 = Math.round(this.distance / 7.5f); - this.l5 = Math.round(this.distance / 6f); + this.l1 = Math.round(this.distance / 18f); + this.l2 = Math.round(this.distance / 16f); + this.l3 = Math.round(this.distance / 13.5f); + this.l4 = Math.round(this.distance / 12f); + this.l5 = Math.round(this.distance / 10f); } @Override diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java index 6e78869a8..40f923aff 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java @@ -1,10 +1,7 @@ package club.joylink.rtss.vo.client.runplan.user; import club.joylink.rtss.entity.RunPlanRunlevel; -import club.joylink.rtss.simulation.cbtc.data.map.MapElement; -import club.joylink.rtss.simulation.cbtc.data.map.Section; -import club.joylink.rtss.vo.client.map.newmap.MapRoutingDataVO; -import club.joylink.rtss.vo.client.map.newmap.MapRoutingSectionNewVO; +import club.joylink.rtss.vo.client.map.newmap.MapStationRunLevelVO; import club.joylink.rtss.vo.client.map.newmap.validate.RunLevelCreateCheck; import club.joylink.rtss.vo.client.map.newmap.validate.RunLevelGenerateCheck; import club.joylink.rtss.vo.client.map.newmap.validate.RunLevelUpdateCheck; @@ -21,7 +18,6 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.PositiveOrZero; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Objects; @ApiModel(value = "运行计划站间运行等级") @@ -119,6 +115,16 @@ public class RunPlanRunlevelVO { return runLevelVO; } + public static List convert2StationRunPlanVOList(List runLevelList) { + List voList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(runLevelList)) { + for (RunPlanRunlevelVO runPlanRunlevelVO : runLevelList) { + voList.add(new MapStationRunLevelVO(runPlanRunlevelVO)); + } + } + return voList; + } + public RunPlanRunlevel convert2Entity() { RunPlanRunlevel runLevel = new RunPlanRunlevel(); runLevel.setId(id);