diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/BeiJingLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/BeiJingLine1RunPlanNew.java index bcf02e032..06661faf4 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/BeiJingLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/BeiJingLine1RunPlanNew.java @@ -30,7 +30,7 @@ public class BeiJingLine1RunPlanNew implements IRunPlanStrategyNew { if(!StringUtils.hasText(runPlanImport.getDirectionCode())) { emptyDirection.add(runPlanImport.getServiceNumber()); } - handleStationAndTime(stationMap, runPlanImport.getArrivalList()); + handleStationAndTime(stationMap, runPlanImport); }); // 筛选存在 只有服务号的数据 Map> onlyServNumMap = runPlanImportList.stream().filter(runPlanImport -> diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine1RunPlanNew.java index 62e906f24..76880ed4a 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine1RunPlanNew.java @@ -32,7 +32,7 @@ public class ChengDuLine1RunPlanNew implements IRunPlanStrategyNew { runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport,upDirection); List arrivalList = runPlanImport.getArrivalList(); - handleStationAndTime(stationMap, arrivalList); + handleStationAndTime(stationMap, runPlanImport); }); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine3RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine3RunPlanNew.java index b839873ec..fc2b5d321 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine3RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine3RunPlanNew.java @@ -29,7 +29,7 @@ public class ChengDuLine3RunPlanNew implements IRunPlanStrategyNew { runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport, upDirection); List arrivalList = runPlanImport.getArrivalList(); - handleStationAndTime(stationMap, arrivalList); + handleStationAndTime(stationMap, runPlanImport); if(Arrays.asList("85331301","85124302","85246602").contains(runPlanImport.getCode())) { runPlanImport.setBackup(true); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java index 8e9864b0f..7e378bf48 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java @@ -33,7 +33,7 @@ public class FoshanTramRunPlanNew implements IRunPlanStrategyNew { runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport, upDirection); List arrivalList = runPlanImport.getArrivalList(); - handleStationAndTime(stationMap, arrivalList); + handleStationAndTime(stationMap, runPlanImport); }); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/FuZhouLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/FuZhouLine1RunPlanNew.java index 157fd18a2..f10aafb19 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/FuZhouLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/FuZhouLine1RunPlanNew.java @@ -32,7 +32,7 @@ public class FuZhouLine1RunPlanNew implements IRunPlanStrategyNew { runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport, upDirection); List arrivalList = runPlanImport.getArrivalList(); - handleStationAndTime(stationMap, arrivalList); + handleStationAndTime(stationMap, runPlanImport); // 判断是否备用计划 // RunPlanArrivalTime last = arrivalList.get(arrivalList.size() - 1); // if(!last.isFlag() && last.getArriveTime().equals(last.getDepartureTime())) { diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/HarBinLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/HarBinLine1RunPlanNew.java index 0ed8a4183..247626154 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/HarBinLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/HarBinLine1RunPlanNew.java @@ -33,7 +33,7 @@ public class HarBinLine1RunPlanNew implements IRunPlanStrategyNew { runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport,upDirection); List arrivalList = runPlanImport.getArrivalList(); - handleStationAndTime(stationMap, arrivalList); + handleStationAndTime(stationMap, runPlanImport); }); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/IRunPlanStrategyNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/IRunPlanStrategyNew.java index c88887097..f865e84df 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/IRunPlanStrategyNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/IRunPlanStrategyNew.java @@ -170,6 +170,11 @@ public interface IRunPlanStrategyNew { tempTripList.add(tripVO); } + for (int i = 1; i < tempTripList.size(); i++) { + RunPlanTripVO pre = tempTripList.get(i - 1); + RunPlanTripVO vo = tempTripList.get(i); + vo.setStartSectionCode(pre.getEndSectionCode()); + } tripList.addAll(tempTripList); }); return tripList; @@ -179,12 +184,14 @@ public interface IRunPlanStrategyNew { * 处理站台 stationName -> stationVO * 处理时间 到发时间处理,偏移 * 服务号按到站时间排序 - * - * @param stationMap - * @param arrivalList + * @param stationMap + * @param runPlanImport */ - default void handleStationAndTime(Map stationMap, List arrivalList) { - arrivalList.forEach(runPlanArrivalTime -> { + default void handleStationAndTime(Map stationMap, RunPlanImport runPlanImport) { + List arrivalList = runPlanImport.getArrivalList(); + List removes = new ArrayList<>(); + for (int i = 0; i < arrivalList.size(); i++) { + RunPlanArrivalTime runPlanArrivalTime = arrivalList.get(i); // 站名查找车站对象 String stationName = runPlanArrivalTime.getStationName().replaceAll("\r\n", ""); MapStationNewVO mapStationVO = stationMap.get(stationName); @@ -192,8 +199,19 @@ public interface IRunPlanStrategyNew { String.format("真实运行图车站名称'%s'没有找到对应车站数据", stationName)); runPlanArrivalTime.setStationNewVO(mapStationVO); // 到发时间处理 - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(Objects.isNull(runPlanArrivalTime.getArriveTime()) && Objects.isNull(runPlanArrivalTime.getDepartureTime()), - String.format("数据异常:‘%s’到发时间都为空", stationName)); + if (i != arrivalList.size() - 1) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(Objects.isNull(runPlanArrivalTime.getArriveTime()) && Objects.isNull(runPlanArrivalTime.getDepartureTime()), + String.format("数据异常:‘%s’到发时间都为空", stationName)); + } else { + // 折返 + if (StringUtils.hasText(runPlanArrivalTime.getTrackName()) && + Objects.isNull(runPlanArrivalTime.getArriveTime()) && + Objects.isNull(runPlanArrivalTime.getDepartureTime())) { + runPlanImport.setTbTrackName(runPlanArrivalTime.getTrackName()); + removes.add(runPlanArrivalTime); + continue; + } + } if (Objects.nonNull(runPlanArrivalTime.getArriveTime())) { runPlanArrivalTime.setArriveTime(runPlanArrivalTime.getArriveTime().minusHours(OFFSET_TIME_HOURS)); } @@ -207,7 +225,8 @@ public interface IRunPlanStrategyNew { } BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(runPlanArrivalTime.getDepartureTime().isBefore(runPlanArrivalTime.getArriveTime()), String.format("数据异常:‘%s’到发时间异常,到达时间%s-发车时间%s", stationName,runPlanArrivalTime.getArriveTime(),runPlanArrivalTime.getDepartureTime())); - }); + } + arrivalList.removeAll(removes); // 按到达时间增序排序 arrivalList.sort(Comparator.comparing(RunPlanArrivalTime::getArriveTime)); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine1RunPlanNew.java index 71371ebad..4abe961c0 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine1RunPlanNew.java @@ -39,7 +39,7 @@ public class NingBoLine1RunPlanNew implements IRunPlanStrategyNew { runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport, upDirection); List arrivalList = runPlanImport.getArrivalList(); - handleStationAndTime(stationMap, arrivalList); + handleStationAndTime(stationMap, runPlanImport); if(OUT2REENTRY_TRIP_CODES.contains(runPlanImport.getCode())){ runPlanImport.setBackup(true); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java index c1baf6f4a..2f80196f0 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java @@ -55,7 +55,7 @@ public class NingBoLine3RunPlanNew implements IRunPlanStrategyNew { if(runPlanImport.getCode().equals("36301")){ arrivalList.remove(0); } - handleStationAndTime(stationMap, arrivalList); + handleStationAndTime(stationMap, runPlanImport); if(Arrays.asList("36102", "36203","36401","36301").contains(runPlanImport.getCode())){ runPlanImport.setBackup(true); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine1RunPlanNew.java index 2699089b9..f2a53dc0e 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine1RunPlanNew.java @@ -31,7 +31,7 @@ public class XianLine1RunPlanNew implements IRunPlanStrategyNew { runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport, upDirection); List arrivalList = runPlanImport.getArrivalList(); - handleStationAndTime(stationMap, arrivalList); + handleStationAndTime(stationMap, runPlanImport); }); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine2RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine2RunPlanNew.java index f5889335e..eebd40013 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine2RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine2RunPlanNew.java @@ -33,7 +33,7 @@ public class XianLine2RunPlanNew implements IRunPlanStrategyNew { runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport, upDirection); List arrivalList = runPlanImport.getArrivalList(); - handleStationAndTime(stationMap, arrivalList); + handleStationAndTime(stationMap, runPlanImport); }); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine3RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine3RunPlanNew.java index d6952185a..fc216160c 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine3RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine3RunPlanNew.java @@ -2,17 +2,13 @@ package club.joylink.rtss.services.runplan.importReal; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.client.map.newmap.MapStationNewVO; -import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -36,6 +32,17 @@ public class XianLine3RunPlanNew implements IRunPlanStrategyNew { /**保税区ZF11折返*/ private static final List BAOSHUIQU_ZF11 = Collections.unmodifiableList(Arrays.asList("022001","021019","062002","061023")); + public static final Map> sectionReflectMap = new HashMap<>(); + static { + sectionReflectMap.putIfAbsent("ZF19", Arrays.asList("T10", "017")); // 鱼化寨 + sectionReflectMap.putIfAbsent("ZF20", Arrays.asList("T5", "014")); // 鱼化寨 + sectionReflectMap.putIfAbsent("ZF10", Arrays.asList("T270", "262")); // 保税区 + sectionReflectMap.putIfAbsent("ZF11", Arrays.asList("T271", "263")); // 保税区 + sectionReflectMap.putIfAbsent("ZF13", Arrays.asList("T209", "213")); // 香湖湾 + sectionReflectMap.putIfAbsent("ZF14", Arrays.asList("T208", "212")); // 香湖湾 + + } + /** * 导入数据检查和预处理 * @@ -50,9 +57,7 @@ public class XianLine3RunPlanNew implements IRunPlanStrategyNew { //处理导入运行图数据信息 runPlanImportList.forEach(runPlanImport -> { this.analyzeAndConvertCode(runPlanImport, upDirection); - List arrivalList = runPlanImport.getArrivalList(); - handleStationAndTime(stationMap, arrivalList); - + handleStationAndTime(stationMap, runPlanImport); }); } @@ -90,42 +95,12 @@ public class XianLine3RunPlanNew implements IRunPlanStrategyNew { */ @Override public void handleTrip(RunPlanImport runPlanImport, RunPlanTripVO tripVO, String startStationName, String endStationName, boolean isFirst, boolean isLast, String firstStationName, String finalStationName) { - switch (startStationName) { case "鱼化寨停车场": tripVO.setStartSectionCode("T7");//G0113 -// tripVO.setDestinationCode("015"); break; case "港务区车辆段": tripVO.setStartSectionCode("T275"); //G2620 -// tripVO.setDestinationCode("266"); - break; - case "鱼化寨": - if (YUHUAZHAI_ZF20.contains(runPlanImport.getCode())) { - tripVO.setStartSectionCode("T5"); //G0120 -// tripVO.setDestinationCode("014"); - } else { - tripVO.setStartSectionCode("T10"); //G0119 -// tripVO.setDestinationCode("017"); - } - break; - case "香湖湾": - if (XIANGHUWAN_ZF13.contains(runPlanImport.getCode())) { - tripVO.setStartSectionCode("T209"); //G2113 -// tripVO.setDestinationCode("213"); - } else { - tripVO.setStartSectionCode("T208"); //G2114 -// tripVO.setDestinationCode("212"); - } - break; - case "保税区": - if (BAOSHUIQU_ZF11.contains(runPlanImport.getCode())) { - tripVO.setStartSectionCode("T271"); //G2611 -// tripVO.setDestinationCode("263"); - } else { - tripVO.setStartSectionCode("T270"); //G2610 -// tripVO.setDestinationCode("262"); - } break; } switch (endStationName) { @@ -137,33 +112,86 @@ public class XianLine3RunPlanNew implements IRunPlanStrategyNew { tripVO.setEndSectionCode("T281"); //G2621 tripVO.setDestinationCode("267"); break; - case "鱼化寨": - if (YUHUAZHAI_ZF20.contains(runPlanImport.getCode())) { - tripVO.setEndSectionCode("T5"); //G0120 - tripVO.setDestinationCode("014"); - } else { - tripVO.setEndSectionCode("T10"); //G0119 - tripVO.setDestinationCode("017"); - } - break; - case "香湖湾": - if (XIANGHUWAN_ZF13.contains(runPlanImport.getCode())) { - tripVO.setEndSectionCode("T209"); //G2113 - tripVO.setDestinationCode("213"); - } else { - tripVO.setEndSectionCode("T208"); //G2114 - tripVO.setDestinationCode("212"); - } - break; - case "保税区": - if (BAOSHUIQU_ZF11.contains(runPlanImport.getCode())) { - tripVO.setEndSectionCode("T271"); //G2611 - tripVO.setDestinationCode("263"); - } else { - tripVO.setEndSectionCode("T270"); //G2610 - tripVO.setDestinationCode("262"); - } - break; + } + if (Objects.nonNull(runPlanImport.getTbTrackName())) { + List strings = sectionReflectMap.get(runPlanImport.getTbTrackName()); + tripVO.setEndSectionCode(strings.get(0)); + tripVO.setDestinationCode(strings.get(1)); + } else { + switch (startStationName) { + case "鱼化寨停车场": + tripVO.setStartSectionCode("T7");//G0113 +// tripVO.setDestinationCode("015"); + break; + case "港务区车辆段": + tripVO.setStartSectionCode("T275"); //G2620 +// tripVO.setDestinationCode("266"); + break; + case "鱼化寨": + if (YUHUAZHAI_ZF20.contains(runPlanImport.getCode())) { + tripVO.setStartSectionCode("T5"); //G0120 +// tripVO.setDestinationCode("014"); + } else { + tripVO.setStartSectionCode("T10"); //G0119 +// tripVO.setDestinationCode("017"); + } + break; + case "香湖湾": + if (XIANGHUWAN_ZF13.contains(runPlanImport.getCode())) { + tripVO.setStartSectionCode("T209"); //G2113 +// tripVO.setDestinationCode("213"); + } else { + tripVO.setStartSectionCode("T208"); //G2114 +// tripVO.setDestinationCode("212"); + } + break; + case "保税区": + if (BAOSHUIQU_ZF11.contains(runPlanImport.getCode())) { + tripVO.setStartSectionCode("T271"); //G2611 +// tripVO.setDestinationCode("263"); + } else { + tripVO.setStartSectionCode("T270"); //G2610 +// tripVO.setDestinationCode("262"); + } + break; + } + switch (endStationName) { + case "鱼化寨停车场": + tripVO.setEndSectionCode("T2");//G0114 + tripVO.setDestinationCode("012"); + break; + case "港务区车辆段": + tripVO.setEndSectionCode("T281"); //G2621 + tripVO.setDestinationCode("267"); + break; + case "鱼化寨": + if (YUHUAZHAI_ZF20.contains(runPlanImport.getCode())) { + tripVO.setEndSectionCode("T5"); //G0120 + tripVO.setDestinationCode("014"); + } else { + tripVO.setEndSectionCode("T10"); //G0119 + tripVO.setDestinationCode("017"); + } + break; + case "香湖湾": + if (XIANGHUWAN_ZF13.contains(runPlanImport.getCode())) { + tripVO.setEndSectionCode("T209"); //G2113 + tripVO.setDestinationCode("213"); + } else { + tripVO.setEndSectionCode("T208"); //G2114 + tripVO.setDestinationCode("212"); + } + break; + case "保税区": + if (BAOSHUIQU_ZF11.contains(runPlanImport.getCode())) { + tripVO.setEndSectionCode("T271"); //G2611 + tripVO.setDestinationCode("263"); + } else { + tripVO.setEndSectionCode("T270"); //G2610 + tripVO.setDestinationCode("262"); + } + break; + } } } diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanArrivalTime.java b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanArrivalTime.java index 4bd867b4e..cfd94c60d 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanArrivalTime.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanArrivalTime.java @@ -18,6 +18,11 @@ public class RunPlanArrivalTime { @NotBlank(message = "车站名称不能为空") private String stationName; + /** + * 停车轨名称 + */ + private String trackName; + @ApiModelProperty(hidden = true) private MapStationVO stationVO; @@ -28,6 +33,8 @@ public class RunPlanArrivalTime { private LocalTime departureTime; + private boolean tb;// 折返 + @ApiModelProperty(value = "是否进入/离开线路") private boolean flag; diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanImport.java b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanImport.java index f2abbd319..c80b78f08 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanImport.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanImport.java @@ -2,7 +2,6 @@ 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; @@ -28,6 +27,11 @@ public class RunPlanImport { @Valid private List arrivalList; + /** + * 折返轨名称 + */ + private String tbTrackName; + @ApiModelProperty(hidden = true) private String serviceNumber;