运行图编制交路设置修改

This commit is contained in:
DU 2021-03-12 15:07:50 +08:00
parent 6505702a13
commit c6b8227823
4 changed files with 58 additions and 28 deletions

View File

@ -43,7 +43,7 @@ public class RunPlanUserDataController {
@ApiOperation(value = "生成通用交路区段数据") @ApiOperation(value = "生成通用交路区段数据")
@PostMapping(path = "/routing/path/generate") @PostMapping(path = "/routing/path/generate")
public RunPlanRoutingVO generateUserRoutingPath(@RequestBody @Validated RunPlanRoutingVO routingVO) { public RunPlanRoutingVO generateUserRoutingPath(@RequestBody @Validated RunPlanRoutingVO routingVO) {
return iRunPlanRoutingService.generateUserRoutingSections(routingVO); return iRunPlanRoutingService.generateUserRoutingData(routingVO);
} }
@ApiOperation(value = "分页获取用户交路") @ApiOperation(value = "分页获取用户交路")

View File

@ -38,5 +38,5 @@ public interface IRunPlanRoutingService {
@Transactional @Transactional
void pullDefaultRoutings(Long userId, Long mapId, List<Long> defaultRoutingIds); void pullDefaultRoutings(Long userId, Long mapId, List<Long> defaultRoutingIds);
RunPlanRoutingVO generateUserRoutingSections(RunPlanRoutingVO routingVO); RunPlanRoutingVO generateUserRoutingData(RunPlanRoutingVO routingVO);
} }

View File

@ -5,6 +5,7 @@ import club.joylink.rtss.dao.RunPlanRoutingDAO;
import club.joylink.rtss.entity.RunPlanDraft; import club.joylink.rtss.entity.RunPlanDraft;
import club.joylink.rtss.entity.RunPlanRouting; import club.joylink.rtss.entity.RunPlanRouting;
import club.joylink.rtss.entity.RunPlanRoutingExample; import club.joylink.rtss.entity.RunPlanRoutingExample;
import club.joylink.rtss.exception.BaseException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService; import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
@ -65,6 +66,13 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
RunPlanRouting routing = routingVO.convert2Entity(); RunPlanRouting routing = routingVO.convert2Entity();
runPlanRoutingDAO.insert(routing); runPlanRoutingDAO.insert(routing);
createRoutingRefData(deviceMap, routingVO); createRoutingRefData(deviceMap, routingVO);
if (Objects.equals(RunPlanRoutingVO.UserRoutingType.LOOP, routingVO.getRoutingType())) {
RunPlanRoutingVO routingDataLoop = routingVO.getRoutingDataLoop();
generateUserRoutingSections(routingDataLoop, deviceMap);
if (routingDataExist(routingDataLoop)) return;
runPlanRoutingDAO.insert(routingDataLoop.convert2Entity());
createRoutingRefData(deviceMap, routingDataLoop);
}
} }
@Override @Override
@ -73,7 +81,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
if (CollectionUtils.isEmpty(defaultRoutings)) return; if (CollectionUtils.isEmpty(defaultRoutings)) return;
MapVO map = this.iMapService.getMapDetail(defaultRoutings.get(0).getMapId()); MapVO map = this.iMapService.getMapDetail(defaultRoutings.get(0).getMapId());
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),"地图基础数据校验不通过"); BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), "地图基础数据校验不通过");
Map<String, MapElement> deviceMap = buildResult.getDeviceMap(); Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
defaultRoutings.forEach(routingVO -> { defaultRoutings.forEach(routingVO -> {
routingVO.setUserId(null); routingVO.setUserId(null);
@ -111,23 +119,27 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
} }
@Override @Override
public RunPlanRoutingVO generateUserRoutingSections(RunPlanRoutingVO routingVO) { public RunPlanRoutingVO generateUserRoutingData(RunPlanRoutingVO routingVO) {
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId()); MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
"地图基础数据校验不通过"); "地图基础数据校验不通过");
Map<String, MapElement> deviceMap = buildResult.getDeviceMap(); Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
generateUserRoutingSections(routingVO, deviceMap);
return routingVO;
}
private void generateUserRoutingSections(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode()); Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode());
Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode()); Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode());
//中间经停所有站台轨 //中间经停所有站台轨
List<Section> passingStandTrack = CalculateService.findPassingStandTrack(startSection, endSection, routingVO.getRight()); List<Section> passingStandTrack = CalculateService.findPassingStandTrack(startSection, endSection, routingVO.getRight());
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(passingStandTrack, BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(passingStandTrack,
"没有找到对应方向的中间经停区段,是否需要更换方向/手动添加/直接保存交路"); String.format("没有找到线路方向[%s]的中间经停区段,是否需要更换方向/手动添加/直接保存交路", routingVO.getRight() ? "右向" : "左向"));
LinkedList<RunPlanRoutingSection> parkSectionCodeList = passingStandTrack.stream().map(section -> new RunPlanRoutingSection(section.getStation().getCode(), section.getCode())).collect(Collectors.toCollection(LinkedList::new)); 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.addFirst(new RunPlanRoutingSection(routingVO.getStartStationCode(), routingVO.getStartSectionCode()));
parkSectionCodeList.addLast(new RunPlanRoutingSection(routingVO.getEndStationCode(), routingVO.getEndSectionCode())); parkSectionCodeList.addLast(new RunPlanRoutingSection(routingVO.getEndStationCode(), routingVO.getEndSectionCode()));
routingVO.setParkSectionCodeList(parkSectionCodeList); routingVO.setParkSectionCodeList(parkSectionCodeList);
return routingVO;
} }
@Override @Override
@ -139,7 +151,6 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
@Transactional @Transactional
@Override @Override
public void updateUserRouting(Long routingId, RunPlanRoutingVO routingVO) { public void updateUserRouting(Long routingId, RunPlanRoutingVO routingVO) {
// BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO),"交路数据重复");
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId()); MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
@ -175,8 +186,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
private void generateUserParktimes(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) { private void generateUserParktimes(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(routingVO); List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(routingVO);
parkingTimeVOS.forEach(p -> { parkingTimeVOS.forEach(p -> {
// if (!((Section) deviceMap.get(p.getSectionCode())).isTransferTrack() && !planParktimeService.isExisted(p)) { if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack() && !planParktimeService.isExisted(p)) {
if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack()) {
planParktimeService.createUserParktime(p); planParktimeService.createUserParktime(p);
} }
}); });
@ -185,6 +195,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
private void generateUserRunlevels(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) { private void generateUserRunlevels(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
List<RunPlanRunlevelVO> levels = RunPlanRunlevelVO.runLevelsFromRouting(routingVO); List<RunPlanRunlevelVO> levels = RunPlanRunlevelVO.runLevelsFromRouting(routingVO);
levels.forEach(l -> { levels.forEach(l -> {
if (!planRunlevelService.isExisted(l)) {
Section startSection = (Section) deviceMap.get(l.getStartSectionCode()); Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
Section endSection = (Section) deviceMap.get(l.getEndSectionCode()); Section endSection = (Section) deviceMap.get(l.getEndSectionCode());
if ((startSection.isTurnBackTrack() && !startSection.isStandTrack()) if ((startSection.isTurnBackTrack() && !startSection.isStandTrack())
@ -207,6 +218,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
l.setDistance(distance); l.setDistance(distance);
l.generateDefaultRunLevel(); l.generateDefaultRunLevel();
planRunlevelService.createUserRunlevel(l); planRunlevelService.createUserRunlevel(l);
}
}); });
} }

View File

@ -201,7 +201,25 @@ public class RunPlanRoutingVO {
startTbFront = startReentrySection.isReentryTrack() && startReentrySection.isStandTrack(); startTbFront = startReentrySection.isReentryTrack() && startReentrySection.isStandTrack();
} }
} }
public enum UserRoutingType{ private final static String LOOP_MARK = "-LOOP";
@JsonIgnore
public RunPlanRoutingVO getRoutingDataLoop() {
RunPlanRoutingVO routing = new RunPlanRoutingVO();
routing.setMapId(mapId);
routing.setUserId(userId);
routing.setName(name + LOOP_MARK);
routing.setCode(code + LOOP_MARK);
routing.setStartStationCode(endStationCode);
routing.setStartSectionCode(endSectionCode);
routing.setEndStationCode(startStationCode);
routing.setEndSectionCode(startSectionCode);
routing.setRight(!right);
routing.setRemarks(remarks + LOOP_MARK);
return routing;
}
public enum UserRoutingType {
OUTBOUND, OUTBOUND,
INBOUND, INBOUND,
LOOP, LOOP,