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 7d03d2a60..8d84bbb31 100644 --- a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java +++ b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java @@ -25,12 +25,19 @@ public interface RtsMapFunctionService { PageVO pagedQuery(RtsMapFunctionQueryVO queryVO); /** - * 生成地图子系统 + * 生成线路功能 * - * @param mapId 要生成子系统的地图id + * @param mapId 要生成线路功能的地图id * @param paramVO 指示生成内容的参数 - * @param creatorId * @return 一些特殊的,但是算不上异常的信息 */ List generate(long mapId, RtsMapFunctionGenerateParamVO paramVO, long creatorId); + + /** + * 生成大客流线路功能 + * + * @param mapId 要生成线路功能的地图id + * @return 一些特殊的,但是算不上异常的信息 + */ + List generateLpf(long mapId, long creatorId); } 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 ad5c42277..067d48fb7 100644 --- a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java @@ -5,11 +5,13 @@ import club.joylink.rtss.entity.RtsMapFunction; import club.joylink.rtss.entity.RtsMapFunctionExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.IMapService; +import club.joylink.rtss.services.publishData.MapPassengerFlowDataService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.mapFunction.*; +import club.joylink.rtss.vo.client.passenger.MapPassengerFlowVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.graph.MapMemberVO; import com.github.pagehelper.Page; @@ -31,6 +33,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { private RtsMapFunctionDAO rtsMapFunctionDAO; @Autowired private IMapService iMapService; + @Autowired + private MapPassengerFlowDataService mapPassengerFlowDataService; @Override public void create(RtsMapFunctionCreateVO createVO, long creatorId) { @@ -89,7 +93,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { public List generate(long mapId, RtsMapFunctionGenerateParamVO paramVO, long creatorId) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(paramVO.getSimTypes(), "要生成子系统的仿真系统类型不能为空"); - //删除所有旧数据 + //查询所有旧数据 List mapFunctions = getEntitiesByMapId(mapId); Set systemNameSet = mapFunctions.stream().map(RtsMapFunction::getName).collect(Collectors.toSet()); @@ -131,6 +135,39 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { return msgList; } + @Override + public List generateLpf(long mapId, long creatorId) { + List pfDataList = mapPassengerFlowDataService.queryAllPassengerFlowBaseDataOfMap(mapId); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertCollectionNotEmpty(pfDataList, "此线路无大客流数据"); + //查询所有旧数据 + List mapFunctions = getEntitiesByMapId(mapId); + Set systemNameSet = mapFunctions.stream().map(RtsMapFunction::getName).collect(Collectors.toSet()); + + MapVO mapData = iMapService.getMapDetail(mapId); + List mapMemberVOS = mapData.getGraphDataNew().getMemberMap().get(Simulation.Type.METRO); + + Optional dispatcherOptional = mapMemberVOS.stream() + .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DISPATCHER)) + .findFirst(); + + List msgList = new ArrayList<>(); + + String name = "大客流仿真系统"; + if (systemNameSet.contains(name)) { + msgList.add(String.format("%s已存在,不生成", name)); + return null; + } + SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder() + .hasLpf(true) + .build(); + Map itemMap = new HashMap<>(); + itemMap.put(SimulationWorkParamVO.Item.LPF, pfDataList.get(0).getId().toString()); //配置加载大客流数据 + dispatcherOptional.ifPresent(mapMemberVO -> itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, mapMemberVO.getId())); //配置默认成员 + RtsMapFunctionCreateVO rtsMapFunctionCreateVO = buildCreateVO(mapId, name, name, Simulation.Type.METRO, itemMap, domConfig); + create(rtsMapFunctionCreateVO, creatorId); + return msgList; + } + private RtsMapFunctionCreateVO buildCreateVO(long mapId, String name, String desc, Simulation.Type simType, Map itemMap, SimulationWorkParamVO.DomConfigVO domConfig) { RtsMapFunctionCreateVO createVO = new RtsMapFunctionCreateVO(); diff --git a/src/test/java/club/joylink/rtss/services/mapSystem/RtsMapFunctionServiceImplTest.java b/src/test/java/club/joylink/rtss/services/mapSystem/RtsMapFunctionServiceImplTest.java index 8909ecca2..38954e40a 100644 --- a/src/test/java/club/joylink/rtss/services/mapSystem/RtsMapFunctionServiceImplTest.java +++ b/src/test/java/club/joylink/rtss/services/mapSystem/RtsMapFunctionServiceImplTest.java @@ -33,13 +33,14 @@ class RtsMapFunctionServiceImplTest { @Autowired private IMapService iMapService; @Autowired - private RtsMapFunctionServiceImpl rtsMapSystemService; + private RtsMapFunctionServiceImpl rtsMapFunctionService; @Test void create() { long mapId = 63L; Simulation.Type simType = Simulation.Type.METRO; String systemName = "单元测试用-ATS行调工作站"; + long creatorId = 42L; //border //correct @@ -60,11 +61,11 @@ class RtsMapFunctionServiceImplTest { createVO.setParamVO(paramVO); paramVO.setType(simType); paramVO.setDomConfig(SimulationWorkParamVO.DomConfigVO.builder().singleMember(true).build()); - rtsMapSystemService.create(createVO, 42L); + rtsMapFunctionService.create(createVO, creatorId); RtsMapFunctionQueryVO queryVO = new RtsMapFunctionQueryVO(); queryVO.setMapId(mapId); - List list = rtsMapSystemService.listQuery(queryVO); + List list = rtsMapFunctionService.listQuery(queryVO); Set collect = list.stream().map(RtsMapFunctionVO::getName).collect(Collectors.toSet()); assertTrue(collect.contains(systemName), "地图子系统创建后查询不到记录"); //error @@ -89,4 +90,11 @@ class RtsMapFunctionServiceImplTest { @Test void generate() { } + + @Test + void generateLpf() { + long mapId = 81L; + long creatorId = 42L; + rtsMapFunctionService.generateLpf(mapId, creatorId); + } }