From ada9bc6fd81320c9f049a745f6c4f6aa64b0a758 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 1 Mar 2021 16:41:11 +0800 Subject: [PATCH 01/24] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/services/SysUserService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/SysUserService.java b/src/main/java/club/joylink/rtss/services/SysUserService.java index cc376ef83..fa71bba74 100644 --- a/src/main/java/club/joylink/rtss/services/SysUserService.java +++ b/src/main/java/club/joylink/rtss/services/SysUserService.java @@ -315,9 +315,9 @@ public class SysUserService implements ISysUserService { @Transactional public CompanyVO userScanCodeBindCompanyManager(Long userId, Integer companyId) { Org company = companyDAO.selectByPrimaryKey(companyId); - BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(company, "不存在此单位"); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(company, String.format("id为[%s]的组织不存在", companyId)); SysUser sysUser = sysUserDAO.selectByPrimaryKey(userId); - BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(sysUser, "不存在的用户"); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(sysUser, String.format("id为[%s]的用户不存在", userId)); UserVO userVO = new UserVO(sysUser); userBindCompanyManager(userVO, companyId); this.loginSessionManager.updateLoginUser(userVO); From 4b4b30ad9bea6bf105b4cd9dbaafc73a931053af Mon Sep 17 00:00:00 2001 From: DU Date: Mon, 1 Mar 2021 17:36:05 +0800 Subject: [PATCH 02/24] =?UTF-8?q?=E4=B8=8B=E6=9E=B6=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/club/joylink/rtss/services/MapSystemService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/MapSystemService.java b/src/main/java/club/joylink/rtss/services/MapSystemService.java index 1dd77b69f..89808cd44 100644 --- a/src/main/java/club/joylink/rtss/services/MapSystemService.java +++ b/src/main/java/club/joylink/rtss/services/MapSystemService.java @@ -232,12 +232,12 @@ public class MapSystemService implements IMapSystemService { } - //默认课程展示 // BusinessConsts.Lesson.PrdInfo prdInfo = BusinessConsts.Lesson.PrdInfo.getBy(mapSystem.getPrdType()); // if (Objects.nonNull(prdInfo)) { // String defaultLessonName = String.join("-", mapVO.getName(), prdInfo.getName()); - LessonVO existedDefaultLesson = iLessonService.findSysFaultByMapAndPrdType(mapSystem.getMapId(), mapSystem.getPrdType()); - if (Objects.nonNull(existedDefaultLesson)) { + //默认课程展示 + LessonVO existedDefaultLesson = iLessonService.findSysFaultByMapAndPrdType(mapSystem.getMapId(), mapSystem.getPrdType()); + if (Objects.nonNull(existedDefaultLesson) && Objects.equals(MapStatus.Online.getCode(),existedDefaultLesson.getStatus())) { if (lessonVOList.stream().noneMatch(lessonVO -> lessonVO.getId().equals(existedDefaultLesson.getId()))) { // existedDefaultLesson.setSystemFault(true); lessonVOList.add(existedDefaultLesson); From 09298761bf80a2946104bd0947c73ef6c00230a1 Mon Sep 17 00:00:00 2001 From: DU Date: Mon, 1 Mar 2021 19:09:24 +0800 Subject: [PATCH 03/24] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E6=95=99=E5=AD=A6=E6=88=90=E7=BB=A9=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=AD=A6=E5=8F=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../training/generatornew/GeneratorNew.java | 4 +- .../base/SpeedLimitGeneratorNew.java | 74 ++++++++++++++++--- .../base/StationGeneratorNew.java | 26 ++++++- .../cbtc/ATS/operation/Operation.java | 2 +- .../handler/StandOperateHandler.java | 6 +- .../handler/StationOperateHandler.java | 2 +- .../simulation/cbtc/CI/CiApiServiceImpl.java | 7 +- .../cbtc/build/MapDeviceBuilder.java | 8 ++ .../rtss/simulation/cbtc/data/map/Signal.java | 5 ++ .../vo/client/student/ExportStudentInfo.java | 11 +++ 10 files changed, 125 insertions(+), 20 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java index b814f6e68..e07fe7b80 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java @@ -185,7 +185,7 @@ public interface GeneratorNew { * @param string * @return */ - private boolean containPlaceholder(String string) { + default boolean containPlaceholder(String string) { if (StringUtils.hasText(string)) { return Pattern.matches(".*\\{\\d+}.*", string); } @@ -200,7 +200,7 @@ public interface GeneratorNew { * @param mapDevice * @return */ - private String replacePlaceholder(String str, Map placeholderVOMap, MapElement mapDevice, Object mapButton, MapVO map) { + default String replacePlaceholder(String str, Map placeholderVOMap, MapElement mapDevice, Object mapButton, MapVO map) { Pattern pattern = Pattern.compile(".*?(\\{(\\d+)}).*?"); Matcher matcher = pattern.matcher(str); while (matcher.find()) { diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SpeedLimitGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SpeedLimitGeneratorNew.java index e2e15ff99..17d5bdaf0 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SpeedLimitGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SpeedLimitGeneratorNew.java @@ -1,35 +1,89 @@ package club.joylink.rtss.services.training.generatornew.base; +import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.services.training.constant.TrainingConsts; import club.joylink.rtss.services.training.data.GenerateConfig; import club.joylink.rtss.services.training.generatornew.GeneratorNew; import club.joylink.rtss.services.training.generatornew.annotation.GeneratorSelectorNew; +import club.joylink.rtss.simulation.cbtc.ATP.ground.TempSpeedLimitService; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.map.*; +import club.joylink.rtss.simulation.cbtc.data.storage.StorageSimulation; +import club.joylink.rtss.vo.client.map.MapTempSpeedLimitVO; +import club.joylink.rtss.vo.client.map.newmap.MapAutomaticRouteButtonVO; +import club.joylink.rtss.vo.client.map.newmap.MapCycleButtonVO; +import club.joylink.rtss.vo.client.map.newmap.MapTotalGuideLockButtonVO; +import club.joylink.rtss.vo.client.map.newmap.MapTurnBackStrategyVO; +import club.joylink.rtss.vo.client.training.TrainingStepVO; import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; import club.joylink.rtss.vo.client.training.TrainingNewVO; +import club.joylink.rtss.vo.client.training.definition.OperatePlaceholderVO; +import club.joylink.rtss.vo.client.training.definition.OperateStepVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import javax.validation.Valid; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.Objects; -@GeneratorSelectorNew(operateObject = Operation.Object.WholeLineTempSpeedLimit) +@GeneratorSelectorNew(operateObject = Operation.Object.LimitControl) public class SpeedLimitGeneratorNew implements GeneratorNew { private final static int LIMIT_SPEED = 30; + @Autowired + private TempSpeedLimitService tempSpeedLimitService; @Override public List generate(GenerateConfig config, Simulation simulation, OperateDefinitionVO operateDefinitionVO) { List trainingVOList = new ArrayList<>(); - //TODO -// simulation.getRepository().getSectionList() -// tempLimitSpeedList.forEach(tempLimitSpeed -> { -// switch (Operation.Type.valueOf (operateDefinitionVO.getOperateType())) { -// case Cancel_Whole_Line_Temp_Speed_Limit: // 取消全线临时限速 -// trainingVOList.add(cancelWholeLineTempSpeedLimit(tempLimitSpeed, config, simulation, operateDefinitionVO)); -// break; -// } -// }); + simulation.getRepository().getSectionList().forEach(section -> tempSpeedLimitService.setSectionLimitSpeed(simulation, section, LIMIT_SPEED)); + switch (Operation.Type.valueOf(operateDefinitionVO.getOperateType())) { + case Cancel_All_Limit_Speed: // 取消全线临时限速 + List tempSpeedLimitList = simulation.getBuildParams().getMap().getGraphDataNew().getTempSpeedLimitList(); + tempSpeedLimitList.forEach(mapTempSpeedLimitVO -> { + trainingVOList.add(this.build(config, simulation,null,mapTempSpeedLimitVO, operateDefinitionVO)); + simulation.reset(); + }); + break; + } return trainingVOList; } + @Override + public TrainingNewVO build(GenerateConfig config, Simulation simulation, MapElement nullableDevice, Object mapButton, OperateDefinitionVO operateDefinitionVO) { + // 实训基本信息 + TrainingNewVO trainingVO = new TrainingNewVO(config, operateDefinitionVO); + // 设置每一步操作的设备 + List stepList = operateDefinitionVO.getStepVOList(); + stepList.get(0).setDeviceCode(((MapTempSpeedLimitVO) mapButton).getCode()); + Map placeholderVOMap = operateDefinitionVO.getPlaceholderVOMap(); + // 设置定位 + trainingVO.setLocateDeviceCode(((MapTempSpeedLimitVO) mapButton).getCode()); + // 替换占位符 + if (containPlaceholder(trainingVO.getName())) { + trainingVO.setName(replacePlaceholder(trainingVO.getName(), placeholderVOMap, nullableDevice, mapButton, simulation.getBuildParams().getMap())); + } + if (containPlaceholder(trainingVO.getRemarks())) { + trainingVO.setRemarks(replacePlaceholder(trainingVO.getRemarks(), placeholderVOMap, nullableDevice, mapButton, simulation.getBuildParams().getMap())); + } + // 添加步骤 + List steps = new ArrayList<>(stepList.size()); + stepList.forEach(operateStepVO -> { + TrainingStepVO stepVO = new TrainingStepVO(operateStepVO); + if (containPlaceholder(stepVO.getTip())) { + stepVO.setTip(replacePlaceholder(stepVO.getTip(), placeholderVOMap, nullableDevice, mapButton, simulation.getBuildParams().getMap())); + } + if (containPlaceholder(stepVO.getVal())) { + stepVO.setVal(replacePlaceholder(stepVO.getVal(), placeholderVOMap, nullableDevice, mapButton, simulation.getBuildParams().getMap())); + } + steps.add(stepVO); + }); + trainingVO.setSteps(steps); + trainingVO.setScenes(new StorageSimulation(simulation, false)); + return trainingVO; + } } diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/StationGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/StationGeneratorNew.java index ffb84547a..97c71a179 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/StationGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/StationGeneratorNew.java @@ -1,5 +1,6 @@ package club.joylink.rtss.services.training.generatornew.base; +import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.services.training.data.GenerateConfig; import club.joylink.rtss.services.training.generatornew.GeneratorNew; import club.joylink.rtss.services.training.generatornew.annotation.GeneratorSelectorNew; @@ -76,7 +77,8 @@ public class StationGeneratorNew implements GeneratorNew { } break; case Station_CIArea_Close_AllSignal: - station.setControlMode(Station.ControlMode.Center); + if(!station.isInterlock())continue; + station.getDeviceStation().setControlMode(Station.ControlMode.Center); // simulation.getRepository().getSignalList().stream() // .filter(s -> Objects.equals(station.getCode(), s.getInterlockStation().getCode())) // .forEach(signal -> { @@ -86,7 +88,13 @@ public class StationGeneratorNew implements GeneratorNew { // }); break; case Station_Close_AllSignal: - station.setControlMode(Station.ControlMode.Local); + if (BusinessConsts.MapPrd.PrdType.Type01.equals(config.getPrdType())) { + if(station.isCentralized()) { + station.setControlMode(Station.ControlMode.Local); + }else{ + station.getDeviceStation().setControlMode(Station.ControlMode.Local); + } + } // simulation.getRepository().getSignalList().stream() // .filter(s -> Objects.equals(station.getCode(), s.getDeviceStation().getCode())) // .forEach(signal -> { @@ -99,7 +107,7 @@ public class StationGeneratorNew implements GeneratorNew { if(!station.isTurnBack()) { continue; } - station.setControlMode(Station.ControlMode.Center); + station.getDeviceStation().setControlMode(Station.ControlMode.Center); if(operateDefinitionVO.turnBackStrategyButton()){ simulation.getBuildParams().getMap().getGraphDataNew().getTbStrategyList() .stream().filter(turnBackStrategyO -> turnBackStrategyO.getStationCode().equals(station.getCode())) @@ -115,7 +123,7 @@ public class StationGeneratorNew implements GeneratorNew { continue; } station.setControlMode(Station.ControlMode.Local); - station.setRestartTime(LocalTime.now()); + station.setRestartTime(LocalTime.of(2,0)); List
sections = simulation.getRepository().getSectionList(); sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), station)).forEach(section -> section.setFaultLock(true)); break; @@ -203,6 +211,16 @@ public class StationGeneratorNew implements GeneratorNew { }); } continue; + case Station_Set_Or_Cancel_Force_Physical_Signal: + if(!station.isInterlock())continue; + if (BusinessConsts.MapPrd.PrdType.Type01.equals(config.getPrdType())) { + if(station.isCentralized()) { + station.setControlMode(Station.ControlMode.Local); + }else{ + station.getDeviceStation().setControlMode(Station.ControlMode.Local); + } + } + break; default: // 其他操作,不生成 continue; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index d50946d09..7f383218d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -395,7 +395,7 @@ public class Operation { /** 集中站 */ Station, /**全线临时限速*/ - WholeLineTempSpeedLimit + LimitControl } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StandOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StandOperateHandler.java index b90391f8a..6d46c0ace 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StandOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StandOperateHandler.java @@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; +import java.util.Objects; @Slf4j @OperateHandler @@ -170,7 +171,10 @@ public class StandOperateHandler { * 区间列车数量限制 */ @OperateHandlerMapping(type = Operation.Type.Stand_Set_Hold_Train_Auto) - public void setHoldTrainAuto(Simulation simulation, String standCode, int limit) { + public void setHoldTrainAuto(Simulation simulation, String standCode, Integer limit) { + if (Objects.isNull(limit)) { + limit = 0; + } atsStandService.setAutoHoldTrainLimit(simulation, standCode, limit); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java index b103d233c..ea23f0244 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java @@ -179,7 +179,7 @@ public class StationOperateHandler { @OperateHandlerMapping(type = Operation.Type.Station_Close_AllSignal) public void closeAllSignal(Simulation simulation, String stationCode){ SimulationDataRepository repository = simulation.getRepository(); - repository.getSignalList().stream().filter(s -> Objects.equals(stationCode,s.getDeviceStation().getCode())).forEach(signal -> ciApiService.blockadeSignal(simulation, signal.getCode())); + repository.getSignalList().stream().filter(s -> Objects.equals(stationCode,s.getStation().getCode())).forEach(signal -> ciApiService.blockadeSignal(simulation, signal.getCode())); } /**关区信号*/ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java index 98e6b8091..6419bed24 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java @@ -517,9 +517,14 @@ public class CiApiServiceImpl implements CiApiService { station = station.getDeviceStation(); } Station deviceStation = station; - if (Objects.nonNull(deviceStation.getRestartTime()) && deviceStation.getRestartTime().plusMinutes(8).isBefore(LocalTime.now())) { + if (Objects.nonNull(deviceStation.getRestartTime()) + && deviceStation.getRestartTime().isBefore(LocalTime.now()) + && ((Simulation.FunctionalType.LESSON.equals(simulation.getBuildParams().getFunctionalType()) + ||Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType())) + ?true: deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()))) { List
sections = simulation.getRepository().getSectionList(); sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock); + return; } throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无效操作或连锁机重启过8分钟需手动解锁"); } 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 06e8d70fe..548754944 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 @@ -866,6 +866,14 @@ public class MapDeviceBuilder { } else { signal.setDeviceStation(deviceStation); } + + // 所属车站 +// Station station = (Station) elementMap.get(signalVO.getBelongStationCode()); +// if (Objects.isNull(station)) { +// errMsgList.add(String.format("信号机[%s(%s)]未设置所属车站或所属车站不存在", signal.getName(), signal.getCode())); +// } else { +// signal.setStation(station); +// } // 所属联锁站 Station interlockStation = ((Station) elementMap.get(signalVO.getInterlockStationCode())); if (Objects.isNull(interlockStation)) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java index 8f6790087..35a535d41 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java @@ -35,6 +35,11 @@ public class Signal extends MayOutOfOrderDevice { */ private Station deviceStation; + /** + * 所属车站 + */ + private Station station; + /** * 联锁站 */ diff --git a/src/main/java/club/joylink/rtss/vo/client/student/ExportStudentInfo.java b/src/main/java/club/joylink/rtss/vo/client/student/ExportStudentInfo.java index b8f91f119..9afc666e3 100644 --- a/src/main/java/club/joylink/rtss/vo/client/student/ExportStudentInfo.java +++ b/src/main/java/club/joylink/rtss/vo/client/student/ExportStudentInfo.java @@ -1,11 +1,14 @@ package club.joylink.rtss.vo.client.student; +import club.joylink.rtss.services.OrgUserService; import io.swagger.annotations.ApiModel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import java.util.ArrayList; import java.util.List; +import java.util.Objects; @ApiModel(value = "导出学生信息") @Getter @@ -27,4 +30,12 @@ public class ExportStudentInfo { public ExportStudentInfo() { this.scores = new ArrayList<>(); } + + public String getStudentID() { + if(Objects.nonNull(studentID)){ + return studentID.substring(0,studentID.indexOf(OrgUserService.companyCodePrefix)); + } + return null; + } + } From 1a5bb58354765303ddd67ac1fee2be4a6da5a616 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 2 Mar 2021 13:30:46 +0800 Subject: [PATCH 04/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E5=9C=B0=E7=A0=81=E6=95=B0=E6=8D=AE=E4=BB=A5=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E5=AE=81=E6=B3=A2=E4=B8=89=E8=BF=90=E8=A1=8C=E7=BA=BF=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=9B=E4=BF=AE=E6=94=B9=E5=A4=B4=E7=A0=81=E8=BD=A6?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E5=88=B0=E7=AB=99=E9=80=BB=E8=BE=91=EF=BC=9B?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=97=E8=BD=A6=E6=89=A3=E8=BD=A6=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E9=80=BB=E8=BE=91=E4=BB=A5=E5=85=BC=E5=AE=B9=E6=B5=99?= =?UTF-8?q?=E5=A4=A7=E7=BD=91=E6=96=B0=E5=88=97=E8=BD=A6=E6=89=A3=E8=BD=A6?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/SimulationV1Controller.java | 4 +- .../rtss/services/DraftMapService.java | 5 +- .../DraftMapCiDataGeneratorImpl.java | 4 + .../cbtc/ATS/service/AtsPlanService.java | 4 +- .../cbtc/ATS/service/AtsStandService.java | 6 +- .../cbtc/ATS/service/AtsTrainService.java | 142 +++++------------- .../cbtc/GroupSimulationService.java | 5 +- .../cbtc/GroupSimulationServiceImpl.java | 9 +- .../cbtc/build/InterlockBuilder2.java | 101 +++++++++++-- .../cbtc/build/MapDeviceBuilder.java | 1 + .../cbtc/data/CalculateService.java | 39 ++++- .../data/map/DestinationCodeDefinition.java | 85 ++++++++--- .../rtss/simulation/cbtc/data/map/Signal.java | 5 + .../cbtc/data/vr/VirtualRealityTrain.java | 6 + .../onboard/ATP/OnboardAtpApiService.java | 4 +- .../onboard/ATP/OnboardAtpApiServiceImpl.java | 12 +- .../rtss/vo/client/map/DestinationCodeVO.java | 26 ++++ .../MapDestinationCodeDefinitionVO.java | 4 +- .../vo/client/map/newmap/MapSignalNewVO.java | 3 + 19 files changed, 298 insertions(+), 167 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/vo/client/map/DestinationCodeVO.java diff --git a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java index d78321009..3a387029d 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java @@ -20,8 +20,8 @@ import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.fault.FaultRuleVO; +import club.joylink.rtss.vo.client.map.DestinationCodeVO; import club.joylink.rtss.vo.client.map.MapVO; -import club.joylink.rtss.vo.client.map.newmap.MapDestinationCodeDefinitionVO; import club.joylink.rtss.vo.client.map.newmap.MapStationNewVO; import club.joylink.rtss.vo.client.runplan.PlanTripNumberVO; import club.joylink.rtss.vo.client.runplan.RunPlanEChartsDataVO; @@ -264,7 +264,7 @@ public class SimulationV1Controller { @ApiOperation(value = "查询所有目的地码") @GetMapping("/{group}/destinationCode/list") - public List getAllDestinationCode(@PathVariable String group) { + public List getAllDestinationCode(@PathVariable String group) { return this.groupSimulationService.getAllDestinationCode(group); } diff --git a/src/main/java/club/joylink/rtss/services/DraftMapService.java b/src/main/java/club/joylink/rtss/services/DraftMapService.java index 1a259c6df..c3ddd1e60 100644 --- a/src/main/java/club/joylink/rtss/services/DraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/DraftMapService.java @@ -4,8 +4,6 @@ import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.dao.*; import club.joylink.rtss.entity.*; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.services.draftData.DraftMapFlankProtectionService; -import club.joylink.rtss.services.draftData.DraftMapRunLevelService; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.map.Section; @@ -27,7 +25,6 @@ import org.springframework.util.StringUtils; import java.time.LocalDateTime; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; @Slf4j @@ -1398,7 +1395,7 @@ public class DraftMapService implements IDraftMapService { return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>()); } List vos = JsonUtils.read(logicData, JsonUtils.getCollectionType(ArrayList.class, MapDestinationCodeDefinitionVO.class)); - vos.sort(Comparator.comparing(o -> Integer.valueOf(o.getCode()))); +// vos.sort(Comparator.comparing(o -> Integer.valueOf(o.getCode()))); int startIndex = (queryVO.getPageNum() - 1) * queryVO.getPageSize(); if (startIndex > vos.size() - 1) { return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>()); diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index 7641e0512..5dc7e3e08 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -1095,8 +1095,12 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { if (!CollectionUtils.isEmpty(ignoreEndCodeList)) { if (ignoreEndCodeList.contains(route.getDestination().getCode())) { removeList.add(route); + continue; } } + if (signal.isNoRoute()) { + removeList.add(route); + } } generatedRouteList.removeAll(removeList); } 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 c17f975c7..a21856302 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 @@ -171,9 +171,9 @@ public class AtsPlanService { // 更新扣车状态 if (!Objects.equals(train.isHold(), hold)) { if (hold) { - this.onboardAtpApiService.holdTrain(simulation, train.getGroupNumber()); + this.onboardAtpApiService.standHoldTrain(simulation, train.getGroupNumber()); } else { - this.onboardAtpApiService.cancelHoldTrain(simulation, train.getGroupNumber()); + this.onboardAtpApiService.standCancelHoldTrain(simulation, train.getGroupNumber()); } } } else { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStandService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStandService.java index 943349fb0..b923e7eb2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStandService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStandService.java @@ -341,7 +341,7 @@ public class AtsStandService { if (trainInfo.isParkingStand(stand) || Objects.equals(stand.getSection().getCode(), trainInfo.getEstimatedArriveStandTrack())) { - this.onboardAtpApiService.holdTrain(simulation, trainInfo.getGroupNumber()); + this.onboardAtpApiService.standHoldTrain(simulation, trainInfo.getGroupNumber()); } } } @@ -391,7 +391,7 @@ public class AtsStandService { for (TrainInfo trainInfo : superviseTrainList) { if (trainInfo.isParkingStand(stand) || Objects.equals(stand.getSection().getCode(), trainInfo.getEstimatedArriveStandTrack())) { - this.onboardAtpApiService.cancelHoldTrain(simulation, trainInfo.getGroupNumber()); + this.onboardAtpApiService.standCancelHoldTrain(simulation, trainInfo.getGroupNumber()); } } } @@ -426,7 +426,7 @@ public class AtsStandService { for (TrainInfo trainInfo : superviseTrainList) { if (trainInfo.isParkingStand(stand) || Objects.equals(stand.getSection().getCode(), trainInfo.getPlanStandTrack())) { - this.onboardAtpApiService.cancelHoldTrain(simulation, trainInfo.getGroupNumber()); + this.onboardAtpApiService.standCancelHoldTrain(simulation, trainInfo.getGroupNumber()); } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java index e4fdded5c..ff6db8d9b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java @@ -489,112 +489,12 @@ public class AtsTrainService { Section destinationSection = destinationCodeDefinition.getSection(); Boolean destinationRight = destinationCodeDefinition.getRight(); switch (destinationCodeDefinition.getType()) { - case NORMAL_OPERATION: { - if (Objects.isNull(estimatedArriveStandTrack)) { - return; - } - - Station leftStation = destinationCodeDefinition.getLeftStation(); - Station rightStation = destinationCodeDefinition.getRightStation(); - if (Math.min(leftStation.getSn(), rightStation.getSn()) > targetStation.getSn() - || targetStation.getSn() > Math.max(leftStation.getSn(), rightStation.getSn())) { //超出环路范围 - log.warn(String.format("仿真[%s]列车[%s]目标轨不在环路范围内", simulation.getGroup(), train.getGroupNumber())); - break; - } - Station station = destinationCodeDefinition.getStationOf(trainRight); - if (Objects.equals(station.getSn(), targetStation.getSn())) { //已经抵达同向边界车站 - if (targetSection.isNormalStandTrack()) { //如果是在站台轨,并开始折返 - List
turnBackList = targetStation.getTurnBackList(); - if (!CollectionUtils.isEmpty(turnBackList)) { - nextTarget = turnBackList.get(0); - // 站后折返 - train.startTurnBack(nextTarget); - // 开始折返 - this.onboardAtpApiService.startTurnBack(simulation, train.getGroupNumber(), - nextTarget.getCode()); - break; - } - } - } else { //未抵达同向边界车站 - Station adjacentStation = repository.findAdjacentStation(targetStation, trainRight); - Optional first; - if ((adjacentStation.equals(leftStation) - || adjacentStation.equals(rightStation)) - && destinationCodeDefinition.isFrontTurnBack(adjacentStation)) { //相邻站是环路的边界车站且是站前折返 - first = adjacentStation.getStandOf(!trainRight).stream().filter(stand -> !stand.isSmall()).limit(1).findFirst(); - } else { - first = adjacentStation.getStandOf(trainRight).stream().filter(stand -> !stand.isSmall()).limit(1).findFirst(); - } - if (first.isPresent()) { - nextTarget = first.get().getSection(); - } else { - log.warn(String.format("地图[%s]车站[%s]所有站台都是小站台", mapId, adjacentStation.getCode())); - } - } - if (targetSection.isTurnBackTrack()) { //如果是在折返轨,选择能到达的站台 - for (Stand stand : targetStation.getAllStandList()) { - Section section = stand.getSection(); - if (!CollectionUtils.isEmpty(repository.queryRoutePaths(targetSection, section))) { - nextTarget = section; - break; - } - } - } - break; - } + case NORMAL_OPERATION: case LAST_OPERATION: case NON_OPERATION: case LAST_NON_OPERATION: - if (Objects.isNull(estimatedArriveStandTrack)) { - return; - } - if (!targetSection.isTurnBackTrack()) { - if (!Objects.equals(trainRight, destinationRight)) { - log.warn(String.format("仿真[%s]列车[%s]目标轨方向和目的地码方向不同", simulation.getGroup(), train.getGroupNumber())); - break; - } - //如果列车目标轨已经超出目的地码的对应区段 - if (trainRight) { - if (targetStation.getSn() >= destinationSection.getStation().getSn()) { - break; - } - } else { - if (targetStation.getSn() <= destinationSection.getStation().getSn()) { - break; - } - } - } - //-------------------------- 找下一目标轨 -------------------------- - Station adjacentStation = repository.findAdjacentStation(targetStation, destinationRight); - Section lastRunPathSection = destinationCodeDefinition.getLastSectionFromRunPath(); - //---运行路径最后一个区段存在,且列车没有越过时:找相邻车站并注意路径--- - if (lastRunPathSection != null) { - Station lastStationOnPath = lastRunPathSection.getStation(); - //如果列车目标车站没有到达/越过目的地码运行路径的最后一个车站 - if ((destinationRight && targetStation.getSn() < lastStationOnPath.getSn()) - || (!destinationRight && targetStation.getSn() > lastStationOnPath.getSn())) { - if (adjacentStation == null) { - break; - } - for (Stand stand : adjacentStation.getAllStandList()) { - if (destinationCodeDefinition.isOnThePath(stand.getSection())) { - nextTarget = stand.getSection(); - break; - } - } - } - } - //尝试找到直达终点的路径 - if (!CollectionUtils.isEmpty(repository.queryRoutePaths(targetSection, destinationSection))) { - nextTarget = destinationSection; - break; - } - //找到相邻车站的同向站台轨 - for (Stand stand : adjacentStation.getStandOf(destinationRight)) { - if (!stand.isSmall()) { - nextTarget = stand.getSection(); - break; - } + if (targetSection != null) { + nextTarget = destinationCodeDefinition.queryNextFunctionSection(targetSection); } break; case OTHER: @@ -722,9 +622,9 @@ public class AtsTrainService { // 更新扣车状态 if (!Objects.equals(train.isHold(), hold)) { if (hold) { - this.onboardAtpApiService.holdTrain(simulation, train.getGroupNumber()); + this.onboardAtpApiService.standHoldTrain(simulation, train.getGroupNumber()); } else { - this.onboardAtpApiService.cancelHoldTrain(simulation, train.getGroupNumber()); + this.onboardAtpApiService.standCancelHoldTrain(simulation, train.getGroupNumber()); } } @@ -795,14 +695,20 @@ public class AtsTrainService { * 扣车 */ public void hold(Simulation simulation, String groupNumber) { - onboardAtpApiService.holdTrain(simulation, groupNumber); + simulation.getRepository().getOnlineTrainList().forEach(train -> { + train.setTrainHold(true); + train.setHold(true); + }); } /** * 取消扣车 */ public void cancelHold(Simulation simulation, String groupNumber) { - onboardAtpApiService.cancelHoldTrain(simulation, groupNumber); + simulation.getRepository().getOnlineTrainList().forEach(train -> { + train.setTrainHold(false); + train.setHold(false); + }); } /** @@ -904,4 +810,26 @@ public class AtsTrainService { VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); train.setRunType(runType); } + + /** + * 设置全线列车扣车 + */ + public void setAllHold(Simulation simulation) { + simulation.getRepository().getOnlineTrainList().forEach(train->{ + train.setTrainHold(true); + train.setHold(true); + }); + } + + /** + * 取消权限列车扣车 + */ + public void cancelAllHold(Simulation simulation) { + simulation.getRepository().getOnlineTrainList().forEach(train -> { + if (train.isTrainHold()) { + train.setTrainHold(false); + train.setHold(false); + } + }); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java index 1c34e46df..1bf8c3764 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java @@ -14,8 +14,8 @@ import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.fault.FaultRuleVO; +import club.joylink.rtss.vo.client.map.DestinationCodeVO; import club.joylink.rtss.vo.client.map.MapVO; -import club.joylink.rtss.vo.client.map.newmap.MapDestinationCodeDefinitionVO; import club.joylink.rtss.vo.client.map.newmap.MapStationNewVO; import club.joylink.rtss.vo.client.runplan.PlanTripNumberVO; import club.joylink.rtss.vo.client.runplan.RunPlanEChartsDataVO; @@ -250,8 +250,9 @@ public interface GroupSimulationService { /** * 获取所有目的地码 + * @return */ - List getAllDestinationCode(String group); + List getAllDestinationCode(String group); /** * 获取仿真报警列表 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 2ea612c1f..1a478e981 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -23,6 +23,7 @@ import club.joylink.rtss.simulation.cbtc.command.CommandInitiateVO; import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.DestinationCodeDefinition; import club.joylink.rtss.simulation.cbtc.data.map.MayOutOfOrderDevice; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.data.storage.StorageSimulation; @@ -45,8 +46,8 @@ import club.joylink.rtss.vo.client.*; import club.joylink.rtss.vo.client.company.CompanyVO; import club.joylink.rtss.vo.client.factory.SocketMessageFactory; import club.joylink.rtss.vo.client.fault.FaultRuleVO; +import club.joylink.rtss.vo.client.map.DestinationCodeVO; import club.joylink.rtss.vo.client.map.MapVO; -import club.joylink.rtss.vo.client.map.newmap.MapDestinationCodeDefinitionVO; import club.joylink.rtss.vo.client.map.newmap.MapStationNewVO; import club.joylink.rtss.vo.client.project.ProjectDeviceVO; import club.joylink.rtss.vo.client.runplan.*; @@ -852,9 +853,11 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { } @Override - public List getAllDestinationCode(String group) { + public List getAllDestinationCode(String group) { Simulation simulation = groupSimulationCache.getSimulationByGroup(group); - return simulation.getBuildParams().getMap().getLogicDataNew().getDestinationCodeDefinitionList(); + Map destinationMap = simulation.getRepository().getDestinationMap(); + return simulation.getBuildParams().getMap().getLogicDataNew().getDestinationCodeDefinitionList() + .stream().map(vo -> new DestinationCodeVO(destinationMap.get(vo.getCode()))).collect(Collectors.toList()); } @Override diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java index 73d4a75cc..f11ee8f7b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.build; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; @@ -524,18 +525,25 @@ public class InterlockBuilder2 { } Set checkCodeDuplicateSet = new HashSet<>(); //用于检查code重复 +// List sortedBySnStations = elementMap.values().stream() +// .filter(element -> MapElement.DeviceType.STATION.equals(element.getDeviceType())) +// .map(element -> (Station) element) +// .sorted(Comparator.comparingInt(Station::getSn)) +// .collect(Collectors.toList()); for (MapDestinationCodeDefinitionVO vo : destinationCodeDefinitionList) { + //构建目的地码定义需要的所有参数 String code = null; DestinationCodeDefinition.Type type = null; String description = null; Section section = null; Boolean right = vo.getRight(); + List
necessarySections = new ArrayList<>(); + Station leftStation = null; + Station rightStation = null; + Boolean rightFrontTurnBack = null; List
runPath = null; - Station stationA = null; - Boolean stationAFrontTurnBack = vo.getStationAFrontTurnBack(); - Station stationB = null; - Boolean stationBFrontTurnBack = vo.getStationBFrontTurnBack(); + Boolean leftFrontTurnBack = null; code = vo.getCode(); if (!checkCodeDuplicateSet.add(code)) { @@ -546,8 +554,12 @@ public class InterlockBuilder2 { errMsgList.add(String.format("目的地码[%s]没有类型", code)); continue; } + if (!CollectionUtils.isEmpty(vo.getRunPath())) { + necessarySections = vo.getRunPath().stream().map(pathSectionCode -> (Section) elementMap.get(pathSectionCode)) + .collect(Collectors.toList()); + } switch (type) { - case NORMAL_OPERATION: + case NORMAL_OPERATION: { description = vo.getDescription(); if (!StringUtils.hasText(description)) { errMsgList.add(String.format("目的地码[%s]没有描述", code)); @@ -560,9 +572,46 @@ public class InterlockBuilder2 { errMsgList.add(String.format("环路类目的地码[%s]没有车站B", code)); continue; } - stationA = (Station) elementMap.get(vo.getStationACode()); - stationB = (Station) elementMap.get(vo.getStationBCode()); + Station stationA = (Station) elementMap.get(vo.getStationACode()); + Station stationB = (Station) elementMap.get(vo.getStationBCode()); + boolean stationAFrontTurnBack = vo.getStationAFrontTurnBack() != null ? vo.getStationAFrontTurnBack() : false; + boolean stationBFrontTurnBack = vo.getStationBFrontTurnBack() != null ? vo.getStationBFrontTurnBack() : false; + if (stationA.getSn() > stationB.getSn()) { + leftStation = stationB; + leftFrontTurnBack = stationBFrontTurnBack; + rightStation = stationA; + rightFrontTurnBack = stationAFrontTurnBack; + } else { + leftStation = stationA; + leftFrontTurnBack = stationAFrontTurnBack; + rightStation = stationB; + rightFrontTurnBack = stationBFrontTurnBack; + } + //从左边车站右行站台站台轨开始,构建运行路径--- (不标准的目的地码定义数据会导致运行路径构建错误) + Set
necessarySectionSet = new HashSet<>(necessarySections); //必经区段副本 + Section startSection = null; //查询路径的起始区段 + Section endSection = null; //查询路径的终点区段 + runPath = new ArrayList<>(); + //从左端车站开始选择路径 + startSection = screeningSection4DestinationCode(leftStation, leftFrontTurnBack, necessarySectionSet, true); + runPath.add(startSection); + endSection = screeningSection4DestinationCode(rightStation, rightFrontTurnBack, necessarySectionSet, false); + //查询并添加路径 + RoutePath optimalPath = CalculateService.queryShortestRoutePath(startSection, endSection, necessarySectionSet, true); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(optimalPath, + String.format("从%s到%s的路径未找到", startSection.debugStr(), endSection.debugStr())); + runPath.addAll(optimalPath.getSectionList()); + //寻找反向的路径 + Section t = startSection; + startSection = endSection; + endSection = t; + runPath.add(startSection); + RoutePath optimalPath2 = CalculateService.queryShortestRoutePath(startSection, endSection, necessarySectionSet, false); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(optimalPath2, + String.format("从%s到%s的路径未找到", startSection.debugStr(), endSection.debugStr())); + runPath.addAll(optimalPath2.getSectionList()); break; + } case LAST_OPERATION: case NON_OPERATION: case LAST_NON_OPERATION: @@ -580,18 +629,46 @@ public class InterlockBuilder2 { continue; } section = (Section) elementMap.get(vo.getSectionCode()); - if (!CollectionUtils.isEmpty(vo.getRunPath())) { - runPath = vo.getRunPath().stream().map(pathSectionCode -> (Section) elementMap.get(pathSectionCode)) - .collect(Collectors.toList()); - } break; } DestinationCodeDefinition destinationCodeDefinition = new DestinationCodeDefinition(code, type, description, section, - right, runPath, stationA, stationAFrontTurnBack, stationB, stationBFrontTurnBack); + right, necessarySections, leftStation, leftFrontTurnBack, rightStation, rightFrontTurnBack, runPath); destinationMap.put(code, destinationCodeDefinition); } } + /** + * 为目的码筛选区段 + * + * @param station + * @param ftb 是否站前折返 + * @param preferredSections 优先区段 + * @param right 站前折返时是否优先选择右向站台轨 + */ + private static Section screeningSection4DestinationCode(Station station, Boolean ftb, Set
preferredSections, boolean right) { + Section section; + if (ftb) { + Optional
selectedSectionOptional = preferredSections.stream() + .filter(ns -> ns.isNormalStandTrack() && station.equals(ns.getStation())).limit(1).findAny(); //查询指定的站台轨 + if (selectedSectionOptional.isPresent()) { + section = selectedSectionOptional.get(); + } else { //没有指定折返轨 + Section rdStandTack = station.getNormalStand(right).get(0).getSection(); + if (rdStandTack.isTurnBackTrack()) { + section = rdStandTack; + } else { + section = station.getNormalStand(!right).get(0).getSection(); + } + } + } else { + Optional
selectedSectionOptional = preferredSections.stream() + .filter(ns -> ns.isTurnBackTrack() && station.equals(ns.getStation())).limit(1).findAny(); + section = selectedSectionOptional.orElseGet(() -> station.getTurnBackList().get(0)); + } + return section; + } + + private static List checkAndBuildRouting(List routingVOList, Map elementMap, List errMsgList) { List routingList = new ArrayList<>(); if (CollectionUtils.isEmpty(routingVOList)) { 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 06e8d70fe..5c9d449b3 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 @@ -886,6 +886,7 @@ public class MapDeviceBuilder { } signal.setRouteEnd(signalVO.isRouteEnd()); signal.setIgnoreRouteEnd(signalVO.getIgnoreRouteEnd()); + signal.setNoRoute(signalVO.isNoRoute()); signal.setCtc(signalVO.isCtc()); signal.setCallOn(signalVO.isCallOn()); signal.setTurnBack(signalVO.isTurnBack()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java index 651377185..6ff74fc40 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java @@ -653,6 +653,43 @@ public class CalculateService { return list; } + /** + * 查询最短的进路路径 + * @param preferredSections 优先经过这些区段,可以为null + */ + public static RoutePath queryShortestRoutePath(Section startSection, Section endSection, Set
preferredSections, boolean toRight) { + List routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, toRight); + if (CollectionUtils.isEmpty(routePaths)) { + return null; + } else { + if (!CollectionUtils.isEmpty(preferredSections)) { //按经过优先区段的数量和长度筛选最优路径 + RoutePath optimalPath = null; + int preferredSectionNum = 0; + for (RoutePath routePath : routePaths) { + int num = 0; + for (Section section : preferredSections) { + if (routePath.containsSection(section)) { + num ++; + } + } + if (optimalPath == null) { + optimalPath = routePath; + preferredSectionNum = num; + } else { + if (num > preferredSectionNum) { + preferredSectionNum = num; + optimalPath = routePath; + } else if (num == preferredSectionNum && routePath.getLength() < optimalPath.getLength()) { + optimalPath = routePath; + } + } + } + return optimalPath; + } + return routePaths.stream().min(Comparator.comparingDouble(RoutePath::getLength)).orElse(null); + } + } + private static void queryRoutePaths(int iter, Section section, RoutePath routePath, List list, List warnList) { if (section == null) { @@ -660,7 +697,7 @@ public class CalculateService { routePath.debugStr(), routePath.getLastSection().debugStr())); return; } - if (iter > 10) { + if (iter > 100) { warnList.add(String.format("进路路径[%s]未找到:迭代10次,最后区段为[%s]", routePath.debugStr(), routePath.getLastSection().debugStr())); return; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DestinationCodeDefinition.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DestinationCodeDefinition.java index c6bd3cf0a..235b9c6d0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DestinationCodeDefinition.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DestinationCodeDefinition.java @@ -26,9 +26,9 @@ public class DestinationCodeDefinition { private Boolean right; /** - * 运行路径(sectionCode) + * 必经区段 */ - private List
runPath; + private List
necessarySections; //----------- 环路类属性 ----------- /** * 车站A @@ -50,31 +50,30 @@ public class DestinationCodeDefinition { */ private Boolean rightFrontTurnBack; + //根据目的地码的定义数据,生成路径 + /** + * 目的地码代表的运行路径(物理区段) + */ + private List
runPath; + public DestinationCodeDefinition(String code, Type type, Section section) { - this(code, type, null, section, null, null, null, null, null, null); + this(code, type, null, section, null, null, null, null, null, null, null); } public DestinationCodeDefinition(String code, Type type, String description, Section section, Boolean right, - List
runPath, Station stationA, Boolean stationAFrontTurnBack, Station stationB, Boolean stationBFrontTurnBack) { + List
necessarySections, Station leftStation, Boolean leftFrontTurnBack, + Station rightStation, Boolean rightFrontTurnBack, List
runPath) { this.code = code; this.type = type; this.description = description; this.section = section; this.right = right; + this.necessarySections = necessarySections; + this.leftStation = leftStation; + this.leftFrontTurnBack = leftFrontTurnBack; + this.rightStation = rightStation; + this.rightFrontTurnBack = rightFrontTurnBack; this.runPath = runPath; - if (Objects.nonNull(stationA) && Objects.nonNull(stationB)) { - if (stationA.getSn() > stationB.getSn()) { - this.leftStation = stationB; - this.leftFrontTurnBack = stationBFrontTurnBack; - this.rightStation = stationA; - this.rightFrontTurnBack = stationAFrontTurnBack; - } else { - this.leftStation = stationA; - this.leftFrontTurnBack = stationAFrontTurnBack; - this.rightStation = stationB; - this.rightFrontTurnBack = stationBFrontTurnBack; - } - } } /** @@ -93,8 +92,8 @@ public class DestinationCodeDefinition { * 获取运行路径上最后一个区段 */ public Section getLastSectionFromRunPath() { - if (!CollectionUtils.isEmpty(runPath)) { - return runPath.get(runPath.size() - 1); + if (!CollectionUtils.isEmpty(necessarySections)) { + return necessarySections.get(necessarySections.size() - 1); } return null; } @@ -103,10 +102,10 @@ public class DestinationCodeDefinition { * 该区段在运行路径上 */ public boolean isOnThePath(Section section) { - if (CollectionUtils.isEmpty(runPath)) { + if (CollectionUtils.isEmpty(necessarySections)) { return false; } - return runPath.stream().anyMatch(path -> Objects.equals(path, section)); + return necessarySections.stream().anyMatch(path -> Objects.equals(path, section)); } public boolean isLoop() { @@ -171,8 +170,8 @@ public class DestinationCodeDefinition { return false; } // 暂时判断逻辑为:或者是runPath中一个,或者是范围内车站且是对应方向站台 - if (!CollectionUtils.isEmpty(this.runPath)) { - return this.runPath.contains(section); + if (!CollectionUtils.isEmpty(this.necessarySections)) { + return this.necessarySections.contains(section); } if (Objects.nonNull(station)) { if (!CollectionUtils.isEmpty(section.getStandList()) && @@ -196,6 +195,46 @@ public class DestinationCodeDefinition { return station.equals(leftStation) || station.equals(rightStation); } + /** + * 查询下一个功能区段 + */ + public Section queryNextFunctionSection(Section currentSection) { + int index = runPath.indexOf(currentSection); + if (index == -1) { + return null; + } else if (index == runPath.size() - 1) { + if (!Type.NORMAL_OPERATION.equals(type)) { + return null; + } + } + if (!Type.NORMAL_OPERATION.equals(type)) { //非环路,找到路径末就结束 + for (int i = index + 1; i < runPath.size(); i++) { + Section section = runPath.get(i); + if (section.isFunctionTrack()) { + return section; + } + } + } else { //环路,循环找 + int next = index + 1; + for (int i = 0; i < runPath.size(); i++) { + if (next == runPath.size()) { + next = 0; + continue; + } + Section section = runPath.get(next); + if (section.isFunctionTrack()) { + return section; + } + next++; + } + } + return null; + } + + public String logStr() { + return String.format("目的地码[%s]", code); + } + public enum Type { /** * 正常运营(环路) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java index 8f6790087..6f1562829 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java @@ -75,6 +75,11 @@ public class Signal extends MayOutOfOrderDevice { */ private List ignoreRouteEnd; + /** + * 不生成以该信号机为始端的进路 + */ + private boolean noRoute; + /** * 是否引导信号机 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index 537665562..fed6991b1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -266,6 +266,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice { */ private boolean hold; + /** + * 当前扣车是否是列车扣车(联合hold使用) + */ + private boolean trainHold; + /** * 是否自动折返中 */ @@ -435,6 +440,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { this.nextParking = false; this.jump = false; this.hold = false; + this.trainHold = false; this.terminalStation = null; this.headPosition = null; this.robotTargetPosition = null; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiService.java index 6ce154809..18ffb01bc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiService.java @@ -64,14 +64,14 @@ public interface OnboardAtpApiService { * @param simulation * @param groupNumber */ - void holdTrain(Simulation simulation, String groupNumber); + void standHoldTrain(Simulation simulation, String groupNumber); /** * 取消扣车 * @param simulation * @param groupNumber */ - void cancelHoldTrain(Simulation simulation, String groupNumber); + void standCancelHoldTrain(Simulation simulation, String groupNumber); /** * 设置跳停 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java index f8e3819d7..af7d22da4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java @@ -131,17 +131,21 @@ public class OnboardAtpApiServiceImpl implements OnboardAtpApiService { } @Override - public void holdTrain(Simulation simulation, String groupNumber) { + public void standHoldTrain(Simulation simulation, String groupNumber) { SimulationDataRepository repository = simulation.getRepository(); VirtualRealityTrain train = repository.getVRByCode(groupNumber, VirtualRealityTrain.class); - train.setHold(true); + if (!train.isTrainHold()) { + train.setHold(true); + } } @Override - public void cancelHoldTrain(Simulation simulation, String groupNumber) { + public void standCancelHoldTrain(Simulation simulation, String groupNumber) { SimulationDataRepository repository = simulation.getRepository(); VirtualRealityTrain train = repository.getVRByCode(groupNumber, VirtualRealityTrain.class); - train.setHold(false); + if (!train.isTrainHold()) { + train.setHold(false); + } } @Override diff --git a/src/main/java/club/joylink/rtss/vo/client/map/DestinationCodeVO.java b/src/main/java/club/joylink/rtss/vo/client/map/DestinationCodeVO.java new file mode 100644 index 000000000..d330e3f54 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/map/DestinationCodeVO.java @@ -0,0 +1,26 @@ +package club.joylink.rtss.vo.client.map; + +import club.joylink.rtss.simulation.cbtc.data.map.DestinationCodeDefinition; +import club.joylink.rtss.simulation.cbtc.data.map.MapElement; +import lombok.Getter; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.stream.Collectors; + +@Getter +public class DestinationCodeVO { + private String code; + + private String description; + + private List runPath; + + public DestinationCodeVO(DestinationCodeDefinition definition) { + this.code = definition.getCode(); + this.description = definition.getDescription(); + if (!CollectionUtils.isEmpty(runPath)) { + this.runPath = definition.getRunPath().stream().map(MapElement::getCode).collect(Collectors.toList()); + } + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java index f15945cac..35e133f1b 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java @@ -72,8 +72,8 @@ public class MapDestinationCodeDefinitionVO { vo.sectionCode = definition.getSection().getCode(); } vo.right = definition.getRight(); - if (!CollectionUtils.isEmpty(definition.getRunPath())) { - vo.runPath =definition.getRunPath().stream().map(MapElement::getCode).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(definition.getNecessarySections())) { + vo.runPath =definition.getNecessarySections().stream().map(MapElement::getCode).collect(Collectors.toList()); } return vo; } diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSignalNewVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSignalNewVO.java index 96d8ae5f0..e713e3816 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSignalNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSignalNewVO.java @@ -46,6 +46,9 @@ public class MapSignalNewVO { @ApiModelProperty(value = "不生成进路的信号机终端") private List ignoreRouteEnd; + @ApiModelProperty("是否不生成进路") + private boolean noRoute; + /** * 所属区段编码 */ From b02db4209e70fef1650e42bb27a5d43ca9810e8d Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 2 Mar 2021 16:02:00 +0800 Subject: [PATCH 05/24] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=99=E5=A4=A7?= =?UTF-8?q?=E7=BD=91=E6=96=B0=E5=81=9C=E8=BD=A6/=E5=8F=91=E8=BD=A6?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/ATS/operation/Operation.java | 4 ++++ .../ATS/operation/handler/TrainOperateHandler.java | 10 ++++++++++ .../cbtc/ATS/service/AtsTrainService.java | 14 ++++++++++++++ .../simulation/cbtc/data/status/TrainStatus.java | 10 +++++++++- .../rtss/simulation/cbtc/data/vo/TrainInfo.java | 4 ++++ .../simulation/cbtc/data/vo/TrainStatusVO.java | 7 +++++-- .../cbtc/data/vr/VirtualRealityTrain.java | 5 +++++ .../cbtc/onboard/ATO/service/ATOService.java | 4 ++++ .../rtss/vo/client/map/DestinationCodeVO.java | 11 +++++++++-- 9 files changed, 64 insertions(+), 5 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index 7f383218d..df52e3f48 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -356,6 +356,10 @@ public class Operation { Train_Set_Route, /** 设置运行类型 */ Train_Set_Run_Type, + /** 下令停车 */ + Train_Order_Stop, + /** 取消停车命令 */ + Train_Cancel_Order_Stop, //--------------------------- 司机 --------------------------- /** 改变列车的牵引/制动力 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java index deeb6b1a9..9356a7ba9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java @@ -333,4 +333,14 @@ public class TrainOperateHandler { public void setRunType(Simulation simulation, String groupNumber, VirtualRealityTrain.RunType runType) { atsTrainService.setRunType(simulation, groupNumber, runType); } + + @OperateHandlerMapping(type = Operation.Type.Train_Order_Stop) + public void orderStop(Simulation simulation) { + atsTrainService.orderStop(simulation); + } + + @OperateHandlerMapping(type = Operation.Type.Train_Cancel_Order_Stop) + public void cancelOrderStop(Simulation simulation) { + atsTrainService.cancelOrderStop(simulation); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java index ff6db8d9b..3a1ada11f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java @@ -832,4 +832,18 @@ public class AtsTrainService { } }); } + + /** + * 下令停车 + */ + public void orderStop(Simulation simulation) { + simulation.getRepository().getOnlineTrainList().forEach(train -> train.setOrderStop(true)); + } + + /** + * 取消停车命令 + */ + public void cancelOrderStop(Simulation simulation) { + simulation.getRepository().getOnlineTrainList().forEach(train -> train.setOrderStop(false)); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/TrainStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/TrainStatus.java index 670a892ac..71628c943 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/TrainStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/TrainStatus.java @@ -1,6 +1,5 @@ package club.joylink.rtss.simulation.cbtc.data.status; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.constant.PlanRoutingType; import club.joylink.rtss.simulation.cbtc.constant.RunLevel; @@ -10,6 +9,7 @@ import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vo.TrainStatusVO; import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import lombok.Getter; import lombok.Setter; @@ -103,6 +103,8 @@ public class TrainStatus extends DeviceStatus { @JsonSerialize(using = Boolean2NumSerializer.class) private boolean backUp; + private boolean orderStop; + public TrainStatus(TrainInfo train) { super(train.getGroupNumber(), MapElement.DeviceType.TRAIN); this.groupNumber = train.getGroupNumber(); @@ -128,6 +130,7 @@ public class TrainStatus extends DeviceStatus { this.hold = train.isHold(); this.dt = train.getDt(); this.backUp = train.isBackUp(); + this.orderStop = train.isOrderStop(); } /** @@ -243,6 +246,11 @@ public class TrainStatus extends DeviceStatus { status.setDt(this.dt); change = true; } + if (!Objects.equals(this.orderStop, train.isOrderStop())) { + this.orderStop = train.isOrderStop(); + status.setOrderStop(this.orderStop); + change = true; + } return change; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java index e2db59f15..27fa91057 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java @@ -146,6 +146,9 @@ public class TrainInfo extends MapElement { @Setter private List
headPath; + /** 下令停车 */ + private boolean orderStop; + public TrainInfo(String groupNumber) { super(groupNumber, DeviceType.TRAIN); this.groupNumber = groupNumber; @@ -253,6 +256,7 @@ public class TrainInfo extends MapElement { this.hold = train.isHold(); this.priorityRouteSet = train.isHold(); this.backUp = train.isBackUp(); + this.orderStop = train.isOrderStop(); } public boolean isCbtcTrack() { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainStatusVO.java index e167ca4aa..2cb3f61bd 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainStatusVO.java @@ -1,13 +1,13 @@ package club.joylink.rtss.simulation.cbtc.data.vo; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.constant.PlanRoutingType; import club.joylink.rtss.simulation.cbtc.constant.RunLevel; import club.joylink.rtss.simulation.cbtc.constant.TrainType; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -102,6 +102,9 @@ public class TrainStatusVO extends DeviceStatusVO { @JsonSerialize(using = Boolean2NumSerializer.class) private Boolean backUp; + @JsonSerialize(using = Boolean2NumSerializer.class) + private Boolean orderStop; + public TrainStatusVO(TrainInfo train) { super(train.getGroupNumber(), MapElement.DeviceType.TRAIN); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index fed6991b1..7fc79396a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -378,6 +378,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice { */ private RunType runType; + /** + * 下令停车 + */ + private boolean orderStop; + public void setRunType(RunType runType) { this.runType = runType; switch (runType) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java index 3060a0f71..30587bfbf 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java @@ -75,6 +75,10 @@ public class ATOService { if (!train.isPowerOn() || !train.isAtoOn()) { return; } + //下令停车 + if (train.isOrderStop()) { + this.doBreakMax(train); + } // 计算到目标/授权终点剩余距离,根据距离计算速度,根据速度,控制牵引/制动输出 MovementAuthority ma = train.getMa(); if (Objects.isNull(ma)) { diff --git a/src/main/java/club/joylink/rtss/vo/client/map/DestinationCodeVO.java b/src/main/java/club/joylink/rtss/vo/client/map/DestinationCodeVO.java index d330e3f54..568d82c93 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/DestinationCodeVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/DestinationCodeVO.java @@ -7,6 +7,7 @@ import org.springframework.util.CollectionUtils; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; @Getter public class DestinationCodeVO { @@ -19,8 +20,14 @@ public class DestinationCodeVO { public DestinationCodeVO(DestinationCodeDefinition definition) { this.code = definition.getCode(); this.description = definition.getDescription(); - if (!CollectionUtils.isEmpty(runPath)) { - this.runPath = definition.getRunPath().stream().map(MapElement::getCode).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(definition.getRunPath())) { + this.runPath = definition.getRunPath().stream().flatMap(section -> { + if (!CollectionUtils.isEmpty(section.getLogicList())) { + return section.getLogicList().stream(); + } else { + return Stream.of(section); + } + }).map(MapElement::getCode).collect(Collectors.toList()); } } } From a397a1c195756ad387f6a3099ed087d574f175e4 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 2 Mar 2021 17:29:46 +0800 Subject: [PATCH 06/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=99=E5=A4=A7?= =?UTF-8?q?=E7=BD=91=E6=96=B0=E5=81=9C=E8=BD=A6/=E5=8F=91=E8=BD=A6?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ATS/operation/handler/TrainOperateHandler.java | 8 ++++---- .../simulation/cbtc/ATS/service/AtsTrainService.java | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java index 9356a7ba9..64b710df2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java @@ -335,12 +335,12 @@ public class TrainOperateHandler { } @OperateHandlerMapping(type = Operation.Type.Train_Order_Stop) - public void orderStop(Simulation simulation) { - atsTrainService.orderStop(simulation); + public void orderStop(Simulation simulation, String groupNumber) { + atsTrainService.orderStop(simulation, groupNumber); } @OperateHandlerMapping(type = Operation.Type.Train_Cancel_Order_Stop) - public void cancelOrderStop(Simulation simulation) { - atsTrainService.cancelOrderStop(simulation); + public void cancelOrderStop(Simulation simulation, String groupNumber) { + atsTrainService.cancelOrderStop(simulation, groupNumber); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java index 3a1ada11f..b09c7ae29 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java @@ -836,14 +836,16 @@ public class AtsTrainService { /** * 下令停车 */ - public void orderStop(Simulation simulation) { - simulation.getRepository().getOnlineTrainList().forEach(train -> train.setOrderStop(true)); + public void orderStop(Simulation simulation, String groupNumber) { + VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); + train.setOrderStop(true); } /** * 取消停车命令 */ - public void cancelOrderStop(Simulation simulation) { - simulation.getRepository().getOnlineTrainList().forEach(train -> train.setOrderStop(false)); + public void cancelOrderStop(Simulation simulation, String groupNumber) { + VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); + train.setOrderStop(false); } } From 8876292193eeb2a3f9c2214f58f294e41a8e0a42 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Wed, 3 Mar 2021 16:56:32 +0800 Subject: [PATCH 07/24] =?UTF-8?q?=E4=BB=BF=E7=9C=9F=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E6=8A=BD=E8=B1=A1(=E6=93=8D=E4=BD=9C=E5=88=86=E5=8F=91?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=8C=E7=94=A8=E6=88=B7=E8=AE=A2=E9=98=85?= =?UTF-8?q?/=E5=8F=96=E6=B6=88=E8=AE=A2=E9=98=85=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E6=9E=84=E5=BB=BA=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E9=A2=91=E7=8E=87=E4=BB=BB=E5=8A=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessExceptionAssertEnum.java | 1 + .../joylink/rtss/simulation/Simulation.java | 155 +++++++++++++++--- .../SimulationCommonController.java | 12 +- .../rtss/simulation/SimulationDelayJob.java | 6 +- .../rtss/simulation/SimulationJob.java | 2 +- .../simulation/SimulationScheduledJob.java | 36 ++-- .../SimulationSubscribeMessageService.java | 8 + .../SimulationSubscribePathChecker.java | 6 - .../websocket/DefaultSubscribeManager.java | 31 ++-- .../SimulationOperationDispatcher.java | 22 ++- 10 files changed, 202 insertions(+), 77 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/SimulationSubscribeMessageService.java delete mode 100644 src/main/java/club/joylink/rtss/simulation/SimulationSubscribePathChecker.java diff --git a/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java b/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java index cd0a1c57f..dd283b859 100644 --- a/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java +++ b/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java @@ -45,6 +45,7 @@ public enum BusinessExceptionAssertEnum implements BusinessExceptionAssert { // 仿真 SIMULATION_NOT_EXIST(30001, "simulation not exist"), + SIMULATION_OPERATION_FAILED(30002, "simulation operation failed"), // LOGIN_INFO_ERROR(40003, "login info error"), diff --git a/src/main/java/club/joylink/rtss/simulation/Simulation.java b/src/main/java/club/joylink/rtss/simulation/Simulation.java index 03bb67cc8..5cc490a45 100644 --- a/src/main/java/club/joylink/rtss/simulation/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/Simulation.java @@ -1,12 +1,11 @@ package club.joylink.rtss.simulation; import lombok.extern.slf4j.Slf4j; +import org.springframework.util.PropertyPlaceholderHelper; import org.springframework.util.StringUtils; import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -22,6 +21,8 @@ public abstract class Simulation destinationMap = new HashMap<>(); + private static final PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("{", "}"); + private List subscribeMessageServiceList; private SimulationMessagePublisher publisher; private Map simulationMemberMap = new ConcurrentHashMap<>(); @@ -174,12 +177,29 @@ public abstract class Simulation 8) { - throw new IllegalArgumentException("speed must small or equal than 8"); + if (speed > MAX_SPEED) { + throw new IllegalArgumentException(String.format("speed must small or equal than [%s]", MAX_SPEED)); } - if (this.speed == speed) { // 速度与当前相同,返回 - return; + if (this.speed != speed) { // 速度不同,重新更改并重新按新速度运行 + this.pause(); + this.speed = speed; + this.runAsSpeed(speed); + for (SimulationScheduledJob job : this.scheduledJobMap.values()) { + job.updateRunPeriod(speed); + } + this.start(); } - this.pause(); - this.speed = speed; - this.runAsSpeed(speed); - for (SimulationScheduledJob job : this.scheduledJobMap.values()) { - job.updateRunPeriod(speed); - } - this.start(); } public void runError(Throwable throwable) { @@ -300,9 +319,13 @@ public abstract class Simulation list) { + this.subscribeMessageServiceList = list; + } + + public void addSubscribeMessageService(SimulationSubscribeMessageService subscribeMessageService) { + if (this.subscribeMessageServiceList == null) { + this.subscribeMessageServiceList = new ArrayList<>(); + } + this.subscribeMessageServiceList.add(subscribeMessageService); + } + + public String handleDestination(String destinationPattern) { + String destination = this.destinationMap.get(destinationPattern); + if (destination != null) { + return destination; + } + Properties properties = new Properties(); + properties.put("id", this.id); + String dest = placeholderHelper.replacePlaceholders(destinationPattern, properties); + this.destinationMap.put(destinationPattern, dest); + return dest; + } + + public boolean isAcceptedSubscribe(String destination) { + if (this.subscribeMessageServiceList != null) { + for (SimulationSubscribeMessageService service : this.subscribeMessageServiceList) { + if (service.acceptedSubscribePath(destination)) { + return true; + } + } + } + return false; + } + public static String tryExtractSidFromDestination(String destination) { + Objects.requireNonNull(destination); + if (!destination.startsWith(MESSAGE_SUB_PREFIX.substring(0, MESSAGE_SUB_PREFIX.length() - 5))) { + return null; + } String[] patterns = StringUtils.tokenizeToStringArray(MESSAGE_SUB_PREFIX, PATH_SEPARATOR); String[] dests = StringUtils.tokenizeToStringArray(destination, PATH_SEPARATOR); for (int i = 0; i < patterns.length; i++) { @@ -356,4 +432,33 @@ public abstract class Simulation params) { - + return this.simulationOperationDispatcher.doDispatch(id, memberId, type, params); } @PutMapping("/{id}/member/{memberId}/playby/{userId}") diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationDelayJob.java b/src/main/java/club/joylink/rtss/simulation/SimulationDelayJob.java index 726b11936..b5310cad8 100644 --- a/src/main/java/club/joylink/rtss/simulation/SimulationDelayJob.java +++ b/src/main/java/club/joylink/rtss/simulation/SimulationDelayJob.java @@ -42,11 +42,7 @@ public final class SimulationDelayJob implements Runnable { @Override public void run() { - try { - this.job.run(); - } catch (Throwable e) { - log.error("仿真延时任务执行异常", e); - } + this.job.run(); } public boolean isTimeToRun(LocalDateTime systemTime) { diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationJob.java b/src/main/java/club/joylink/rtss/simulation/SimulationJob.java index b5baf179f..2daa0bae2 100644 --- a/src/main/java/club/joylink/rtss/simulation/SimulationJob.java +++ b/src/main/java/club/joylink/rtss/simulation/SimulationJob.java @@ -2,5 +2,5 @@ package club.joylink.rtss.simulation; public interface SimulationJob { - void run() throws InterruptedException; + void run(); } diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationScheduledJob.java b/src/main/java/club/joylink/rtss/simulation/SimulationScheduledJob.java index c82accde5..7abf01993 100644 --- a/src/main/java/club/joylink/rtss/simulation/SimulationScheduledJob.java +++ b/src/main/java/club/joylink/rtss/simulation/SimulationScheduledJob.java @@ -16,14 +16,18 @@ public final class SimulationScheduledJob implements Runnable { /** * 原始频率,单位ms */ - private int rate; + private final int rate; + /** + * 是否固定频率 + */ + private final boolean fixed; /** * 实际运行间隔,单位ns */ long runPeriod; LocalDateTime nextRunTime; - public SimulationScheduledJob(Simulation simulation, String name, SimulationJob job, int rate) { + public SimulationScheduledJob(Simulation simulation, String name, SimulationJob job, int rate, boolean fixed) { if (null == job) { throw new IllegalArgumentException("job must not be null"); } @@ -34,28 +38,32 @@ public final class SimulationScheduledJob implements Runnable { this.name = name; this.job = job; this.rate = rate; + this.fixed = fixed; this.updateRunPeriod(1); } + public SimulationScheduledJob(Simulation simulation, String name, SimulationJob job, int rate) { + this(simulation, name, job, rate, false); + } + public static final int TIMEOUT = 10; @Override public void run() { - try { - long start = System.nanoTime(); - this.job.run(); - long used = System.nanoTime() - start; - if (used > TimeUnit.MILLISECONDS.toNanos(TIMEOUT)) { - log.warn(String.format("仿真任务[%s]执行耗时[%sns]超过[%sms],请检查并调优", - this.name, TimeUnit.NANOSECONDS.toMillis(used), TIMEOUT)); - } - } catch (Throwable e) { - simulation.runError(e); - log.error(String.format("仿真任务[%s]执行异常,仿真停止运行", this.name), e); + long start = System.nanoTime(); + this.job.run(); + long used = System.nanoTime() - start; + if (used > TimeUnit.MILLISECONDS.toNanos(TIMEOUT)) { + log.warn(String.format("仿真任务[%s]执行耗时[%sns]超过[%sms],请检查并调优", + this.name, TimeUnit.NANOSECONDS.toMillis(used), TIMEOUT)); } } public void updateRunPeriod(int speed) { - this.runPeriod = TimeUnit.MILLISECONDS.toNanos(this.rate) / speed; + if (this.fixed) { + this.runPeriod = TimeUnit.MILLISECONDS.toNanos(this.rate); + } else { + this.runPeriod = TimeUnit.MILLISECONDS.toNanos(this.rate) / speed; + } } public boolean isTimeToRun(LocalDateTime systemTime) { diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationSubscribeMessageService.java b/src/main/java/club/joylink/rtss/simulation/SimulationSubscribeMessageService.java new file mode 100644 index 000000000..0f9c1d00e --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/SimulationSubscribeMessageService.java @@ -0,0 +1,8 @@ +package club.joylink.rtss.simulation; + +public interface SimulationSubscribeMessageService { + + boolean acceptedSubscribePath(String destination); + + Object buildMessageOfSubscribe(String destination); +} diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationSubscribePathChecker.java b/src/main/java/club/joylink/rtss/simulation/SimulationSubscribePathChecker.java deleted file mode 100644 index 5fc8cb4a6..000000000 --- a/src/main/java/club/joylink/rtss/simulation/SimulationSubscribePathChecker.java +++ /dev/null @@ -1,6 +0,0 @@ -package club.joylink.rtss.simulation; - -public interface SimulationSubscribePathChecker { - - boolean acceptedSubscribePath(String destination); -} diff --git a/src/main/java/club/joylink/rtss/simulation/messaging/websocket/DefaultSubscribeManager.java b/src/main/java/club/joylink/rtss/simulation/messaging/websocket/DefaultSubscribeManager.java index 8f20760d1..70c197ec2 100644 --- a/src/main/java/club/joylink/rtss/simulation/messaging/websocket/DefaultSubscribeManager.java +++ b/src/main/java/club/joylink/rtss/simulation/messaging/websocket/DefaultSubscribeManager.java @@ -50,24 +50,14 @@ public class DefaultSubscribeManager { } wsIdDestMap.put(this.buildWsSessionSubId(wsSessionId, subId), destination); String sid = Simulation.tryExtractSidFromDestination(destination); - SimulationUser simulationUser = this.tryGetSimulationUser(sid, user.getName()); - if (simulationUser == null) { + if (sid == null) { return; } - simulationUser.subscribe(wsSessionId, destination); - wsSidMap.put(wsSessionId, sid); - } - - private SimulationUser tryGetSimulationUser(String sid, String userId) { - if (sid == null) { - return null; - } Simulation simulation = this.simulationManager.queryById(sid); - if (simulation == null) { - return null; + if (simulation != null) { + simulation.handleUserSubscribe(user.getName(), wsSessionId, destination); } - SimulationUser simulationUser = simulation.querySimulationUserById(userId); - return simulationUser; + wsSidMap.put(wsSessionId, sid); } private String buildWsSessionSubId(String wsSessionId, String subId) { @@ -77,11 +67,16 @@ public class DefaultSubscribeManager { public void unsubscribe(WebsocketConfig.MyPrincipal user, String wsSessionId, String subId) { String key = this.buildWsSessionSubId(wsSessionId, subId); String destination = wsIdDestMap.remove(key); - String sid = Simulation.tryExtractSidFromDestination(destination); - SimulationUser simulationUser = this.tryGetSimulationUser(sid, user.getName()); - if (simulationUser == null) { + if (destination == null) { return; } - simulationUser.unsubscribe(wsSessionId, destination); + String sid = Simulation.tryExtractSidFromDestination(destination); + if (sid == null) { + return; + } + Simulation simulation = this.simulationManager.queryById(sid); + if (simulation != null) { + simulation.handleUserUnsubscribe(user.getName(), wsSessionId, destination); + } } } diff --git a/src/main/java/club/joylink/rtss/simulation/operation/SimulationOperationDispatcher.java b/src/main/java/club/joylink/rtss/simulation/operation/SimulationOperationDispatcher.java index 70786ec2e..55e1cccaf 100644 --- a/src/main/java/club/joylink/rtss/simulation/operation/SimulationOperationDispatcher.java +++ b/src/main/java/club/joylink/rtss/simulation/operation/SimulationOperationDispatcher.java @@ -1,14 +1,18 @@ package club.joylink.rtss.simulation.operation; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.Simulation; import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.SimulationMember; import club.joylink.rtss.simulation.operation.converter.ConvertUtil; +import club.joylink.rtss.util.JsonUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.lang.reflect.Parameter; +import java.lang.reflect.ParameterizedType; +import java.util.List; import java.util.Map; @Slf4j @@ -29,8 +33,8 @@ public class SimulationOperationDispatcher { return handlerMethod.getMethod().invoke(handlerMethod.getBean(), args); } catch (Exception e) { log.error(String.format("仿真[%s]操作[%s]分发异常", id, operation), e); + throw BusinessExceptionAssertEnum.SIMULATION_OPERATION_FAILED.exception(e); } - return null; } private Object[] buildParameters(Simulation simulation, OperationHandlerMethod handlerMethod, Map params) { @@ -43,10 +47,20 @@ public class SimulationOperationDispatcher { continue; } Object o = params.get(parameter.getName()); + // 简单对象处理 args[i] = ConvertUtil.convert(o, parameter.getType()); - // 复杂对象处理,需要再加 -// if (args[i] == null && o != null) { -// } + // 复杂对象处理 + if (args[i] == null && o != null) { + if (List.class.isAssignableFrom(parameter.getType())) { + ParameterizedType parameterizedType = (ParameterizedType) parameter.getParameterizedType(); + Class actualClass = (Class) parameterizedType.getActualTypeArguments()[0]; + args[i] = JsonUtils.read(JsonUtils.writeValueAsString(params.get(parameter.getName())), + JsonUtils.getCollectionType(parameter.getType(), actualClass)); + } else { + args[i] = JsonUtils.read(JsonUtils.writeValueAsString(params.get(parameter.getName())), + parameter.getType()); + } + } } return args; } From fb7f3fa70c62f1e85a0f5a88fbc7edc5076aef3b Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Wed, 3 Mar 2021 19:22:31 +0800 Subject: [PATCH 08/24] =?UTF-8?q?=E4=BB=BF=E7=9C=9F=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E6=8A=BD=E8=B1=A1(=E4=BB=BF=E7=9C=9F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E6=8A=BD=E8=B1=A1=EF=BC=8C=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/simulation/Simulation.java | 26 +++++++++++++------ .../rtss/simulation/SimulationDelayJob.java | 2 +- .../rtss/simulation/SimulationRepository.java | 21 ++++++++++++--- .../simulation/SimulationScheduledJob.java | 2 +- .../rtss/simulation/rt/RtSimulation.java | 15 ----------- .../rtss/simulation/rt/srd/SrdService.java | 4 +-- .../simulation/rt/srd/bo/SrdRepository.java | 11 +++++++- 7 files changed, 49 insertions(+), 32 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/Simulation.java b/src/main/java/club/joylink/rtss/simulation/Simulation.java index 5cc490a45..6dff419fe 100644 --- a/src/main/java/club/joylink/rtss/simulation/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/Simulation.java @@ -69,6 +69,7 @@ public abstract class Simulation subscribeMessageServiceList; private SimulationMessagePublisher publisher; + private Map repositoryMap = new ConcurrentHashMap<>(); private Map simulationMemberMap = new ConcurrentHashMap<>(); private Map simulationUserMap = new ConcurrentHashMap<>(); @@ -139,11 +140,6 @@ public abstract class Simulation T getRepository(String name, Class cls) { + Objects.requireNonNull(name); + return (T) this.repositoryMap.get(name); + } + public M querySimulationMemberById(String id) { Objects.requireNonNull(id, "id 不能为空"); return this.simulationMemberMap.get(id); diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationDelayJob.java b/src/main/java/club/joylink/rtss/simulation/SimulationDelayJob.java index b5310cad8..24c6971ac 100644 --- a/src/main/java/club/joylink/rtss/simulation/SimulationDelayJob.java +++ b/src/main/java/club/joylink/rtss/simulation/SimulationDelayJob.java @@ -9,7 +9,7 @@ import java.util.concurrent.atomic.AtomicLong; @Slf4j @Getter -public final class SimulationDelayJob implements Runnable { +final class SimulationDelayJob implements Runnable { private static final AtomicLong ID_SEED = new AtomicLong(0); private Simulation simulation; diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationRepository.java b/src/main/java/club/joylink/rtss/simulation/SimulationRepository.java index 78edd8aba..59662ce46 100644 --- a/src/main/java/club/joylink/rtss/simulation/SimulationRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/SimulationRepository.java @@ -1,9 +1,22 @@ package club.joylink.rtss.simulation; -public abstract class SimulationRepository { - private Simulation simulation; +import java.util.Objects; - public Simulation getSimulation() { - return simulation; +public abstract class SimulationRepository { + private String name; + + public SimulationRepository(String name) { + Objects.requireNonNull(name); + this.name = name; } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public abstract void initState(); } diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationScheduledJob.java b/src/main/java/club/joylink/rtss/simulation/SimulationScheduledJob.java index 7abf01993..1fe4e3f10 100644 --- a/src/main/java/club/joylink/rtss/simulation/SimulationScheduledJob.java +++ b/src/main/java/club/joylink/rtss/simulation/SimulationScheduledJob.java @@ -6,7 +6,7 @@ import java.time.LocalDateTime; import java.util.concurrent.TimeUnit; @Slf4j -public final class SimulationScheduledJob implements Runnable { +final class SimulationScheduledJob implements Runnable { private Simulation simulation; private String name; /** diff --git a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulation.java b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulation.java index a9b2dc4e0..a9c1f2fe0 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulation.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulation.java @@ -1,30 +1,15 @@ package club.joylink.rtss.simulation.rt; import club.joylink.rtss.simulation.Simulation; -import club.joylink.rtss.simulation.rt.srd.bo.SrdRepository; import lombok.Getter; @Getter public class RtSimulation extends Simulation { - /** - * 模拟真实设备数据仓库 - */ - SrdRepository srdRepository; - public RtSimulation(String id) { super(id); } - @Override - protected void initState() { - - } - - public void setSrdRepository(SrdRepository srdRepository) { - this.srdRepository = srdRepository; - } - @Override public String debugStr() { return String.format("轨道交通仿真[%s]", getId()); diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java index 871d9b2aa..baec00caf 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java @@ -16,12 +16,12 @@ public class SrdService { public void buildRepository(RtSimulation rtSimulation, MapVO mapVO) { SrdRepository srdRepository = SrdRepositoryBuilder.buildFrom(mapVO); - rtSimulation.setSrdRepository(srdRepository); + rtSimulation.addRepository(srdRepository); } public void addJobs(RtSimulation rtSimulation) { rtSimulation.addJob("srTrainRun", - () -> this.srTrainRun(rtSimulation.getSrdRepository()), + () -> this.srTrainRun(rtSimulation.getRepository(SrdRepository.NAME, SrdRepository.class)), TRAIN_RUN_RATE); } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java index 5f843bd12..607ee244e 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java @@ -1,11 +1,14 @@ package club.joylink.rtss.simulation.rt.srd.bo; +import club.joylink.rtss.simulation.SimulationRepository; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -public class SrdRepository { +public class SrdRepository extends SimulationRepository { + public static final String NAME = "SDR"; Map trackMap; Map axcMap; @@ -15,6 +18,7 @@ public class SrdRepository { Map trainMap; public SrdRepository() { + super(NAME); this.trackMap = new HashMap<>(); this.axcMap = new HashMap<>(); this.turnoutMap = new HashMap<>(); @@ -26,4 +30,9 @@ public class SrdRepository { public List getTrainList() { return new ArrayList<>(this.trainMap.values()); } + + @Override + public void initState() { + + } } From 6b0db15a6df9feaa5fb9eac23552aff09de32654 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 3 Mar 2021 21:30:38 +0800 Subject: [PATCH 09/24] =?UTF-8?q?=E9=92=88=E5=AF=B9=E6=88=90=E5=B7=A5?= =?UTF-8?q?=E9=99=A2=E4=BF=AE=E6=94=B9=E7=95=99=E8=A8=80=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20210303-zhangsai.sql | 9 + .../joylink/rtss/configuration/WebConfig.java | 5 + .../rtss/controller/LearnController.java | 26 +++ .../joylink/rtss/dao/LearnMessageDAO.java | 36 +--- .../joylink/rtss/entity/LearnComment.java | 20 +- .../rtss/entity/LearnCommentExample.java | 70 +++++++ .../joylink/rtss/entity/LearnMessage.java | 52 ++++- .../rtss/entity/LearnMessageExample.java | 190 ++++++++++++++++++ .../rtss/entity/LearnMessageWithBLOBs.java | 89 -------- .../joylink/rtss/services/ILearnService.java | 20 ++ .../joylink/rtss/services/LearnService.java | 63 +++++- .../vo/client/learn/LearnCommentUpdateVO.java | 25 +++ .../rtss/vo/client/learn/LearnCommentVO.java | 5 +- .../rtss/vo/client/learn/LearnCreateVO.java | 2 + .../vo/client/learn/LearnMessageUpdateVO.java | 23 +++ .../vo/client/post/LearnMessageCreateVO.java | 8 +- .../rtss/vo/client/post/LearnMessageVO.java | 7 +- .../mybatis/mapper/LearnCommentDAO.xml | 28 ++- .../mybatis/mapper/LearnMessageDAO.xml | 144 +++++-------- 19 files changed, 588 insertions(+), 234 deletions(-) create mode 100644 sql/20210303-zhangsai.sql delete mode 100644 src/main/java/club/joylink/rtss/entity/LearnMessageWithBLOBs.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/learn/LearnCommentUpdateVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/learn/LearnMessageUpdateVO.java diff --git a/sql/20210303-zhangsai.sql b/sql/20210303-zhangsai.sql new file mode 100644 index 000000000..af7422c41 --- /dev/null +++ b/sql/20210303-zhangsai.sql @@ -0,0 +1,9 @@ +alter table learn_comment + add user_name varchar(32) null comment '给成都工业临时加的'; + +alter table learn_message + add user_name varchar(32) null comment '给成都工业临时加的'; + +alter table learn_message modify creator_id bigint null comment '留言者'; + +alter table learn_comment modify creator_id bigint null comment '创建者'; diff --git a/src/main/java/club/joylink/rtss/configuration/WebConfig.java b/src/main/java/club/joylink/rtss/configuration/WebConfig.java index dc1352c35..3ced4ff1b 100644 --- a/src/main/java/club/joylink/rtss/configuration/WebConfig.java +++ b/src/main/java/club/joylink/rtss/configuration/WebConfig.java @@ -50,6 +50,11 @@ public class WebConfig implements WebMvcConfigurer { whiteList.add("/api/license/local"); // 微信回调接口 whiteList.add("/api/wechatPay/receive"); + // 成都工业留言板 + whiteList.add("/api/learn/cgy/message/create"); + whiteList.add("/api/learn/cgy/{messageId}/comment"); + whiteList.add("/api/learn/{postId}/message/pagedQuery/postId"); + whiteList.add("/api/learn/{messageId}/comment"); registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList); } diff --git a/src/main/java/club/joylink/rtss/controller/LearnController.java b/src/main/java/club/joylink/rtss/controller/LearnController.java index 994da8c9b..982a470f2 100644 --- a/src/main/java/club/joylink/rtss/controller/LearnController.java +++ b/src/main/java/club/joylink/rtss/controller/LearnController.java @@ -91,6 +91,12 @@ public class LearnController { return iLearnService.createMessage(messageCreateVO, user); } + @ApiOperation("成工院留言") + @PostMapping("/cgy/message/create") + public long cgyCreateMessage(@RequestBody @Validated LearnMessageCreateVO messageCreateVO) { + return iLearnService.cgyCreateMessage(messageCreateVO); + } + @ApiOperation("分页查询留言") @GetMapping("/{postId}/message/pagedQuery/postId") public PageVO pagedQueryMessageByPostId(@PathVariable Long postId, LearnMessagePagedQueryVO queryVO) { @@ -149,6 +155,13 @@ public class LearnController { iLearnService.addComment(messageId, commentCreateVO, user); } + @ApiOperation(value = "成工院评论") + @PostMapping(path = "/cgy/{messageId}/comment") + public void cygComment(@PathVariable Long messageId, + @RequestBody @Validated(value = LearnCommentCreateCheck.class) LearnCreateVO commentCreateVO) { + iLearnService.cgyAddComment(messageId, commentCreateVO); + } + @ApiOperation(value = "回复") @PostMapping(path = "/{messageId}/{commentId}/comment") public void comment(@PathVariable Long messageId, @PathVariable Long commentId, @@ -187,4 +200,17 @@ public class LearnController { iLearnService.userDeleteComment(commentId, user); } + //----------------------------------------- 改数据 ----------------------------------------- + @ApiOperation(value = "管理员修改留言数据") + @DeleteMapping(path = "/admin/update/message") + public void adminUpdateMessage(LearnMessageUpdateVO messageUpdateVO) { + iLearnService.adminUpdateMessage(messageUpdateVO); + } + + @ApiOperation(value = "管理员修改评论数据") + @DeleteMapping(path = "/admin/update/comment") + public void adminUpdateComment(LearnCommentUpdateVO commentUpdateVO) { + iLearnService.adminUpdateComment(commentUpdateVO); + } + } diff --git a/src/main/java/club/joylink/rtss/dao/LearnMessageDAO.java b/src/main/java/club/joylink/rtss/dao/LearnMessageDAO.java index 4621698f0..9b20db6f1 100644 --- a/src/main/java/club/joylink/rtss/dao/LearnMessageDAO.java +++ b/src/main/java/club/joylink/rtss/dao/LearnMessageDAO.java @@ -2,45 +2,18 @@ package club.joylink.rtss.dao; import club.joylink.rtss.entity.LearnMessage; import club.joylink.rtss.entity.LearnMessageExample; -import club.joylink.rtss.entity.LearnMessageWithBLOBs; import club.joylink.rtss.vo.client.post.LearnMessagePagedQueryVO; import club.joylink.rtss.vo.client.post.LearnMessageVO; -import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; import java.util.List; +/** + * LearnMessageDAO继承基类 + */ @Repository -public interface LearnMessageDAO { - long countByExample(LearnMessageExample example); - - int deleteByExample(LearnMessageExample example); - - int deleteByPrimaryKey(Long id); - - int insert(LearnMessageWithBLOBs record); - - int insertSelective(LearnMessageWithBLOBs record); - - List selectByExampleWithBLOBs(LearnMessageExample example); - - List selectByExample(LearnMessageExample example); - - LearnMessageWithBLOBs selectByPrimaryKey(Long id); - - int updateByExampleSelective(@Param("record") LearnMessageWithBLOBs record, @Param("example") LearnMessageExample example); - - int updateByExampleWithBLOBs(@Param("record") LearnMessageWithBLOBs record, @Param("example") LearnMessageExample example); - - int updateByExample(@Param("record") LearnMessage record, @Param("example") LearnMessageExample example); - - int updateByPrimaryKeySelective(LearnMessageWithBLOBs record); - - int updateByPrimaryKeyWithBLOBs(LearnMessageWithBLOBs record); - - int updateByPrimaryKey(LearnMessage record); - +public interface LearnMessageDAO extends MyBatisBaseDao { @Select("