修改重设车次号逻辑的位置以覆盖生成单条计划的情况
This commit is contained in:
parent
15f9f69428
commit
6372892cdb
@ -441,17 +441,18 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
public void generateRunPlanService(Long userId, Long planId, RunPlanInputData inputData) {
|
||||
RunPlanVO planVO = getRunPlanById(planId);
|
||||
MapVO mapVO = this.iMapService.getMapDetail(planVO.getMapId());
|
||||
RealLineConfigVO configVO = mapVO.getConfigVO();
|
||||
if (Objects.nonNull(inputData.getDepartureInterval())) {
|
||||
String max = planVO.getTripList().stream().map(RunPlanTripVO::getServiceNumber).max(Comparator.comparingInt(Integer::parseInt)).orElse("0");
|
||||
// 当前已有最大服务号
|
||||
int maxServiceNumber = Integer.parseInt(max);
|
||||
RealLineConfigVO configVO = mapVO.getConfigVO();
|
||||
String serviceFormat = String.format("%%0%sd", configVO.getFiguresOfServiceNumber());
|
||||
inputData.setServiceNumber(String.format(serviceFormat, ++maxServiceNumber));
|
||||
Integer departureInterval = inputData.getDepartureInterval() < 60 ? 180 : inputData.getDepartureInterval();
|
||||
inputData.setDepartureInterval(departureInterval);
|
||||
}
|
||||
List<RunPlanTripVO> newTripList = runPlanGenerator.generatorTrips(userId, inputData, mapVO);
|
||||
rearrangeTripNumber(configVO, newTripList);
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(CollectionUtils.isEmpty(newTripList), String.format("生成服务号%s运行图数据失败", inputData.getServiceNumber()));
|
||||
planVO.getTripList().addAll(newTripList);
|
||||
RunPlanDraft planDraft = planVO.convert2Draft();
|
||||
@ -460,6 +461,39 @@ public class RunPlanDraftService implements IRunPlanDraftService {
|
||||
runPlanDraftDAO.updateByPrimaryKeySelective(planDraft);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据线路配置,重排车次号
|
||||
*/
|
||||
private void rearrangeTripNumber(RealLineConfigVO mapConfigVO, List<RunPlanTripVO> tripList) {
|
||||
//重排车次号
|
||||
if (mapConfigVO.isTripNumberIsUnique()) {
|
||||
//上下行车次号
|
||||
int upTn = 1;
|
||||
int downTn = 1;
|
||||
//上下行方向编号
|
||||
String upDirection;
|
||||
String downDirection;
|
||||
String tripFormat;
|
||||
if (mapConfigVO.getFiguresOfTripNumber() == 2) {
|
||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("两位车次号暂不支持车次号唯一");
|
||||
// upDirection = "";
|
||||
// downDirection = "";
|
||||
// tripFormat = "%02d";
|
||||
} else {
|
||||
upDirection = "2";
|
||||
downDirection = "1";
|
||||
tripFormat = String.format("%%0%sd", mapConfigVO.getFiguresOfTripNumber() - 1);
|
||||
}
|
||||
for (RunPlanTripVO tripVO : tripList.stream().sorted(Comparator.comparing(RunPlanTripVO::getStartTime)).collect(Collectors.toList())) {
|
||||
if (mapConfigVO.isUp(tripVO.getRight())) {
|
||||
tripVO.setTripNumber(upDirection + String.format(tripFormat, upTn++));
|
||||
} else {
|
||||
tripVO.setTripNumber(downDirection + String.format(tripFormat, downTn++));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateRunPlanService(Long planId, String serviceNumber, RunPlanServiceConfigVO serviceConfig, AccountVO accountVO) {
|
||||
|
@ -83,7 +83,6 @@ public class RunPlanGenerator {
|
||||
inputData.setServiceNumber(String.format(serviceFormat, startServiceNumber + 2));
|
||||
departEndTime1 = serviceTripList1.get(2).getTimeList().get(0).getArrivalTime();
|
||||
generateServices(inputData, mapVO, running1Routing, running2Routing, inboundRoutings, outBoundRouting1, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime1);
|
||||
rearrangeTripNumber(mapConfigVO, tripList);
|
||||
return tripList;
|
||||
} else if (Objects.nonNull(outBoundRouting2)) {
|
||||
tripList.removeAll(serviceTripList1);
|
||||
@ -91,7 +90,6 @@ public class RunPlanGenerator {
|
||||
inputData.setServiceNumber(String.format(serviceFormat, startServiceNumber + 3));
|
||||
departEndTime2 = serviceTripList2.get(2).getTimeList().get(0).getArrivalTime();
|
||||
generateServices(inputData, mapVO, running2Routing, running1Routing, inboundRoutings, outBoundRouting2, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime2);
|
||||
rearrangeTripNumber(mapConfigVO, tripList);
|
||||
return tripList;
|
||||
}
|
||||
}
|
||||
@ -101,7 +99,6 @@ public class RunPlanGenerator {
|
||||
|
||||
inputData.setServiceNumber(String.format(serviceFormat, startServiceNumber + 3));
|
||||
generateServices(inputData, mapVO, running2Routing, running1Routing, inboundRoutings, outBoundRouting2, runLevelMap, parkTimeMap, reentryData, tripList, initBeginTime, departEndTime2);
|
||||
rearrangeTripNumber(mapConfigVO, tripList);
|
||||
} else {
|
||||
|
||||
Routing2BoundInfo outBoundRouting = null;
|
||||
@ -129,39 +126,6 @@ public class RunPlanGenerator {
|
||||
return tripList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据线路配置,重排车次号
|
||||
*/
|
||||
private void rearrangeTripNumber(RealLineConfigVO mapConfigVO, List<RunPlanTripVO> tripList) {
|
||||
//重排车次号
|
||||
if (mapConfigVO.isTripNumberIsUnique()) {
|
||||
//上下行车次号
|
||||
int upTn = 1;
|
||||
int downTn = 1;
|
||||
//上下行方向编号
|
||||
String upDirection;
|
||||
String downDirection;
|
||||
String tripFormat;
|
||||
if (mapConfigVO.getFiguresOfTripNumber() == 2) {
|
||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("两位车次号暂不支持车次号唯一");
|
||||
// upDirection = "";
|
||||
// downDirection = "";
|
||||
// tripFormat = "%02d";
|
||||
} else {
|
||||
upDirection = "2";
|
||||
downDirection = "1";
|
||||
tripFormat = String.format("%%0%sd", mapConfigVO.getFiguresOfTripNumber() - 1);
|
||||
}
|
||||
for (RunPlanTripVO tripVO : tripList.stream().sorted(Comparator.comparing(RunPlanTripVO::getStartTime)).collect(Collectors.toList())) {
|
||||
if (mapConfigVO.isUp(tripVO.getRight())) {
|
||||
tripVO.setTripNumber(upDirection + String.format(tripFormat, upTn++));
|
||||
} else {
|
||||
tripVO.setTripNumber(downDirection + String.format(tripFormat, downTn++));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkInputTime(RunPlanInputData inputData) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(inputData.getOverTime().isAfter(inputData.getBeginTime()), "输入参数错误:发车时间应早于结束时间");
|
||||
LocalTime beginTimeOffset = inputData.getBeginTime().minusHours(OFFSET_TIME_HOURS);
|
||||
|
Loading…
Reference in New Issue
Block a user