运行图编制交路设置修改

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 = "生成通用交路区段数据")
@PostMapping(path = "/routing/path/generate")
public RunPlanRoutingVO generateUserRoutingPath(@RequestBody @Validated RunPlanRoutingVO routingVO) {
return iRunPlanRoutingService.generateUserRoutingSections(routingVO);
return iRunPlanRoutingService.generateUserRoutingData(routingVO);
}
@ApiOperation(value = "分页获取用户交路")

View File

@ -38,5 +38,5 @@ public interface IRunPlanRoutingService {
@Transactional
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.RunPlanRouting;
import club.joylink.rtss.entity.RunPlanRoutingExample;
import club.joylink.rtss.exception.BaseException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
@ -65,6 +66,13 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
RunPlanRouting routing = routingVO.convert2Entity();
runPlanRoutingDAO.insert(routing);
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
@ -111,23 +119,27 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
}
@Override
public RunPlanRoutingVO generateUserRoutingSections(RunPlanRoutingVO routingVO) {
public RunPlanRoutingVO generateUserRoutingData(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();
generateUserRoutingSections(routingVO, deviceMap);
return routingVO;
}
private void generateUserRoutingSections(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
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,
"没有找到对应方向的中间经停区段,是否需要更换方向/手动添加/直接保存交路");
String.format("没有找到线路方向[%s]的中间经停区段,是否需要更换方向/手动添加/直接保存交路", routingVO.getRight() ? "右向" : "左向"));
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
@ -139,7 +151,6 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
@Transactional
@Override
public void updateUserRouting(Long routingId, RunPlanRoutingVO routingVO) {
// BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO),"交路数据重复");
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
@ -175,8 +186,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
private void generateUserParktimes(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(routingVO);
parkingTimeVOS.forEach(p -> {
// if (!((Section) deviceMap.get(p.getSectionCode())).isTransferTrack() && !planParktimeService.isExisted(p)) {
if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack()) {
if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack() && !planParktimeService.isExisted(p)) {
planParktimeService.createUserParktime(p);
}
});
@ -185,6 +195,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
private void generateUserRunlevels(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
List<RunPlanRunlevelVO> levels = RunPlanRunlevelVO.runLevelsFromRouting(routingVO);
levels.forEach(l -> {
if (!planRunlevelService.isExisted(l)) {
Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
Section endSection = (Section) deviceMap.get(l.getEndSectionCode());
if ((startSection.isTurnBackTrack() && !startSection.isStandTrack())
@ -207,6 +218,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
l.setDistance(distance);
l.generateDefaultRunLevel();
planRunlevelService.createUserRunlevel(l);
}
});
}

View File

@ -201,6 +201,24 @@ public class RunPlanRoutingVO {
startTbFront = startReentrySection.isReentryTrack() && startReentrySection.isStandTrack();
}
}
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,
INBOUND,