Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
249c8c1eb7
@ -95,9 +95,9 @@ public class RunPlanUserDataController {
|
||||
iRunPlanRunlevelService.updateRefLevels(user.getId(), mapId, list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用于区段数据变化时更新站间距离")
|
||||
@ApiOperation(value = "用于区段数据变化时更新站间距离且重新计算运行等级数据")
|
||||
@PutMapping(path = "/{mapId}/runlevelDistance")
|
||||
public Map<Long, Float> updateRunlevelDistance(@PathVariable Long mapId, @RequestAttribute UserVO user) {
|
||||
public List<RunPlanRunlevelVO> updateRunlevelDistance(@PathVariable Long mapId, @RequestAttribute UserVO user) {
|
||||
return iRunPlanRunlevelService.updateRunlevelDistance(user.getId(), mapId);
|
||||
}
|
||||
|
||||
|
@ -745,22 +745,22 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
tripVO.setTripNumber(tripVO.getDirectionCode() + String.format("%03d", ++downTripNumber));
|
||||
}
|
||||
if (i == 0) {
|
||||
tripVO.setIsOutbound(true);
|
||||
tripVO.setIsInbound(true);
|
||||
// tripVO.setIsOutbound(true);
|
||||
// tripVO.setIsInbound(true);
|
||||
tripVO.setIsReentry(false);
|
||||
}
|
||||
if (newTripList.size() > 1) {
|
||||
if (i == newTripList.size() - 1) {
|
||||
tripVO.setIsInbound(true);
|
||||
// tripVO.setIsInbound(true);
|
||||
tripVO.setIsReentry(false);
|
||||
tripVO.setIsOutbound(false);
|
||||
// tripVO.setIsOutbound(false);
|
||||
} else if (i == 0) {
|
||||
tripVO.setIsReentry(true);
|
||||
tripVO.setIsInbound(false);
|
||||
// tripVO.setIsInbound(false);
|
||||
} else {
|
||||
tripVO.setIsInbound(false);
|
||||
// tripVO.setIsInbound(false);
|
||||
tripVO.setIsReentry(true);
|
||||
tripVO.setIsOutbound(false);
|
||||
// tripVO.setIsOutbound(false);
|
||||
}
|
||||
}
|
||||
//是否为备用车
|
||||
@ -787,12 +787,19 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
Map<String, List<RunPlanTripVO>> serviceMap = planVO.getTripList().stream().collect(Collectors.groupingBy(RunPlanTripVO::getServiceNumber));
|
||||
serviceMap.forEach((s, trips) -> {
|
||||
trips.sort(Comparator.comparing(RunPlanTripVO::getStartTime));
|
||||
if(Objects.isNull(trips.get(0).getIsOutbound()) || !trips.get(0).getIsOutbound()){
|
||||
errorList.add(String.format("服务号[%s]首班车次[%s]不是出库", s, trips.get(0).getTripNumber()));
|
||||
}
|
||||
LocalTime departTime = trips.get(0).getStartTime().plusHours(OFFSET_TIME_HOURS);
|
||||
//服务首班车次时间 >2:00
|
||||
if (departTime.isBefore(LocalTime.of(2, 0))) {
|
||||
errorList.add(String.format("服务号[%s]首班车次发车时间[%s]过早,应不早于02:00", s, departTime));
|
||||
}
|
||||
LocalTime overTime = trips.get(trips.size() - 1).getEndTime();
|
||||
|
||||
if(Objects.isNull(trips.get(trips.size() - 1).getIsInbound()) || !trips.get(trips.size() - 1).getIsInbound()){
|
||||
errorList.add(String.format("服务号[%s]最后一班车次[%s]不是回库", s, trips.get(trips.size() - 1).getTripNumber()));
|
||||
}
|
||||
LocalTime overTime = trips.get(trips.size() - 1).getEndTime().plusHours(OFFSET_TIME_HOURS);
|
||||
//服务最后一班车次时间 <2:00
|
||||
if (overTime.isAfter(LocalTime.of(2, 0)) && overTime.isBefore(LocalTime.of(4, 0))) {
|
||||
errorList.add(String.format("服务号[%s]最后一班车次结束时间[%s]太晚,应不晚于次日02:00", s, overTime));
|
||||
@ -881,6 +888,10 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
continue;
|
||||
}
|
||||
Float distance = stationSpacingMap.get(tripTime.getSectionCode() + "-" + nextTripTime.getSectionCode());
|
||||
MapSectionNewVO startSection = map.findSection(tripTime.getSectionCode());
|
||||
if (startSection.isReentryTrack() && !startSection.isStandTrack()){
|
||||
continue;
|
||||
}
|
||||
if (Objects.isNull(distance)) {
|
||||
errorList.add(String.format("服务号[%s]车次号[%s]从车站[%s]至车站[%s]缺少站间距离数据", s, trip.getTripNumber(), map.findStation(tripTime.getStationCode()).getName(), map.findStation(nextTripTime.getStationCode()).getName()));
|
||||
continue;
|
||||
@ -976,8 +987,8 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
cur.getServiceNumber(), cur.getTripNumber(), map.findStation(cur.getStationCode()).getName()));
|
||||
return;
|
||||
}
|
||||
if (ChronoUnit.SECONDS.between(pre.getDepartureTime(), cur.getArrivalTime()) < 60) {
|
||||
errorList.add(String.format("相邻车次[%s-%s] 与 车次[%s-%s]行车至车站[%s]时运行间隔太小不安全,应不小于1分钟",
|
||||
if (ChronoUnit.SECONDS.between(pre.getDepartureTime(), cur.getArrivalTime()) < 45) {
|
||||
errorList.add(String.format("相邻车次[%s-%s] 与 车次[%s-%s]行车至车站[%s]时运行间隔太小不安全,应不小于45秒",
|
||||
pre.getServiceNumber(), pre.getTripNumber(),
|
||||
cur.getServiceNumber(), cur.getTripNumber(),map.findStation(cur.getStationCode()).getName()));
|
||||
return;
|
||||
|
@ -14,7 +14,7 @@ public interface IRunPlanRunlevelService {
|
||||
|
||||
void updateRefLevels(Long userId, Long mapId, List<RunPlanRunlevelVO> list);
|
||||
|
||||
Map<Long,Float> updateRunlevelDistance(Long userId, Long mapId);
|
||||
List<RunPlanRunlevelVO> updateRunlevelDistance(Long userId, Long mapId);
|
||||
|
||||
PageVO<RunPlanRunlevelVO> queryUserRunLevels(Long userId, Long mapId, RunPlanRunLevelQueryVO queryVO);
|
||||
|
||||
|
@ -3,11 +3,12 @@ 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.RunPlanInputData;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -56,35 +57,35 @@ public class RunPlanGenerator {
|
||||
int startServiceNumber = Integer.parseInt(inputData.getServiceNumber());
|
||||
LocalTime initBeginTime = inputData.getBeginTime();
|
||||
|
||||
LinkedList<RunPlanTripVO> serviceTripList1 = generateService(inputData, mapVO,inboundRoutings, running1Routing, running2Routing, runLevelMap, parkTimeMap, reentryData);
|
||||
LinkedList<RunPlanTripVO> serviceTripList1 = generateService(inputData, mapVO, inboundRoutings, running1Routing, running2Routing, runLevelMap, parkTimeMap, reentryData);
|
||||
tripList.addAll(serviceTripList1);
|
||||
LocalTime departEndTime2 = serviceTripList1.get(1).getStartTime();
|
||||
LocalTime departEndTime2 = serviceTripList1.get(1).getTimeList().get(0).getArrivalTime();
|
||||
|
||||
inputData.setServiceNumber(String.format("%03d", startServiceNumber + 1));
|
||||
LinkedList<RunPlanTripVO> serviceTripList2 = generateService(inputData, mapVO,inboundRoutings, running2Routing, running1Routing, runLevelMap, parkTimeMap, reentryData);
|
||||
LinkedList<RunPlanTripVO> serviceTripList2 = generateService(inputData, mapVO, inboundRoutings, running2Routing, running1Routing, runLevelMap, parkTimeMap, reentryData);
|
||||
tripList.addAll(serviceTripList2);
|
||||
LocalTime departEndTime1 = serviceTripList2.get(1).getStartTime();
|
||||
LocalTime departEndTime1 = serviceTripList2.get(1).getTimeList().get(0).getArrivalTime();
|
||||
|
||||
RunPlanRoutingVO outBoundRouting2 = null;
|
||||
RunPlanRoutingVO outBoundRouting1 = null;
|
||||
Routing2BoundInfo outBoundRouting2 = null;
|
||||
Routing2BoundInfo outBoundRouting1 = null;
|
||||
if (inputData.hasOutAndInBound()) {
|
||||
outBoundRouting1 = getOutboundRouting(running1Routing, outboundRoutings);
|
||||
outBoundRouting2 = getOutboundRouting(running2Routing, outboundRoutings);
|
||||
outBoundRouting1 = getOutboundRouting(running1Routing, outboundRoutings,runLevelMap);
|
||||
outBoundRouting2 = getOutboundRouting(running2Routing, outboundRoutings,runLevelMap);
|
||||
if (Objects.nonNull(outBoundRouting1) && Objects.nonNull(outBoundRouting2)) {
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList1, outBoundRouting1);
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList2, outBoundRouting2);
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList1, outBoundRouting1);
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList2, outBoundRouting2);
|
||||
} else if (Objects.nonNull(outBoundRouting1)) {
|
||||
tripList.removeAll(serviceTripList2);
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList1, outBoundRouting1);
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList1, outBoundRouting1);
|
||||
inputData.setServiceNumber(String.format("%03d", startServiceNumber + 2));
|
||||
departEndTime1 = serviceTripList1.get(2).getStartTime();
|
||||
departEndTime1 = serviceTripList1.get(2).getTimeList().get(0).getArrivalTime();
|
||||
generateServices(inputData, mapVO, running1Routing, running2Routing, inboundRoutings, outBoundRouting1, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime1);
|
||||
return tripList;
|
||||
} else if(Objects.nonNull(outBoundRouting2)){
|
||||
} else if (Objects.nonNull(outBoundRouting2)) {
|
||||
tripList.removeAll(serviceTripList1);
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList2, outBoundRouting2);
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList2, outBoundRouting2);
|
||||
inputData.setServiceNumber(String.format("%03d", startServiceNumber + 3));
|
||||
departEndTime2 = serviceTripList2.get(2).getStartTime();
|
||||
departEndTime2 = serviceTripList2.get(2).getTimeList().get(0).getArrivalTime();
|
||||
generateServices(inputData, mapVO, running2Routing, running1Routing, inboundRoutings, outBoundRouting2, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime2);
|
||||
return tripList;
|
||||
}
|
||||
@ -97,17 +98,17 @@ public class RunPlanGenerator {
|
||||
generateServices(inputData, mapVO, running2Routing, running1Routing, inboundRoutings, outBoundRouting2, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime2);
|
||||
} else {
|
||||
|
||||
RunPlanRoutingVO outBoundRouting = null;
|
||||
Routing2BoundInfo outBoundRouting = null;
|
||||
//出库的衔接环路
|
||||
RunPlanRoutingVO outRefLoop = running1Routing;
|
||||
//另一个交路
|
||||
RunPlanRoutingVO otherLoop = running2Routing;
|
||||
if (inputData.hasOutAndInBound()) {
|
||||
outBoundRouting = getOutboundRouting(running1Routing, outboundRoutings);
|
||||
outBoundRouting = getOutboundRouting(running1Routing, outboundRoutings,runLevelMap);
|
||||
outRefLoop = running1Routing;
|
||||
otherLoop = running2Routing;
|
||||
if (Objects.isNull(outBoundRouting)) {
|
||||
outBoundRouting = getOutboundRouting(running2Routing, outboundRoutings);
|
||||
outBoundRouting = getOutboundRouting(running2Routing, outboundRoutings,runLevelMap);
|
||||
outRefLoop = running2Routing;
|
||||
otherLoop = running1Routing;
|
||||
}
|
||||
@ -115,34 +116,13 @@ public class RunPlanGenerator {
|
||||
LinkedList<RunPlanTripVO> serviceTripList = generateService(inputData, mapVO, inboundRoutings, outRefLoop, otherLoop, runLevelMap, parkTimeMap, reentryData);
|
||||
//构建出库车次时刻
|
||||
if (inputData.hasOutAndInBound() && Objects.nonNull(outBoundRouting)) {
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList, outBoundRouting);
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList, outBoundRouting);
|
||||
}
|
||||
tripList.addAll(serviceTripList);
|
||||
}
|
||||
return tripList;
|
||||
}
|
||||
|
||||
private void setOutBoundTripTimes(Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap,
|
||||
LinkedList<RunPlanTripVO> serviceTripList, RunPlanRoutingVO outBoundRouting) {
|
||||
//首趟车次连接车辆段或停车场
|
||||
RunPlanTripVO firstTrip = serviceTripList.getFirst();
|
||||
firstTrip.setStartSectionCode(outBoundRouting.getStartSectionCode());
|
||||
List<RunPlanTripTimeVO> timeList = firstTrip.getTimeList();
|
||||
RunPlanTripTimeVO runPlanTripTime = timeList.get(0);
|
||||
if(Objects.equals(runPlanTripTime.getSectionCode(),firstTrip.getStartSectionCode())){
|
||||
runPlanTripTime.setArrivalTime(runPlanTripTime.getDepartureTime().minusSeconds(parkTimeMap.get(runPlanTripTime.getSectionCode())));
|
||||
}
|
||||
LocalTime arrivalTime = runPlanTripTime.getArrivalTime();
|
||||
String sectionCode = runPlanTripTime.getSectionCode();
|
||||
RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO();
|
||||
runPlanTripTimeVO.setStationCode(outBoundRouting.getStartStationCode());
|
||||
runPlanTripTimeVO.setSectionCode(outBoundRouting.getStartSectionCode());
|
||||
runPlanTripTimeVO.setDepartureTime(arrivalTime.minusSeconds(runLevelMap.get(runPlanTripTimeVO.getSectionCode() + "-" + sectionCode)));
|
||||
runPlanTripTimeVO.setArrivalTime(runPlanTripTimeVO.getDepartureTime());
|
||||
timeList.add(0, runPlanTripTimeVO);
|
||||
firstTrip.setStartTime(timeList.get(0).getArrivalTime());
|
||||
}
|
||||
|
||||
private void checkInputTime(RunPlanInputData inputData) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(inputData.getOverTime().isAfter(inputData.getBeginTime()), "输入参数错误:发车时间应早于结束时间");
|
||||
LocalTime beginTimeOffset = inputData.getBeginTime().minusHours(OFFSET_TIME_HOURS);
|
||||
@ -151,7 +131,11 @@ public class RunPlanGenerator {
|
||||
inputData.setOverTime(inputData.getOverTime().minusHours(OFFSET_TIME_HOURS));
|
||||
}
|
||||
|
||||
private void generateServices(RunPlanInputData inputData, MapVO mapVO, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, List<RunPlanRoutingVO> inboundRoutings, RunPlanRoutingVO outBoundRouting, Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData, List<RunPlanTripVO> tripList, LocalTime initBeginTime, LocalTime departEndTime) {
|
||||
private void generateServices(RunPlanInputData inputData, MapVO mapVO,
|
||||
RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, List<RunPlanRoutingVO> inboundRoutings, Routing2BoundInfo outBoundRouting,
|
||||
Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData,
|
||||
List<RunPlanTripVO> tripList,
|
||||
LocalTime initBeginTime, LocalTime departEndTime) {
|
||||
LinkedList<RunPlanTripVO> serviceTripList;
|
||||
inputData.setBeginTime(initBeginTime);
|
||||
LocalTime preServiceDepartTime = inputData.getBeginTime();
|
||||
@ -161,8 +145,8 @@ public class RunPlanGenerator {
|
||||
inputData.setServiceNumber(String.format("%03d", Integer.parseInt(inputData.getServiceNumber()) + 2));
|
||||
preServiceDepartTime = serviceTripList.getFirst().getStartTime();
|
||||
//构建出库车次时刻
|
||||
if (inputData.hasOutAndInBound() && Objects.nonNull(outBoundRouting)) {
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, serviceTripList, outBoundRouting);
|
||||
if (inputData.hasOutAndInBound() && Objects.nonNull(outBoundRouting)) {
|
||||
setOutBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList, outBoundRouting);
|
||||
}
|
||||
tripList.addAll(serviceTripList);
|
||||
}
|
||||
@ -180,11 +164,9 @@ public class RunPlanGenerator {
|
||||
if (Objects.isNull(reentryData.get(endStationCode))) {
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception(String.format("车站[%s]缺少折返数据", mapVO.findStation(endStationCode).getName()));
|
||||
}
|
||||
Boolean startTBIsFront = startTBIsFront(running1Routing, mapVO);
|
||||
checkStationReentryData(mapVO, reentryData, startStationCode, startTBIsFront);
|
||||
checkStationReentryData(mapVO, reentryData, startStationCode, running1Routing.getStartTbFront());
|
||||
|
||||
Boolean endTBIsFront = endTBIsFront(running1Routing, mapVO);
|
||||
checkStationReentryData(mapVO, reentryData, endStationCode, endTBIsFront);
|
||||
checkStationReentryData(mapVO, reentryData, endStationCode, running1Routing.getEndTbFront());
|
||||
return reentryData;
|
||||
}
|
||||
|
||||
@ -203,15 +185,11 @@ public class RunPlanGenerator {
|
||||
LinkedList<RunPlanTripVO> serviceTripList = new LinkedList<>();
|
||||
int nextTripNumber = 1;
|
||||
|
||||
int outRefTripRunTime = getLoopTripRunTime(mapVO, outRefLoop, runLevelMap, parkTimeMap, reentryData);
|
||||
|
||||
int otherTripRunTime = getLoopTripRunTime(mapVO, otherLoop, runLevelMap, parkTimeMap, reentryData);
|
||||
|
||||
//构建环路车次
|
||||
boolean loop = false;
|
||||
while (CollectionUtils.isEmpty(serviceTripList) ||
|
||||
(loop ? serviceTripList.getLast().getEndTime().plusSeconds(otherTripRunTime).isBefore(inputData.getOverTime())
|
||||
: serviceTripList.getLast().getEndTime().plusSeconds(outRefTripRunTime).isBefore(inputData.getOverTime()))) {
|
||||
(loop ? serviceTripList.getLast().getEndTime().isBefore(inputData.getOverTime())
|
||||
: serviceTripList.getLast().getEndTime().isBefore(inputData.getOverTime()))) {
|
||||
|
||||
if (loop) {
|
||||
nextTripNumber = buildServiceTrip(inputData, mapVO, otherLoop, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
|
||||
@ -223,110 +201,78 @@ public class RunPlanGenerator {
|
||||
}
|
||||
|
||||
if (inputData.hasOutAndInBound()) {
|
||||
RunPlanRoutingVO inboundRouting = getInboundRouting(inboundRoutings, outRefLoop, otherLoop, serviceTripList, loop);
|
||||
Routing2BoundInfo inboundRouting = getInboundRouting(loop ? outRefLoop : otherLoop, inboundRoutings,runLevelMap);
|
||||
if (Objects.isNull(inboundRouting)) {
|
||||
serviceTripList.removeLast();
|
||||
inboundRouting = getInboundRouting(!loop ? outRefLoop : otherLoop, inboundRoutings,runLevelMap);
|
||||
}
|
||||
if (Objects.nonNull(inboundRouting)) {
|
||||
if (Objects.equals(serviceTripList.getLast().getRight(), inboundRouting.getRight()) || (inboundRouting.getParkSectionCodeList().size() == 2 && inboundRouting.getStartTbFront())) {
|
||||
|
||||
//末班车次与连接车辆段或停车场
|
||||
RunPlanTripVO lastTrip = serviceTripList.getLast();
|
||||
lastTrip.setEndSectionCode(inboundRouting.getEndSectionCode());
|
||||
List<RunPlanTripTimeVO> timeList = lastTrip.getTimeList();
|
||||
RunPlanTripTimeVO runPlanTripTime = timeList.get(timeList.size() - 1);
|
||||
if (!Objects.equals(serviceTripList.getLast().getRight(), inboundRouting.getRight())) {
|
||||
runPlanTripTime.setDepartureTime(runPlanTripTime.getArrivalTime().plusSeconds(reentryData.get(runPlanTripTime.getStationCode()).getTbFront()));
|
||||
}
|
||||
|
||||
LocalTime departureTime = runPlanTripTime.getDepartureTime();
|
||||
String sectionCode = runPlanTripTime.getSectionCode();
|
||||
List<RunPlanRoutingSection> parkSectionList = inboundRouting.getParkSectionCodeList();
|
||||
for (int i = 1; i < parkSectionList.size(); i++) {
|
||||
RunPlanRoutingSection routingSection = parkSectionList.get(i);
|
||||
RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO();
|
||||
runPlanTripTimeVO.setStationCode(routingSection.getStationCode());
|
||||
runPlanTripTimeVO.setSectionCode(routingSection.getSectionCode());
|
||||
runPlanTripTimeVO.setArrivalTime(departureTime.plusSeconds(runLevelMap.get(sectionCode + "-" + runPlanTripTimeVO.getSectionCode())));
|
||||
runPlanTripTimeVO.setDepartureTime(i == parkSectionList.size() - 1 ? runPlanTripTimeVO.getArrivalTime() : runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
|
||||
timeList.add(runPlanTripTimeVO);
|
||||
departureTime = runPlanTripTimeVO.getDepartureTime();
|
||||
sectionCode = runPlanTripTimeVO.getSectionCode();
|
||||
}
|
||||
lastTrip.setEndTime(timeList.get(timeList.size() - 1).getArrivalTime());
|
||||
} else {
|
||||
//构建回库车次
|
||||
buildServiceTrip(inputData, mapVO, inboundRouting, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
|
||||
}
|
||||
setInBoundTripTimes(runLevelMap, parkTimeMap, reentryData, serviceTripList, inboundRouting);
|
||||
}
|
||||
}
|
||||
serviceTripList.getFirst().setIsOutbound(true);
|
||||
serviceTripList.getLast().setIsInbound(true);
|
||||
serviceTripList.getLast().setIsReentry(false);
|
||||
return serviceTripList;
|
||||
}
|
||||
|
||||
private RunPlanRoutingVO getInboundRouting(List<RunPlanRoutingVO> inboundRoutings, RunPlanRoutingVO outRefLoop, RunPlanRoutingVO otherLoop, LinkedList<RunPlanTripVO> serviceTripList, boolean loop) {
|
||||
RunPlanRoutingVO inboundRouting = getRunPlanRouting(inboundRoutings, outRefLoop, otherLoop, loop);
|
||||
if (Objects.isNull(inboundRouting)) {
|
||||
serviceTripList.removeLast();
|
||||
inboundRouting = getRunPlanRouting(inboundRoutings, otherLoop, outRefLoop, loop);
|
||||
}
|
||||
return inboundRouting;
|
||||
}
|
||||
|
||||
private RunPlanRoutingVO getRunPlanRouting(List<RunPlanRoutingVO> inboundRoutings, RunPlanRoutingVO outRefLoop, RunPlanRoutingVO otherLoop, boolean loop) {
|
||||
RunPlanRoutingVO inboundRouting;
|
||||
if (loop) {
|
||||
inboundRouting = getRunPlanRouting(inboundRoutings, outRefLoop, otherLoop);
|
||||
} else {
|
||||
inboundRouting = getRunPlanRouting(inboundRoutings, otherLoop, outRefLoop);
|
||||
}
|
||||
return inboundRouting;
|
||||
}
|
||||
private Routing2BoundInfo getInboundRouting(RunPlanRoutingVO runningRouting, List<RunPlanRoutingVO> inboundRoutings, Map<String, Integer> runLevelMap) {
|
||||
//找入库
|
||||
RunPlanRoutingVO inboundRouting = null;
|
||||
List<RunPlanRoutingSection> parkSectionCodeList = runningRouting.getParkSectionCodeList();
|
||||
int r = 0;
|
||||
t:
|
||||
for (int index = runningRouting.getStartTbFront() ? 0 : 1, i = parkSectionCodeList.size() - (runningRouting.getEndTbFront() ? 1 : 2); i > index; i--) {
|
||||
RunPlanRoutingSection parkSection = parkSectionCodeList.get(i);
|
||||
|
||||
private RunPlanRoutingVO getRunPlanRouting(List<RunPlanRoutingVO> inboundRoutings, RunPlanRoutingVO outRefLoop, RunPlanRoutingVO otherLoop) {
|
||||
RunPlanRoutingVO inboundRouting;
|
||||
RunPlanRoutingSection routingSection = outRefLoop.getParkSectionCodeList().get(outRefLoop.getParkSectionCodeList().size()-2);
|
||||
inboundRouting = inboundRoutings.stream().filter(inRouting ->
|
||||
Objects.equals(inRouting.getStartSectionCode(), otherLoop.getStartSectionCode())
|
||||
&& !inRouting.getParkSectionCodeList().contains(routingSection))
|
||||
.sorted(Comparator.comparingInt(o -> o.getParkSectionCodeList().size()))
|
||||
.findFirst().orElse(null);
|
||||
return inboundRouting;
|
||||
}
|
||||
inboundRouting = inboundRoutings.stream().filter(inRouting -> {
|
||||
|
||||
|
||||
private int getLoopTripRunTime(MapVO mapVO, RunPlanRoutingVO loop, Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData) {
|
||||
int parkTime = 0;
|
||||
int runTime;
|
||||
|
||||
//计算出库对接环路运行所需时间
|
||||
int oNum = loop.getParkSectionCodeList().size() - 1;
|
||||
int outRefTripRunTime = 0;
|
||||
for (int i = 0; i < oNum; i++) {
|
||||
RunPlanRoutingSection routingSection = loop.getParkSectionCodeList().get(i);
|
||||
RunPlanRoutingSection nextRoutingSection = loop.getParkSectionCodeList().get(i + 1);
|
||||
if (i == 0) {
|
||||
if (startTBIsFront(loop, mapVO)) {
|
||||
parkTime = reentryData.get(routingSection.getStationCode()).getTbFront() - parkTimeMap.get(routingSection.getSectionCode());
|
||||
runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
|
||||
} else {
|
||||
runTime = reentryData.get(routingSection.getStationCode()).getTbBack() - reentryData.get(routingSection.getStationCode()).getTbFrom();
|
||||
}
|
||||
} else if (i == oNum - 1) {
|
||||
if (endTBIsFront(loop, mapVO)) {
|
||||
parkTime = parkTimeMap.get(routingSection.getSectionCode()) + parkTimeMap.get(routingSection.getSectionCode());
|
||||
runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
|
||||
} else {
|
||||
parkTime = parkTimeMap.get(routingSection.getSectionCode());
|
||||
runTime = reentryData.get(nextRoutingSection.getStationCode()).getTbFrom();
|
||||
}
|
||||
} else {
|
||||
parkTime = parkTimeMap.get(routingSection.getSectionCode());
|
||||
runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
|
||||
List<RunPlanRoutingSection> inSectionList = inRouting.getParkSectionCodeList();
|
||||
RunPlanRoutingSection inSection = inSectionList.get(inSectionList.size() - 2);
|
||||
return Objects.equals(parkSection.getSectionCode(), inSection.getSectionCode());
|
||||
}).sorted(Comparator.comparing(routingVO -> runLevelMap.get(parkSection.getSectionCode() + "-" + routingVO.getEndSectionCode()))).findFirst().orElse(null);
|
||||
if (Objects.nonNull(inboundRouting)) {
|
||||
r = runningRouting.getStartTbFront() ? i + 1 : i;
|
||||
break t;
|
||||
}
|
||||
outRefTripRunTime = outRefTripRunTime + parkTime + runTime;
|
||||
parkTime = 0;
|
||||
|
||||
// for (int x = 0, y = inboundRoutings.size(); x < y; x++) {
|
||||
// RunPlanRoutingVO inRouting = inboundRoutings.get(x);
|
||||
// List<RunPlanRoutingSection> inSectionList = inRouting.getParkSectionCodeList();
|
||||
// RunPlanRoutingSection inSection = inSectionList.get(inSectionList.size() - 2);
|
||||
// if (Objects.equals(parkSection.getSectionCode(), inSection.getSectionCode())) {
|
||||
// inboundRouting = inRouting;
|
||||
// r = runningRouting.getStartTbFront() ? i + 1 : i;
|
||||
// break t;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return outRefTripRunTime;
|
||||
if (Objects.isNull(inboundRouting)) return null;
|
||||
return new Routing2BoundInfo(inboundRouting, r);
|
||||
}
|
||||
|
||||
private void setInBoundTripTimes(Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData,
|
||||
LinkedList<RunPlanTripVO> serviceTripList, Routing2BoundInfo inBoundInfo) {
|
||||
//末班车次连接车辆段或停车场
|
||||
RunPlanTripVO lastTrip = serviceTripList.getLast();
|
||||
lastTrip.setEndSectionCode(inBoundInfo.getBoundRouting().getEndSectionCode());
|
||||
List<RunPlanTripTimeVO> timeList = lastTrip.getTimeList();
|
||||
timeList = timeList.subList(0, inBoundInfo.getR());
|
||||
lastTrip.setTimeList(timeList);
|
||||
RunPlanTripTimeVO runPlanTripTime = timeList.get(timeList.size() - 1);
|
||||
if (!Objects.equals(lastTrip.getRight(), inBoundInfo.getBoundRouting().getRight())) {
|
||||
runPlanTripTime.setDepartureTime(runPlanTripTime.getArrivalTime().plusSeconds(reentryData.get(runPlanTripTime.getStationCode()).getTbFront()));
|
||||
} else if (Objects.equals(runPlanTripTime.getSectionCode(), lastTrip.getEndSectionCode())) {
|
||||
runPlanTripTime.setDepartureTime(runPlanTripTime.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTime.getSectionCode())));
|
||||
}
|
||||
|
||||
RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO();
|
||||
runPlanTripTimeVO.setStationCode(inBoundInfo.getBoundRouting().getEndStationCode());
|
||||
runPlanTripTimeVO.setSectionCode(inBoundInfo.getBoundRouting().getEndSectionCode());
|
||||
runPlanTripTimeVO.setArrivalTime(runPlanTripTime.getDepartureTime().plusSeconds(runLevelMap.get(runPlanTripTime.getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode())));
|
||||
runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime());
|
||||
timeList.add(runPlanTripTimeVO);
|
||||
lastTrip.setEndTime(runPlanTripTimeVO.getArrivalTime());
|
||||
lastTrip.setIsInbound(true);
|
||||
lastTrip.setIsReentry(false);
|
||||
}
|
||||
|
||||
private int buildServiceTrip(RunPlanInputData inputData, MapVO mapVO, RunPlanRoutingVO routing,
|
||||
@ -337,14 +283,15 @@ public class RunPlanGenerator {
|
||||
tripVO.setServiceNumber(inputData.getServiceNumber());
|
||||
tripVO.setTripNumber(tripVO.getDirectionCode() + String.format("%03d", tripNumber));
|
||||
tripVO.setIsReentry(true);
|
||||
if (routing.isOutBoundRoute()) {
|
||||
tripVO.setIsOutbound(true);
|
||||
}
|
||||
if (routing.isInBoundRoute()) {
|
||||
tripVO.setIsInbound(true);
|
||||
tripVO.setIsReentry(false);
|
||||
}
|
||||
Boolean startTBIsFront = startTBIsFront(routing, mapVO);
|
||||
tripVO.setIsInbound(false);
|
||||
tripVO.setIsOutbound(false);
|
||||
// if (routing.isOutBoundRoute()) {
|
||||
// tripVO.setIsOutbound(true);
|
||||
// }
|
||||
// if (routing.isInBoundRoute()) {
|
||||
// tripVO.setIsInbound(true);
|
||||
// tripVO.setIsReentry(false);
|
||||
// }
|
||||
LinkedList<RunPlanTripTimeVO> tripTimeList = new LinkedList<>();
|
||||
int size = routing.getParkSectionCodeList().size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
@ -353,8 +300,8 @@ public class RunPlanGenerator {
|
||||
runPlanTripTimeVO.setStationCode(routingSection.getStationCode());
|
||||
runPlanTripTimeVO.setSectionCode(routingSection.getSectionCode());
|
||||
if (CollectionUtils.isEmpty(tripList) && i == 0) {//首发车次
|
||||
if (Objects.nonNull(startTBIsFront)) {
|
||||
if (!startTBIsFront) continue;
|
||||
if (Objects.nonNull(routing.getStartTbFront())) {
|
||||
if (!routing.getStartTbFront()) continue;
|
||||
runPlanTripTimeVO.setArrivalTime(inputData.getBeginTime());
|
||||
runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
|
||||
} else {
|
||||
@ -362,26 +309,26 @@ public class RunPlanGenerator {
|
||||
runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime());
|
||||
}
|
||||
} else if (i == 0) { //其它车次发车
|
||||
if (!startTBIsFront) {
|
||||
if (!routing.getStartTbFront()) {
|
||||
continue;
|
||||
}
|
||||
RunPlanTripTimeVO lastTripTime = tripList.getLast().getTimeList().get(tripList.getLast().getTimeList().size()-1);
|
||||
RunPlanTripTimeVO lastTripTime = tripList.getLast().getTimeList().get(tripList.getLast().getTimeList().size() - 1);
|
||||
runPlanTripTimeVO.setArrivalTime(
|
||||
lastTripTime.getDepartureTime());
|
||||
runPlanTripTimeVO.setDepartureTime(lastTripTime.getDepartureTime());
|
||||
} else if (i == size - 1) {
|
||||
Boolean endTBIsFront = endTBIsFront(routing, mapVO);
|
||||
if (Objects.nonNull(endTBIsFront) && !endTBIsFront) {
|
||||
if (Objects.nonNull(routing.getEndTbFront()) && !routing.getEndTbFront()) {
|
||||
continue;
|
||||
}
|
||||
RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get(routingSection.getStationCode());
|
||||
runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripTimeList) ? tripList.getLast().getEndTime().plusSeconds(45)
|
||||
runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripTimeList) ?
|
||||
CollectionUtils.isEmpty(tripList) ? inputData.getBeginTime().plusSeconds(reentryData.get(routing.getStartStationCode()).getTbTo()): tripList.getLast().getEndTime().plusSeconds(reentryData.get(routing.getStartStationCode()).getTbBack()-reentryData.get(routing.getStartStationCode()).getTbFrom())
|
||||
: tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelMap.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode())));
|
||||
runPlanTripTimeVO.setDepartureTime(Objects.isNull(endTBIsFront)
|
||||
runPlanTripTimeVO.setDepartureTime(Objects.isNull(routing.getEndTbFront())
|
||||
? runPlanTripTimeVO.getArrivalTime()
|
||||
: runPlanTripTimeVO.getArrivalTime().plusSeconds(reentryTime.getTbFront()));
|
||||
} else {
|
||||
if (i == 1 && Objects.nonNull(startTBIsFront) && !startTBIsFront) {
|
||||
if (i == 1 && Objects.nonNull(routing.getStartTbFront()) && !routing.getStartTbFront()) {
|
||||
RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get(routing.getStartStationCode());
|
||||
runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripList) ? inputData.getBeginTime() : tripList.getLast().getEndTime().plusSeconds(reentryTime.getTbBack() - reentryTime.getTbFrom()));
|
||||
runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
|
||||
@ -439,42 +386,72 @@ public class RunPlanGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean startTBIsFront(RunPlanRoutingVO runningRouting, MapVO mapVO) {
|
||||
MapSectionNewVO startReentrySection = mapVO.findSection(runningRouting.getStartSectionCode());
|
||||
if (startReentrySection.isReentryTrack()) {
|
||||
if (startReentrySection.isStandTrack()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean endTBIsFront(RunPlanRoutingVO runningRouting, MapVO mapVO) {
|
||||
MapSectionNewVO endReentrySection = mapVO.findSection(runningRouting.getEndSectionCode());
|
||||
if (endReentrySection.isReentryTrack()) {
|
||||
if (endReentrySection.isStandTrack()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private RunPlanRoutingVO getOutboundRouting(RunPlanRoutingVO runningRouting, List<RunPlanRoutingVO> outboundRoutings) {
|
||||
RunPlanRoutingVO outboundRouting = null;
|
||||
private Routing2BoundInfo getOutboundRouting(RunPlanRoutingVO runningRouting, List<RunPlanRoutingVO> outboundRoutings,Map<String, Integer> runLevelMap) {
|
||||
//找出库
|
||||
RunPlanRoutingVO outboundRouting = null;
|
||||
List<RunPlanRoutingSection> parkSectionCodeList = runningRouting.getParkSectionCodeList();
|
||||
RunPlanRoutingSection parkSection = parkSectionCodeList.get(runningRouting.getStartTbFront() ? 0 : 1);
|
||||
for (int x = 0; x < outboundRoutings.size(); x++) {
|
||||
RunPlanRoutingVO outRouting = outboundRoutings.get(x);
|
||||
List<RunPlanRoutingSection> outSectionList = outRouting.getParkSectionCodeList();
|
||||
RunPlanRoutingSection outSection = outSectionList.get(1);
|
||||
if (Objects.equals(parkSection.getSectionCode(), outSection.getSectionCode())) {
|
||||
outboundRouting = outRouting;
|
||||
break;
|
||||
int r = 0;
|
||||
t:
|
||||
for (int i = runningRouting.getStartTbFront() ? 0 : 1, index = parkSectionCodeList.size() - (runningRouting.getEndTbFront() ? 1 : 2); i < index; i++) {
|
||||
RunPlanRoutingSection parkSection = parkSectionCodeList.get(i);
|
||||
|
||||
outboundRouting = outboundRoutings.stream().filter(outRouting -> {
|
||||
RunPlanRoutingSection outSection = outRouting.getParkSectionCodeList().get(1);
|
||||
return Objects.equals(parkSection.getSectionCode(), outSection.getSectionCode());
|
||||
}).sorted(Comparator.comparing(routingVO -> runLevelMap.get(routingVO.getStartSectionCode() + "-" + parkSection.getSectionCode()))).findFirst().orElse(null);
|
||||
if (Objects.nonNull(outboundRouting)) {
|
||||
r = runningRouting.getStartTbFront() ? i : i - 1;
|
||||
break t;
|
||||
}
|
||||
|
||||
|
||||
// for (int x = 0, y = outboundRoutings.size(); x < y; x++) {
|
||||
// RunPlanRoutingVO outRouting = outboundRoutings.get(x);
|
||||
// RunPlanRoutingSection outSection = outRouting.getParkSectionCodeList().get(1);
|
||||
// if (Objects.equals(parkSection.getSectionCode(), outSection.getSectionCode())) {
|
||||
// outboundRouting = outRouting;
|
||||
// r = runningRouting.getStartTbFront() ? i : i - 1;
|
||||
// break t;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return outboundRouting;
|
||||
if (Objects.isNull(outboundRouting)) return null;
|
||||
return new Routing2BoundInfo(outboundRouting, r);
|
||||
}
|
||||
|
||||
private void setOutBoundTripTimes(Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData,
|
||||
LinkedList<RunPlanTripVO> serviceTripList, Routing2BoundInfo outBoundInfo) {
|
||||
//首趟车次连接车辆段或停车场
|
||||
RunPlanTripVO firstTrip = serviceTripList.getFirst();
|
||||
firstTrip.setStartSectionCode(outBoundInfo.getBoundRouting().getStartSectionCode());
|
||||
List<RunPlanTripTimeVO> timeList = firstTrip.getTimeList();
|
||||
//倒推从第二站开始
|
||||
if (outBoundInfo.getR() != 0) {
|
||||
timeList = timeList.subList(outBoundInfo.getR(), timeList.size());
|
||||
firstTrip.setTimeList(timeList);
|
||||
}
|
||||
RunPlanTripTimeVO runPlanTripTime = timeList.get(0);
|
||||
if (!Objects.equals(firstTrip.getRight(), outBoundInfo.getBoundRouting().getRight())) {
|
||||
runPlanTripTime.setArrivalTime(runPlanTripTime.getDepartureTime().minusSeconds(reentryData.get(runPlanTripTime.getStationCode()).getTbFront()));
|
||||
} else if (Objects.equals(runPlanTripTime.getSectionCode(), firstTrip.getStartSectionCode())) {
|
||||
runPlanTripTime.setArrivalTime(runPlanTripTime.getDepartureTime().minusSeconds(parkTimeMap.get(runPlanTripTime.getSectionCode())));
|
||||
}
|
||||
|
||||
RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO();
|
||||
runPlanTripTimeVO.setStationCode(outBoundInfo.getBoundRouting().getStartStationCode());
|
||||
runPlanTripTimeVO.setSectionCode(outBoundInfo.getBoundRouting().getStartSectionCode());
|
||||
runPlanTripTimeVO.setDepartureTime(runPlanTripTime.getArrivalTime().minusSeconds(runLevelMap.get(runPlanTripTimeVO.getSectionCode() + "-" + runPlanTripTime.getSectionCode())));
|
||||
runPlanTripTimeVO.setArrivalTime(runPlanTripTimeVO.getDepartureTime());
|
||||
timeList.add(0, runPlanTripTimeVO);
|
||||
firstTrip.setStartTime(timeList.get(0).getArrivalTime());
|
||||
firstTrip.setIsOutbound(true);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private class Routing2BoundInfo {
|
||||
|
||||
private RunPlanRoutingVO boundRouting;
|
||||
private int r;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -68,7 +67,7 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Map<Long,Float> updateRunlevelDistance(Long userId, Long mapId) {
|
||||
public List<RunPlanRunlevelVO> updateRunlevelDistance(Long userId, Long mapId) {
|
||||
MapVO map = this.iMapService.getMapDetail(mapId);
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
|
||||
@ -76,7 +75,6 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService {
|
||||
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
|
||||
List<RunPlanRunlevelVO> list = queryUserRunLevels(userId, mapId);
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(CollectionUtils.isEmpty(list), "操作失败,运行等级数据为空");
|
||||
Map<Long,Float> r = new LinkedHashMap<>();
|
||||
list.forEach(l -> {
|
||||
Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
|
||||
Section endSection = (Section) deviceMap.get(l.getEndSectionCode());
|
||||
@ -91,14 +89,20 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService {
|
||||
|
||||
distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
|
||||
}
|
||||
l.setDistance(distance);
|
||||
l.generateDefaultRunLevel();
|
||||
RunPlanRunlevel entity = new RunPlanRunlevel();
|
||||
entity.setId(l.getId());
|
||||
entity.setMapId(l.getMapId());
|
||||
entity.setDistance(distance);
|
||||
entity.setLevel1(l.getL1());
|
||||
entity.setLevel2(l.getL2());
|
||||
entity.setLevel3(l.getL3());
|
||||
entity.setLevel4(l.getL4());
|
||||
entity.setLevel5(l.getL5());
|
||||
this.runPlanRunlevelDAO.updateByPrimaryKeySelective(entity);
|
||||
r.put(l.getId(),distance);
|
||||
});
|
||||
return r;
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,8 @@ import club.joylink.rtss.vo.client.runplan.RunPlanTripVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -30,11 +32,31 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew {
|
||||
public void importDataCheckAndPreHandle(List<RunPlanImport> runPlanImportList, List<MapStationNewVO> stationList, String upDirection) {
|
||||
Map<String, MapStationNewVO> stationMap = stationList.stream().collect(
|
||||
Collectors.toMap(MapStationNewVO::getRunPlanName, Function.identity()));
|
||||
//增加36203回库到奉化22:00
|
||||
RunPlanImport newTrip = new RunPlanImport();
|
||||
newTrip.setCode("36401");
|
||||
newTrip.setDestinationCode("");
|
||||
List<RunPlanArrivalTime> newArrivalList = new ArrayList<>();
|
||||
newTrip.setArrivalList(newArrivalList);
|
||||
RunPlanArrivalTime tripTime = new RunPlanArrivalTime();
|
||||
tripTime.setStationName("金海路");
|
||||
tripTime.setArriveTime(LocalTime.of(5,5,43));
|
||||
tripTime.setDepartureTime(LocalTime.of(21,59,30));
|
||||
RunPlanArrivalTime tripTime2 = new RunPlanArrivalTime();
|
||||
tripTime2.setStationName("奉化停车场");
|
||||
tripTime2.setArriveTime(LocalTime.of(22,0));
|
||||
tripTime2.setDepartureTime(LocalTime.of(22,0));
|
||||
newArrivalList.add(tripTime);
|
||||
newArrivalList.add(tripTime2);
|
||||
runPlanImportList.add(newTrip);
|
||||
runPlanImportList.forEach(runPlanImport -> {
|
||||
this.analyzeAndConvertCode(runPlanImport, upDirection);
|
||||
List<RunPlanArrivalTime> arrivalList = runPlanImport.getArrivalList();
|
||||
if(runPlanImport.getCode().equals("36301")){
|
||||
arrivalList.remove(0);
|
||||
}
|
||||
handleStationAndTime(stationMap, arrivalList);
|
||||
if(Arrays.asList("36102", "36203","36301").contains(runPlanImport.getCode())){
|
||||
if(Arrays.asList("36102", "36203","36401","36301").contains(runPlanImport.getCode())){
|
||||
runPlanImport.setBackup(true);
|
||||
}
|
||||
});
|
||||
@ -59,75 +81,12 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew {
|
||||
@Override
|
||||
public void handleTrip(RunPlanImport runPlanImport, RunPlanTripVO tripVO, String startStationName, String endStationName, boolean isFirst, boolean isLast, String firstStationName , String finalStationName) {
|
||||
|
||||
// Y315工作日
|
||||
switch (endStationName) {
|
||||
case "奉化停车场":
|
||||
if(runPlanImport.isBackup()){
|
||||
tripVO.setEndSectionCode("T60"); //T2101
|
||||
}else if(Arrays.asList("32403","32503","32603","31215","30119","30819","31119").contains(runPlanImport.getCode())){
|
||||
tripVO.setEndSectionCode("T62"); //T2102
|
||||
}
|
||||
break;
|
||||
case "金海路":
|
||||
if (runPlanImport.isBackup()) {
|
||||
tripVO.setEndSectionCode("T4");//T2107
|
||||
} else {
|
||||
tripVO.setEndSectionCode("T9");//T2108
|
||||
}
|
||||
break;
|
||||
case "首南车辆段":
|
||||
if(Arrays.asList("30518","30618","30918","31718","31818","31918","32018").contains(runPlanImport.getCode())){
|
||||
tripVO.setEndSectionCode("T238"); //T3002
|
||||
}else{
|
||||
tripVO.setEndSectionCode("T237");//T3001
|
||||
}
|
||||
break;
|
||||
case "南部商务区":
|
||||
tripVO.setEndSectionCode("T313");//T3307
|
||||
break;
|
||||
case "大通桥":
|
||||
tripVO.setEndSectionCode("T545");//T4407
|
||||
break;
|
||||
case "体育馆":
|
||||
tripVO.setEndSectionCode("T442");//T4107
|
||||
break;
|
||||
}
|
||||
|
||||
switch (startStationName) {
|
||||
case "奉化停车场":
|
||||
tripVO.setStartSectionCode("T62"); //T2102
|
||||
break;
|
||||
case "金海路":
|
||||
if (runPlanImport.isBackup()) {
|
||||
tripVO.setStartSectionCode("T4");//T2107
|
||||
} else {
|
||||
tripVO.setStartSectionCode("T9");//T2108
|
||||
}
|
||||
break;
|
||||
case "首南车辆段":
|
||||
if(Arrays.asList("30102","30202","30402","32402","32502","32602","30702","31002","31302","30602","30902","31202").contains(runPlanImport.getCode())){
|
||||
tripVO.setStartSectionCode("T238");//T3002
|
||||
}else{
|
||||
tripVO.setStartSectionCode("T237"); //T3001
|
||||
}
|
||||
break;
|
||||
case "南部商务区":
|
||||
tripVO.setStartSectionCode("T313");//T3307
|
||||
break;
|
||||
case "大通桥":
|
||||
tripVO.setStartSectionCode("T545");//T4407
|
||||
break;
|
||||
case "体育馆":
|
||||
tripVO.setStartSectionCode("T442");//T4107
|
||||
break;
|
||||
}
|
||||
|
||||
//Y316双休日
|
||||
// // Y315工作日
|
||||
// switch (endStationName) {
|
||||
// case "奉化停车场":
|
||||
// if(runPlanImport.isBackup()){
|
||||
// tripVO.setEndSectionCode("T60"); //T2101
|
||||
// }else if(Arrays.asList("30915","31115","30117","30219","31417","30419").contains(runPlanImport.getCode())){
|
||||
// }else if(Arrays.asList("32403","32503","32603","31215","30119","30819","31119").contains(runPlanImport.getCode())){
|
||||
// tripVO.setEndSectionCode("T62"); //T2102
|
||||
// }
|
||||
// break;
|
||||
@ -139,7 +98,7 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew {
|
||||
// }
|
||||
// break;
|
||||
// case "首南车辆段":
|
||||
// if(Arrays.asList("31616","31716","31018","31816","31218","31916","30820").contains(runPlanImport.getCode())){
|
||||
// if(Arrays.asList("30518","30618","30918","31718","31818","31918","32018").contains(runPlanImport.getCode())){
|
||||
// tripVO.setEndSectionCode("T238"); //T3002
|
||||
// }else{
|
||||
// tripVO.setEndSectionCode("T237");//T3001
|
||||
@ -168,7 +127,7 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew {
|
||||
// }
|
||||
// break;
|
||||
// case "首南车辆段":
|
||||
// if(Arrays.asList("30102","30202","30402","31302","31502","30502","30702","30902").contains(runPlanImport.getCode())){
|
||||
// if(Arrays.asList("30102","30202","30402","32402","32502","32602","30702","31002","31302","30602","30902","31202").contains(runPlanImport.getCode())){
|
||||
// tripVO.setStartSectionCode("T238");//T3002
|
||||
// }else{
|
||||
// tripVO.setStartSectionCode("T237"); //T3001
|
||||
@ -183,54 +142,127 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew {
|
||||
// case "体育馆":
|
||||
// tripVO.setStartSectionCode("T442");//T4107
|
||||
// break;
|
||||
// case "樱花公园":
|
||||
// tripVO.setStartSectionCode("T442");//T4107
|
||||
// break;
|
||||
// }
|
||||
|
||||
//Y316双休日
|
||||
switch (endStationName) {
|
||||
case "奉化停车场":
|
||||
if(runPlanImport.isBackup()){
|
||||
tripVO.setEndSectionCode("T60"); //T2101
|
||||
}else if(Arrays.asList("30915","31115","30117","30219","31417","30419").contains(runPlanImport.getCode())){
|
||||
tripVO.setEndSectionCode("T62"); //T2102
|
||||
}
|
||||
break;
|
||||
case "金海路":
|
||||
if (runPlanImport.isBackup()) {
|
||||
tripVO.setEndSectionCode("T4");//T2107
|
||||
} else {
|
||||
tripVO.setEndSectionCode("T9");//T2108
|
||||
}
|
||||
break;
|
||||
case "首南车辆段":
|
||||
if(Arrays.asList("31616","31716","31018","31816","31218","31916","30820").contains(runPlanImport.getCode())){
|
||||
tripVO.setEndSectionCode("T238"); //T3002
|
||||
}else{
|
||||
tripVO.setEndSectionCode("T237");//T3001
|
||||
}
|
||||
break;
|
||||
case "南部商务区":
|
||||
tripVO.setEndSectionCode("T313");//T3307
|
||||
break;
|
||||
case "大通桥":
|
||||
tripVO.setEndSectionCode("T545");//T4407
|
||||
break;
|
||||
case "体育馆":
|
||||
tripVO.setEndSectionCode("T442");//T4107
|
||||
break;
|
||||
}
|
||||
|
||||
switch (startStationName) {
|
||||
case "奉化停车场":
|
||||
tripVO.setStartSectionCode("T62"); //T2102
|
||||
break;
|
||||
case "金海路":
|
||||
if (runPlanImport.isBackup()) {
|
||||
tripVO.setStartSectionCode("T4");//T2107
|
||||
} else {
|
||||
tripVO.setStartSectionCode("T9");//T2108
|
||||
}
|
||||
break;
|
||||
case "首南车辆段":
|
||||
if(Arrays.asList("30102","30202","30402","31302","31502","30502","30702","30902").contains(runPlanImport.getCode())){
|
||||
tripVO.setStartSectionCode("T238");//T3002
|
||||
}else{
|
||||
tripVO.setStartSectionCode("T237"); //T3001
|
||||
}
|
||||
break;
|
||||
case "南部商务区":
|
||||
tripVO.setStartSectionCode("T313");//T3307
|
||||
break;
|
||||
case "大通桥":
|
||||
tripVO.setStartSectionCode("T545");//T4407
|
||||
break;
|
||||
case "体育馆":
|
||||
tripVO.setStartSectionCode("T442");//T4107
|
||||
break;
|
||||
case "樱花公园":
|
||||
tripVO.setStartSectionCode("T442");//T4107
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTripTime(RunPlanTripTimeVO timeVO, RunPlanImport runPlanImport, MapStationNewVO stationVO, String startStationName, String endStationName) {
|
||||
|
||||
// Y315工作日
|
||||
if("高塘桥".equals(stationVO.getRunPlanName())){
|
||||
if(Arrays.asList("36203","30803","31103").contains(runPlanImport.getCode())){
|
||||
timeVO.setSectionCode("T273");//T3015
|
||||
}
|
||||
return;
|
||||
}
|
||||
if("首南车辆段".equals(stationVO.getRunPlanName())){
|
||||
if(Arrays.asList("30518","30618","30918","31718","31818","31918","32018","30102","30202","30402","32402","32502","32602","30702","31002","31302","30602","30902","31202").contains(runPlanImport.getCode())){
|
||||
timeVO.setSectionCode("T238");//T3002
|
||||
}else{
|
||||
timeVO.setSectionCode("T237"); //T3001
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//通用
|
||||
if("奉化停车场".equals(stationVO.getRunPlanName())){
|
||||
if(runPlanImport.isBackup() && runPlanImport.getCode().equals("36203")){
|
||||
timeVO.setSectionCode("T60"); //T2101
|
||||
}else{
|
||||
timeVO.setSectionCode("T62"); //T2102
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// // Y316工作日
|
||||
// // Y315工作日
|
||||
// if("高塘桥".equals(stationVO.getRunPlanName())){
|
||||
// if(Arrays.asList("36203","30603","30803").contains(runPlanImport.getCode())){
|
||||
// if(Arrays.asList("36203","30803","31103").contains(runPlanImport.getCode())){
|
||||
// timeVO.setSectionCode("T273");//T3015
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if("首南车辆段".equals(stationVO.getRunPlanName())){
|
||||
// if(Arrays.asList("31616","31716","31018","31816","31218","31916","30820","30102","30202","30402","31302","31502","30502","30702","30902").contains(runPlanImport.getCode())){
|
||||
// if(Arrays.asList("30518","30618","30918","31718","31818","31918","32018","30102","30202","30402","32402","32502","32602","30702","31002","31302","30602","30902","31202").contains(runPlanImport.getCode())){
|
||||
// timeVO.setSectionCode("T238");//T3002
|
||||
// }else{
|
||||
// timeVO.setSectionCode("T237"); //T3001
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
//通用
|
||||
if("奉化停车场".equals(stationVO.getRunPlanName())){
|
||||
if(runPlanImport.isBackup() && (runPlanImport.getCode().equals("36203") ||runPlanImport.getCode().equals("36401"))){
|
||||
timeVO.setSectionCode("T60"); //T2101
|
||||
}else{
|
||||
timeVO.setSectionCode("T62"); //T2102
|
||||
}
|
||||
return;
|
||||
}
|
||||
if("金海路".equals(stationVO.getRunPlanName()) && runPlanImport.getCode().equals("36401")){
|
||||
timeVO.setSectionCode("T4"); //T2101
|
||||
return;
|
||||
}
|
||||
|
||||
// Y316工作日
|
||||
if("高塘桥".equals(stationVO.getRunPlanName())){
|
||||
if(Arrays.asList("36203","30603","30803").contains(runPlanImport.getCode())){
|
||||
timeVO.setSectionCode("T273");//T3015
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if("首南车辆段".equals(stationVO.getRunPlanName())){
|
||||
if(Arrays.asList("31616","31716","31018","31816","31218","31916","30820","30102","30202","30402","31302","31502","30502","30702","30902").contains(runPlanImport.getCode())){
|
||||
timeVO.setSectionCode("T238");//T3002
|
||||
}else{
|
||||
timeVO.setSectionCode("T237"); //T3001
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.rtss.vo.client.runplan;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
@ -117,6 +117,8 @@ public class RunPlanTripVO {
|
||||
|
||||
public RunPlanTripVO(RunPlanRoutingVO routingVO) {
|
||||
this.right = routingVO.getRight();
|
||||
this.isOutbound = routingVO.isInBoundRoute();
|
||||
this.isInbound = routingVO.isOutBoundRoute();
|
||||
this.destinationCode = Objects.isNull(routingVO.getDestinationCode()) ? "" : routingVO.getDestinationCode();
|
||||
this.startSectionCode = routingVO.getStartSectionCode();
|
||||
this.endSectionCode = routingVO.getEndSectionCode();
|
||||
|
@ -159,19 +159,6 @@ public class RunPlanRoutingVO {
|
||||
routingVO.setParkSectionCodeList(JsonUtils.readCollection(JsonUtils.writeValueAsString(mapRoutingDataVO.getParkSectionCodeList()), List.class, RunPlanRoutingSection.class));
|
||||
return routingVO;
|
||||
}
|
||||
// public RunPlanRoutingVO generateLoopRoutingBasicData(){
|
||||
// RunPlanRoutingVO routing = new RunPlanRoutingVO();
|
||||
// routing.setMapId(mapId);
|
||||
// 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.setDescription(description+LOOP_MARK);
|
||||
// return routing;
|
||||
// }
|
||||
|
||||
public static List<RunPlanRoutingVO> convert2VOList(List<RunPlanRouting> runPlanRoutings){
|
||||
return runPlanRoutings.stream().map(RunPlanRoutingVO::convert2VO).collect(Collectors.toList());
|
||||
|
Loading…
Reference in New Issue
Block a user