运行图交路定义修改,增加车站折返时间配置
This commit is contained in:
parent
15ec7c7b3b
commit
bfd278017a
@ -43,7 +43,7 @@ public class RunPlanUserDataController {
|
||||
@ApiOperation(value = "生成通用交路区段数据")
|
||||
@PostMapping(path = "/routing/path/generate")
|
||||
public RunPlanRoutingVO generateUserRoutingPath(@RequestBody @Validated RunPlanRoutingVO routingVO) {
|
||||
return iRunPlanRoutingService.generateUserRouting(routingVO);
|
||||
return iRunPlanRoutingService.generateUserRoutingSections(routingVO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页获取用户交路")
|
||||
|
@ -21,7 +21,6 @@ import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.UserVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.map.MapRoutingVO;
|
||||
import club.joylink.rtss.vo.client.map.MapVO;
|
||||
import club.joylink.rtss.vo.client.map.RealLineConfigVO;
|
||||
import club.joylink.rtss.vo.client.map.newmap.*;
|
||||
@ -199,8 +198,6 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
checkNameRepeat(null, name, mapId, userVO);
|
||||
// 查询车站数据(车站 --- 站台 --- 站台轨)
|
||||
MapVO mapVO = this.iMapService.getMapDetail(mapId);
|
||||
List<RunPlanTripVO> tripVOList;
|
||||
|
||||
List<MapStationNewVO> stationList = this.prepareStationDataNew(mapVO);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(stationList);
|
||||
// 查询目的地码-区段code关系
|
||||
@ -226,7 +223,7 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
IRunPlanStrategyNew runPlanStrategy =RunPlanImportStrategyEnum.matchImportStrategy(mapVO.getLineCode());
|
||||
runPlanStrategy.importDataCheckAndPreHandle(runPlanImportList, stationList, upDirection);
|
||||
// 生成到站计划数据
|
||||
tripVOList = runPlanStrategy.parseRunPlanImport(runPlanImportList, sectionMap, upDirection);
|
||||
List<RunPlanTripVO> tripVOList = runPlanStrategy.parseRunPlanImport(runPlanImportList, sectionMap, upDirection);
|
||||
// 生成计划对象
|
||||
RunPlanDraft plan = new RunPlanDraft();
|
||||
plan.setMapId(mapId);
|
||||
@ -393,56 +390,54 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
List<RunPlanTripVO> newTripList = new ArrayList<>();
|
||||
RunPlanUserConfigVO config = runPlanUserConfigService.getConfig(userVO.getId(), mapVO.getId());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(config) && config.hasReentryData(), "运行图-用户缺少配置或没有配置车站折返数据");
|
||||
Map<String, String> userReentryData = config.getConfig().getRunPlanUserReentryData();
|
||||
Map<String, RunPlanUserConfigVO.ReentryTime> userReentryData = config.getConfig().getReentryData();
|
||||
List<RunPlanRoutingVO> userRoutings = runPlanRoutingService.getUserRoutingBy(userVO.getId(), mapVO.getId());
|
||||
Map<String, RunPlanRoutingVO> userRoutingMap = userRoutings.stream().collect(Collectors.toMap(RunPlanRoutingVO::getCode, Function.identity()));
|
||||
for (RunPlanTripConfigVO tripConfigVO : serviceConfig.getTripConfigList()) {
|
||||
// 查询交路
|
||||
// MapRoutingDataVO routingData = mapVO.findRoutingDataByCode(tripConfigVO.getRoutingCode());
|
||||
RunPlanRoutingVO routingData = userRoutingMap.get(tripConfigVO.getRoutingCode());
|
||||
String endSectionCode = routingData.getEndSectionCode();
|
||||
String startSectionCode = routingData.getStartSectionCode();
|
||||
MapSectionNewVO endSection = mapVO.findSectionNew(endSectionCode);
|
||||
MapSectionNewVO endReentrySection = null;
|
||||
if (endSection.isStandTrack()) {
|
||||
String endReentrySectionCode = userReentryData.get(routingData.getEndStationCode());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(endReentrySectionCode, "车站" + routingData.getEndStationCode() + "折返轨未设置");
|
||||
endReentrySection = mapVO.findSectionNew(endReentrySectionCode);
|
||||
}
|
||||
MapSectionNewVO startSection = mapVO.findSectionNew(startSectionCode);
|
||||
MapSectionNewVO startReentrySection = null;
|
||||
if (startSection.isStandTrack()) {
|
||||
String startReentrySectionCode = userReentryData.get(routingData.getStartStationCode());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(startReentrySectionCode, "车站" + routingData.getStartStationCode() + "折返轨未设置");
|
||||
startReentrySection = mapVO.findSectionNew(startReentrySectionCode);
|
||||
}
|
||||
|
||||
RunPlanTripVO tripVO = new RunPlanTripVO(tripConfigVO, routingData, startReentrySection, endReentrySection);
|
||||
if (mapVO.getConfigVO().getUpRight()) {
|
||||
if (routingData.getRight()) {
|
||||
tripVO.setDirectionCode(DirectionType.Type02);
|
||||
} else {
|
||||
tripVO.setDirectionCode(DirectionType.Type01);
|
||||
}
|
||||
} else {
|
||||
if (routingData.getRight()) {
|
||||
tripVO.setDirectionCode(DirectionType.Type01);
|
||||
} else {
|
||||
tripVO.setDirectionCode(DirectionType.Type02);
|
||||
}
|
||||
}
|
||||
// String endSectionCode = routingData.getEndSectionCode();
|
||||
// String startSectionCode = routingData.getStartSectionCode();
|
||||
// MapSectionNewVO endSection = mapVO.findSectionNew(endSectionCode);
|
||||
//// MapSectionNewVO endReentrySection = null;
|
||||
// if (endSection.isStandTrack()) {
|
||||
// RunPlanUserConfigVO.ReentryTime endReentryTime = userReentryData.get(routingData.getEndStationCode());
|
||||
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(endReentryTime, "车站未设置折返数据");
|
||||
//// endReentrySection = mapVO.findSectionNew(endReentrySectionCode);
|
||||
// }
|
||||
// MapSectionNewVO startSection = mapVO.findSectionNew(startSectionCode);
|
||||
//// MapSectionNewVO startReentrySection = null;
|
||||
// if (startSection.isStandTrack()) {
|
||||
// RunPlanUserConfigVO.ReentryTime startReentryTime = userReentryData.get(routingData.getStartStationCode());
|
||||
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(startReentryTime, "车站未设置折返数据");
|
||||
//// startReentrySection = mapVO.findSectionNew(startReentrySectionCode);
|
||||
// }
|
||||
RunPlanTripVO tripVO = new RunPlanTripVO(routingData);
|
||||
setDirectionCode(mapVO.getConfigVO().getUpRight(), tripVO);
|
||||
// if (mapVO.getConfigVO().getUpRight()) {
|
||||
// if (routingData.getRight()) {
|
||||
// tripVO.setDirectionCode(DirectionType.Type02);
|
||||
// } else {
|
||||
// tripVO.setDirectionCode(DirectionType.Type01);
|
||||
// }
|
||||
// } else {
|
||||
// if (routingData.getRight()) {
|
||||
// tripVO.setDirectionCode(DirectionType.Type01);
|
||||
// } else {
|
||||
// tripVO.setDirectionCode(DirectionType.Type02);
|
||||
// }
|
||||
// }
|
||||
// 构建类车到站数据
|
||||
tripVO.setServiceNumber(serviceConfig.getServiceNumber());
|
||||
//增加方向码
|
||||
|
||||
List<RunPlanArriveConfigVO> arriveConfigList = tripConfigVO.getArriveConfigList();
|
||||
arriveConfigList.stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO));
|
||||
if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<>(tripVO.getTimeList())).getLast().getSectionCode())) {
|
||||
arriveConfigList.stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.addTime(timeVO));
|
||||
// if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<>(tripVO.getTimeList())).getLast().getSectionCode())) {
|
||||
tripVO.setEndTime(tripConfigVO.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME));
|
||||
}
|
||||
if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<>(tripVO.getTimeList())).getFirst().getSectionCode())) {
|
||||
// }
|
||||
// if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<>(tripVO.getTimeList())).getFirst().getSectionCode())) {
|
||||
tripVO.setStartTime(tripConfigVO.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME));
|
||||
}
|
||||
// }
|
||||
newTripList.add(tripVO);
|
||||
}
|
||||
// 添加数据
|
||||
@ -688,31 +683,31 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
MapVO mapVO = this.iMapService.getMapDetail(runPlanVO.getMapId());
|
||||
RunPlanUserConfigVO config = runPlanUserConfigService.getConfig(userVO.getId(), mapVO.getId());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(config) && config.hasReentryData(), "运行图-用户缺少配置或没有配置车站折返数据");
|
||||
Map<String, String> userReentryData = config.getConfig().getRunPlanUserReentryData();
|
||||
Map<String, RunPlanUserConfigVO.ReentryTime> userReentryData = config.getConfig().getReentryData();
|
||||
List<RunPlanRoutingVO> userRoutings = runPlanRoutingService.getUserRoutingBy(userVO.getId(), mapVO.getId());
|
||||
Map<String, RunPlanRoutingVO> userRoutingMap = userRoutings.stream().collect(Collectors.toMap(RunPlanRoutingVO::getCode, Function.identity()));
|
||||
String tripNumber = "000";
|
||||
RunPlanTripVO tripVO;
|
||||
|
||||
// 查询交路
|
||||
// MapRoutingDataVO routing = mapVO.findRoutingDataByCode(tripConfig.getRoutingCode());
|
||||
RunPlanRoutingVO routingData = userRoutingMap.get(tripConfig.getRoutingCode());
|
||||
String endSectionCode = routingData.getEndSectionCode();
|
||||
String startSectionCode = routingData.getStartSectionCode();
|
||||
MapSectionNewVO endSection = mapVO.findSectionNew(endSectionCode);
|
||||
MapSectionNewVO endReentrySection = null;
|
||||
if (endSection.isStandTrack()) {
|
||||
String endReentrySectionCode = userReentryData.get(routingData.getEndStationCode());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(endReentrySectionCode, "车站" + routingData.getEndStationCode() + "折返轨未设置");
|
||||
endReentrySection = mapVO.findSectionNew(endReentrySectionCode);
|
||||
}
|
||||
MapSectionNewVO startSection = mapVO.findSectionNew(startSectionCode);
|
||||
MapSectionNewVO startReentrySection = null;
|
||||
if (startSection.isStandTrack()) {
|
||||
String startReentrySectionCode = userReentryData.get(routingData.getStartStationCode());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(startReentrySectionCode, "车站" + routingData.getStartStationCode() + "折返轨未设置");
|
||||
startReentrySection = mapVO.findSectionNew(startReentrySectionCode);
|
||||
}
|
||||
tripVO = new RunPlanTripVO(tripConfig, routingData, startReentrySection, endReentrySection);
|
||||
// String endSectionCode = routingData.getEndSectionCode();
|
||||
// String startSectionCode = routingData.getStartSectionCode();
|
||||
// MapSectionNewVO endSection = mapVO.findSectionNew(endSectionCode);
|
||||
// MapSectionNewVO endReentrySection = null;
|
||||
// if (endSection.isStandTrack()) {
|
||||
// String endReentrySectionCode = userReentryData.get(routingData.getEndStationCode());
|
||||
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(endReentrySectionCode, "车站" + routingData.getEndStationCode() + "折返轨未设置");
|
||||
// endReentrySection = mapVO.findSectionNew(endReentrySectionCode);
|
||||
// }
|
||||
// MapSectionNewVO startSection = mapVO.findSectionNew(startSectionCode);
|
||||
// MapSectionNewVO startReentrySection = null;
|
||||
// if (startSection.isStandTrack()) {
|
||||
// String startReentrySectionCode = userReentryData.get(routingData.getStartStationCode());
|
||||
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(startReentrySectionCode, "车站" + routingData.getStartStationCode() + "折返轨未设置");
|
||||
// startReentrySection = mapVO.findSectionNew(startReentrySectionCode);
|
||||
// }
|
||||
RunPlanTripVO tripVO = new RunPlanTripVO(routingData);
|
||||
// 构建类车到站数据
|
||||
// tripVO = new RunPlanTripVO(tripConfig, routing);
|
||||
setDirectionCode(mapVO.getConfigVO().getUpRight(), tripVO);
|
||||
@ -720,12 +715,12 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
tripVO.setTripNumber(tripVO.getDirectionCode() + tripNumber);
|
||||
tripConfig.getArriveConfigList().stream().map(RunPlanTripTimeVO::new).sorted(Comparator.comparing(RunPlanTripTimeVO::getArrivalTime)).forEach(timeVO -> tripVO.getTimeList().add(timeVO));
|
||||
|
||||
if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getLast().getSectionCode())) {
|
||||
// if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getLast().getSectionCode())) {
|
||||
tripVO.setEndTime(tripConfig.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME));
|
||||
}
|
||||
if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getFirst().getSectionCode())) {
|
||||
// }
|
||||
// if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getFirst().getSectionCode())) {
|
||||
tripVO.setStartTime(tripConfig.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME));
|
||||
}
|
||||
// }
|
||||
|
||||
if (CollectionUtils.isEmpty(runPlanVO.getTripList())) {
|
||||
runPlanVO.setTripList(new ArrayList<>());
|
||||
|
@ -30,5 +30,5 @@ public interface IRunPlanRoutingService {
|
||||
|
||||
List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId, Long planId, String routingCode);
|
||||
|
||||
RunPlanRoutingVO generateUserRouting(RunPlanRoutingVO routingVO);
|
||||
RunPlanRoutingVO generateUserRoutingSections(RunPlanRoutingVO routingVO);
|
||||
}
|
||||
|
@ -1,474 +0,0 @@
|
||||
package club.joylink.rtss.services.runplan;
|
||||
|
||||
import club.joylink.rtss.constants.BusinessConsts;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.vo.client.map.MapVO;
|
||||
import club.joylink.rtss.vo.client.map.newmap.MapSectionNewVO;
|
||||
import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO;
|
||||
import club.joylink.rtss.vo.client.runplan.RunPlanTripVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.*;
|
||||
import club.joylink.rtss.vo.runplan.RunPlanInput;
|
||||
import club.joylink.rtss.vo.runplan.RunPlanInputData;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 通用运行图生成
|
||||
*/
|
||||
@Component
|
||||
public class RunPlanGenerator {
|
||||
|
||||
private static final int OFFSET_TIME_HOURS = 2; //时间偏移早两小时
|
||||
|
||||
@Autowired
|
||||
private IRunPlanRoutingService runPlanRoutingService;
|
||||
@Autowired
|
||||
private IRunPlanRunlevelService runPlanRunlevelService;
|
||||
@Autowired
|
||||
private IRunPlanParktimeService runPlanParktimeService;
|
||||
@Autowired
|
||||
private IRunPlanUserConfigService runPlanUserConfigService;
|
||||
|
||||
|
||||
public List<RunPlanTripVO> generatorTrips(Long userId, RunPlanInput runPlanInput, MapVO mapVO) {
|
||||
|
||||
//校验发车停运时间
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(runPlanInput.getOverTime().isAfter(runPlanInput.getBeginTime()));
|
||||
//校验车站
|
||||
|
||||
LocalTime beginTimeOffset = runPlanInput.getBeginTime().minusHours(OFFSET_TIME_HOURS);
|
||||
//向前推两小时,如果到前一天,则时间不合理
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(runPlanInput.getBeginTime().isAfter(beginTimeOffset), "发车时间过早,建议晚于上午两点");
|
||||
runPlanInput.setBeginTime(beginTimeOffset);
|
||||
runPlanInput.setOverTime(runPlanInput.getOverTime().minusHours(OFFSET_TIME_HOURS));
|
||||
|
||||
//检查环路
|
||||
RunPlanRoutingVO running1Routing = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), runPlanInput.getRunningRouting1());
|
||||
RunPlanRoutingVO running2Routing = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), runPlanInput.getRunningRouting2());
|
||||
boolean isLoop = running1Routing.getParkSectionCodeList().get(0).getStationCode().equals(running2Routing.getParkSectionCodeList().get(running2Routing.getParkSectionCodeList().size() - 1).getStationCode())
|
||||
&& running2Routing.getParkSectionCodeList().get(0).getStationCode().equals(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getStationCode());
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(isLoop, "运行两交路无法构成环路数据");
|
||||
//查站间运行等级
|
||||
List<RunPlanRunlevelVO> levels = runPlanRunlevelService.queryUserRunLevels(userId, mapVO.getId());
|
||||
Map<String, Integer> runLevelTime = levels.stream().collect(Collectors.toMap(runLevelVO -> String.format("%s-%s", runLevelVO.getStartSectionCode(), runLevelVO.getEndSectionCode()), runLevelVO -> runLevelVO.getLevelTime(runPlanInput.getRunLevel())));
|
||||
//查停站时间
|
||||
List<RunPlanParkingTimeVO> parkTimes = runPlanParktimeService.queryUserParktimes(userId, mapVO.getId());
|
||||
Map<String, Integer> parkTime = parkTimes.stream().collect(Collectors.toMap(RunPlanParkingTimeVO::getSectionCode, RunPlanParkingTimeVO::getParkingTime));
|
||||
//查折返
|
||||
RunPlanUserConfigVO config = runPlanUserConfigService.getConfig(userId, mapVO.getId());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(config) && config.hasReentryData(), "运行图-用户缺少配置或没有配置车站折返数据");
|
||||
Map<String, String> userReentryData = config.getConfig().getRunPlanUserReentryData();
|
||||
// 检测折返轨配置
|
||||
if (Objects.isNull(userReentryData.get(running1Routing.getParkSectionCodeList().get(0).getStationCode()))
|
||||
|| Objects.isNull(userReentryData.get(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getStationCode()))) {
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("折返轨未设置");
|
||||
}
|
||||
|
||||
//生成车次
|
||||
LinkedList<RunPlanTripVO> tripList = new LinkedList<>();
|
||||
//是否同时相向发车
|
||||
boolean opposite = Objects.isNull(runPlanInput.getRight());
|
||||
if (opposite) {
|
||||
//相向发车
|
||||
int initialServiceNum = 1;
|
||||
/*分别先发一辆车,计算控制左右发车服务号*/
|
||||
//上个服务号发车时刻
|
||||
//首班发车时间,首班车往返回来时间 来限定发车服务数量
|
||||
ServiceTempResult tempResultLeft = new ServiceTempResult(runPlanInput.getBeginTime(), null);
|
||||
serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResultLeft, false, runLevelTime, parkTime, userReentryData);
|
||||
|
||||
//上个服务号发车时刻
|
||||
//首班发车时间,首班车往返回来时间 来限定发车服务数量
|
||||
ServiceTempResult tempResultRight = new ServiceTempResult(runPlanInput.getBeginTime(), null);
|
||||
serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResultRight, true, runLevelTime, parkTime, userReentryData);
|
||||
|
||||
LocalTime firstRoundTripTimeLeft = tempResultLeft.getFirstRoundTripTime();
|
||||
LocalTime firstRoundTripTimeRight = tempResultRight.getFirstRoundTripTime();
|
||||
tempResultRight.setFirstRoundTripTime(firstRoundTripTimeLeft);
|
||||
tempResultLeft.setFirstRoundTripTime(firstRoundTripTimeRight);
|
||||
//暂时先定义发完左行,再发右行..
|
||||
do {
|
||||
tempResultLeft.setPreServiceDepartTime(tempResultLeft.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()));
|
||||
serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResultLeft, false, runLevelTime, parkTime, userReentryData);
|
||||
} while (tempResultLeft.getPreServiceDepartTime().minusSeconds(runPlanInput.getReentryTime()).plusSeconds(runPlanInput.getDepartureTimeInterval() * 2).compareTo(tempResultLeft.getFirstRoundTripTime()) <= 0);
|
||||
//发完左行,再发右行
|
||||
do {
|
||||
tempResultRight.setPreServiceDepartTime(tempResultRight.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()));
|
||||
serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResultRight, true, runLevelTime, parkTime, userReentryData);
|
||||
} while (tempResultRight.getPreServiceDepartTime().minusSeconds(runPlanInput.getReentryTime()).plusSeconds(runPlanInput.getDepartureTimeInterval() * 2).compareTo(tempResultRight.getFirstRoundTripTime()) <= 0);
|
||||
|
||||
} else {
|
||||
//单向发车
|
||||
allServiceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, tripList, runLevelTime, parkTime, userReentryData);
|
||||
|
||||
}
|
||||
return tripList;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务号发车
|
||||
*/
|
||||
private void serviceNumberDepart(MapVO mapVO, RunPlanInput runPlanInput, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, int initialServiceNum, LinkedList<RunPlanTripVO> tripList, ServiceTempResult tempResult, boolean isRight, Map<String, Integer> runLevelTime, Map<String, Integer> parkTime, Map<String, String> userReentryData) {
|
||||
String serviceNumber = String.format("%03d", initialServiceNum);
|
||||
//初始化车次号,右行偶数,左行奇数
|
||||
int initTripNumber = isRight ? 0 : 1;
|
||||
LocalTime lastTripEndTime = null;//一个车次终点时间
|
||||
LinkedList<RunPlanTripVO> tempTripList = new LinkedList<>();
|
||||
//根据运行时间判断结束末班车次
|
||||
do {
|
||||
RunPlanRoutingVO routing = Objects.equals(running1Routing.getRight(), isRight) ? running1Routing : running2Routing;
|
||||
String startReentrySectionCode = userReentryData.get(routing.getStartStationCode());
|
||||
String endReentrySectionCode = userReentryData.get(routing.getEndStationCode());
|
||||
MapSectionNewVO endReentrySection = null;
|
||||
if (Objects.nonNull(endReentrySectionCode)) {
|
||||
endReentrySection = mapVO.findSectionNew(endReentrySectionCode);
|
||||
}
|
||||
MapSectionNewVO startReentrySection = null;
|
||||
if (Objects.nonNull(startReentrySectionCode)) {
|
||||
startReentrySection = mapVO.findSectionNew(startReentrySectionCode);
|
||||
}
|
||||
RunPlanTripVO runPlanTripVO = new RunPlanTripVO(routing, startReentrySection, endReentrySection);
|
||||
runPlanTripVO.setServiceNumber(serviceNumber);
|
||||
setDirectionCode(mapVO, runPlanTripVO);
|
||||
runPlanTripVO.setIsReentry(true);
|
||||
//车次号
|
||||
String tripNumber = String.format("%03d", initTripNumber++);
|
||||
runPlanTripVO.setTripNumber(runPlanTripVO.getDirectionCode() + tripNumber);
|
||||
//首班右行方向
|
||||
LinkedList<RunPlanTripTimeVO> tripTimeList = new LinkedList<>();//车次时刻表
|
||||
routing.getParkSectionCodeList().forEach(runPlanRoutingSection -> {
|
||||
RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO();
|
||||
runPlanTripTimeVO.setStationCode(runPlanRoutingSection.getStationCode());
|
||||
runPlanTripTimeVO.setSectionCode(runPlanRoutingSection.getSectionCode());
|
||||
runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tempTripList) && CollectionUtils.isEmpty(tripTimeList) ?
|
||||
tempResult.getPreServiceDepartTime() :
|
||||
(CollectionUtils.isEmpty(tripTimeList) ?
|
||||
(Objects.equals(tempTripList.getLast().getEndSectionCode(), runPlanTripTimeVO.getSectionCode()) ?
|
||||
tempTripList.getLast().getEndTime() : ((LinkedList<RunPlanTripTimeVO>) tempTripList.getLast().getTimeList()).getLast().getDepartureTime().plusSeconds(runPlanInput.getReentryTime())) : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelTime.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode()))));
|
||||
runPlanTripTimeVO.setDepartureTime(CollectionUtils.isEmpty(tempTripList) && CollectionUtils.isEmpty(tripTimeList) ? tempResult.getPreServiceDepartTime() : runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTime.getOrDefault(runPlanTripTimeVO.getSectionCode(), 0)));
|
||||
tripTimeList.add(runPlanTripTimeVO);
|
||||
});
|
||||
runPlanTripVO.setTimeList(tripTimeList);
|
||||
setTripTerminalTime(runPlanTripVO, tripTimeList, runPlanInput.getReentryTime());
|
||||
lastTripEndTime = runPlanTripVO.getEndTime();
|
||||
if(CollectionUtils.isEmpty(tempTripList)){
|
||||
runPlanTripVO.setIsOutbound(true);
|
||||
}
|
||||
tempTripList.add(runPlanTripVO);
|
||||
if (tempTripList.size() > 50) { // 最快半小时跑一趟的一天车次数,如果大于这个,可能死循环,此时停止发车
|
||||
|
||||
break;
|
||||
}
|
||||
isRight = !isRight;
|
||||
|
||||
} while (lastTripEndTime.isBefore(runPlanInput.getOverTime()));
|
||||
//设置服务号末班车次入库
|
||||
RunPlanTripVO lastrunPlanTrip = tempTripList.get(tempTripList.size() - 1);
|
||||
lastrunPlanTrip.setIsInbound(true);
|
||||
lastrunPlanTrip.setIsReentry(false);
|
||||
LinkedList<RunPlanTripTimeVO> tripTimeList = (LinkedList<RunPlanTripTimeVO>) lastrunPlanTrip.getTimeList();
|
||||
setTripEndTime(lastrunPlanTrip, tripTimeList, runPlanInput.getReentryTime());
|
||||
tripList.addAll(tempTripList);
|
||||
if (Objects.isNull(tempResult.getFirstRoundTripTime())) {
|
||||
tempResult.setFirstRoundTripTime(((RunPlanTripTimeVO) (((LinkedList) (tempTripList.get(0).getTimeList())).getLast())).getDepartureTime());
|
||||
}
|
||||
tempResult.setPreServiceDepartTime(((RunPlanTripTimeVO) (((LinkedList) (tempTripList.get(0).getTimeList())).getFirst())).getArrivalTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 单向发车
|
||||
*/
|
||||
private void allServiceNumberDepart(MapVO mapVO, RunPlanInput runPlanInput, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, LinkedList<RunPlanTripVO> tripList, Map<String, Integer> runLevelTime, Map<String, Integer> parkTime, Map<String, String> userReentryData) {
|
||||
|
||||
|
||||
//设置初始服务号
|
||||
int initialServiceNum = 1;
|
||||
//上个服务号发车时刻
|
||||
//首班发车时间,首班车往返回来时间 来限定发车服务数量
|
||||
ServiceTempResult tempResult = new ServiceTempResult(runPlanInput.getBeginTime(), null);
|
||||
do {
|
||||
if (initialServiceNum != 1) {
|
||||
tempResult.setPreServiceDepartTime(tempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()));
|
||||
}
|
||||
serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResult, runPlanInput.getRight(), runLevelTime, parkTime, userReentryData);
|
||||
} while (tempResult.getPreServiceDepartTime().minusSeconds(runPlanInput.getReentryTime()).plusSeconds(runPlanInput.getDepartureTimeInterval() * 2).compareTo(tempResult.getFirstRoundTripTime()) <= 0);
|
||||
|
||||
}
|
||||
|
||||
public List<RunPlanTripVO> generatorTrips(Long userId, RunPlanInputData inputData, MapVO mapVO) {
|
||||
//校验时间
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(inputData.getOverTime().isAfter(inputData.getBeginTime()),"输入参数错误:发车时间应早于结束时间");
|
||||
LocalTime beginTimeOffset = inputData.getBeginTime().minusHours(OFFSET_TIME_HOURS);
|
||||
//向前推两小时,如果到前一天,则时间不合理
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(inputData.getBeginTime().isAfter(beginTimeOffset), "发车时间过早,建议晚于上午两点");
|
||||
inputData.setBeginTime(beginTimeOffset);
|
||||
inputData.setOverTime(inputData.getOverTime().minusHours(OFFSET_TIME_HOURS));
|
||||
|
||||
//查交路
|
||||
RunPlanRoutingVO outboundRouting = null;
|
||||
if (inputData.hasOutbound()) {
|
||||
outboundRouting = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), inputData.getOutboundRouting());
|
||||
}
|
||||
RunPlanRoutingVO inboundRouting = null;
|
||||
if (inputData.hasInbound()) {
|
||||
inboundRouting = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), inputData.getInboundRouting());
|
||||
}
|
||||
RunPlanRoutingVO running1Routing = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), inputData.getRunningRouting1());
|
||||
RunPlanRoutingVO running2Routing = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), inputData.getRunningRouting2());
|
||||
|
||||
//构建环路 和 出入库关系
|
||||
|
||||
//验证 出库和入库 一端折返轨 一段转换轨,验证环路 两端折返轨 ,环路是否闭环 或出入库跟环路是否衔接
|
||||
boolean isLoop = running1Routing.getParkSectionCodeList().get(0).getStationCode().equals(running2Routing.getParkSectionCodeList().get(running2Routing.getParkSectionCodeList().size() - 1).getStationCode())
|
||||
&& running2Routing.getParkSectionCodeList().get(0).getStationCode().equals(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getStationCode());
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(isLoop, "运行两交路无法构成环路数据");
|
||||
|
||||
boolean outToRun1 = outboundRouting.getParkSectionCodeList().get(outboundRouting.getParkSectionCodeList().size() - 1).getStationCode().equals(running1Routing.getParkSectionCodeList().get(0).getStationCode());
|
||||
boolean outToRun2 = outboundRouting.getParkSectionCodeList().get(outboundRouting.getParkSectionCodeList().size() - 1).getStationCode().equals(running2Routing.getParkSectionCodeList().get(0).getStationCode());
|
||||
|
||||
boolean inToRun1 = inboundRouting.getParkSectionCodeList().get(0).getStationCode().equals(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getStationCode());
|
||||
boolean inToRun2 = inboundRouting.getParkSectionCodeList().get(0).getStationCode().equals(running2Routing.getParkSectionCodeList().get(running2Routing.getParkSectionCodeList().size() - 1).getStationCode());
|
||||
|
||||
//出库关联环路某交楼
|
||||
RunPlanRoutingVO outRef = null;
|
||||
//环路其它交路
|
||||
RunPlanRoutingVO other = null;
|
||||
boolean same = false;
|
||||
if (outToRun1 && inToRun1) {
|
||||
same = true;
|
||||
outRef = running1Routing;
|
||||
other = running2Routing;
|
||||
} else if (outToRun2 && inToRun2) {
|
||||
same = true;
|
||||
outRef = running2Routing;
|
||||
other = running1Routing;
|
||||
} else if (outToRun1 && inToRun2) {
|
||||
outRef = running1Routing;
|
||||
other = running2Routing;
|
||||
} else if (outToRun2 && inToRun1) {
|
||||
outRef = running2Routing;
|
||||
other = running1Routing;
|
||||
} else {
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("出库交路 无法与环路交路相接");
|
||||
}
|
||||
//查站间运行等级
|
||||
List<RunPlanRunlevelVO> levels = runPlanRunlevelService.queryUserRunLevels(userId, mapVO.getId());
|
||||
Map<String, Integer> runLevelMap = levels.stream().collect(Collectors.toMap(runLevelVO -> String.format("%s-%s", runLevelVO.getStartSectionCode(), runLevelVO.getEndSectionCode()), runLevelVO -> runLevelVO.getLevelTime(inputData.getRunLevel())));
|
||||
//查停站时间
|
||||
List<RunPlanParkingTimeVO> parktimes = runPlanParktimeService.queryUserParktimes(userId, mapVO.getId());
|
||||
Map<String, Integer> parkTimeMap = parktimes.stream().collect(Collectors.toMap(RunPlanParkingTimeVO::getSectionCode, RunPlanParkingTimeVO::getParkingTime));
|
||||
//查折返
|
||||
RunPlanUserConfigVO config = runPlanUserConfigService.getConfig(userId, mapVO.getId());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(config) && config.hasReentryData(), "运行图-用户缺少配置或没有配置车站折返数据");
|
||||
Map<String, String> userReentryData = config.getConfig().getRunPlanUserReentryData();
|
||||
// 检测折返轨配置
|
||||
if (Objects.isNull(userReentryData.get(running1Routing.getParkSectionCodeList().get(0).getStationCode()))
|
||||
|| Objects.isNull(userReentryData.get(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getStationCode()))) {
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("折返轨未设置");
|
||||
}
|
||||
|
||||
List<RunPlanTripVO> tripList = new ArrayList<>(100);
|
||||
ServiceTempResult serviceResult = new ServiceTempResult();
|
||||
//单个服务号还是多个
|
||||
if (Objects.nonNull(inputData.getDepartureInterval())) {
|
||||
do {
|
||||
generateService(inputData, mapVO, outboundRouting, inboundRouting, outRef, same, other, runLevelMap, parkTimeMap, userReentryData, tripList, serviceResult);
|
||||
inputData.setServiceNumber(String.format("%03d", Integer.parseInt(inputData.getServiceNumber()) + 1));
|
||||
inputData.setBeginTime(inputData.getBeginTime().plusSeconds(inputData.getDepartureInterval()));
|
||||
} while (serviceResult.preServiceDepartTime.plusSeconds(inputData.getDepartureInterval()).compareTo(serviceResult.firstRoundTripTime) <= 0);
|
||||
|
||||
} else {
|
||||
generateService(inputData, mapVO, outboundRouting, inboundRouting, outRef, same, other, runLevelMap, parkTimeMap, userReentryData, tripList, serviceResult);
|
||||
}
|
||||
return tripList;
|
||||
}
|
||||
|
||||
private void generateService(RunPlanInputData inputData, MapVO mapVO, RunPlanRoutingVO outboundRouting, RunPlanRoutingVO inboundRouting, RunPlanRoutingVO outRef, final boolean same, RunPlanRoutingVO other, Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, String> userReentryData, List<RunPlanTripVO> tripList, ServiceTempResult serviceResult) {
|
||||
LinkedList<RunPlanTripVO> serviceTripList = new LinkedList<>();
|
||||
int initTripNumber = 1;
|
||||
TripTempResult temp = new TripTempResult(initTripNumber, inputData.getBeginTime());
|
||||
//构建出库车次
|
||||
buildServiceTrips(inputData, mapVO, outboundRouting, true, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp);
|
||||
|
||||
//计算出库车次运行所需时间
|
||||
int size = inboundRouting.getParkSectionCodeList().size();
|
||||
int inboundTripRunTime = inputData.getReentryTime()/2;
|
||||
for (int i = 0; i < size - 1; i++) {
|
||||
RunPlanRoutingSection routingSection = inboundRouting.getParkSectionCodeList().get(i);
|
||||
RunPlanRoutingSection nextRoutingSection = inboundRouting.getParkSectionCodeList().get(i + 1);
|
||||
Integer parkTime = parkTimeMap.get(routingSection.getSectionCode() );
|
||||
Integer runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
|
||||
inboundTripRunTime = inboundTripRunTime + parkTime + runTime;
|
||||
}
|
||||
|
||||
//计算出库对接环路运行所需时间
|
||||
int oSize = outRef.getParkSectionCodeList().size();
|
||||
int outRefTripRunTime = inputData.getReentryTime()+parkTimeMap.get(outRef.getParkSectionCodeList().get(oSize - 1).getSectionCode());
|
||||
for (int i = 0; i < oSize - 1; i++) {
|
||||
RunPlanRoutingSection routingSection = outRef.getParkSectionCodeList().get(i);
|
||||
RunPlanRoutingSection nextRoutingSection = outRef.getParkSectionCodeList().get(i + 1);
|
||||
Integer parkTime = parkTimeMap.get(routingSection.getSectionCode());
|
||||
Integer runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
|
||||
outRefTripRunTime = outRefTripRunTime + parkTime + runTime;
|
||||
}
|
||||
|
||||
//计算另一环路运行所需时间
|
||||
int iSize = other.getParkSectionCodeList().size();
|
||||
int otherTripRunTime = inputData.getReentryTime()+parkTimeMap.get(other.getParkSectionCodeList().get(iSize - 1).getSectionCode());
|
||||
for (int i = 0; i < iSize - 1; i++) {
|
||||
RunPlanRoutingSection routingSection = other.getParkSectionCodeList().get(i);
|
||||
RunPlanRoutingSection nextRoutingSection = other.getParkSectionCodeList().get(i + 1);
|
||||
Integer parkTime = parkTimeMap.get(routingSection.getSectionCode());
|
||||
Integer runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
|
||||
otherTripRunTime = otherTripRunTime + parkTime + runTime;
|
||||
}
|
||||
if (same ? true :
|
||||
(temp.getLastStationDepartTime().plusSeconds(inputData.getReentryTime()/2 + inboundTripRunTime).isBefore(inputData.getOverTime()) &&
|
||||
(temp.getLastStationDepartTime().plusSeconds(inputData.getReentryTime()/2).getHour()<3
|
||||
|| temp.getLastStationDepartTime().plusSeconds(inputData.getReentryTime()/2 + outRefTripRunTime + otherTripRunTime + inboundTripRunTime).getHour()>3))
|
||||
) {
|
||||
//构建环路车次
|
||||
boolean loop = false;
|
||||
do {
|
||||
if (same) {
|
||||
if (!loop) {
|
||||
buildServiceTrips(inputData, mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp);
|
||||
loop = true;
|
||||
} else {
|
||||
buildServiceTrips(inputData, mapVO, other, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp);
|
||||
buildServiceTrips(inputData, mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp);
|
||||
}
|
||||
} else {
|
||||
buildServiceTrips(inputData, mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp);
|
||||
buildServiceTrips(inputData, mapVO, other, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp);
|
||||
}
|
||||
}
|
||||
while (temp.getLastStationDepartTime().plusSeconds(inputData.getReentryTime()/2 + inboundTripRunTime).isBefore(inputData.getOverTime())
|
||||
&&
|
||||
(temp.getLastStationDepartTime().plusSeconds(inputData.getReentryTime()/2).getHour()<3||temp.getLastStationDepartTime().plusSeconds(inputData.getReentryTime()/2 + outRefTripRunTime + otherTripRunTime + inboundTripRunTime).getHour()>3));
|
||||
}
|
||||
//构建回库计划
|
||||
buildServiceTrips(inputData, mapVO, inboundRouting, false, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp);
|
||||
|
||||
if (Objects.isNull(serviceResult.getFirstRoundTripTime())) {
|
||||
serviceResult.setFirstRoundTripTime(serviceTripList.get(1).getEndTime());
|
||||
}
|
||||
serviceResult.setPreServiceDepartTime(serviceTripList.getFirst().getStartTime());
|
||||
tripList.addAll(serviceTripList);
|
||||
}
|
||||
|
||||
private void buildServiceTrips(RunPlanInputData inputData, MapVO mapVO, RunPlanRoutingVO routing, Boolean outbound,
|
||||
Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, String> userReentryData,
|
||||
LinkedList<RunPlanTripVO> tripList, TripTempResult tempResult) {
|
||||
String startReentrySectionCode = userReentryData.get(routing.getStartStationCode());
|
||||
String endReentrySectionCode = userReentryData.get(routing.getEndStationCode());
|
||||
MapSectionNewVO endReentrySection = null;
|
||||
if (Objects.nonNull(endReentrySectionCode)) {
|
||||
endReentrySection = mapVO.findSectionNew(endReentrySectionCode);
|
||||
}
|
||||
MapSectionNewVO startReentrySection = null;
|
||||
if (Objects.nonNull(startReentrySectionCode)) {
|
||||
startReentrySection = mapVO.findSectionNew(startReentrySectionCode);
|
||||
}
|
||||
RunPlanTripVO tripVO = new RunPlanTripVO(routing, startReentrySection, endReentrySection);
|
||||
setDirectionCode(mapVO, tripVO);
|
||||
tripVO.setServiceNumber(inputData.getServiceNumber());
|
||||
tripVO.setTripNumber(tripVO.getDirectionCode() + String.format("%03d", tempResult.getTripNumber()));
|
||||
tripVO.setIsReentry(true);
|
||||
if (Objects.nonNull(outbound)) {
|
||||
if (outbound) {
|
||||
tripVO.setIsOutbound(true);
|
||||
} else {
|
||||
tripVO.setIsInbound(true);
|
||||
tripVO.setIsReentry(false);
|
||||
}
|
||||
}
|
||||
LinkedList<RunPlanTripTimeVO> tripTimeList = new LinkedList<>();
|
||||
routing.getParkSectionCodeList().forEach(runPlanRoutingSection -> {
|
||||
RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO();
|
||||
runPlanTripTimeVO.setStationCode(runPlanRoutingSection.getStationCode());
|
||||
runPlanTripTimeVO.setSectionCode(runPlanRoutingSection.getSectionCode());
|
||||
runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripList) && CollectionUtils.isEmpty(tripTimeList) ?
|
||||
tempResult.getLastStationDepartTime() :
|
||||
(CollectionUtils.isEmpty(tripTimeList) ?
|
||||
(Objects.equals(tripList.getLast().getEndSectionCode(), runPlanTripTimeVO.getSectionCode()) ?
|
||||
tripList.getLast().getEndTime() : tempResult.getLastStationDepartTime().plusSeconds(inputData.getReentryTime())) : tempResult.getLastStationDepartTime().plusSeconds(runLevelMap.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode()))));
|
||||
runPlanTripTimeVO.setDepartureTime(CollectionUtils.isEmpty(tripList) && CollectionUtils.isEmpty(tripTimeList) ? tempResult.getLastStationDepartTime() : runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.getOrDefault(runPlanTripTimeVO.getSectionCode(), 0)));
|
||||
tempResult.setLastStationDepartTime(runPlanTripTimeVO.getDepartureTime());
|
||||
tripTimeList.add(runPlanTripTimeVO);
|
||||
});
|
||||
tripVO.setTimeList(tripTimeList);
|
||||
setTripTerminalTime(tripVO, tripTimeList, inputData.getReentryTime());
|
||||
tripList.add(tripVO);
|
||||
tempResult.incrementTripNumber();
|
||||
}
|
||||
|
||||
private void setDirectionCode(MapVO mapVO, RunPlanTripVO tripVO) {
|
||||
if (mapVO.getConfigVO().getUpRight()) {
|
||||
if (tripVO.getRight()) {
|
||||
tripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type02);
|
||||
} else {
|
||||
tripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type01);
|
||||
}
|
||||
} else {
|
||||
if (tripVO.getRight()) {
|
||||
tripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type01);
|
||||
} else {
|
||||
tripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type02);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTripTerminalTime(RunPlanTripVO runPlanTripVO, LinkedList<RunPlanTripTimeVO> tripTimeList, int reentryTime) {
|
||||
setTripStartTime(runPlanTripVO, tripTimeList, reentryTime);
|
||||
setTripEndTime(runPlanTripVO, tripTimeList, reentryTime);
|
||||
}
|
||||
|
||||
private void setTripEndTime(RunPlanTripVO lastRunPlanTrip, LinkedList<RunPlanTripTimeVO> tripTimeList, int reentryTime) {
|
||||
if (Objects.equals(lastRunPlanTrip.getEndSectionCode(), tripTimeList.getLast().getSectionCode())) {
|
||||
lastRunPlanTrip.setEndTime(tripTimeList.getLast().getDepartureTime());
|
||||
} else {
|
||||
lastRunPlanTrip.setEndTime(tripTimeList.getLast().getDepartureTime().plusSeconds(reentryTime / 2));
|
||||
}
|
||||
}
|
||||
|
||||
private void setTripStartTime(RunPlanTripVO runPlanTripVO, LinkedList<RunPlanTripTimeVO> tripTimeList, int reentryTime) {
|
||||
if (Objects.equals(runPlanTripVO.getStartSectionCode(), tripTimeList.getFirst().getSectionCode())) {
|
||||
runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime());
|
||||
} else {
|
||||
runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime().minusSeconds(reentryTime / 2));
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
private class TripTempResult {
|
||||
private int tripNumber;
|
||||
private LocalTime lastStationDepartTime;
|
||||
|
||||
public void incrementTripNumber() {
|
||||
tripNumber++;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
private class ServiceTempResult {
|
||||
private LocalTime preServiceDepartTime;
|
||||
private LocalTime firstRoundTripTime;
|
||||
}
|
||||
|
||||
}
|
@ -11,7 +11,6 @@ import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
@ -61,14 +60,14 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
||||
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
|
||||
Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode());
|
||||
Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode());
|
||||
if (startSection.isTransferTrack() && endSection.isTransferTrack()) {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.OTHER);
|
||||
} else if (startSection.isTransferTrack()) {
|
||||
if (startSection.isTransferTrack() && endSection.isTurnBackTrack()) {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.OUTBOUND);
|
||||
} else if (endSection.isTransferTrack()) {
|
||||
} else if (startSection.isTurnBackTrack() && endSection.isTransferTrack()) {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.INBOUND);
|
||||
} else {
|
||||
} else if (startSection.isTurnBackTrack() && endSection.isTurnBackTrack()) {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.LOOP);
|
||||
} else {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.OTHER);
|
||||
}
|
||||
RunPlanRouting routing = routingVO.convert2Entity();
|
||||
runPlanRoutingDAO.insert(routing);
|
||||
@ -77,7 +76,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunPlanRoutingVO generateUserRouting(RunPlanRoutingVO routingVO) {
|
||||
public RunPlanRoutingVO generateUserRoutingSections(RunPlanRoutingVO routingVO) {
|
||||
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
|
||||
@ -113,14 +112,14 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
||||
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
|
||||
Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode());
|
||||
Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode());
|
||||
if (startSection.isTransferTrack() && endSection.isTransferTrack()) {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.OTHER);
|
||||
} else if (startSection.isTransferTrack()) {
|
||||
if (startSection.isTransferTrack() && endSection.isTurnBackTrack()) {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.OUTBOUND);
|
||||
} else if (endSection.isTransferTrack()) {
|
||||
} else if (startSection.isTurnBackTrack() && endSection.isTransferTrack()) {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.INBOUND);
|
||||
} else {
|
||||
} else if (startSection.isTurnBackTrack() && endSection.isTurnBackTrack()) {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.LOOP);
|
||||
} else {
|
||||
routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.OTHER);
|
||||
}
|
||||
RunPlanRouting newRouting = routingVO.convert2Entity();
|
||||
newRouting.setId(routingId);
|
||||
@ -132,19 +131,23 @@ 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())).isTransferTrack() && !planParktimeService.isExisted(p)) {
|
||||
if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack() && !planParktimeService.isExisted(p)) {
|
||||
planParktimeService.createUserParktime(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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())
|
||||
|| (endSection.isTurnBackTrack() && !endSection.isStandTrack())) {
|
||||
return;
|
||||
}
|
||||
if (!planRunlevelService.isExisted(l)) {
|
||||
if ((startSection.isStandTrack() && endSection.isTransferTrack()) || (endSection.isStandTrack() && startSection.isTransferTrack())) {
|
||||
Float distance;
|
||||
try {
|
||||
@ -199,7 +202,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
||||
RunPlanRoutingExample example = new RunPlanRoutingExample();
|
||||
example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId);
|
||||
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
|
||||
return RunPlanRoutingVO.convert2VOList(runPlanRoutings);
|
||||
return RunPlanRoutingVO.convert2VOList(runPlanRoutings,this.iMapService.getMapDetail(mapId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -209,15 +212,11 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
||||
.filter(tripVO -> tripVO.getSDTNumberNew().equals(SDTNumber))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception());
|
||||
List<RunPlanRoutingSection> routingSections = trip.getTimeList().stream().map(rt -> {
|
||||
RunPlanRoutingSection routingSection = new RunPlanRoutingSection();
|
||||
routingSection.setStationCode(rt.getStationCode());
|
||||
routingSection.setSectionCode(rt.getSectionCode());
|
||||
return routingSection;
|
||||
}).collect(Collectors.toList());
|
||||
RunPlanRouting runPlanRouting = runPlanRoutingDAO.getUserRoutingBySectionData(userId,planVO.getMapId(),JsonUtils.writeValueAsString(routingSections));
|
||||
if (Objects.isNull(runPlanRouting)) return null;
|
||||
return RunPlanRoutingVO.convert2VO(runPlanRouting);
|
||||
RunPlanRoutingExample example = new RunPlanRoutingExample();
|
||||
example.createCriteria().andMapIdEqualTo(planVO.getMapId()).andUserIdEqualTo(userId).andStartSectionCodeEqualTo(trip.getStartSectionCode()).andEndSectionCodeEqualTo(trip.getEndSectionCode());
|
||||
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
|
||||
if (CollectionUtils.isEmpty(runPlanRoutings)) return null;
|
||||
return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0), this.iMapService.getMapDetail(planVO.getMapId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -232,12 +231,11 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
||||
@Override
|
||||
public List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId, Long planId, String routingCode) {
|
||||
RunPlanDraft runPlanDraft = runPlanDraftDAO.selectByPrimaryKey(planId);
|
||||
|
||||
RunPlanRoutingExample example = new RunPlanRoutingExample();
|
||||
example.createCriteria().andMapIdEqualTo(runPlanDraft.getMapId()).andUserIdEqualTo(userId).andCodeEqualTo(routingCode);
|
||||
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
|
||||
if (CollectionUtils.isEmpty(runPlanRoutings)) return Collections.emptyList();
|
||||
return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0)).getParkSectionCodeList();
|
||||
List<RunPlanRouting> list = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
|
||||
if (CollectionUtils.isEmpty(list)) return Collections.emptyList();
|
||||
return RunPlanRoutingVO.convert2VO(list.get(0)).getParkSectionCodeList();
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class MapVO {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public MapSectionNewVO findSectionNew(String code) {
|
||||
public MapSectionNewVO findSection(String code) {
|
||||
MapGraphDataNewVO graphData = this.getGraphDataNew();
|
||||
if (Objects.nonNull(graphData)) {
|
||||
List<MapSectionNewVO> sectionList = graphData.getSectionList();
|
||||
@ -163,6 +163,19 @@ public class MapVO {
|
||||
return null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public MapStationNewVO findStation(String code) {
|
||||
MapGraphDataNewVO graphData = this.getGraphDataNew();
|
||||
if (Objects.nonNull(graphData)) {
|
||||
List<MapStationNewVO> stationList = graphData.getStationList();
|
||||
if (!CollectionUtils.isEmpty(stationList)) {
|
||||
MapStationNewVO station = stationList.stream().filter(mapStationNewVO -> mapStationNewVO.getCode().equals(code)).findFirst().orElse(null);
|
||||
return station;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public List<MapStationNewVO> findSortedAllStationListNew() {
|
||||
|
@ -1,13 +1,12 @@
|
||||
package club.joylink.rtss.vo.client.runplan;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.vo.client.map.newmap.MapSectionNewVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
|
||||
import club.joylink.rtss.vo.client.map.MapRoutingVO;
|
||||
import club.joylink.rtss.vo.client.map.newmap.MapRoutingDataVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -15,7 +14,6 @@ import lombok.Setter;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -140,23 +138,31 @@ public class RunPlanTripVO {
|
||||
this.timeList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public RunPlanTripVO(RunPlanTripConfigVO tripConfigVO, RunPlanRoutingVO routingVO , MapSectionNewVO startReentrySection, MapSectionNewVO endReentrySection) {
|
||||
public RunPlanTripVO(RunPlanRoutingVO routingVO) {
|
||||
this.right = routingVO.getRight();
|
||||
this.destinationCode = Objects.nonNull(endReentrySection) ? endReentrySection.getDestinationCode() : routingVO.getDestinationCode();
|
||||
this.startSectionCode = Objects.nonNull(startReentrySection) ? startReentrySection.getCode() : routingVO.getStartSectionCode();
|
||||
this.endSectionCode = Objects.nonNull(endReentrySection) ? endReentrySection.getCode() : routingVO.getEndSectionCode();
|
||||
this.startTime = tripConfigVO.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME).minusSeconds(40);
|
||||
this.endTime = tripConfigVO.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME).plusSeconds(40);
|
||||
this.destinationCode = routingVO.getDestinationCode();
|
||||
this.startSectionCode = routingVO.getStartSectionCode();
|
||||
this.endSectionCode = routingVO.getEndSectionCode();
|
||||
this.timeList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public RunPlanTripVO(RunPlanRoutingVO routingVO , MapSectionNewVO startReentrySection, MapSectionNewVO endReentrySection) {
|
||||
this.right = routingVO.getRight();
|
||||
this.destinationCode = Objects.nonNull(endReentrySection) ? endReentrySection.getDestinationCode() : routingVO.getDestinationCode();
|
||||
this.startSectionCode = Objects.nonNull(startReentrySection) ? startReentrySection.getCode() : routingVO.getStartSectionCode();
|
||||
this.endSectionCode = Objects.nonNull(endReentrySection) ? endReentrySection.getCode() : routingVO.getEndSectionCode();
|
||||
this.timeList = new ArrayList<>();
|
||||
}
|
||||
// public RunPlanTripVO(RunPlanTripConfigVO tripConfigVO, RunPlanRoutingVO routingVO , MapSectionNewVO startReentrySection, MapSectionNewVO endReentrySection) {
|
||||
// this.right = routingVO.getRight();
|
||||
// this.destinationCode = Objects.nonNull(endReentrySection) ? endReentrySection.getDestinationCode() : routingVO.getDestinationCode();
|
||||
// this.startSectionCode = Objects.nonNull(startReentrySection) ? startReentrySection.getCode() : routingVO.getStartSectionCode();
|
||||
// this.endSectionCode = Objects.nonNull(endReentrySection) ? endReentrySection.getCode() : routingVO.getEndSectionCode();
|
||||
// this.startTime = tripConfigVO.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME).minusSeconds(40);
|
||||
// this.endTime = tripConfigVO.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME).plusSeconds(40);
|
||||
// this.timeList = new ArrayList<>();
|
||||
// }
|
||||
//
|
||||
// public RunPlanTripVO(RunPlanRoutingVO routingVO , MapSectionNewVO startReentrySection, MapSectionNewVO endReentrySection) {
|
||||
// this.right = routingVO.getRight();
|
||||
// this.destinationCode = Objects.nonNull(endReentrySection) ? endReentrySection.getDestinationCode() : routingVO.getDestinationCode();
|
||||
// this.startSectionCode = Objects.nonNull(startReentrySection) ? startReentrySection.getCode() : routingVO.getStartSectionCode();
|
||||
// this.endSectionCode = Objects.nonNull(endReentrySection) ? endReentrySection.getCode() : routingVO.getEndSectionCode();
|
||||
// this.timeList = new ArrayList<>();
|
||||
// }
|
||||
|
||||
public RunPlanTripVO(TripPlan plan) {
|
||||
this.serviceNumber = plan.getServiceNumber();
|
||||
@ -179,6 +185,9 @@ public class RunPlanTripVO {
|
||||
}
|
||||
|
||||
public void addTime(RunPlanTripTimeVO timeVO) {
|
||||
if(Objects.isNull(timeList)){
|
||||
timeList = new ArrayList<>();
|
||||
}
|
||||
this.timeList.add(timeVO);
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,13 @@
|
||||
package club.joylink.rtss.vo.client.runplan.user;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value="交路经停区段草稿")
|
||||
@NoArgsConstructor
|
||||
@ -28,13 +24,4 @@ public class RunPlanRoutingSection {
|
||||
@NotBlank(message = "区段编号不能为空")
|
||||
private String sectionCode;
|
||||
|
||||
public static List<RunPlanRoutingSection> from(List<Section> viaSectionList) {
|
||||
List<RunPlanRoutingSection> voList = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(viaSectionList)) {
|
||||
for (Section section : viaSectionList) {
|
||||
voList.add(new RunPlanRoutingSection(section.getStation().getCode(), section.getCode()));
|
||||
}
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,9 @@ package club.joylink.rtss.vo.client.runplan.user;
|
||||
|
||||
import club.joylink.rtss.entity.RunPlanRouting;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.client.map.MapVO;
|
||||
import club.joylink.rtss.vo.client.map.newmap.MapSectionNewVO;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
@ -12,7 +15,9 @@ import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ApiModel(value = "运行图用户交路对象")
|
||||
@ -67,6 +72,11 @@ public class RunPlanRoutingVO {
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String remarks;
|
||||
|
||||
/**起始车站是否站前折返,是:站前折返,否:站后折返,null 不是折返*/
|
||||
private Boolean startTbFront;
|
||||
|
||||
/**终到车站是否站前折返,是:站前折返,否:站后折返,null 不是折返*/
|
||||
private Boolean endTbFront;
|
||||
|
||||
public RunPlanRoutingVO() {
|
||||
this.parkSectionCodeList = new ArrayList<>();
|
||||
@ -91,6 +101,26 @@ public class RunPlanRoutingVO {
|
||||
return routingVO;
|
||||
}
|
||||
|
||||
public static RunPlanRoutingVO convert2VO(RunPlanRouting runPlanRouting, MapVO mapVO ) {
|
||||
RunPlanRoutingVO routingVO = new RunPlanRoutingVO();
|
||||
routingVO.setId(runPlanRouting.getId());
|
||||
routingVO.setMapId(runPlanRouting.getMapId());
|
||||
routingVO.setUserId(runPlanRouting.getUserId());
|
||||
routingVO.setName(runPlanRouting.getName());
|
||||
routingVO.setCode(runPlanRouting.getCode());
|
||||
routingVO.setRoutingType(UserRoutingType.valueOf(runPlanRouting.getType()));
|
||||
routingVO.setStartStationCode(runPlanRouting.getStartStationCode());
|
||||
routingVO.setStartSectionCode(runPlanRouting.getStartSectionCode());
|
||||
routingVO.setEndStationCode(runPlanRouting.getEndStationCode());
|
||||
routingVO.setEndSectionCode(runPlanRouting.getEndSectionCode());
|
||||
routingVO.setRight(runPlanRouting.getRight());
|
||||
routingVO.setDestinationCode(runPlanRouting.getDestinationCode());
|
||||
routingVO.setRemarks(runPlanRouting.getRemarks());
|
||||
routingVO.setParkSectionCodeList(JsonUtils.readCollection(runPlanRouting.getSectionData(), List.class, RunPlanRoutingSection.class));
|
||||
routingVO.setReentryType(mapVO);
|
||||
return routingVO;
|
||||
}
|
||||
|
||||
public RunPlanRouting convert2Entity() {
|
||||
RunPlanRouting routing = new RunPlanRouting();
|
||||
routing.setId(id);
|
||||
@ -128,6 +158,34 @@ public class RunPlanRoutingVO {
|
||||
return runPlanRoutings.stream().map(RunPlanRoutingVO::convert2VO).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<RunPlanRoutingVO> convert2VOList(List<RunPlanRouting> runPlanRoutings, MapVO mapVO) {
|
||||
return runPlanRoutings.stream().map(r -> RunPlanRoutingVO.convert2VO(r, mapVO)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isOutBoundRoute(){
|
||||
return Objects.equals(UserRoutingType.OUTBOUND,routingType);
|
||||
}
|
||||
@JsonIgnore
|
||||
public boolean isInBoundRoute(){
|
||||
return Objects.equals(UserRoutingType.INBOUND,routingType);
|
||||
}
|
||||
@JsonIgnore
|
||||
public boolean isLoopRoute(){
|
||||
return Objects.equals(UserRoutingType.LOOP,routingType);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
private void setReentryType(MapVO mapVO){
|
||||
if(isOutBoundRoute() || isLoopRoute()){
|
||||
MapSectionNewVO endReentrySection = mapVO.findSection(endSectionCode);
|
||||
endTbFront = endReentrySection.isReentryTrack() && endReentrySection.isStandTrack();
|
||||
}
|
||||
if(isInBoundRoute() || isLoopRoute()){
|
||||
MapSectionNewVO startReentrySection = mapVO.findSection(startSectionCode);
|
||||
startTbFront = startReentrySection.isReentryTrack() && startReentrySection.isStandTrack();
|
||||
}
|
||||
}
|
||||
public enum UserRoutingType{
|
||||
OUTBOUND,
|
||||
INBOUND,
|
||||
|
@ -148,7 +148,8 @@ public class RunPlanRunlevelVO {
|
||||
public static List<RunPlanRunlevelVO> runLevelsFromRouting(RunPlanRoutingVO routingVO) {
|
||||
List<RunPlanRoutingSection> parkSectionList = routingVO.getParkSectionCodeList();
|
||||
List<RunPlanRunlevelVO> list = new ArrayList<>();
|
||||
for (int i = 0; i < parkSectionList.size()-1; i++) {
|
||||
int n = parkSectionList.size()- 1;
|
||||
for (int i = 0; i < n; i++) {
|
||||
RunPlanRunlevelVO runlevelVO = new RunPlanRunlevelVO();
|
||||
runlevelVO.setMapId(routingVO.getMapId());
|
||||
runlevelVO.setUserId(routingVO.getUserId());
|
||||
|
@ -9,8 +9,9 @@ import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -33,6 +34,7 @@ public class RunPlanUserConfigVO {
|
||||
|
||||
@ApiModelProperty(value = "交路编号")
|
||||
@NotNull(message = "交路编号不能为空")
|
||||
@Valid
|
||||
private Config config;
|
||||
|
||||
public static RunPlanUserConfigVO convert2VO(RunPlanUserConfig runPlanUserConfig) {
|
||||
@ -58,7 +60,7 @@ public class RunPlanUserConfigVO {
|
||||
}
|
||||
|
||||
public boolean hasReentryData(){
|
||||
return Objects.nonNull(config) && !CollectionUtils.isEmpty(config.getRunPlanUserReentryData());
|
||||
return Objects.nonNull(config) && !CollectionUtils.isEmpty(config.reentryData);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ -68,6 +70,20 @@ public class RunPlanUserConfigVO {
|
||||
/**运行车站折返配置数据:车站code->折返轨code*/
|
||||
@ApiModelProperty(value = "运行车站折返配置数据")
|
||||
@NonNull
|
||||
private Map<String,String> runPlanUserReentryData;
|
||||
private Map<String,ReentryTime> reentryData=new HashMap<>();
|
||||
// private Map<String,String> runPlanUserReentryData;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ReentryTime{
|
||||
/**站前折返s*/
|
||||
private Integer tbFront;
|
||||
/**站后折返s*/
|
||||
private Integer tbBack;
|
||||
/**从股道到折返s*/
|
||||
private Integer tbFrom;
|
||||
/**从折返到股道s*/
|
||||
private Integer tbTo;
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ public class RunPlanInput {
|
||||
@NotBlank(message= "环路不能为空")
|
||||
private String runningRouting2;
|
||||
|
||||
/**折返时间*/
|
||||
@ApiModelProperty(value = "折返时间")
|
||||
private int reentryTime;
|
||||
// /**折返时间*/
|
||||
// @ApiModelProperty(value = "折返时间")
|
||||
// private int reentryTime;
|
||||
|
||||
/**运行等级默认-站间运行时间*/
|
||||
private int runLevel=3;
|
||||
|
@ -52,9 +52,9 @@ public class RunPlanInputData {
|
||||
@ApiModelProperty(value = "发车间隔,s")
|
||||
private Integer departureInterval ;
|
||||
|
||||
/**折返时间*/
|
||||
@ApiModelProperty(value = "折返时间")
|
||||
private int reentryTime = 80;
|
||||
// /**折返时间*/
|
||||
// @ApiModelProperty(value = "折返时间")
|
||||
// private int reentryTime = 80;
|
||||
|
||||
/**运行等级默认-站间运行时间*/
|
||||
private int runLevel = 3;
|
||||
|
Loading…
Reference in New Issue
Block a user