diff --git a/src/main/java/club/joylink/rtss/controller/publish/MapFunctionController.java b/src/main/java/club/joylink/rtss/controller/publish/MapFunctionController.java index 25a5e5801..2ed2d6f77 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/MapFunctionController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/MapFunctionController.java @@ -2,14 +2,19 @@ package club.joylink.rtss.controller.publish; import club.joylink.rtss.constants.RoleEnum; import club.joylink.rtss.controller.advice.Role; +import club.joylink.rtss.dao.MapDataDAO; +import club.joylink.rtss.dao.MapSystemDAO; +import club.joylink.rtss.services.IMapService; import club.joylink.rtss.services.mapFunction.RtsMapFunctionService; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.mapFunction.*; +import club.joylink.rtss.vo.map.MapVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; /** @@ -90,4 +95,25 @@ public class MapFunctionController { public RtsMapFunctionVO queryOne(@PathVariable Long id) { return rtsMapFunctionService.get(id); } + + @Autowired + private IMapService iMapService; + @Autowired + private MapSystemDAO mapSystemDAO; + @Autowired + private MapDataDAO mapDataDAO; + + /** + * 旧数据处理(用完删除) + */ + @PostMapping("/oldDataHandle") + public List oldDataHandle() { + List onlineMaps = iMapService.listOnline(); + List msgList = new ArrayList<>(); + for (MapVO onlineMap : onlineMaps) { + List list = rtsMapFunctionService.transferOldData(onlineMap.getId()); + msgList.addAll(list); + } + return msgList; + } } diff --git a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java index 8aca0f6d4..e5e42aa9c 100644 --- a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java +++ b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java @@ -45,4 +45,6 @@ public interface RtsMapFunctionService { * 批量删除地图下所有地图功能 */ void batchDelete(long mapId); + + List transferOldData(Long mapId); } diff --git a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java index 8efdaaf27..f6d3491a4 100644 --- a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java @@ -1,6 +1,12 @@ package club.joylink.rtss.services.mapFunction; +import club.joylink.rtss.constants.MapPrdTypeEnum; +import club.joylink.rtss.dao.MapDataDAO; +import club.joylink.rtss.dao.MapInfoDAO; +import club.joylink.rtss.dao.MapSystemDAO; import club.joylink.rtss.dao.RtsMapFunctionDAO; +import club.joylink.rtss.entity.MapSystem; +import club.joylink.rtss.entity.MapSystemExample; import club.joylink.rtss.entity.RtsMapFunction; import club.joylink.rtss.entity.RtsMapFunctionExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; @@ -16,10 +22,12 @@ import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.graph.MapMemberVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalDateTime; @@ -88,7 +96,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { return PageVO.convert(page, list); } - @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) + @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) @Override public List generate(long mapId, RtsMapFunctionGenerateParamVO paramVO, long creatorId) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(paramVO.getSimTypes(), @@ -135,7 +143,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { return msgList; } - @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) + @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) @Override public List generateLpf(long mapId, long creatorId) { List pfDataList = mapPassengerFlowDataService.queryAllPassengerFlowBaseDataOfMap(mapId); @@ -176,6 +184,118 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { rtsMapFunctionDAO.deleteByExample(rtsMapFunctionExample); } + + @Autowired + private MapInfoDAO mapInfoDAO; + @Autowired + private MapSystemDAO mapSystemDAO; + @Autowired + private MapDataDAO mapDataDAO; + + @Transactional + @Override + public List transferOldData(Long mapId) { + List msgList = new ArrayList<>(); + + MapVO mapDetail = iMapService.getMapDetail(mapId); + + Set systemNameSet = new HashSet<>(); + Simulation.Type simType; + if (mapDetail.getConfigVO().isRailway()) { + simType = Simulation.Type.RAILWAY; + } else { + simType = Simulation.Type.METRO; + } + + MapSystemExample mapSystemExample = new MapSystemExample(); + mapSystemExample.createCriteria().andMapIdEqualTo(mapDetail.getId()); + List mapSystems = mapSystemDAO.selectByExample(mapSystemExample); + Map> memberMap = mapDetail.getGraphDataNew().getMemberMap(); + String prefixMsg = String.format("地图[id:%s]", mapDetail.getId()); + if (CollectionUtils.isEmpty(memberMap)) { + msgList.add(String.format("%s无成员数据", prefixMsg)); + return msgList; + } + List mapMemberVOS = memberMap.get(simType); + if (CollectionUtils.isEmpty(mapMemberVOS)) { + msgList.add(String.format("%s无%s成员数据", prefixMsg, simType)); + return msgList; + } + Optional dispatcherOptional = mapMemberVOS.stream() + .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DISPATCHER)) + .findFirst(); + Optional stationOptional = mapMemberVOS.stream() + .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.STATION_SUPERVISOR)) + .findFirst(); + + boolean hasTraining = false; + boolean hasExam = false; + for (MapSystem mapSystem : mapSystems) { + Supplier supplier; + if (mapSystem.getType().equals("Simulation")) { + MapPrdTypeEnum prdType = MapPrdTypeEnum.getMapPrdTypeEnumByCode(mapSystem.getPrdType()); + switch (prdType) { + case LOCAL: + supplier = getStationFunctionSupplier(mapSystem.getMapId(), systemNameSet, msgList, prefixMsg, simType, stationOptional); + break; + case CENTER: + supplier = getDispatcherFunctionSupplier(mapId, systemNameSet, msgList, prefixMsg, simType, dispatcherOptional); + break; + case JOINT: + supplier = getJointFunctionSupplier(mapId, systemNameSet, msgList, prefixMsg, simType, dispatcherOptional); + break; + case DRIVER: + supplier = getDriverFunctionSupplier(mapId, systemNameSet, msgList, prefixMsg, simType, mapMemberVOS); + break; + case SCHEDULING: + supplier = getSchedulingFunctionSupplier(mapId, systemNameSet, msgList, prefixMsg, simType, dispatcherOptional); + break; + case ISCS: + supplier = () -> null; + break; + case BIG_SCREEN: + supplier = () -> null; + break; + case RUN_PLAN_MAKE: + supplier = getRunPlanDesignFunctionSupplier(mapId, systemNameSet, msgList, simType); + break; + case DEPOT_IL: + supplier = getDepotILFunctionSupplier(mapId, systemNameSet, msgList, prefixMsg, simType, mapMemberVOS); + break; + case YJDDZH: + supplier = getEmergencyFunctionSupplier(mapId, systemNameSet, msgList, Simulation.Type.EMERGENCY); + break; + default: + throw new RuntimeException(); + } + RtsMapFunctionCreateVO rtsMapFunctionCreateVO = supplier.get(); + if (rtsMapFunctionCreateVO != null) { + create(rtsMapFunctionCreateVO, 1); + } + } else if (mapSystem.getType().equals("Lesson")) { + if (!hasTraining) { + hasTraining = true; + RtsMapFunctionCreateVO rtsMapFunctionCreateVO = getSingleOperationTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType).get(); + if (rtsMapFunctionCreateVO != null) { + create(rtsMapFunctionCreateVO, 1); + } + } + } else if (mapSystem.getType().equals("Exam")) { + if (!hasExam) { + hasExam = true; + RtsMapFunctionCreateVO rtsMapFunctionCreateVO = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType).get(); + if (rtsMapFunctionCreateVO != null) { + create(rtsMapFunctionCreateVO, 1); + } + } + } else { + throw new RuntimeException(); + } + + } + return msgList; + } + private RtsMapFunctionCreateVO buildCreateVO(long mapId, String name, String desc, Simulation.Type simType, Map itemMap, SimulationWorkParamVO.DomConfigVO domConfig) { RtsMapFunctionCreateVO createVO = new RtsMapFunctionCreateVO(); @@ -209,47 +329,120 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { Optional stationSupervisorOptional = mapMemberVOS.stream() .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.STATION_SUPERVISOR)) .findFirst(); - //ATS行调工作站 - Supplier dispatchSystem = () -> { - String name = "行调仿真系统"; + Supplier dispatchSystem = getDispatcherFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier stationSystem = getStationFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, stationSupervisorOptional); + Supplier driveSystem = getDriverFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, mapMemberVOS); + Supplier dispatchTrainingSystem = getSingleOperationTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier stationTrainingSystem = getSceneTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier stationExamSystem = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier joint = getJointFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier trainingDesign = getTrainingDesignFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + + fillFunctions.add(dispatchSystem); + fillFunctions.add(stationSystem); + fillFunctions.add(driveSystem); + fillFunctions.add(dispatchTrainingSystem); + fillFunctions.add(stationTrainingSystem); + fillFunctions.add(stationExamSystem); + fillFunctions.add(joint); + fillFunctions.add(trainingDesign); + + return fillFunctions; + } + + private Supplier getTrainingDesignFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType, Optional dispatcherOptional) { + //实训设计 + return () -> { + String name = "实训设计"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); return null; } + Map itemMap = null; if (dispatcherOptional.isEmpty()) { - msgList.add(String.format("%s无行调成员,未生成%s", msgPrefix, name)); - return null; + msgList.add(String.format("%s无行调成员,未设置%s默认扮演成员", msgPrefix, name)); + } else { + itemMap = new HashMap<>(); + itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); } SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .singleMember(true) + .trainingDesign(true) .hasMemberManager(true) .build(); - Map itemMap = new HashMap<>(); - itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); }; - //ATS现地工作站 - Supplier stationSystem = () -> { - String name = "行值仿真系统"; + } + + private Supplier getJointFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType, Optional dispatcherOptional) { + //综合演练 + return () -> { + String name = "综合演练"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); return null; } - if (stationSupervisorOptional.isEmpty()) { - msgList.add(String.format("%s无行值成员,未生成%s", msgPrefix, name)); + Map itemMap = null; + if (dispatcherOptional.isEmpty()) { + msgList.add(String.format("%s无行调成员,未设置%s默认扮演成员", msgPrefix, name)); + } else { + itemMap = new HashMap<>(); + itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); + } + SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() + .isJoint(true) + .hasMemberManager(true) + .build(); + return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); + }; + } + + private Supplier getExamFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + return () -> { + String name = "考试"; + if (systemNameSet.contains(name)) { + msgList.add(String.format("%s已存在,不生成", name)); return null; } SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .singleMember(true) + .hasExam(true) + .build(); + return buildCreateVO(mapId, name, name, simType, null, domConfig); + }; + } + + private Supplier getSceneTrainingFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + return () -> { + String name = "场景实训"; + if (systemNameSet.contains(name)) { + msgList.add(String.format("%s已存在,不生成", name)); + return null; + } + SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() + .hasTraining(true) .hasMemberManager(true) .build(); - Map itemMap = new HashMap<>(); - itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, stationSupervisorOptional.get().getId()); - return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); + return buildCreateVO(mapId, name, name, simType, null, domConfig); }; - //司机模拟驾驶系统 - Supplier driveSystem = () -> { - String name = "司机仿真"; + } + + private Supplier getSingleOperationTrainingFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + return () -> { + String name = "单操实训"; + if (systemNameSet.contains(name)) { + msgList.add(String.format("%s已存在,不生成", name)); + return null; + } + SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() + .hasTraining(true) + .build(); + return buildCreateVO(mapId, name, name, simType, null, domConfig); + }; + } + + private Supplier getDriverFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, List mapMemberVOS) { + return () -> { + String name = "模拟驾驶"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); return null; @@ -269,29 +462,13 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, memberOptional.get().getId()); return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); }; - //ATS行调实训系统 - Supplier dispatchTrainingSystem = () -> { - String name = "行调实训系统"; - if (systemNameSet.contains(name)) { - msgList.add(String.format("%s已存在,不生成", name)); - return null; - } - if (dispatcherOptional.isEmpty()) { - msgList.add(String.format("%s无行调成员,未生成%s", msgPrefix, name)); - return null; - } - SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .singleMember(true) - .hasTraining(true) - .hasMemberManager(true) - .build(); - Map itemMap = new HashMap<>(); - itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); - return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); - }; - //ATS现地实训系统 - Supplier stationTrainingSystem = () -> { - String name = "行值实训系统"; + } + + private Supplier getStationFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional stationSupervisorOptional) { + //ATS现地工作站 + return () -> { + String name = "车站仿真"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); return null; @@ -302,16 +479,19 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { } SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() .singleMember(true) - .hasTraining(true) .hasMemberManager(true) .build(); Map itemMap = new HashMap<>(); itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, stationSupervisorOptional.get().getId()); return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); }; - //ATS行调考试系统 - Supplier dispatchExamSystem = () -> { - String name = "行调考试系统"; + } + + private Supplier getDispatcherFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional dispatcherOptional) { + //ATS行调工作站 + return () -> { + String name = "调度仿真"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); return null; @@ -321,82 +501,13 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { return null; } SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .hasExam(true) + .singleMember(true) + .hasMemberManager(true) .build(); Map itemMap = new HashMap<>(); itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); }; - //ATS现地考试系统 - Supplier stationExamSystem = () -> { - String name = "行值考试系统"; - if (systemNameSet.contains(name)) { - msgList.add(String.format("%s已存在,不生成", name)); - return null; - } - if (stationSupervisorOptional.isEmpty()) { - msgList.add(String.format("%s无行值成员,未生成%s", msgPrefix, name)); - return null; - } - SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .hasExam(true) - .build(); - Map itemMap = new HashMap<>(); - itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, stationSupervisorOptional.get().getId()); - return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); - }; - //综合演练 - Supplier joint = () -> { - String name = "综合演练"; - if (systemNameSet.contains(name)) { - msgList.add(String.format("%s已存在,不生成", name)); - return null; - } - Map itemMap = null; - if (dispatcherOptional.isEmpty()) { - msgList.add(String.format("%s无行调成员,未设置%s默认扮演成员", msgPrefix, name)); - } else { - itemMap = new HashMap<>(); - itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); - } - SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .isJoint(true) - .hasMemberManager(true) - .build(); - return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); - }; - //实训设计 - Supplier trainingDesign = () -> { - String name = "实训设计"; - if (systemNameSet.contains(name)) { - msgList.add(String.format("%s已存在,不生成", name)); - return null; - } - Map itemMap = null; - if (dispatcherOptional.isEmpty()) { - msgList.add(String.format("%s无行调成员,未设置%s默认扮演成员", msgPrefix, name)); - } else { - itemMap = new HashMap<>(); - itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); - } - SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .trainingDesign(true) - .hasMemberManager(true) - .build(); - return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); - }; - - fillFunctions.add(dispatchSystem); - fillFunctions.add(stationSystem); - fillFunctions.add(driveSystem); - fillFunctions.add(dispatchTrainingSystem); - fillFunctions.add(stationTrainingSystem); - fillFunctions.add(dispatchExamSystem); - fillFunctions.add(stationExamSystem); - fillFunctions.add(joint); - fillFunctions.add(trainingDesign); - - return fillFunctions; } /** @@ -417,27 +528,29 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { Optional stationSupervisorOptional = mapMemberVOS.stream() .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.STATION_SUPERVISOR)) .findFirst(); - //调度台 - Supplier dispatchSystem = () -> { - String name = "调度台"; - if (systemNameSet.contains(name)) { - msgList.add(String.format("%s已存在,不生成", name)); - return null; - } - if (dispatcherOptional.isEmpty()) { - msgList.add(String.format("%s无行调成员,未生成%s", msgPrefix, name)); - return null; - } - SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .singleMember(true) - .hasMemberManager(true) - .build(); - Map itemMap = new HashMap<>(); - itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); - return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); - }; + Supplier dispatchSystem = getRailDispatcherFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier stationSystem = getRailStationFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, stationSupervisorOptional); + Supplier singleOperationTrainingFunctionSupplier = getSingleOperationTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier sceneTrainingFunctionSupplier = getSceneTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier examFunctionSupplier = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier joint = getJointFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier trainingDesign = getTrainingDesignFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + + fillFunctions.add(dispatchSystem); + fillFunctions.add(stationSystem); + fillFunctions.add(singleOperationTrainingFunctionSupplier); + fillFunctions.add(sceneTrainingFunctionSupplier); + fillFunctions.add(examFunctionSupplier); + fillFunctions.add(joint); + fillFunctions.add(trainingDesign); + + return fillFunctions; + } + + private Supplier getRailStationFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional stationSupervisorOptional) { //车站 - Supplier stationSystem = () -> { + return () -> { String name = "车站"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); @@ -455,76 +568,147 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, stationSupervisorOptional.get().getId()); return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); }; - //综合演练 - Supplier joint = () -> { - String name = "综合演练"; + } + + private Supplier getRailDispatcherFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional dispatcherOptional) { + //调度台 + return () -> { + String name = "调度台"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); return null; } - Map itemMap = null; if (dispatcherOptional.isEmpty()) { - msgList.add(String.format("%s无行调成员,未设置%s默认扮演成员", msgPrefix, name)); - } else { - itemMap = new HashMap<>(); - itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); + msgList.add(String.format("%s无行调成员,未生成%s", msgPrefix, name)); + return null; } SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .isJoint(true) + .singleMember(true) .hasMemberManager(true) .build(); + Map itemMap = new HashMap<>(); + itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); }; - //实训设计 - Supplier trainingDesign = () -> { - String name = "实训设计"; + } + + private Supplier getSchedulingFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional dispatcherOptional) { + return () -> { + String name = "派班"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); return null; } - Map itemMap = null; if (dispatcherOptional.isEmpty()) { - msgList.add(String.format("%s无行调成员,未设置%s默认扮演成员", msgPrefix, name)); - } else { - itemMap = new HashMap<>(); - itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); + msgList.add(String.format("%s无行调成员,未生成%s", msgPrefix, name)); + return null; } SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() - .trainingDesign(true) - .hasMemberManager(true) + .singleClient(true) + .client(Simulation.Client.SCHEDULING.name()) .build(); + Map itemMap = new HashMap<>(); + itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); }; + } - fillFunctions.add(dispatchSystem); - fillFunctions.add(stationSystem); - fillFunctions.add(joint); - fillFunctions.add(trainingDesign); + private Supplier getIscsFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional dispatcherOptional) { + return () -> { + String name = "综合监控"; + if (systemNameSet.contains(name)) { + msgList.add(String.format("%s已存在,不生成", name)); + return null; + } + if (dispatcherOptional.isEmpty()) { + msgList.add(String.format("%s无行调成员,未生成%s", msgPrefix, name)); + return null; + } + SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() + .singleClient(true) + .client(Simulation.Client.ISCS.name()) + .build(); + Map itemMap = new HashMap<>(); + itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId()); + return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); + }; + } - return fillFunctions; + private Supplier getRunPlanDesignFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + return () -> { + String name = "运行图编制"; + if (systemNameSet.contains(name)) { + msgList.add(String.format("%s已存在,不生成", name)); + return null; + } + SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() + .singleClient(true) + .client(Simulation.Client.RUN_PLAN_DESIGN.name()) + .build(); + return buildCreateVO(mapId, name, name, simType, null, domConfig); + }; + } + + private Supplier getBigScreenFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + return () -> { + String name = "中心大屏"; + if (systemNameSet.contains(name)) { + msgList.add(String.format("%s已存在,不生成", name)); + return null; + } + SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() + .singleClient(true) + .client(Simulation.Client.C_ATS_BS.name()) + .build(); + return buildCreateVO(mapId, name, name, simType, null, domConfig); + }; + } + + private Supplier getDepotILFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, List mapMemberVOS) { + return () -> { + String name = "车辆段联锁"; + if (systemNameSet.contains(name)) { + msgList.add(String.format("%s已存在,不生成", name)); + return null; + } + Optional optional = mapMemberVOS.stream().filter(member -> SimulationMember.Type.DEPOT_DISPATCHER.equals(member.getType())) + .findFirst(); + if (optional.isEmpty()) { + msgList.add(String.format("%s无车辆段行调成员,未生成%s", msgPrefix, name)); + return null; + } + SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() + .build(); + Map itemMap = new HashMap<>(); + itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, optional.get().getId()); + return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); + }; } private List> buildEmergencyFillCreateVOSuppliers(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType, List mapMemberVOS) { List> fillFunctions = new ArrayList<>(); -// Optional dispatcherOptional = mapMemberVOS.stream() -// .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DISPATCHER)) -// .findFirst(); -// Optional stationSupervisorOptional = mapMemberVOS.stream() -// .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.STATION_SUPERVISOR)) -// .findFirst(); + Supplier system = getEmergencyFunctionSupplier(mapId, systemNameSet, msgList, simType); + + fillFunctions.add(system); + + return fillFunctions; + } + + @Nullable + private Supplier getEmergencyFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { //应急调度指挥系统 Supplier system = () -> { - String name = "应急调度指挥系统"; + String name = "应急调度指挥仿真"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); return null; } -// if (dispatcherOptional.isEmpty()) { -// msgList.add(String.format("%s无行调成员,未生成%s", msgPrefix, name)); -// return null; -// } SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() .singleClient(true) .client(SimulationWorkParamVO.DomConfigVO.EMERGENCY) @@ -532,10 +716,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { Map itemMap = new HashMap<>(); return buildCreateVO(mapId, name, name, simType, itemMap, domConfig); }; - - fillFunctions.add(system); - - return fillFunctions; + return system; } private Optional findEntityOptional(long id) { diff --git a/src/main/java/club/joylink/rtss/simulation/Simulation.java b/src/main/java/club/joylink/rtss/simulation/Simulation.java index 9c1980b07..c45630fb9 100644 --- a/src/main/java/club/joylink/rtss/simulation/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/Simulation.java @@ -459,6 +459,9 @@ public abstract class Simulation realRunRecordList = simulation.getRepository().getRealRunRecordList(); + if (!CollectionUtils.isEmpty(realRunRecordList)) { + SocketMessageVO allTrainRealRunRecord = + SocketMessageFactory.build(WebSocketMessageType.Simulation_RunFact, + simulation.getId(), realRunRecordList); + this.stompMessageService.sendToUser(userId, allTrainRealRunRecord); + } + } // case Room: // break; // case Wgu3d: @@ -133,14 +143,6 @@ public class SimulationUserWsListener { private void handleSubscribeSimulationMain(club.joylink.rtss.simulation.cbtc.Simulation simulation, SimulationUser simulationUser) { String group = simulation.getId(); String userId = simulationUser.getId(); - // 将当前所有列车实际运行数据同步给用户 - List realRunRecordList = simulation.getRepository().getRealRunRecordList(); - if (!CollectionUtils.isEmpty(realRunRecordList)) { - SocketMessageVO allTrainRealRunRecord = - SocketMessageFactory.build(WebSocketMessageType.Simulation_RunFact, - group, realRunRecordList); - this.stompMessageService.sendToUser(userId, allTrainRealRunRecord); - } // 将车次计划变化信息同步给用户 List changeTrips = simulation.getRepository().getChangeTrips(); if (!CollectionUtils.isEmpty(changeTrips)) { diff --git a/src/main/java/club/joylink/rtss/simulation/vo/SimulationUserVO.java b/src/main/java/club/joylink/rtss/simulation/vo/SimulationUserVO.java index c56cfaa6b..5443d2d32 100644 --- a/src/main/java/club/joylink/rtss/simulation/vo/SimulationUserVO.java +++ b/src/main/java/club/joylink/rtss/simulation/vo/SimulationUserVO.java @@ -14,6 +14,7 @@ public class SimulationUserVO { private String id; private String name; private int creator; + private SimulationUser.Type type; /** * 用户仿真消息订阅 * key-wsSessionId @@ -27,6 +28,7 @@ public class SimulationUserVO { this.id = user.getId(); this.name = user.getName(); this.creator = convert(user.isCreator()); + this.type = user.getType(); this.wsSubscribeMap = user.getSubscribeMap(); this.memberId = user.getMemberId(); } diff --git a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java index ffdfd3872..5b79a77bd 100644 --- a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java +++ b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java @@ -77,6 +77,10 @@ public class SocketMessageFactory { topicList.add(WebSocketSubscribeTopic.Common); break; } + case Simulation_RunFact: { + topicList.add(SimulationSubscribeTopic.RUN_FACT.buildDestination(group)); + break; + } case Simulation_Time_Sync: case SIMULATION_WORK_PARAM: case Simulation_User: @@ -86,7 +90,6 @@ public class SocketMessageFactory { case Simulation_AutoFault_Trigger: case Simulation_Error: case Simulation_RunAsPlan_Start: - case Simulation_RunFact: case Simulation_ApplyHandle: case Simulation_Control_Pause: case Simulation_Run_Plan_Reload: diff --git a/src/main/java/club/joylink/rtss/vo/client/simulationv1/SimulationUserVO.java b/src/main/java/club/joylink/rtss/vo/client/simulationv1/SimulationUserVO.java index 6c85fc7c1..f7602bae1 100644 --- a/src/main/java/club/joylink/rtss/vo/client/simulationv1/SimulationUserVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/simulationv1/SimulationUserVO.java @@ -24,10 +24,10 @@ public class SimulationUserVO { private ProjectDeviceVO deviceVO; - /** - * 是否管理员 - */ - private boolean admin; +// /** +// * 是否管理员 +// */ +// private boolean admin; /** * 是否裁判 @@ -54,11 +54,15 @@ public class SimulationUserVO { */ private String deviceCode; + /** + * 仿真用户类型 + */ + private club.joylink.rtss.simulation.SimulationUser.Type userType; + public SimulationUserVO(SimulationUser simulationUser) { this.userId = simulationUser.getUser().getId(); this.nickName = simulationUser.getUser().getNickname(); this.deviceVO = simulationUser.getProjectDevice(); - this.admin = simulationUser.isAdmin(); this.referee = simulationUser.isReferee(); this.online = simulationUser.isOnline(); if (Objects.nonNull(simulationUser.getPlayedMember())) { @@ -68,6 +72,7 @@ public class SimulationUserVO { this.deviceCode = simulationUser.getPlayedMember().getDevice().getCode(); } } + this.userType = simulationUser.getType(); } public static List convert2VOList(List list) {