用户交路定义增加生成通用路径,

This commit is contained in:
DU 2020-12-23 19:04:01 +08:00
parent ea7eb75078
commit 8f748e6323
3 changed files with 29 additions and 2 deletions

View File

@ -39,6 +39,12 @@ public class RunPlanUserDataController {
iRunPlanRoutingService.createUserRouting(routingVO);
}
@ApiOperation(value = "生成通用交路区段数据")
@PostMapping(path = "/routing/path/generate")
public RunPlanRoutingVO generateUserRoutingPath(@RequestBody @Validated RunPlanRoutingVO routingVO) {
return iRunPlanRoutingService.generateUserRouting(routingVO);
}
@ApiOperation(value = "分页获取用户交路")
@GetMapping(path = "/{mapId}/routing/page")
public PageVO<RunPlanRoutingVO> queryPagedUserRouting(@PathVariable Long mapId, RunPlanRoutingQueryVO queryVO, @RequestAttribute UserVO user) {

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.services.runplan;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.newmap.MapRoutingDataVO;
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingQueryVO;
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingSection;
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO;
@ -29,4 +30,5 @@ public interface IRunPlanRoutingService {
List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId, Long planId, String routingCode);
RunPlanRoutingVO generateUserRouting(RunPlanRoutingVO routingVO);
}

View File

@ -27,9 +27,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
@Slf4j
@ -76,6 +74,26 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
generateUserParktimes(routingVO, deviceMap);
}
@Override
public RunPlanRoutingVO generateUserRouting(RunPlanRoutingVO routingVO) {
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
"地图基础数据校验不通过");
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode());
Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode());
//中间经停所有站台轨
List<Section> passingStandTrack = CalculateService.findPassingStandTrack(startSection, endSection, routingVO.getRight());
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(passingStandTrack,
"没有找到对应方向的中间经停区段,是否需要更换方向/手动添加/直接保存交路");
LinkedList<RunPlanRoutingSection> parkSectionCodeList = passingStandTrack.stream().map(section -> new RunPlanRoutingSection(section.getStation().getCode(), section.getCode())).collect(Collectors.toCollection(LinkedList::new));
parkSectionCodeList.addFirst(new RunPlanRoutingSection(routingVO.getStartStationCode(), routingVO.getStartSectionCode()));
parkSectionCodeList.addLast(new RunPlanRoutingSection(routingVO.getEndStationCode(), routingVO.getEndSectionCode()));
routingVO.setParkSectionCodeList(parkSectionCodeList);
return routingVO;
}
@Override
public RunPlanRoutingVO getUserRouting(Long routingId) {
RunPlanRouting routing = getRunPlanRoutingData(routingId);
@ -208,6 +226,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0)).getParkSectionCodeList();
}
private boolean ifRoutingDataExist(RunPlanRoutingVO routingVO) {
return runPlanRoutingDAO.countUserRoutingBySectionData(routingVO.getUserId(), routingVO.getMapId(), JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList())) > 0;
}