增加生成大客流线路功能接口
This commit is contained in:
parent
f56eb47d53
commit
4cff884c4b
@ -25,12 +25,19 @@ public interface RtsMapFunctionService {
|
||||
PageVO<RtsMapFunctionVO> pagedQuery(RtsMapFunctionQueryVO queryVO);
|
||||
|
||||
/**
|
||||
* 生成地图子系统
|
||||
* 生成线路功能
|
||||
*
|
||||
* @param mapId 要生成子系统的地图id
|
||||
* @param mapId 要生成线路功能的地图id
|
||||
* @param paramVO 指示生成内容的参数
|
||||
* @param creatorId
|
||||
* @return 一些特殊的,但是算不上异常的信息
|
||||
*/
|
||||
List<String> generate(long mapId, RtsMapFunctionGenerateParamVO paramVO, long creatorId);
|
||||
|
||||
/**
|
||||
* 生成大客流线路功能
|
||||
*
|
||||
* @param mapId 要生成线路功能的地图id
|
||||
* @return 一些特殊的,但是算不上异常的信息
|
||||
*/
|
||||
List<String> generateLpf(long mapId, long creatorId);
|
||||
}
|
||||
|
@ -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<String> generate(long mapId, RtsMapFunctionGenerateParamVO paramVO, long creatorId) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(paramVO.getSimTypes(),
|
||||
"要生成子系统的仿真系统类型不能为空");
|
||||
//删除所有旧数据
|
||||
//查询所有旧数据
|
||||
List<RtsMapFunction> mapFunctions = getEntitiesByMapId(mapId);
|
||||
Set<String> systemNameSet = mapFunctions.stream().map(RtsMapFunction::getName).collect(Collectors.toSet());
|
||||
|
||||
@ -131,6 +135,39 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
return msgList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> generateLpf(long mapId, long creatorId) {
|
||||
List<MapPassengerFlowVO> pfDataList = mapPassengerFlowDataService.queryAllPassengerFlowBaseDataOfMap(mapId);
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertCollectionNotEmpty(pfDataList, "此线路无大客流数据");
|
||||
//查询所有旧数据
|
||||
List<RtsMapFunction> mapFunctions = getEntitiesByMapId(mapId);
|
||||
Set<String> systemNameSet = mapFunctions.stream().map(RtsMapFunction::getName).collect(Collectors.toSet());
|
||||
|
||||
MapVO mapData = iMapService.getMapDetail(mapId);
|
||||
List<MapMemberVO> mapMemberVOS = mapData.getGraphDataNew().getMemberMap().get(Simulation.Type.METRO);
|
||||
|
||||
Optional<MapMemberVO> dispatcherOptional = mapMemberVOS.stream()
|
||||
.filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DISPATCHER))
|
||||
.findFirst();
|
||||
|
||||
List<String> 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<SimulationWorkParamVO.Item, String> 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<SimulationWorkParamVO.Item, String> itemMap, SimulationWorkParamVO.DomConfigVO domConfig) {
|
||||
RtsMapFunctionCreateVO createVO = new RtsMapFunctionCreateVO();
|
||||
|
@ -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<RtsMapFunctionVO> list = rtsMapSystemService.listQuery(queryVO);
|
||||
List<RtsMapFunctionVO> list = rtsMapFunctionService.listQuery(queryVO);
|
||||
Set<String> 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user