From 9562c726e30f761caee7460d38bfd50f421d7a23 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 8 Dec 2020 11:23:35 +0800 Subject: [PATCH 01/23] =?UTF-8?q?=E4=BB=BF=E7=9C=9F=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=83=85=E5=86=B5=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20201208.sql | 2 + .../script/ScriptSimulationService.java | 12 +- ...ce.java => UserSimulationStatService.java} | 3 +- .../rtss/simulation/cbtc/Simulation.java | 10 +- .../cbtc/event/SimulationSubscribeEvent.java | 19 +++ .../event/SimulationUnsubscribeAllEvent.java | 22 +++ .../message/UserSimulationStatsListen.java | 35 ++++ .../message/UserSimulationStatsManager.java | 161 ++++++++++++++++++ .../websocket/SimulationSubscribeManager.java | 30 +++- 9 files changed, 281 insertions(+), 13 deletions(-) create mode 100644 sql/20201208.sql rename src/main/java/club/joylink/rtss/services/user/{UserSimulationStatStatService.java => UserSimulationStatService.java} (98%) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationSubscribeEvent.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationUnsubscribeAllEvent.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsListen.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java diff --git a/sql/20201208.sql b/sql/20201208.sql new file mode 100644 index 000000000..cc4f8c4f5 --- /dev/null +++ b/sql/20201208.sql @@ -0,0 +1,2 @@ +alter table user_simulation_stats modify role varchar(32) null comment '用户角色'; + diff --git a/src/main/java/club/joylink/rtss/services/script/ScriptSimulationService.java b/src/main/java/club/joylink/rtss/services/script/ScriptSimulationService.java index d7aa3fad1..74a65bc8b 100644 --- a/src/main/java/club/joylink/rtss/services/script/ScriptSimulationService.java +++ b/src/main/java/club/joylink/rtss/services/script/ScriptSimulationService.java @@ -1,6 +1,7 @@ package club.joylink.rtss.services.script; -import club.joylink.rtss.services.script.IScriptSimulationService; +import club.joylink.rtss.entity.ScriptDraftWithBLOBs; +import club.joylink.rtss.services.IScriptDraftService; import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.GroupSimulationCache; @@ -22,9 +23,6 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop; import club.joylink.rtss.simulation.cbtc.script.ScriptActionBO; import club.joylink.rtss.simulation.cbtc.script.ScriptBO; -import club.joylink.rtss.entity.ScriptDraftWithBLOBs; -import club.joylink.rtss.services.IScriptDraftService; -import club.joylink.rtss.services.script.IScriptService; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.SocketMessageVO; @@ -36,11 +34,11 @@ import club.joylink.rtss.vo.client.script.ScriptActionVO; import club.joylink.rtss.vo.client.script.ScriptVO; import club.joylink.rtss.vo.client.simulationv1.SimulationMemberVO; import club.joylink.rtss.websocket.StompMessageService; -import org.springframework.context.event.EventListener; -import org.springframework.util.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.util.List; import java.util.Map; @@ -195,7 +193,7 @@ public class ScriptSimulationService implements IScriptSimulationService { } // 构建一个仿真 Simulation simulation = this.groupSimulationService.create(loginUserInfoVO, draftScript.getMapId(), null, - Simulation.FunctionalType.SIMULATION); + Simulation.FunctionalType.SCRIPT_PREVIEW); loadDraftScript(simulation, draftScriptId); return simulation.getGroup(); } diff --git a/src/main/java/club/joylink/rtss/services/user/UserSimulationStatStatService.java b/src/main/java/club/joylink/rtss/services/user/UserSimulationStatService.java similarity index 98% rename from src/main/java/club/joylink/rtss/services/user/UserSimulationStatStatService.java rename to src/main/java/club/joylink/rtss/services/user/UserSimulationStatService.java index 6f97b77ba..7a427ef40 100644 --- a/src/main/java/club/joylink/rtss/services/user/UserSimulationStatStatService.java +++ b/src/main/java/club/joylink/rtss/services/user/UserSimulationStatService.java @@ -16,12 +16,11 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import java.util.regex.Pattern; import java.util.stream.Collectors; @Service -public class UserSimulationStatStatService implements IUserSimulationStatService { +public class UserSimulationStatService implements IUserSimulationStatService { @Autowired private UserSimulationStatsDAO userSimulationStatsDAO; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java index eae54272b..beee1036c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java @@ -211,6 +211,10 @@ public class Simulation { return Objects.equals(this.buildParams.getFunctionalType(), FunctionalType.SCRIPT_MAKING); } + public boolean isScriptPreviewSimulation() { + return FunctionalType.SCRIPT_PREVIEW.equals(buildParams.getFunctionalType()); + } + /** * 获取该角色类型的所有成员 */ @@ -484,7 +488,11 @@ public class Simulation { /** * 剧本编制 */ - SCRIPT_MAKING; + SCRIPT_MAKING, + /** + * 剧本预览 + */ + SCRIPT_PREVIEW; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationSubscribeEvent.java b/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationSubscribeEvent.java new file mode 100644 index 000000000..134ed28ff --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationSubscribeEvent.java @@ -0,0 +1,19 @@ +package club.joylink.rtss.simulation.cbtc.event; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.context.ApplicationEvent; + +@Getter +@Setter +public class SimulationSubscribeEvent extends ApplicationEvent { + private Long userId; + + private String group; + + public SimulationSubscribeEvent(Object source, Long userId, String group) { + super(source); + this.userId = userId; + this.group = group; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationUnsubscribeAllEvent.java b/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationUnsubscribeAllEvent.java new file mode 100644 index 000000000..35c1ea90e --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationUnsubscribeAllEvent.java @@ -0,0 +1,22 @@ +package club.joylink.rtss.simulation.cbtc.event; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.context.ApplicationEvent; + +/** + * 用户退订仿真的所有订阅路径 + */ +@Getter +@Setter +public class SimulationUnsubscribeAllEvent extends ApplicationEvent { + private Long userId; + + private String group; + + public SimulationUnsubscribeAllEvent(Object source, Long userId, String group) { + super(source); + this.userId = userId; + this.group = group; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsListen.java b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsListen.java new file mode 100644 index 000000000..0645f2af3 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsListen.java @@ -0,0 +1,35 @@ +package club.joylink.rtss.simulation.cbtc.message; + +import club.joylink.rtss.simulation.cbtc.event.SimulationDestroyEvent; +import club.joylink.rtss.simulation.cbtc.event.SimulationSubscribeEvent; +import club.joylink.rtss.simulation.cbtc.event.SimulationUnsubscribeAllEvent; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +@Component +public class UserSimulationStatsListen { + + @Autowired + private UserSimulationStatsManager userSimulationStatsManager; + + @Async("nsExecutor") + @EventListener + public void subscribeSimulation(SimulationSubscribeEvent event) { + userSimulationStatsManager.subscribeSimulation(event.getUserId(), event.getGroup()); + } + + @Async("nsExecutor") + @EventListener + public void unsubscribeAll(SimulationUnsubscribeAllEvent event) { + userSimulationStatsManager.unsubscribeAll(event.getUserId(), event.getGroup()); + } + + @Async("nsExecutor") + @EventListener + public void simulationDestroy(SimulationDestroyEvent event) { + userSimulationStatsManager.simulationDestroy(event.getSimulation()); + } + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java new file mode 100644 index 000000000..e654fc0cd --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java @@ -0,0 +1,161 @@ +package club.joylink.rtss.simulation.cbtc.message; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.user.IUserSimulationStatService; +import club.joylink.rtss.simulation.cbtc.GroupSimulationService; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams; +import club.joylink.rtss.simulation.cbtc.member.SimulationMember; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 用户使用仿真情况记录 + */ +@Slf4j +@Component +public class UserSimulationStatsManager { + @Autowired + private GroupSimulationService groupSimulationService; + + @Autowired + private IUserSimulationStatService iUserSimulationStatService; + + /** + * k - userId + * v - 用户订阅的仿真的groups + */ + private final Map> userAndUseInfosMap = new ConcurrentHashMap<>(); + + /** + * k - group + * v - 仿真使用记录 + */ + private final Map> simulationAndUseInfosMap = new ConcurrentHashMap<>(); + + /** + * 仿真被订阅,记录仿真使用记录 + */ + public void subscribeSimulation(Long userId, String group) { + Simulation simulation = groupSimulationService.getSimulationByGroup(group); + if (simulation.isScriptMakingSimulation() || simulation.isScriptPreviewSimulation()) { + return; + } + Set useInfos = userAndUseInfosMap.computeIfAbsent(userId, k -> new HashSet<>()); + Optional infoOptional = useInfos.stream().filter(info -> group.equals(info.getGroup())).limit(1).findFirst(); + if (infoOptional.isPresent()) { //如果记录已经存在 + SimulationUseInfo useInfo = infoOptional.get(); + useInfo.restart(); + } else { //如果记录不存在 + SimulationUseInfo newInfo = new SimulationUseInfo(group, userId); + useInfos.add(newInfo); + Set groupKeyUseInfos = simulationAndUseInfosMap.computeIfAbsent(group, k -> new HashSet<>()); + groupKeyUseInfos.add(newInfo); + } + } + + /** + * 用户将仿真所有订阅退订,则仿真使用记录暂停 + */ + public void unsubscribeAll(Long userId, String group) { + Simulation simulation = groupSimulationService.getSimulationByGroup(group); + if (simulation.isScriptMakingSimulation() || simulation.isScriptPreviewSimulation()) { + return; + } + SimulationUseInfo useInfo = findUseInfo(userId, group); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(useInfo, String.format("仿真[%s]的使用未被记录", group)); + useInfo.pause(); + } + + /** + * 仿真销毁,持久化数据 + */ + public void simulationDestroy(Simulation simulation) { + if (simulation.isScriptMakingSimulation() || simulation.isScriptPreviewSimulation()) { //剧本编制和预览仿真不记录 + return; + } + + //暂停并从map中移除仿真使用记录 + String group = simulation.getGroup(); + Set useInfos = simulationAndUseInfosMap.remove(group); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(useInfos, String.format("仿真[%s]的使用未被记录", group)); + useInfos.forEach(info -> { + info.pause(); + Set infos = userAndUseInfosMap.get(info.getUserId()); + infos.removeIf(i -> group.equals(i.getGroup())); + }); + SimulationBuildParams buildParams = simulation.getBuildParams(); + useInfos.forEach(info -> { + Long userId = info.getUserId(); + SimulationMember member = simulation.findMemberByUserId(userId); + String memberType = member == null ? null : member.getType().name(); + String prdType = buildParams.getProdType() == null ? null : buildParams.getProdType().getCode(); + iUserSimulationStatService.addUserSimulationStats(userId, buildParams.getMap().getId(), + prdType, info.getDuration(), memberType); + }); + } + + private SimulationUseInfo findUseInfo(Long userId, String group) { + Set infos = userAndUseInfosMap.get(userId); + if (CollectionUtils.isEmpty(infos)) { + return null; + } else { + Optional optional = infos.stream().filter(info -> group.equals(info.getGroup())).limit(1).findFirst(); + return optional.orElse(null); + } + } + + /** + * 仿真使用信息 + */ + @Getter + @Setter + public class SimulationUseInfo { + private String group; + + private Long userId; + + private LocalDateTime startTime = LocalDateTime.now(); + + private int duration; + + private boolean pause; + + public SimulationUseInfo(String group, Long userId) { + this.group = group; + this.userId = userId; + } + + /** + * 暂停计时 + */ + public void pause() { + if (!pause) { + duration = (int) (duration + Duration.between(startTime, LocalDateTime.now()).toSeconds()); + this.pause = true; + } + } + + /** + * 重新开始计时 + */ + public void restart() { + if (pause) { + startTime = LocalDateTime.now(); + pause = false; + } + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/message/websocket/SimulationSubscribeManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/message/websocket/SimulationSubscribeManager.java index c084f3fa2..257c886ca 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/message/websocket/SimulationSubscribeManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/message/websocket/SimulationSubscribeManager.java @@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.message.websocket; import club.joylink.rtss.simulation.cbtc.event.*; import club.joylink.rtss.websocket.WebsocketConfig; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -48,6 +49,7 @@ public class SimulationSubscribeManager { /** * 发布仿真连接/断连事件 + * * @param user * @param subscribeTopic * @param destination @@ -58,12 +60,18 @@ public class SimulationSubscribeManager { String destination, boolean sub) { if (sub) { log.info(String.format("用户[%s]订阅仿真[%s]", user.getName(), destination)); + this.applicationContext.publishEvent(new SimulationSubscribeEvent(this, user.getUser().getId(), subscribeTopic.getId(destination))); } else { log.info(String.format("用户[%s]取消订阅仿真[%s]", user.getName(), destination)); + //如果某个仿真的所有订阅都被取消 + SimulationUserSubscribeInfo simulationUserSubscribeInfo = userSubInfoMap.get(user.getName()); + if (simulationUserSubscribeInfo == null || simulationUserSubscribeInfo.isSubscribeInfoEmpty(destination)) { + this.applicationContext.publishEvent(new SimulationUnsubscribeAllEvent(this, user.getUser().getId(), subscribeTopic.getId(destination))); + } } switch (subscribeTopic) { case Main: - case WeChatMini:{ + case WeChatMini: { if (sub) { this.applicationContext.publishEvent(new SimulationUserConnectEvent(user.getUser().getId(), subscribeTopic.getId(destination), this)); } else { @@ -71,7 +79,7 @@ public class SimulationSubscribeManager { } break; } - case SandBox:{ + case SandBox: { if (sub) { this.applicationContext.publishEvent(new SandboxUserConnectEvent(user.getUser().getId(), subscribeTopic.getId(destination), this)); } else { @@ -79,7 +87,7 @@ public class SimulationSubscribeManager { } break; } - case Drive:{ + case Drive: { if (sub) { this.applicationContext.publishEvent(new Drive3DUserConnectEvent(user.getUser().getId(), subscribeTopic.getId(destination), this)); } else { @@ -150,6 +158,7 @@ public class SimulationSubscribeManager { /** * 断开连接,删除此连接的所有订阅,并查询此用户所有客户端都不再订阅的路径返回 + * * @param wsSessionId * @return 此用户所有客户端都没有订阅的路径 */ @@ -177,9 +186,24 @@ public class SimulationSubscribeManager { return false; } + public boolean isSubscribeInfoEmpty(String destination) { + if (sessionSubMap == null || sessionSubMap.isEmpty()) { + return true; + } + for (Set infos : sessionSubMap.values()) { + for (SubscribeInfo info : infos) { + if (destination.equals(info.getDestination())) { + return false; + } + } + } + return true; + } + class SubscribeInfo { String wsSessionId; String subId; + @Getter String destination; public SubscribeInfo(String wsSessionId, String subId, String destination) { From b148976759e78a8e77b4b5ae07333a348d5f9f30 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Tue, 8 Dec 2020 19:32:12 +0800 Subject: [PATCH 02/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=97=E8=BD=A6?= =?UTF-8?q?=E5=81=9C=E7=AB=99=E6=97=B6=E9=97=B4=E8=AE=A1=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20=E4=BF=AE=E6=94=B9=E5=88=97=E8=BD=A6=E7=AB=99?= =?UTF-8?q?=E5=8F=B0=E5=81=9C=E8=BD=A6=E5=85=B3=E9=97=A8=E6=97=B6=E6=9C=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20=E4=BF=AE=E6=94=B9ITC=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E8=AE=A1=E7=AE=97=E4=BD=8D=E7=BD=AE=E4=B8=BA?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=9C=BA=E5=89=8D5=E7=B1=B3=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9ATS=E8=BF=9B=E8=B7=AF=E8=A7=A6=E5=8F=91=E8=A5=BF?= =?UTF-8?q?=E9=97=A8=E5=AD=90=E7=B1=BB=E8=BF=9B=E8=B7=AFbug=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=98=E8=BF=94=E8=BF=9B=E8=B7=AF=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E6=97=B6=E6=9C=BA=20=E4=BF=AE=E6=94=B9=E5=A4=87?= =?UTF-8?q?=E7=94=A8=E8=BD=A6=E6=9B=B4=E6=96=B0=E8=BD=A6=E6=AC=A1=E6=97=B6?= =?UTF-8?q?=E6=9C=BA=20=E4=BF=AE=E6=94=B9=E8=BF=9B=E8=B7=AF=E5=BB=B6?= =?UTF-8?q?=E7=BB=AD=E4=BF=9D=E6=8A=A4=E8=A7=A3=E9=94=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DraftMapCiDataGeneratorImpl.java | 2 +- .../cbtc/ATP/ground/ZCLogicLoop.java | 13 ++++++- .../cbtc/ATS/service/AtsPlanService.java | 21 ++++++----- .../ATS/service/AtsRouteSettingService.java | 13 +++---- .../cbtc/CI/service/RouteService.java | 35 ++++++++++++------- .../rtss/simulation/cbtc/data/map/Route.java | 12 +++---- .../cbtc/data/map/RouteOverlap.java | 2 +- .../cbtc/onboard/ATP/ATPLogicLoop.java | 13 ++++--- .../onboard/ATP/OnboardAtpApiServiceImpl.java | 8 ++--- 9 files changed, 70 insertions(+), 49 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index 7917c72ec..756e8fd88 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -36,7 +36,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { MapVO mapVO = this.draftMapService.getDraftMapData(mapId); SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildBasicMapData(mapVO); BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), - String.format("地图基础数据有错误")); + String.format("地图基础数据有错误: %s", JsonUtils.writeValueAsString(buildResult.getErrMsgList()))); MapCiGenerateConfig generateConfig = mapVO.getGraphDataNew().getGenerateConfig(); Map deviceMap = buildResult.getDeviceMap(); // 联锁关系数据生成 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java index 4fd3cbe72..6f6f87697 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java @@ -54,7 +54,7 @@ public class ZCLogicLoop { } else if (RunLevel.CBTC.equals(defaultRunLevel)) { //更新ITC ma Float distance2NextSignal = train.calculateDistance2NextNormalOpenSignal(); - if (distance2NextSignal != null && distance2NextSignal <= 100) { + if (distance2NextSignal != null && distance2NextSignal <= 5) { this.calculateMAOfITC(simulation, train, trainList); } //更新CBTC ma @@ -105,6 +105,17 @@ public class ZCLogicLoop { this.groundAtpApiService.handleTrainStopMessage(simulation, trainStopMessage); } + private void calculateMaOfCtc(Simulation simulation, VirtualRealityTrain train, + List trainList) { + // 查找移动授权终端列表 + List endList = this.findCtcMaEnd(simulation, train, trainList); + } + + private List findCtcMaEnd(Simulation simulation, VirtualRealityTrain train, + List trainList) { + return null; + } + private void calculateMAOfCBTC(Simulation simulation, VirtualRealityTrain train, List trainList) { // 查找移动授权终端列表 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java index 41ab41c7f..b08a05e03 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java @@ -275,8 +275,10 @@ public class AtsPlanService { //找不到计划,不处理 return; } - //有计划折返 - this.turnBackTrain(simulation, train, nextTripPlan); + if (simulation.getSystemTime().toLocalTime().plusSeconds(60).isAfter(nextTripPlan.getStartTime())) { + //有计划折返,且到发车时间 + this.turnBackTrain(simulation, train, nextTripPlan); + } } /** @@ -621,23 +623,20 @@ public class AtsPlanService { // 更新追踪列车到站状态 StationPlan stationPlan = tripPlan.queryStationPlanByStation(station); if (parkTime < 0) { - - int planParkTime = stationPlan.getParkTime(); + parkTime = stationPlan.getLeaveTime().toSecondOfDay() - systemTime.toSecondOfDay(); if (this.checkIfFrontTurnBack(simulation, train, section, tripPlan, stationPlan)) { //是站台折返车 //如果停车时间为0 ,则取后一个车次计划的首站发车时间 TripPlan nextTripPlan = repository.queryServiceNextTripPlan(tripPlan.getServiceNumber(), tripPlan.getTripNumber()); StationPlan nextFirstStationPlan = nextTripPlan.queryStationPlanByStation(station); - planParkTime = nextFirstStationPlan.getLeaveTime().toSecondOfDay() - stationPlan.getArriveTime().toSecondOfDay(); + parkTime = nextFirstStationPlan.getLeaveTime().toSecondOfDay() - systemTime.toSecondOfDay(); } - parkTime = planParkTime; - } - } else { - if (parkTime < 0) { - // 头码车和人工车默认给30s - parkTime = 30; } } + if (parkTime < 25) { + // 头码车和人工车默认给25s + parkTime = 25; + } LocalTime leaveTime = systemTime.plusSeconds(parkTime); train.updateEstimatedLeaveInfo(section, leaveTime); this.atsStandService.updateStandParkTime(section, parkTime); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java index 3bb4c427b..47e6d4fcd 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java @@ -222,10 +222,6 @@ public class AtsRouteSettingService { // 处理站前折返的进路排列 routePaths = repository.queryRoutePaths(trainSection, nextSection); } else if (train.isStop() && !trainSection.isNormalStandTrack() && (trainSection.isTurnBackTrack() || trainSection.isTransferTrack())) { // 折返轨停车 - if (tripPlan.getStartSection().isSamePhysical(trainSection.getCode()) && - !simulation.getSystemTime().toLocalTime().plusSeconds(60).isAfter(train.getPlanArriveTime())) { - return null; - } List routePaths1 = repository.queryRoutePaths(trainSection, nextSection); if (!CollectionUtils.isEmpty(routePaths1)) { routePaths = routePaths1; @@ -287,9 +283,7 @@ public class AtsRouteSettingService { if (route.isTurnBack() && firstChoiceRoutePath.getEnd().isNormalStandTrack()) { continue; } - if (this.isAtsTrigger(simulation, train, route, false, trainList)) { - triggerList.add(route); - } + triggerList.add(route); } } if (CollectionUtils.isEmpty(triggerList)) { @@ -297,9 +291,12 @@ public class AtsRouteSettingService { } else if (triggerList.size() > 1) { if (this.hasSameEnd(triggerList)) { // 多延续保护进路,取延续保护是定位的那条 + // todo 暂时逻辑定为只触发定位保护进路,后需完善为根据接下来的运行目的选择延续保护 for (Route route : triggerList) { if (this.isOverlapStraight(route)) { - return route; + if (this.isAtsTrigger(simulation, train, route, false, trainList)) { + return route; + } } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java index 45c102940..17adfcd39 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java @@ -968,18 +968,18 @@ public class RouteService { } SectionPath sectionPath = overlap.selectPath(); if (Objects.nonNull(sectionPath)) { - boolean routeLock = true; - for (Section section : sectionPath.getSectionList()) { - if (!section.isRouteLock()) { - routeLock = false; - break; - } - } - if (routeLock) { // 延续保护区段进路锁闭,立即解锁 - overlap.releaseImmediately(); - } else if (overlap.getSection().isRouteLock() && - - overlap.getSection().isOccupied()) { // 前方进路最后子进路占用,触发/解锁执行 +// boolean routeLock = true; +// for (Section section : sectionPath.getSectionList()) { +// if (!section.isRouteLock()) { +// routeLock = false; +// break; +// } +// } +// if (routeLock) { // 延续保护区段进路锁闭,立即解锁 +// overlap.releaseImmediately(); +// } else + if (overlap.getSection().isRouteLock() && + overlap.getSection().isOccupied()) { // 前方进路最后子进路占用,触发/解锁执行 if (!overlap.isReleasing()) { log.debug(String.format("[%s]延续保护[%s],触发区段[%s(%s)]触发开始解锁", overlap.isRight() ? "右向" : "左向", overlap.getName(), @@ -991,6 +991,17 @@ public class RouteService { } else if (!overlap.getSection().isRouteLock()) { // 最后子进路解锁,则延续保护解锁 overlap.releaseImmediately(); + } else { + boolean allUnlock = true; + for (Section section : sectionPath.getSectionList()) { + if (section.isOverlapLock()) { + allUnlock = false; + break; + } + } + if (allUnlock) { + overlap.releaseImmediately(); + } } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java index a6fb3e03d..6b8aa50f7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java @@ -370,10 +370,10 @@ public class Route extends MapNamedElement { * 排列失败 */ public void settingFailed() { - this.lock = false; - if (Objects.equals(this.start.getLockedRoute(), this)) { - this.start.setLockedRoute(null); - } +// this.lock = false; +// if (Objects.equals(this.start.getLockedRoute(), this)) { +// this.start.setLockedRoute(null); +// } this.setting = false; if (Objects.nonNull(this.overlap)) { this.overlap.settingFailed(); @@ -447,8 +447,8 @@ public class Route extends MapNamedElement { Switch aSwitch = element.getASwitch(); if (aSwitch.isFault() && (Switch.SwitchFault.SPLIT.equals(aSwitch.getFault()) || - (element.isNormal() && Switch.SwitchFault.NORMAL_SPLIT.equals(aSwitch.getFault())) || - (!element.isNormal() && Switch.SwitchFault.REVERSE_SPLIT.equals(aSwitch.getFault())))) { + (element.isNormal() && !aSwitch.isReversePosition() && Switch.SwitchFault.NORMAL_SPLIT.equals(aSwitch.getFault())) || + (!element.isNormal() && !aSwitch.isNormalPosition() && Switch.SwitchFault.REVERSE_SPLIT.equals(aSwitch.getFault())))) { return true; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlap.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlap.java index 11daa841b..5906277e0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlap.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlap.java @@ -219,7 +219,7 @@ public class RouteOverlap extends MapNamedElement { } public void settingFailed() { - this.lock = false; +// this.lock = false; this.setting = false; this.settingStartTime = null; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java index 2469261d6..9e4946499 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java @@ -189,6 +189,13 @@ public class ATPLogicLoop { private void handleStandParkedTrain(Simulation simulation, VirtualRealityTrain train) { StandParkedTrainActivity activity = train.getStandParkedTrainActivity(); + int parkRemainTime = train.getParkRemainTime(); + if (parkRemainTime > 0) { + parkRemainTime -= SimulationModule.ATP.getRateMs(); + train.setParkRemainTime(parkRemainTime); + } else { + train.setParkRemainTime(0); + } switch (activity) { case PARK: // 停靠 train.nextParkedTrainActivity(); @@ -204,11 +211,7 @@ public class ATPLogicLoop { } break; case BOARD: // 乘客乘降 - int parkRemainTime = train.getParkRemainTime(); - if (parkRemainTime >= 0) { - parkRemainTime -= SimulationModule.ATP.getRateMs(); - train.setParkRemainTime(parkRemainTime); - } else { + if (parkRemainTime < 10000) { // 小于10秒,关门 train.nextParkedTrainActivity(); } break; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java index 72842d0e2..8b62e1d25 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java @@ -80,10 +80,10 @@ public class OnboardAtpApiServiceImpl implements OnboardAtpApiService { train.park(parkTime); log.debug(String.format("列车[%s]停站时间[%s s]", train.getGroupNumber(), parkTime)); - if (parkTime > 0) { - // 开屏蔽门 - this.ATOService.syncOpenDoor(simulation, train); - } +// if (parkTime > 0) { +// // 开屏蔽门 +// this.ATOService.syncOpenDoor(simulation, train); +// } } @Override From c802b2115f11f62a75534e4fe4131c57b9661c6d Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Wed, 9 Dec 2020 13:30:40 +0800 Subject: [PATCH 03/23] =?UTF-8?q?=E5=88=97=E8=BD=A6=E7=AB=99=E9=97=B4?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E9=80=9F=E5=BA=A6=E6=8E=A7=E5=88=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=AB=99=E5=8F=B0=E6=97=B6=E9=97=B4=E8=80=83=E8=99=91?= =?UTF-8?q?=20=E5=88=97=E8=BD=A6=E5=81=9C=E7=AB=99=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=BE=AE=E8=B0=83=20=E5=88=97=E8=BD=A6?= =?UTF-8?q?=E5=8C=BA=E9=97=B4=E9=80=9A=E4=BF=A1=E6=95=85=E9=9A=9C=E7=84=B6?= =?UTF-8?q?=E5=90=8E=E6=81=A2=E5=A4=8D=E8=BF=9B=E8=B7=AF=E9=94=81=E9=97=AD?= =?UTF-8?q?=E5=85=89=E5=B8=A6=E7=BC=BA=E5=A4=B1=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/simulation/cbtc/ATS/service/AtsPlanService.java | 2 +- .../joylink/rtss/simulation/cbtc/CI/service/RouteService.java | 2 +- .../simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java index b08a05e03..7350e471b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java @@ -633,7 +633,7 @@ public class AtsPlanService { } } } - if (parkTime < 25) { + if (parkTime < 10) { // 头码车和人工车默认给25s parkTime = 25; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java index 17adfcd39..99e0bfd2f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java @@ -853,7 +853,7 @@ public class RouteService { Collections.reverse(logicList); } for (Section logic : logicList) { - if (!logic.isCtOccupied()) { + if (!logic.isOccupied()) { logic.routeUnlocking(right); } else { break; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java index 8b62e1d25..b01b976a9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java @@ -112,7 +112,7 @@ public class OnboardAtpApiServiceImpl implements OnboardAtpApiService { train.updateNextStationPlan(nextStation, targetSection, parking); this.checkAndChangeDirection(simulation, train, targetSection); //根据时间控制速度 - runningTime -= 10; //减去开关门和延迟启动耗费的时间 +// runningTime -= 10; //减去开关门和延迟启动耗费的时间 Float atoMaxSpeed = CalculateService.calculateAtoSpeedMax4RunTime(train, runningTime); if (atoMaxSpeed != null) { train.setAtoSpeedMax(atoMaxSpeed); From 468d641a1fc98392bb7deb995ec959cc1c8fe76a Mon Sep 17 00:00:00 2001 From: DU Date: Wed, 9 Dec 2020 16:52:29 +0800 Subject: [PATCH 04/23] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E5=9B=BE=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=87=BA=E5=85=A5=E5=BA=93=E5=8F=8A=E7=8E=AF=E8=B7=AF?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=8D=95=E4=B8=AA=E8=AE=A1=E5=88=92=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/Swagger2.java | 42 ++++ .../controller/draft/DraftMapController.java | 42 ++-- .../controller/publish/LessonController.java | 2 +- .../{ => runplan}/RunPlanDraftController.java | 28 ++- .../rtss/services/IRunPlanDraftService.java | 3 + .../rtss/services/RunPlanDraftService.java | 236 ++++++++---------- .../joylink/rtss/vo/client/map/MapVO.java | 13 + .../rtss/vo/client/runplan/RunPlanTripVO.java | 22 ++ .../vo/runplan/newdraw/RunPlanGenerator.java | 236 +++++++++++++++++- 9 files changed, 471 insertions(+), 153 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/Swagger2.java rename src/main/java/club/joylink/rtss/controller/{ => runplan}/RunPlanDraftController.java (88%) diff --git a/src/main/java/club/joylink/rtss/Swagger2.java b/src/main/java/club/joylink/rtss/Swagger2.java new file mode 100644 index 000000000..84fb01661 --- /dev/null +++ b/src/main/java/club/joylink/rtss/Swagger2.java @@ -0,0 +1,42 @@ +package club.joylink.rtss; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +//@EnableOpenApi +public class Swagger2 { + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .enable(true) + .select() + // 自行修改为自己的包路径 + .apis(RequestHandlerSelectors.basePackage("club.joylink.rtss.controller")) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("管理工具API文档") + .description("restful 风格接口") + //服务条款网址 +// .termsOfServiceUrl("http://localhost:9000/") + .version("1.0") +// .licenseUrl("http://localhost:9000/") +// .contact(new Contact("walker-sheng", "#", "walkersxq@163.com")) + .build(); + } + +} diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java index bba228360..8594a5182 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java @@ -239,31 +239,31 @@ public class DraftMapController { /*!!!!!!!!!!!!!!!!!!!!!!! 新 自动信号 !!!!!!!!!!!!!!!!!!!!!!!!!!*/ - @ApiOperation(value = "创建自动信号") + @ApiOperation(value = "新创建自动信号") @PostMapping(path = "/autoSignalNew") public void createAutoSignal(@RequestBody @Validated MapAutoSignalNewVO autoSignalVO) { iDraftMapService.createAutoSignal(autoSignalVO); } - @ApiOperation(value = "分页获取自动信号") + @ApiOperation(value = "新分页获取自动信号") @GetMapping(path = "/{mapId}/autoSignalNew") public PageVO queryPagedAutoSignalNew(@PathVariable Long mapId, MapAutoSignalQueryVO queryVO) { return iDraftMapService.queryPagedAutoSignalNew(mapId, queryVO); } - @ApiOperation(value = "获取自动信号") + @ApiOperation(value = "新获取自动信号") @GetMapping(path = "/autoSignalNew/{autoSignalId}") public MapAutoSignalNewVO getAutoSignalNew(@PathVariable Long autoSignalId) { return iDraftMapService.getAutoSignalNew(autoSignalId); } - @ApiOperation(value = "更新自动信号") + @ApiOperation(value = "新更新自动信号") @PutMapping(path = "/autoSignalNew/{autoSignalId}") public void updateAutoSignal(@PathVariable Long autoSignalId, @RequestBody @Validated MapAutoSignalNewVO autoSignalVO) { iDraftMapService.updateAutoSignal(autoSignalId, autoSignalVO); } - @ApiOperation(value = "删除自动信号") + @ApiOperation(value = "新删除自动信号") @DeleteMapping(path = "/autoSignalNew/{autoSignalId}") public void deleteAutoSignalNew(@PathVariable Long autoSignalId) { iDraftMapService.deleteAutoSignal(autoSignalId); @@ -303,31 +303,31 @@ public class DraftMapController { /*-------------- 新 进路 ------------------*/ - @ApiOperation(value = "创建进路") + @ApiOperation(value = "新创建进路") @PostMapping(path = "/routeNew") public void createRoute(@RequestBody @Validated MapRouteNewVO routeVO) { iDraftMapService.createRoute(routeVO); } - @ApiOperation(value = "查询进路列表") + @ApiOperation(value = "新查询进路列表") @GetMapping(path = "/{mapId}/routeNew") public PageVO queryPagedRouteNew(@PathVariable Long mapId, MapRouteQueryVO queryVO) { return iDraftMapService.queryPagedRouteNew(mapId, queryVO); } - @ApiOperation(value = "查询进路数据明细") + @ApiOperation(value = "新查询进路数据明细") @GetMapping(path = "/routeNew/{routeId}") public MapRouteNewVO getRouteDetailNew(@PathVariable Long routeId) { return iDraftMapService.getRouteDetailNew(routeId); } - @ApiOperation(value = "更新进路数据") + @ApiOperation(value = "新更新进路数据") @PutMapping(path = "/routeNew/{routeId}") public void updateRoute(@PathVariable Long routeId, @RequestBody @Validated MapRouteNewVO routeVO) { iDraftMapService.updateRoute(routeId, routeVO); } - @ApiOperation(value = "删除进路") + @ApiOperation(value = "新删除进路") @DeleteMapping(path = "/routeNew/{routeId}") public void deleteRouteNew(@PathVariable Long routeId) { iDraftMapService.deleteRoute(routeId); @@ -474,37 +474,37 @@ public class DraftMapController { /*-------------- 新 交路 ------------------*/ - @ApiOperation(value = "创建交路,可同时创建回路") + @ApiOperation(value = "新创建交路,可同时创建回路") @PostMapping(path = "/routingData") public void createRoutingData(@RequestBody @Validated MapRoutingDataVO routingVO) { iDraftMapService.createRoutingData(routingVO); } - @ApiOperation(value = "生成交路区段数据") + @ApiOperation(value = "新生成交路区段数据") @PutMapping(path = "/routingData/generate") public MapRoutingDataVO generateRoutingData(@RequestBody @Validated MapRoutingDataVO routingVO) { return iDraftMapService.generateRoutingData(routingVO); } - @ApiOperation(value = "分页获取交路") + @ApiOperation(value = "新分页获取交路") @GetMapping(path = "/{mapId}/routingData") public PageVO queryPagedRoutingData(@PathVariable Long mapId, MapRoutingDataQueryVO queryVO) { return iDraftMapService.queryPagedRoutingData(mapId, queryVO); } - @ApiOperation(value = "获取交路详情") + @ApiOperation(value = "新获取交路详情") @GetMapping(path = "/routingData/{routingId}") public MapRoutingDataVO getRoutingData(@PathVariable Long routingId) { return iDraftMapService.getRoutingData(routingId); } - @ApiOperation(value = "更新交路") + @ApiOperation(value = "新更新交路") @PutMapping(path = "/routingData/{routingId}") public void updateRoutingData(@PathVariable Long routingId, @RequestBody @Validated MapRoutingDataVO routingVO) { iDraftMapService.updateRoutingData(routingId, routingVO); } - @ApiOperation(value = "删除交路") + @ApiOperation(value = "新删除交路") @DeleteMapping(path = "/routingData/{routingId}") public void deleteRoutingData(@PathVariable Long routingId) { iDraftMapService.deleteRouting(routingId); @@ -512,31 +512,31 @@ public class DraftMapController { /*-------------- 新 车站区段停站时间 ------------------*/ - @ApiOperation(value = "创建车站区段停站时间") + @ApiOperation(value = "新创建车站区段停站时间") @PostMapping(path = "/stationParkTime") public void createStationParkTime(@RequestBody @Validated MapStationParkingTimeVO parkingTimeVO) { iDraftMapService.createStationParkTime(parkingTimeVO); } - @ApiOperation(value = "分页车站区段停站时间") + @ApiOperation(value = "新分页车站区段停站时间") @GetMapping(path = "/{mapId}/stationParkTime") public PageVO queryPagedStationParkTime(@PathVariable Long mapId, MapParkTimeQueryVO queryVO) { return iDraftMapService.queryPagedStationParkTime(mapId, queryVO); } - @ApiOperation(value = "获取车站区段停站时间") + @ApiOperation(value = "新获取车站区段停站时间") @GetMapping(path = "/stationParkTime/{id}") public MapStationParkingTimeVO getStationParkTime(@PathVariable Long id) { return iDraftMapService.getStationParkTime(id); } - @ApiOperation(value = "更新车站区段停站时间") + @ApiOperation(value = "新更新车站区段停站时间") @PutMapping(path = "/stationParkTime/{id}") public void updateStationParkTime(@PathVariable Long id, @RequestBody @Validated MapStationParkingTimeVO parkingTimeVO) { iDraftMapService.updateStationParkTime(id, parkingTimeVO); } - @ApiOperation(value = "删除车站区段停站时间") + @ApiOperation(value = "新删除车站区段停站时间") @DeleteMapping(path = "/stationParkTime/{id}") public void deleteStationParkTime(@PathVariable Long id) { iDraftMapService.deleteStationParkTime(id); diff --git a/src/main/java/club/joylink/rtss/controller/publish/LessonController.java b/src/main/java/club/joylink/rtss/controller/publish/LessonController.java index a7b247b6a..4f0e2a77f 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/LessonController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/LessonController.java @@ -47,7 +47,7 @@ public class LessonController { return this.iLessonService.getLessonDetail(id, user); } - @ApiOperation(value = "获取课程列表") + @ApiOperation(value = "根据条件获取课程列表") @GetMapping(path = "") public List queryLessons(LessonQueryVO lessonQueryVO) { return this.iLessonService.queryLessons(lessonQueryVO); diff --git a/src/main/java/club/joylink/rtss/controller/RunPlanDraftController.java b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java similarity index 88% rename from src/main/java/club/joylink/rtss/controller/RunPlanDraftController.java rename to src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java index 04cd840e6..ddc5c9962 100644 --- a/src/main/java/club/joylink/rtss/controller/RunPlanDraftController.java +++ b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java @@ -1,18 +1,22 @@ -package club.joylink.rtss.controller; +package club.joylink.rtss.controller.runplan; import club.joylink.rtss.constants.RoleEnum; import club.joylink.rtss.controller.advice.AuthenticateInterceptor; import club.joylink.rtss.controller.advice.Role; import club.joylink.rtss.services.IRunPlanDraftService; +import club.joylink.rtss.services.runplan.IRunPlanRoutingService; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.map.newmap.MapStationParkingTimeVO; import club.joylink.rtss.vo.client.map.newmap.MapStationRunLevelVO; import club.joylink.rtss.vo.client.runplan.*; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingSection; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO; import club.joylink.rtss.vo.client.validGroup.RunPlanCreateCheck; import club.joylink.rtss.vo.client.validGroup.RunPlanNameCheck; import club.joylink.rtss.vo.client.validGroup.ValidList; import club.joylink.rtss.vo.runplan.newdraw.RunPlanInput; +import club.joylink.rtss.vo.runplan.newdraw.RunPlanInputData; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +35,9 @@ public class RunPlanDraftController { @Autowired private IRunPlanDraftService iRunPlanDraftService; + @Autowired + private IRunPlanRoutingService iRunPlanRoutingService; + @ApiOperation(value = "创建运行图草稿") @PostMapping(path = "") public String create(@RequestBody @Validated(value = RunPlanCreateCheck.class) RunPlanVO runPlanVO, @@ -40,6 +47,7 @@ public class RunPlanDraftController { @ApiOperation(value = "自动生成运行图车次数据") @PostMapping(path = "/{id}") + @Deprecated public RunPlanEChartsDataVO create(@RequestBody @Validated RunPlanInput runPlanInput, @PathVariable Long id) { return iRunPlanDraftService.createCommon(id,runPlanInput); } @@ -144,12 +152,24 @@ public class RunPlanDraftController { return this.iRunPlanDraftService.queryRoutingBySDTNumber(planId, SDTNumber); } + @ApiOperation(value = "根据车次号查询用户交路") + @GetMapping(path = "/{planId}/userRouting") + public RunPlanRoutingVO queryRoutingBySDTNumber(@PathVariable Long planId, String SDTNumber, @ApiIgnore @RequestAttribute UserVO user) { + return this.iRunPlanRoutingService.queryUserRoutingBySDTNumber(user.getId(), planId, SDTNumber); + } + @ApiOperation(value = "根据交路查询交路区段列表") @GetMapping(path = "/{planId}/{routingCode}/routingSectionList") public List getRoutingSectionList(@PathVariable Long planId, @PathVariable String routingCode) { return this.iRunPlanDraftService.getRoutingSectionList(planId, routingCode); } + @ApiOperation(value = "根据用户交路查询交路区段列表") + @GetMapping(path = "/{planId}/{routingCode}/userRoutingSectionList") + public List getRoutingSectionList(@PathVariable Long planId, @PathVariable String routingCode, @ApiIgnore @RequestAttribute UserVO user) { + return this.iRunPlanRoutingService.getRoutingSectionDataBy(user.getId() , planId, routingCode); + } + @ApiOperation(value = "增加计划") @PostMapping(path = "/{planId}/service") public void addRunPlanService(@PathVariable Long planId, @@ -158,6 +178,12 @@ public class RunPlanDraftController { this.iRunPlanDraftService.addRunPlanService(planId, serviceConfig, user); } + @ApiOperation(value = "生成计划") + @PostMapping(path = "/{planId}/service/generate") + public void generateRunPlanService(@RequestBody @Validated RunPlanInputData inputData, @PathVariable Long planId,@ApiIgnore @RequestAttribute UserVO user) { + iRunPlanDraftService.generateRunPlanService(user.getId(),planId,inputData); + } + @ApiOperation(value = "修改计划") @PutMapping(path = "/{planId}/service/{serviceNumber}") public void updateRunPlanService(@PathVariable Long planId, diff --git a/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java index 1048f8d12..742e7558a 100644 --- a/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java @@ -8,6 +8,7 @@ import club.joylink.rtss.vo.client.map.newmap.MapStationParkingTimeVO; import club.joylink.rtss.vo.client.map.newmap.MapStationRunLevelVO; import club.joylink.rtss.vo.client.runplan.*; import club.joylink.rtss.vo.runplan.newdraw.RunPlanInput; +import club.joylink.rtss.vo.runplan.newdraw.RunPlanInputData; import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -149,6 +150,8 @@ public interface IRunPlanDraftService { */ void addRunPlanService(Long planId, RunPlanServiceConfigVO serviceConfig, UserVO userVO); + void generateRunPlanService(Long userId, Long planId, RunPlanInputData inputData); + /** * 修改计划 * @param planId diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 2458fcf26..60af9bedf 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -6,17 +6,25 @@ import club.joylink.rtss.dao.RealLineDAO; import club.joylink.rtss.dao.RunPlanDraftDAO; import club.joylink.rtss.dao.RunPlanLevelDAO; import club.joylink.rtss.entity.*; +import club.joylink.rtss.exception.BusinessExceptionAssert; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.runplan.IRunPlanRoutingService; +import club.joylink.rtss.services.runplan.IRunPlanUserConfigService; import club.joylink.rtss.simulation.cbtc.GroupSimulationService; 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.*; +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.*; import club.joylink.rtss.vo.client.runplan.*; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanUserConfigVO; import club.joylink.rtss.vo.runplan.newdraw.RunPlanGenerator; import club.joylink.rtss.vo.runplan.newdraw.RunPlanInput; +import club.joylink.rtss.vo.runplan.newdraw.RunPlanInputData; import club.joylink.rtss.vo.runplan.newrunplan.*; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; @@ -62,6 +70,14 @@ public class RunPlanDraftService implements IRunPlanDraftService { @Autowired private RealLineDAO realLineDAO; + @Autowired + private IRunPlanRoutingService runPlanRoutingService; + @Autowired + private IRunPlanUserConfigService runPlanUserConfigService; + + @Autowired + private RunPlanGenerator runPlanGenerator; + @Override @Transactional public String create(RunPlanVO runPlanVO, UserVO userVO) { @@ -79,7 +95,7 @@ public class RunPlanDraftService implements IRunPlanDraftService { public RunPlanEChartsDataVO createCommon(Long id, RunPlanInput runPlanInput) { RunPlanDraft draftPlan = runPlanDraftDAO.selectByPrimaryKey(id); MapVO mapVO = this.iMapService.getMapDetail(draftPlan.getMapId()); - List runPlanTrips = RunPlanGenerator.generatorTrips(runPlanInput, mapVO); + List runPlanTrips = runPlanGenerator.generatorTrips(runPlanInput, mapVO); draftPlan.setTrips(JsonUtils.writeValueAsString(runPlanTrips)); draftPlan.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01); runPlanDraftDAO.updateByPrimaryKeyWithBLOBs(draftPlan); @@ -410,65 +426,65 @@ public class RunPlanDraftService implements IRunPlanDraftService { @Transactional public void addRunPlanService(Long planId, RunPlanServiceConfigVO serviceConfig, UserVO userVO) { RunPlanVO planVO = getRunPlanById(planId); - // 判断服务号是否已存在 -// if (this.ifServerExists(planVO, serviceConfig.getServiceNumber())) { -// // TODO 若存在,删除 合并后期处理 -// this.deleteRunPlanService(planId, serviceConfig.getServiceNumber(), userVO); - planVO.getTripList().removeAll(planVO.getTripList().stream().filter(tripVO -> tripVO.getServiceNumber().equals(serviceConfig.getServiceNumber())).collect(Collectors.toList())); -// } - // 查询上/下行最大车次号 - int maxUpTripNumber = 0; //新地图右行,后续再修改变量 - int maxDownTripNumber = 0; //新地图左行,后续再修改变量 + planVO.getTripList().removeAll(planVO.getTripList().stream().filter(tripVO -> tripVO.getServiceNumber().equals(serviceConfig.getServiceNumber())).collect(Collectors.toList())); MapVO mapVO = this.iMapService.getMapDetail(planVO.getMapId()); -// String tripNumber = ""; List newTripList = new ArrayList<>(); - if(mapVO.isDrawWay()){ + if (mapVO.isDrawWay()) { + RunPlanUserConfigVO config = runPlanUserConfigService.getConfig(userVO.getId(), mapVO.getId()); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(config) && config.hasReentryData(), "运行图-用户缺少配置或没有配置车站折返数据"); + Map userReentryData = config.getConfig().getRunPlanUserReentryData(); + List userRoutings = runPlanRoutingService.getUserRoutingBy(userVO.getId(), mapVO.getId()); + Map userRoutingMap = userRoutings.stream().collect(Collectors.toMap(RunPlanRoutingVO::getCode, Function.identity())); for (RunPlanTripConfigVO tripConfigVO : serviceConfig.getTripConfigList()) { // 查询交路 - MapRoutingDataVO routingData = mapVO.findRoutingDataByCode(tripConfigVO.getRoutingCode()); - RunPlanTripVO tripVO = new RunPlanTripVO(tripConfigVO, routingData); - if(mapVO.getConfigVO().getUpRight()){ - if(routingData.getRight()){ -// tripNumber = String.format("%03d", ++maxUpTripNumber); - tripVO.setDirectionCode(DirectionType.Type02); - }else{ -// tripNumber = String.format("%03d", ++maxDownTripNumber); - tripVO.setDirectionCode(DirectionType.Type01); - } - }else{ - if(routingData.getRight()){ -// tripNumber = String.format("%03d", ++maxDownTripNumber); - tripVO.setDirectionCode(DirectionType.Type01); - }else{ -// tripNumber = String.format("%03d", ++maxUpTripNumber); - tripVO.setDirectionCode(DirectionType.Type02); - } +// MapRoutingDataVO routingData = mapVO.findRoutingDataByCode(tripConfigVO.getRoutingCode()); + RunPlanRoutingVO routingData = userRoutingMap.get(tripConfigVO.getRoutingCode()); + String endReentrySectionCode = userReentryData.get(routingData.getEndStationCode()); + String startReentrySectionCode = userReentryData.get(routingData.getStartStationCode()); + MapSectionNewVO endReentrySection = null; + if (Objects.nonNull(endReentrySectionCode)) { + endReentrySection = mapVO.findSectionNew(endReentrySectionCode); + } else { + BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getEndStationCode() + "折返轨未设置"); + } + MapSectionNewVO startReentrySection = null; + if (Objects.nonNull(startReentrySectionCode)) { + startReentrySection = mapVO.findSectionNew(startReentrySectionCode); + } else { + BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getStartStationCode() + "折返轨未设置"); + } + RunPlanTripVO tripVO = new RunPlanTripVO(tripConfigVO, routingData, startReentrySection, endReentrySection); + if (mapVO.getConfigVO().getUpRight()) { + if (routingData.getRight()) { + tripVO.setDirectionCode(DirectionType.Type02); + } else { + tripVO.setDirectionCode(DirectionType.Type01); } - // 构建类车到站数据 -// tripVO.setTripNumber(tripVO.getDirectionCode() + tripNumber); - tripVO.setServiceNumber(serviceConfig.getServiceNumber()); - //增加方向码 + } else { + if (routingData.getRight()) { + tripVO.setDirectionCode(DirectionType.Type01); + } else { + tripVO.setDirectionCode(DirectionType.Type02); + } + } + // 构建类车到站数据 + tripVO.setServiceNumber(serviceConfig.getServiceNumber()); + //增加方向码 - List arriveConfigList = tripConfigVO.getArriveConfigList(); - arriveConfigList.stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO)); - newTripList.add(tripVO); + List arriveConfigList = tripConfigVO.getArriveConfigList(); + arriveConfigList.stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO)); + newTripList.add(tripVO); } - }else{ + } else { for (RunPlanTripConfigVO tripConfigVO : serviceConfig.getTripConfigList()) { // 查询交路 - MapRoutingVO routing = mapVO.findRoutingByCode(tripConfigVO.getRoutingCode()); -// if (DirectionType.Type02.equals(routing.getDirectionCode())) { -// tripNumber = DirectionType.Type02 + String.format("%03d", ++maxUpTripNumber); -// } else if (DirectionType.Type01.equals(routing.getDirectionCode())) { -// tripNumber = DirectionType.Type01 + String.format("%03d", ++maxDownTripNumber); -// } - RunPlanTripVO tripVO = new RunPlanTripVO(tripConfigVO, routing); - // 构建类车到站数据 -// tripVO.setTripNumber(tripNumber); - tripVO.setServiceNumber(serviceConfig.getServiceNumber()); - List arriveConfigList = tripConfigVO.getArriveConfigList(); - arriveConfigList.stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO)); - newTripList.add(tripVO); + MapRoutingVO routing = mapVO.findRoutingByCode(tripConfigVO.getRoutingCode()); + RunPlanTripVO tripVO = new RunPlanTripVO(tripConfigVO, routing); + // 构建类车到站数据 + tripVO.setServiceNumber(serviceConfig.getServiceNumber()); + List arriveConfigList = tripConfigVO.getArriveConfigList(); + arriveConfigList.stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO)); + newTripList.add(tripVO); } } @@ -481,6 +497,23 @@ public class RunPlanDraftService implements IRunPlanDraftService { runPlanDraftDAO.updateByPrimaryKeySelective(planDraft); } + @Override + @Transactional + public void generateRunPlanService(Long userId,Long planId, RunPlanInputData inputData) { + RunPlanVO planVO = getRunPlanById(planId); + MapVO mapVO = this.iMapService.getMapDetail(planVO.getMapId()); + List newTripList = runPlanGenerator.generatorTrips(userId,inputData, mapVO); + BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(CollectionUtils.isEmpty(newTripList),String.format("生成服务号%s运行图数据失败",inputData.getServiceNumber())); + planVO.getTripList().addAll(newTripList); + RunPlanDraft planDraft = planVO.convert2Draft(); + planDraft.setTrips(JsonUtils.writeValueAsString(planVO.getTripList())); + planDraft.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01); + runPlanDraftDAO.updateByPrimaryKeySelective(planDraft); +// draftPlan.setTrips(JsonUtils.writeValueAsString(runPlanTrips)); +// draftPlan.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01); +// runPlanDraftDAO.updateByPrimaryKeyWithBLOBs(draftPlan); + } + @Override @Transactional public void updateRunPlanService(Long planId, String serviceNumber, RunPlanServiceConfigVO serviceConfig, UserVO userVO) { @@ -593,7 +626,7 @@ public class RunPlanDraftService implements IRunPlanDraftService { public void addRunPlanTrip(Long planId, String serviceNumber, RunPlanTripConfigVO tripConfig, UserVO userVO) { RunPlanVO planVO = getRunPlanById(planId); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(this.ifServerExists(planVO, serviceNumber)); - this.addTrip(planVO, serviceNumber, tripConfig); + this.addTrip(planVO, serviceNumber, tripConfig, userVO); } @Override @@ -615,7 +648,7 @@ public class RunPlanDraftService implements IRunPlanDraftService { // planDraft.setTrips(JsonUtils.writeValueAsString(runPlanVO.getTripList())); // planDraft.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01); // runPlanDraftDAO.updateByPrimaryKeySelective(planDraft); - this.addTrip(runPlanVO, del.getServiceNumber(), tripConfig); + this.addTrip(runPlanVO, del.getServiceNumber(), tripConfig,userVO); } /**修改车次号*/ @@ -635,15 +668,36 @@ public class RunPlanDraftService implements IRunPlanDraftService { } /** 添加车次号(不校验服务号)*/ - private void addTrip(RunPlanVO runPlanVO, String serviceNumber, RunPlanTripConfigVO tripConfig) { + private void addTrip(RunPlanVO runPlanVO, String serviceNumber, RunPlanTripConfigVO tripConfig,UserVO userVO) { 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 userReentryData = config.getConfig().getRunPlanUserReentryData(); + List userRoutings = runPlanRoutingService.getUserRoutingBy(userVO.getId(), mapVO.getId()); + Map userRoutingMap = userRoutings.stream().collect(Collectors.toMap(RunPlanRoutingVO::getCode, Function.identity())); String tripNumber = "000"; RunPlanTripVO tripVO; if (mapVO.isDrawWay()) { // 查询交路 - MapRoutingDataVO routing = mapVO.findRoutingDataByCode(tripConfig.getRoutingCode()); +// MapRoutingDataVO routing = mapVO.findRoutingDataByCode(tripConfig.getRoutingCode()); + RunPlanRoutingVO routingData = userRoutingMap.get(tripConfig.getRoutingCode()); + String endReentrySectionCode = userReentryData.get(routingData.getEndStationCode()); + String startReentrySectionCode = userReentryData.get(routingData.getStartStationCode()); + MapSectionNewVO endReentrySection = null; + if (Objects.nonNull(endReentrySectionCode)) { + endReentrySection = mapVO.findSectionNew(endReentrySectionCode); + } else { + BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getEndStationCode() + "折返轨未设置"); + } + MapSectionNewVO startReentrySection = null; + if (Objects.nonNull(startReentrySectionCode)) { + startReentrySection = mapVO.findSectionNew(startReentrySectionCode); + } else { + BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getStartStationCode() + "折返轨未设置"); + } + tripVO = new RunPlanTripVO(tripConfig, routingData, startReentrySection, endReentrySection); // 构建类车到站数据 - tripVO = new RunPlanTripVO(tripConfig, routing); +// tripVO = new RunPlanTripVO(tripConfig, routing); setDirectionCode(mapVO.getConfigVO().getUpRight(), tripVO); } else { // 查询交路 @@ -669,49 +723,6 @@ public class RunPlanDraftService implements IRunPlanDraftService { runPlanDraftDAO.updateByPrimaryKeySelective(planDraft); } - /*** 修改车次号(不校验服务号)*/ - private void updateTrip(RunPlanVO runPlanVO, RunPlanTripVO tripVO0, RunPlanTripConfigVO tripConfig) { - MapVO mapVO = this.iMapService.getMapDetail(runPlanVO.getMapId()); - if(mapVO.isDrawWay()){ - - // 查询交路 - MapRoutingDataVO routing = mapVO.findRoutingDataByCode(tripConfig.getRoutingCode()); - String tripNumber = "000"; - // 构建类车到站数据 - RunPlanTripVO tripVO = new RunPlanTripVO(tripConfig, routing); - tripVO.setServiceNumber(tripVO0.getServiceNumber()); - setDirectionCode(mapVO.getConfigVO().getUpRight(),tripVO); - tripVO.setTripNumber(tripVO0.getTripNumber()); - tripVO.setIsReentry(tripVO0.getIsReentry()); - tripVO.setIsOutbound(tripVO0.getIsOutbound()); - tripVO.setIsInbound(tripVO0.getIsInbound()); - tripVO.setIsBackUp(tripVO0.getIsBackUp()); - tripConfig.getArriveConfigList().stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO)); - if (CollectionUtils.isEmpty(runPlanVO.getTripList())) { - runPlanVO.setTripList(new ArrayList<>()); - } - runPlanVO.getTripList().add(tripVO); - - }else{ - - // 查询交路 - MapRoutingVO routing = mapVO.findRoutingByCode(tripConfig.getRoutingCode()); - String tripNumber = "000"; - // 构建类车到站数据 - RunPlanTripVO tripVO = new RunPlanTripVO(tripConfig, routing); - tripVO.setServiceNumber(tripVO0.getServiceNumber()); - tripVO.setTripNumber(tripVO0.getTripNumber()); - tripVO.setIsReentry(tripVO0.getIsReentry()); - tripVO.setIsOutbound(tripVO0.getIsOutbound()); - tripVO.setIsInbound(tripVO0.getIsInbound()); - tripVO.setIsBackUp(tripVO0.getIsBackUp()); - tripConfig.getArriveConfigList().stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO)); - if (CollectionUtils.isEmpty(runPlanVO.getTripList())) { - runPlanVO.setTripList(new ArrayList<>()); - } - runPlanVO.getTripList().add(tripVO); - } - } private void setDirectionCode(Boolean upRight, RunPlanTripVO runPlanTripVO) { if (runPlanTripVO.getRight()) { @@ -1020,31 +1031,6 @@ public class RunPlanDraftService implements IRunPlanDraftService { return runPlanVO; } - private List prepareStationData(MapVO mapVO) { - // 获取站台轨 - List standTrackList = mapVO.findStandTrackList(); - BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(standTrackList); - // 获取车站 - List stationList = mapVO.findSortedAllStationList(); - BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(stationList); - // 获取站台 - List standList = mapVO.findAllStandList(); - BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(standList); - Map standVOMap = standList.stream().collect( - Collectors.toMap(MapStationStandVO::getCode, Function.identity())); - // 处理车站站台轨数据 - standTrackList.forEach(sectionVO -> standVOMap.get(sectionVO.getRelStandCode()).setStandTrack(sectionVO)); - // 处理车站站台数据 - for (MapStationVO station : stationList) { - for (MapStationStandVO stand : standList) { - if (station.getCode().equals(stand.getStationCode())) { - station.addStand(stand); - } - } - } - return stationList; - } - private List prepareStationDataNew(MapVO mapVO) { // // 获取站台轨 // List standTrackList = mapVO.findStandTrackListNew(); diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapVO.java index d06757809..a811e0e10 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/MapVO.java @@ -186,6 +186,19 @@ public class MapVO { return null; } + @JsonIgnore + public MapSectionNewVO findSectionNew(String code) { + MapGraphDataNewVO graphData = this.getGraphDataNew(); + if (Objects.nonNull(graphData)) { + List sectionList = graphData.getSectionList(); + if (!CollectionUtils.isEmpty(sectionList)) { + MapSectionNewVO section = sectionList.stream().filter(mapSectionNewVO -> mapSectionNewVO.getCode().equals(code)).findFirst().orElse(null); + return section; + } + } + return null; + } + @JsonIgnore public List findSortedAllStationList() { MapGraphDataVO graphData = this.getGraphData(); diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanTripVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanTripVO.java index de7f7868f..d67716bf8 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanTripVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanTripVO.java @@ -1,6 +1,8 @@ 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; @@ -13,6 +15,8 @@ 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; /** @@ -136,6 +140,24 @@ public class RunPlanTripVO { 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(); this.tripNumber = plan.getTripNumber(); diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java index 681614f7b..f8bd30b99 100644 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java @@ -1,22 +1,53 @@ package club.joylink.rtss.vo.runplan.newdraw; +import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.runplan.IRunPlanParktimeService; +import club.joylink.rtss.services.runplan.IRunPlanRoutingService; +import club.joylink.rtss.services.runplan.IRunPlanRunlevelService; +import club.joylink.rtss.services.runplan.IRunPlanUserConfigService; 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.newdraw.mainstack.DrawFuzhouRunPlan; import club.joylink.rtss.vo.runplan.newdraw.mainstack.DrawHarbinRunPlan; import club.joylink.rtss.vo.runplan.newdraw.mainstack.DrawRunPlan; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.time.LocalTime; +import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; /** * 通用运行图生成 */ +@Component public class RunPlanGenerator { private static final int OFFSET_TIME_HOURS = 2; //时间偏移早两小时 - public static List generatorTrips(RunPlanInput runPlanInput, MapVO mapVO) { + + @Autowired + private IRunPlanRoutingService runPlanRoutingService; + @Autowired + private IRunPlanRunlevelService runPlanRunlevelService; + @Autowired + private IRunPlanParktimeService runPlanParktimeService; + @Autowired + private IRunPlanUserConfigService runPlanUserConfigService; + + + public List generatorTrips(RunPlanInput runPlanInput, MapVO mapVO) { //校验发车停运时间 BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(runPlanInput.getOverTime().isAfter(runPlanInput.getBeginTime())); @@ -24,16 +55,211 @@ public class RunPlanGenerator { LocalTime beginTimeOffset = runPlanInput.getBeginTime().minusHours(OFFSET_TIME_HOURS); //向前推两小时,如果到前一天,则时间不合理 - BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(runPlanInput.getBeginTime().isAfter(beginTimeOffset), - "发车时间过早,建议晚于上午两点"); + BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(runPlanInput.getBeginTime().isAfter(beginTimeOffset), "发车时间过早,建议晚于上午两点"); runPlanInput.setBeginTime(beginTimeOffset); runPlanInput.setOverTime(runPlanInput.getOverTime().minusHours(OFFSET_TIME_HOURS)); - return drawRunPlanOf(runPlanInput.getRunLevel(),mapVO).generatorTrips(runPlanInput, mapVO); + return drawRunPlanOf(runPlanInput.getRunLevel(), mapVO).generatorTrips(runPlanInput, mapVO); } - private static DrawRunPlan drawRunPlanOf(int runLevel, MapVO mapVO) { + public List 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()); + + //构建环路 和 出入库关系 + //出库关联某环路 + RunPlanRoutingVO outboundRefRunningRouting = null; + //回库关联某环路 + RunPlanRoutingVO inboundRefRunningRouting = null; + + //验证 出库和入库 一端折返轨 一段转换轨,验证环路 两端折返轨 ,环路是否闭环 或出入库跟环路是否衔接 + 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()); + if (outToRun1) { + outboundRefRunningRouting = running1Routing; + } else if (outToRun2) { + outboundRefRunningRouting = running2Routing; + } else { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("出库交路 无法与环路交路相接"); + } + + 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()); + if (inToRun1) { + inboundRefRunningRouting = running1Routing; + } else if (inToRun2) { + inboundRefRunningRouting = running2Routing; + } else { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("出库交路 无法与环路交路相接"); + } + + //查站间运行等级 + List levels = runPlanRunlevelService.queryUserRunLevels(userId, mapVO.getId()); + Map runLevelMap = levels.stream().collect(Collectors.toMap(runLevelVO -> String.format("%s-%s", runLevelVO.getStartSectionCode(), runLevelVO.getEndSectionCode()), runLevelVO -> runLevelVO.getLevelTime(inputData.getRunLevel()))); + //查停站时间 + List parktimes = runPlanParktimeService.queryUserParktimes(userId, mapVO.getId()); + Map 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 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()))) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("折返轨未设置"); + } + + LinkedList tripList = new LinkedList<>(); + int initTripNumber = 1; + TempResult temp = new TempResult(initTripNumber, inputData.getBeginTime()); + //构建出库车次 + buildServiceTrips(inputData.getServiceNumber(), mapVO, outboundRouting, true, runLevelMap, parkTimeMap, userReentryData, tripList, temp); + //计算出库车次运行所需时间 + int size = inboundRouting.getParkSectionCodeList().size(); + int inboundTripRunTime = 40; + for (int i = 0; i < size - 1; i++) { + RunPlanRoutingSection routingSection = inboundRouting.getParkSectionCodeList().get(i); + RunPlanRoutingSection nextRoutingSection = inboundRouting.getParkSectionCodeList().get(i + 1); + Integer parkTime = parkTimeMap.getOrDefault(routingSection, 0); + Integer runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode()); + inboundTripRunTime = inboundTripRunTime + parkTime + runTime; + } + //构建环路车次 + boolean loop = false; + while (temp.getLastStationDepartTime().plusSeconds(80 + inboundTripRunTime).isBefore(inputData.getOverTime())) { + buildServiceTrips(inputData.getServiceNumber(), mapVO, outboundRefRunningRouting, null, runLevelMap, parkTimeMap, userReentryData, tripList, temp); + if (!loop && outboundRefRunningRouting == inboundRefRunningRouting) { + loop = true; + continue; + } else { + buildServiceTrips(inputData.getServiceNumber(), mapVO, inboundRefRunningRouting, null, runLevelMap, parkTimeMap, userReentryData, tripList, temp); + loop = false; + } + } + //构建回库计划 + buildServiceTrips(inputData.getServiceNumber(), mapVO, inboundRouting, false, runLevelMap, parkTimeMap, userReentryData, tripList, temp); + return tripList; + } + + private void buildServiceTrips(String serviceNumber, MapVO mapVO, RunPlanRoutingVO routing, Boolean outbound, + Map runLevelMap, Map parkTimeMap, Map userReentryData, + LinkedList tripList, TempResult 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(serviceNumber); + 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 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().getStartTime() : tempResult.getLastStationDepartTime().plusSeconds(80)) : 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); + setTripRunTime(tripVO, tripTimeList); + 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); + } + } + } + + private void setTripRunTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList) { + setTripStartTime(runPlanTripVO, tripTimeList); + setTripEndTime(runPlanTripVO, tripTimeList); + } + + private void setTripEndTime(RunPlanTripVO lastRunPlanTrip, LinkedList tripTimeList) { + if (Objects.equals(lastRunPlanTrip.getEndSectionCode(), tripTimeList.getLast().getSectionCode())) { + lastRunPlanTrip.setEndTime(tripTimeList.getLast().getDepartureTime()); + } else { + lastRunPlanTrip.setEndTime(tripTimeList.getLast().getDepartureTime().plusSeconds(40)); + } + } + + private void setTripStartTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList) { + if (Objects.equals(runPlanTripVO.getStartSectionCode(), tripTimeList.getFirst().getSectionCode())) { + runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime()); + } else { + runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime().minusSeconds(40)); + } + } + + @Getter + @Setter + @AllArgsConstructor + private class TempResult { + private int tripNumber; + private LocalTime lastStationDepartTime; + + public void incrementTripNumber() { + tripNumber++; + } + } + + private DrawRunPlan drawRunPlanOf(int runLevel, MapVO mapVO) { DrawRunPlan drawRunPlan; switch (mapVO.getLineCode()) { case "07": From 14f4a94c5879e01b6078db84b368b46d2d04b423 Mon Sep 17 00:00:00 2001 From: DU Date: Wed, 9 Dec 2020 16:56:44 +0800 Subject: [PATCH 05/23] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20201204.sql | 72 ++ src/main/java/club/joylink/rtss/Swagger2.java | 42 - .../runplan/RunPlanUserDataController.java | 107 ++ .../joylink/rtss/dao/RunPlanParktimeDAO.java | 12 + .../joylink/rtss/dao/RunPlanRoutingDAO.java | 48 + .../joylink/rtss/dao/RunPlanRunlevelDAO.java | 12 + .../rtss/dao/RunPlanUserConfigDAO.java | 38 + .../joylink/rtss/entity/RunPlanParktime.java | 136 ++ .../rtss/entity/RunPlanParktimeExample.java | 602 +++++++++ .../joylink/rtss/entity/RunPlanRouting.java | 261 ++++ .../rtss/entity/RunPlanRoutingExample.java | 1092 ++++++++++++++++ .../joylink/rtss/entity/RunPlanRunlevel.java | 264 ++++ .../rtss/entity/RunPlanRunlevelExample.java | 1102 +++++++++++++++++ .../rtss/entity/RunPlanUserConfig.java | 104 ++ .../rtss/entity/RunPlanUserConfigExample.java | 402 ++++++ .../runplan/IRunPlanParktimeService.java | 22 + .../runplan/IRunPlanRoutingService.java | 32 + .../runplan/IRunPlanRunlevelService.java | 21 + .../runplan/IRunPlanUserConfigService.java | 10 + .../runplan/RunPlanParktimeService.java | 103 ++ .../runplan/RunPlanRoutingService.java | 229 ++++ .../runplan/RunPlanRunlevelService.java | 102 ++ .../runplan/RunPlanUserConfigService.java | 51 + .../runplan/user/RunPlanParkingTimeVO.java | 87 ++ .../runplan/user/RunPlanParktimeQueryVO.java | 20 + .../runplan/user/RunPlanRoutingQueryVO.java | 25 + .../runplan/user/RunPlanRoutingSection.java | 40 + .../client/runplan/user/RunPlanRoutingVO.java | 137 ++ .../runplan/user/RunPlanRunLevelQueryVO.java | 20 + .../runplan/user/RunPlanRunlevelVO.java | 185 +++ .../runplan/user/RunPlanUserConfigVO.java | 73 ++ .../vo/runplan/newdraw/RunPlanInputData.java | 74 ++ .../mybatis/mapper/RunPlanParktimeDAO.xml | 228 ++++ .../mybatis/mapper/RunPlanRoutingDAO.xml | 421 +++++++ .../mybatis/mapper/RunPlanRunlevelDAO.xml | 355 ++++++ .../mybatis/mapper/RunPlanUserConfigDAO.xml | 244 ++++ 36 files changed, 6731 insertions(+), 42 deletions(-) create mode 100644 sql/20201204.sql delete mode 100644 src/main/java/club/joylink/rtss/Swagger2.java create mode 100644 src/main/java/club/joylink/rtss/controller/runplan/RunPlanUserDataController.java create mode 100644 src/main/java/club/joylink/rtss/dao/RunPlanParktimeDAO.java create mode 100644 src/main/java/club/joylink/rtss/dao/RunPlanRoutingDAO.java create mode 100644 src/main/java/club/joylink/rtss/dao/RunPlanRunlevelDAO.java create mode 100644 src/main/java/club/joylink/rtss/dao/RunPlanUserConfigDAO.java create mode 100644 src/main/java/club/joylink/rtss/entity/RunPlanParktime.java create mode 100644 src/main/java/club/joylink/rtss/entity/RunPlanParktimeExample.java create mode 100644 src/main/java/club/joylink/rtss/entity/RunPlanRouting.java create mode 100644 src/main/java/club/joylink/rtss/entity/RunPlanRoutingExample.java create mode 100644 src/main/java/club/joylink/rtss/entity/RunPlanRunlevel.java create mode 100644 src/main/java/club/joylink/rtss/entity/RunPlanRunlevelExample.java create mode 100644 src/main/java/club/joylink/rtss/entity/RunPlanUserConfig.java create mode 100644 src/main/java/club/joylink/rtss/entity/RunPlanUserConfigExample.java create mode 100644 src/main/java/club/joylink/rtss/services/runplan/IRunPlanParktimeService.java create mode 100644 src/main/java/club/joylink/rtss/services/runplan/IRunPlanRoutingService.java create mode 100644 src/main/java/club/joylink/rtss/services/runplan/IRunPlanRunlevelService.java create mode 100644 src/main/java/club/joylink/rtss/services/runplan/IRunPlanUserConfigService.java create mode 100644 src/main/java/club/joylink/rtss/services/runplan/RunPlanParktimeService.java create mode 100644 src/main/java/club/joylink/rtss/services/runplan/RunPlanRoutingService.java create mode 100644 src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java create mode 100644 src/main/java/club/joylink/rtss/services/runplan/RunPlanUserConfigService.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParkingTimeVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParktimeQueryVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingQueryVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingSection.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunLevelQueryVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanUserConfigVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java create mode 100644 src/main/resources/mybatis/mapper/RunPlanParktimeDAO.xml create mode 100644 src/main/resources/mybatis/mapper/RunPlanRoutingDAO.xml create mode 100644 src/main/resources/mybatis/mapper/RunPlanRunlevelDAO.xml create mode 100644 src/main/resources/mybatis/mapper/RunPlanUserConfigDAO.xml diff --git a/sql/20201204.sql b/sql/20201204.sql new file mode 100644 index 000000000..5628bd80a --- /dev/null +++ b/sql/20201204.sql @@ -0,0 +1,72 @@ +CREATE TABLE `run_plan_routing` ( + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, + `map_id` BIGINT(20) NOT NULL COMMENT '地图ID', + `user_id` BIGINT(20) NOT NULL, + `name` VARCHAR(64) NOT NULL COMMENT '名称' COLLATE 'utf8_general_ci', + `code` VARCHAR(32) NOT NULL COMMENT '编号' COLLATE 'utf8_general_ci', + `type` VARCHAR(32) NOT NULL COMMENT '交路类型', + `start_station_code` VARCHAR(32) NOT NULL COMMENT '起始车站' COLLATE 'utf8_general_ci', + `start_section_code` VARCHAR(32) NOT NULL COMMENT '起始站台' COLLATE 'utf8_general_ci', + `end_station_code` VARCHAR(32) NOT NULL COMMENT '终点车站' COLLATE 'utf8_general_ci', + `end_section_code` VARCHAR(32) NOT NULL COMMENT '终点站台' COLLATE 'utf8_general_ci', + `right` TINYINT(1) NULL DEFAULT '0' COMMENT '左右行方向', + `destination_code` VARCHAR(45) NULL DEFAULT NULL COMMENT '目的地码' COLLATE 'utf8_general_ci', + `remarks` VARCHAR(512) NULL DEFAULT NULL COMMENT '描述' COLLATE 'utf8_general_ci', + `section_data` LONGTEXT NOT NULL COMMENT '区段数据' COLLATE 'utf8_general_ci', + PRIMARY KEY (`id`), + INDEX `map_id_user_id` (`map_id`, `user_id`) +) +COMMENT='运行图用户交路' +COLLATE='utf8_general_ci' +ENGINE=InnoDB +; +CREATE TABLE `run_plan_runlevel` ( + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, + `map_id` BIGINT(20) NOT NULL COMMENT '地图id', + `user_id` BIGINT(20) NOT NULL COMMENT '用户id', + `start_station_code` VARCHAR(32) NOT NULL COMMENT '起始车站' COLLATE 'utf8_general_ci', + `start_section_code` VARCHAR(32) NOT NULL COMMENT '起始站台' COLLATE 'utf8_general_ci', + `end_station_code` VARCHAR(32) NOT NULL COMMENT '终点车站' COLLATE 'utf8_general_ci', + `end_section_code` VARCHAR(32) NOT NULL COMMENT '终点站台' COLLATE 'utf8_general_ci', + `right` TINYINT(1) NOT NULL COMMENT '方向', + `distance` FLOAT NOT NULL COMMENT '距离(米)', + `level1` INT(11) NOT NULL COMMENT '等级一(s)', + `level2` INT(11) NOT NULL COMMENT '等级二(s)', + `level3` INT(11) NOT NULL COMMENT '等级三(s)', + `level4` INT(11) NOT NULL COMMENT '等级四(s)', + `level5` INT(11) NOT NULL COMMENT '等级五(s)', + PRIMARY KEY (`id`), + INDEX `map_id_user_id` (`map_id`, `user_id`) +) +COMMENT='运行图用户站间运行等级' +COLLATE='utf8_general_ci' +ENGINE=InnoDB +; +CREATE TABLE `run_plan_parktime` ( + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, + `map_id` BIGINT(20) NOT NULL COMMENT '所属地图id', + `user_id` BIGINT(20) NOT NULL COMMENT '用户id', + `station_code` VARCHAR(32) NOT NULL COMMENT '车站code' COLLATE 'utf8_general_ci', + `section_code` VARCHAR(32) NOT NULL COMMENT '区段code' COLLATE 'utf8_general_ci', + `parking_time` INT(11) NOT NULL DEFAULT '30' COMMENT '停站时间s', + PRIMARY KEY (`id`), + INDEX `map_id_user_id` (`map_id`, `user_id`) +) +COMMENT='运行图用户车站停站时间' +COLLATE='utf8_general_ci' +ENGINE=InnoDB +; +CREATE TABLE `run_plan_user_config` ( + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, + `map_id` BIGINT(20) NOT NULL COMMENT '所属地图id', + `user_id` BIGINT(20) NOT NULL COMMENT '用户id', + `config` LONGTEXT NOT NULL COMMENT '折返车站code' COLLATE 'utf8_general_ci', + PRIMARY KEY (`id`), + INDEX `map_id_user_id` (`map_id`, `user_id`) +) +COMMENT='运行图用户配置数据' +COLLATE='utf8_general_ci' +ENGINE=InnoDB +; + + diff --git a/src/main/java/club/joylink/rtss/Swagger2.java b/src/main/java/club/joylink/rtss/Swagger2.java deleted file mode 100644 index 84fb01661..000000000 --- a/src/main/java/club/joylink/rtss/Swagger2.java +++ /dev/null @@ -1,42 +0,0 @@ -package club.joylink.rtss; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -//@EnableOpenApi -public class Swagger2 { - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .apiInfo(apiInfo()) - .enable(true) - .select() - // 自行修改为自己的包路径 - .apis(RequestHandlerSelectors.basePackage("club.joylink.rtss.controller")) - .paths(PathSelectors.any()) - .build(); - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("管理工具API文档") - .description("restful 风格接口") - //服务条款网址 -// .termsOfServiceUrl("http://localhost:9000/") - .version("1.0") -// .licenseUrl("http://localhost:9000/") -// .contact(new Contact("walker-sheng", "#", "walkersxq@163.com")) - .build(); - } - -} diff --git a/src/main/java/club/joylink/rtss/controller/runplan/RunPlanUserDataController.java b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanUserDataController.java new file mode 100644 index 000000000..d3e485594 --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanUserDataController.java @@ -0,0 +1,107 @@ +package club.joylink.rtss.controller.runplan; + +import club.joylink.rtss.services.runplan.IRunPlanParktimeService; +import club.joylink.rtss.services.runplan.IRunPlanRoutingService; +import club.joylink.rtss.services.runplan.IRunPlanRunlevelService; +import club.joylink.rtss.services.runplan.IRunPlanUserConfigService; +import club.joylink.rtss.vo.UserVO; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.runplan.user.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Api(tags = {"运行计划用户数据接口"}) +@RestController +@RequestMapping("/api/runPlan/userData") +public class RunPlanUserDataController { + + @Autowired + private IRunPlanRoutingService iRunPlanRoutingService; + + @Autowired + private IRunPlanRunlevelService iRunPlanRunlevelService; + + @Autowired + private IRunPlanParktimeService iRunPlanParktimeService; + + @Autowired + private IRunPlanUserConfigService iRunPlanUserConfigService; + + @ApiOperation(value = "用户创建交路") + @PostMapping(path = "/routing") + public void createUserRouting(@RequestBody @Validated RunPlanRoutingVO routingVO, @RequestAttribute UserVO user) { + routingVO.setUserId(user.getId()); + iRunPlanRoutingService.createUserRouting(routingVO); + } + + @ApiOperation(value = "分页获取用户交路") + @GetMapping(path = "/{mapId}/routing/page") + public PageVO queryPagedUserRouting(@PathVariable Long mapId, RunPlanRoutingQueryVO queryVO, @RequestAttribute UserVO user) { + return iRunPlanRoutingService.queryPagedUserRouting(user.getId(), mapId, queryVO); + } + + @ApiOperation(value = "获取用户交路数据") + @GetMapping(path = "/{mapId}/routing") + public List queryUserRoutings(@PathVariable Long mapId, @RequestAttribute UserVO user) { + return iRunPlanRoutingService.getUserRoutingBy(user.getId(), mapId); + } + + @ApiOperation(value = "获取用户交路详情") + @GetMapping(path = "/routing/{routingId}") + public RunPlanRoutingVO getUserRouting(@PathVariable Long routingId) { + return iRunPlanRoutingService.getUserRouting(routingId); + } + + @ApiOperation(value = "更新用户交路") + @PutMapping(path = "/routing/{routingId}") + public void updateUserRouting(@PathVariable Long routingId, @RequestBody @Validated RunPlanRoutingVO routingVO) { + iRunPlanRoutingService.updateUserRouting(routingId, routingVO); + } + + @ApiOperation(value = "删除用户交路") + @DeleteMapping(path = "/routing/{routingId}") + public void deleteUserRouting(@PathVariable Long routingId) { + iRunPlanRoutingService.deleteUserRouting(routingId); + } + + @ApiOperation(value = "分页获取用户站间运行等级") + @GetMapping(path = "/{mapId}/runlevel/page") + public PageVO queryPagedUserRunlevel(@PathVariable Long mapId, RunPlanRunLevelQueryVO queryVO, @RequestAttribute UserVO user) { + return iRunPlanRunlevelService.queryUserRunLevels(user.getId(), mapId, queryVO); + } + + @ApiOperation(value = "更新用户站间运行等级") + @PutMapping(path = "/{mapId}/runlevel") + public void updateUserRunlevel(@PathVariable Long mapId, @RequestBody @Validated List list, @RequestAttribute UserVO user) { + iRunPlanRunlevelService.updateRefLevels(user.getId(), mapId, list); + } + + @ApiOperation(value = "分页获取用户轨道停车时间") + @GetMapping(path = "/{mapId}/parktime/page") + public PageVO queryPagedUserParktime(@PathVariable Long mapId, RunPlanParktimeQueryVO queryVO, @RequestAttribute UserVO user) { + return iRunPlanParktimeService.queryUserParktimes(user.getId(), mapId, queryVO); + } + + @ApiOperation(value = "更新用户轨道停车时间") + @PutMapping(path = "/{mapId}/parktime") + public void updateUserParktime(@PathVariable Long mapId, @RequestBody @Validated List list, @RequestAttribute UserVO user) { + iRunPlanParktimeService.updateRefUserParktime(user.getId(), mapId, list); + } + + @ApiOperation(value = "保存用户配置") + @PostMapping(path = "/{mapId}/config") + public void createUserConfig(@PathVariable Long mapId, @RequestBody @Validated RunPlanUserConfigVO.Config config, @RequestAttribute UserVO user) { + iRunPlanUserConfigService.saveConfig(user.getId(), mapId, config); + } + + @ApiOperation(value = "获取用户配置") + @GetMapping(path = "/{mapId}/config") + public RunPlanUserConfigVO getUserConfig(@PathVariable Long mapId, @RequestAttribute UserVO user) { + return iRunPlanUserConfigService.getConfig(user.getId(), mapId); + } +} diff --git a/src/main/java/club/joylink/rtss/dao/RunPlanParktimeDAO.java b/src/main/java/club/joylink/rtss/dao/RunPlanParktimeDAO.java new file mode 100644 index 000000000..8c1558331 --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/RunPlanParktimeDAO.java @@ -0,0 +1,12 @@ +package club.joylink.rtss.dao; + +import club.joylink.rtss.entity.RunPlanParktime; +import club.joylink.rtss.entity.RunPlanParktimeExample; +import org.springframework.stereotype.Repository; + +/** + * RunPlanParktimeDAO继承基类 + */ +@Repository +public interface RunPlanParktimeDAO extends MyBatisBaseDao { +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/dao/RunPlanRoutingDAO.java b/src/main/java/club/joylink/rtss/dao/RunPlanRoutingDAO.java new file mode 100644 index 000000000..41ea31dbc --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/RunPlanRoutingDAO.java @@ -0,0 +1,48 @@ +package club.joylink.rtss.dao; + +import club.joylink.rtss.entity.RunPlanRouting; +import club.joylink.rtss.entity.RunPlanRoutingExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +@Repository +public interface RunPlanRoutingDAO { + long countByExample(RunPlanRoutingExample example); + + int deleteByExample(RunPlanRoutingExample example); + + int deleteByPrimaryKey(Long id); + + int insert(RunPlanRouting record); + + int insertSelective(RunPlanRouting record); + + List selectByExampleWithBLOBs(RunPlanRoutingExample example); + + List selectByExample(RunPlanRoutingExample example); + + RunPlanRouting selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") RunPlanRouting record, @Param("example") RunPlanRoutingExample example); + + int updateByExampleWithBLOBs(@Param("record") RunPlanRouting record, @Param("example") RunPlanRoutingExample example); + + int updateByExample(@Param("record") RunPlanRouting record, @Param("example") RunPlanRoutingExample example); + + int updateByPrimaryKeySelective(RunPlanRouting record); + + int updateByPrimaryKeyWithBLOBs(RunPlanRouting record); + + int updateByPrimaryKey(RunPlanRouting record); + + @Select("") + Integer countUserRoutingBySectionData(@Param("userId") Long userId, @Param("mapId") Long mapId, @Param("sectionData") String sectionData); +} diff --git a/src/main/java/club/joylink/rtss/dao/RunPlanRunlevelDAO.java b/src/main/java/club/joylink/rtss/dao/RunPlanRunlevelDAO.java new file mode 100644 index 000000000..7718477e5 --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/RunPlanRunlevelDAO.java @@ -0,0 +1,12 @@ +package club.joylink.rtss.dao; + +import club.joylink.rtss.entity.RunPlanRunlevel; +import club.joylink.rtss.entity.RunPlanRunlevelExample; +import org.springframework.stereotype.Repository; + +/** + * RunPlanRunlevelDAO继承基类 + */ +@Repository +public interface RunPlanRunlevelDAO extends MyBatisBaseDao { +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/dao/RunPlanUserConfigDAO.java b/src/main/java/club/joylink/rtss/dao/RunPlanUserConfigDAO.java new file mode 100644 index 000000000..5477ba7f4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/RunPlanUserConfigDAO.java @@ -0,0 +1,38 @@ +package club.joylink.rtss.dao; + +import club.joylink.rtss.entity.RunPlanUserConfig; +import club.joylink.rtss.entity.RunPlanUserConfigExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +@Repository +public interface RunPlanUserConfigDAO { + long countByExample(RunPlanUserConfigExample example); + + int deleteByExample(RunPlanUserConfigExample example); + + int deleteByPrimaryKey(Long id); + + int insert(RunPlanUserConfig record); + + int insertSelective(RunPlanUserConfig record); + + List selectByExampleWithBLOBs(RunPlanUserConfigExample example); + + List selectByExample(RunPlanUserConfigExample example); + + RunPlanUserConfig selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") RunPlanUserConfig record, @Param("example") RunPlanUserConfigExample example); + + int updateByExampleWithBLOBs(@Param("record") RunPlanUserConfig record, @Param("example") RunPlanUserConfigExample example); + + int updateByExample(@Param("record") RunPlanUserConfig record, @Param("example") RunPlanUserConfigExample example); + + int updateByPrimaryKeySelective(RunPlanUserConfig record); + + int updateByPrimaryKeyWithBLOBs(RunPlanUserConfig record); + + int updateByPrimaryKey(RunPlanUserConfig record); +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/RunPlanParktime.java b/src/main/java/club/joylink/rtss/entity/RunPlanParktime.java new file mode 100644 index 000000000..cd4654b64 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/RunPlanParktime.java @@ -0,0 +1,136 @@ +package club.joylink.rtss.entity; + +import java.io.Serializable; + +/** + * run_plan_parktime + * @author + */ +public class RunPlanParktime implements Serializable { + private Long id; + + /** + * 所属地图id + */ + private Long mapId; + + /** + * 用户id + */ + private Long userId; + + /** + * 车站code + */ + private String stationCode; + + /** + * 区段code + */ + private String sectionCode; + + /** + * 停站时间 + */ + private Integer parkingTime; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getMapId() { + return mapId; + } + + public void setMapId(Long mapId) { + this.mapId = mapId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getStationCode() { + return stationCode; + } + + public void setStationCode(String stationCode) { + this.stationCode = stationCode; + } + + public String getSectionCode() { + return sectionCode; + } + + public void setSectionCode(String sectionCode) { + this.sectionCode = sectionCode; + } + + public Integer getParkingTime() { + return parkingTime; + } + + public void setParkingTime(Integer parkingTime) { + this.parkingTime = parkingTime; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + RunPlanParktime other = (RunPlanParktime) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getStationCode() == null ? other.getStationCode() == null : this.getStationCode().equals(other.getStationCode())) + && (this.getSectionCode() == null ? other.getSectionCode() == null : this.getSectionCode().equals(other.getSectionCode())) + && (this.getParkingTime() == null ? other.getParkingTime() == null : this.getParkingTime().equals(other.getParkingTime())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getMapId() == null) ? 0 : getMapId().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getStationCode() == null) ? 0 : getStationCode().hashCode()); + result = prime * result + ((getSectionCode() == null) ? 0 : getSectionCode().hashCode()); + result = prime * result + ((getParkingTime() == null) ? 0 : getParkingTime().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", mapId=").append(mapId); + sb.append(", userId=").append(userId); + sb.append(", stationCode=").append(stationCode); + sb.append(", sectionCode=").append(sectionCode); + sb.append(", parkingTime=").append(parkingTime); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/RunPlanParktimeExample.java b/src/main/java/club/joylink/rtss/entity/RunPlanParktimeExample.java new file mode 100644 index 000000000..119586e24 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/RunPlanParktimeExample.java @@ -0,0 +1,602 @@ +package club.joylink.rtss.entity; + +import java.util.ArrayList; +import java.util.List; + +public class RunPlanParktimeExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public RunPlanParktimeExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andMapIdIsNull() { + addCriterion("map_id is null"); + return (Criteria) this; + } + + public Criteria andMapIdIsNotNull() { + addCriterion("map_id is not null"); + return (Criteria) this; + } + + public Criteria andMapIdEqualTo(Long value) { + addCriterion("map_id =", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotEqualTo(Long value) { + addCriterion("map_id <>", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThan(Long value) { + addCriterion("map_id >", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThanOrEqualTo(Long value) { + addCriterion("map_id >=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThan(Long value) { + addCriterion("map_id <", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThanOrEqualTo(Long value) { + addCriterion("map_id <=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdIn(List values) { + addCriterion("map_id in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotIn(List values) { + addCriterion("map_id not in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdBetween(Long value1, Long value2) { + addCriterion("map_id between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotBetween(Long value1, Long value2) { + addCriterion("map_id not between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andStationCodeIsNull() { + addCriterion("station_code is null"); + return (Criteria) this; + } + + public Criteria andStationCodeIsNotNull() { + addCriterion("station_code is not null"); + return (Criteria) this; + } + + public Criteria andStationCodeEqualTo(String value) { + addCriterion("station_code =", value, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeNotEqualTo(String value) { + addCriterion("station_code <>", value, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeGreaterThan(String value) { + addCriterion("station_code >", value, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeGreaterThanOrEqualTo(String value) { + addCriterion("station_code >=", value, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeLessThan(String value) { + addCriterion("station_code <", value, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeLessThanOrEqualTo(String value) { + addCriterion("station_code <=", value, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeLike(String value) { + addCriterion("station_code like", value, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeNotLike(String value) { + addCriterion("station_code not like", value, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeIn(List values) { + addCriterion("station_code in", values, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeNotIn(List values) { + addCriterion("station_code not in", values, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeBetween(String value1, String value2) { + addCriterion("station_code between", value1, value2, "stationCode"); + return (Criteria) this; + } + + public Criteria andStationCodeNotBetween(String value1, String value2) { + addCriterion("station_code not between", value1, value2, "stationCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeIsNull() { + addCriterion("section_code is null"); + return (Criteria) this; + } + + public Criteria andSectionCodeIsNotNull() { + addCriterion("section_code is not null"); + return (Criteria) this; + } + + public Criteria andSectionCodeEqualTo(String value) { + addCriterion("section_code =", value, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeNotEqualTo(String value) { + addCriterion("section_code <>", value, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeGreaterThan(String value) { + addCriterion("section_code >", value, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeGreaterThanOrEqualTo(String value) { + addCriterion("section_code >=", value, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeLessThan(String value) { + addCriterion("section_code <", value, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeLessThanOrEqualTo(String value) { + addCriterion("section_code <=", value, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeLike(String value) { + addCriterion("section_code like", value, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeNotLike(String value) { + addCriterion("section_code not like", value, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeIn(List values) { + addCriterion("section_code in", values, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeNotIn(List values) { + addCriterion("section_code not in", values, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeBetween(String value1, String value2) { + addCriterion("section_code between", value1, value2, "sectionCode"); + return (Criteria) this; + } + + public Criteria andSectionCodeNotBetween(String value1, String value2) { + addCriterion("section_code not between", value1, value2, "sectionCode"); + return (Criteria) this; + } + + public Criteria andParkingTimeIsNull() { + addCriterion("parking_time is null"); + return (Criteria) this; + } + + public Criteria andParkingTimeIsNotNull() { + addCriterion("parking_time is not null"); + return (Criteria) this; + } + + public Criteria andParkingTimeEqualTo(Integer value) { + addCriterion("parking_time =", value, "parkingTime"); + return (Criteria) this; + } + + public Criteria andParkingTimeNotEqualTo(Integer value) { + addCriterion("parking_time <>", value, "parkingTime"); + return (Criteria) this; + } + + public Criteria andParkingTimeGreaterThan(Integer value) { + addCriterion("parking_time >", value, "parkingTime"); + return (Criteria) this; + } + + public Criteria andParkingTimeGreaterThanOrEqualTo(Integer value) { + addCriterion("parking_time >=", value, "parkingTime"); + return (Criteria) this; + } + + public Criteria andParkingTimeLessThan(Integer value) { + addCriterion("parking_time <", value, "parkingTime"); + return (Criteria) this; + } + + public Criteria andParkingTimeLessThanOrEqualTo(Integer value) { + addCriterion("parking_time <=", value, "parkingTime"); + return (Criteria) this; + } + + public Criteria andParkingTimeIn(List values) { + addCriterion("parking_time in", values, "parkingTime"); + return (Criteria) this; + } + + public Criteria andParkingTimeNotIn(List values) { + addCriterion("parking_time not in", values, "parkingTime"); + return (Criteria) this; + } + + public Criteria andParkingTimeBetween(Integer value1, Integer value2) { + addCriterion("parking_time between", value1, value2, "parkingTime"); + return (Criteria) this; + } + + public Criteria andParkingTimeNotBetween(Integer value1, Integer value2) { + addCriterion("parking_time not between", value1, value2, "parkingTime"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/RunPlanRouting.java b/src/main/java/club/joylink/rtss/entity/RunPlanRouting.java new file mode 100644 index 000000000..697196f93 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/RunPlanRouting.java @@ -0,0 +1,261 @@ +package club.joylink.rtss.entity; + +import java.io.Serializable; + +/** + * run_plan_routing + * @author + */ +public class RunPlanRouting implements Serializable { + private Long id; + + /** + * 地图ID + */ + private Long mapId; + + private Long userId; + + /** + * 名称 + */ + private String name; + + /** + * 编号 + */ + private String code; + + /** + * 交路类型 + */ + private String type; + + /** + * 起始车站 + */ + private String startStationCode; + + /** + * 起始站台 + */ + private String startSectionCode; + + /** + * 终点车站 + */ + private String endStationCode; + + /** + * 终点站台 + */ + private String endSectionCode; + + /** + * 左右行方向 + */ + private Boolean right; + + /** + * 目的地码 + */ + private String destinationCode; + + /** + * 描述 + */ + private String remarks; + + /** + * 区段数据 + */ + private String sectionData; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getMapId() { + return mapId; + } + + public void setMapId(Long mapId) { + this.mapId = mapId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getStartStationCode() { + return startStationCode; + } + + public void setStartStationCode(String startStationCode) { + this.startStationCode = startStationCode; + } + + public String getStartSectionCode() { + return startSectionCode; + } + + public void setStartSectionCode(String startSectionCode) { + this.startSectionCode = startSectionCode; + } + + public String getEndStationCode() { + return endStationCode; + } + + public void setEndStationCode(String endStationCode) { + this.endStationCode = endStationCode; + } + + public String getEndSectionCode() { + return endSectionCode; + } + + public void setEndSectionCode(String endSectionCode) { + this.endSectionCode = endSectionCode; + } + + public Boolean getRight() { + return right; + } + + public void setRight(Boolean right) { + this.right = right; + } + + public String getDestinationCode() { + return destinationCode; + } + + public void setDestinationCode(String destinationCode) { + this.destinationCode = destinationCode; + } + + public String getRemarks() { + return remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } + + public String getSectionData() { + return sectionData; + } + + public void setSectionData(String sectionData) { + this.sectionData = sectionData; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + RunPlanRouting other = (RunPlanRouting) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) + && (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode())) + && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) + && (this.getStartStationCode() == null ? other.getStartStationCode() == null : this.getStartStationCode().equals(other.getStartStationCode())) + && (this.getStartSectionCode() == null ? other.getStartSectionCode() == null : this.getStartSectionCode().equals(other.getStartSectionCode())) + && (this.getEndStationCode() == null ? other.getEndStationCode() == null : this.getEndStationCode().equals(other.getEndStationCode())) + && (this.getEndSectionCode() == null ? other.getEndSectionCode() == null : this.getEndSectionCode().equals(other.getEndSectionCode())) + && (this.getRight() == null ? other.getRight() == null : this.getRight().equals(other.getRight())) + && (this.getDestinationCode() == null ? other.getDestinationCode() == null : this.getDestinationCode().equals(other.getDestinationCode())) + && (this.getRemarks() == null ? other.getRemarks() == null : this.getRemarks().equals(other.getRemarks())) + && (this.getSectionData() == null ? other.getSectionData() == null : this.getSectionData().equals(other.getSectionData())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getMapId() == null) ? 0 : getMapId().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); + result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode()); + result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); + result = prime * result + ((getStartStationCode() == null) ? 0 : getStartStationCode().hashCode()); + result = prime * result + ((getStartSectionCode() == null) ? 0 : getStartSectionCode().hashCode()); + result = prime * result + ((getEndStationCode() == null) ? 0 : getEndStationCode().hashCode()); + result = prime * result + ((getEndSectionCode() == null) ? 0 : getEndSectionCode().hashCode()); + result = prime * result + ((getRight() == null) ? 0 : getRight().hashCode()); + result = prime * result + ((getDestinationCode() == null) ? 0 : getDestinationCode().hashCode()); + result = prime * result + ((getRemarks() == null) ? 0 : getRemarks().hashCode()); + result = prime * result + ((getSectionData() == null) ? 0 : getSectionData().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", mapId=").append(mapId); + sb.append(", userId=").append(userId); + sb.append(", name=").append(name); + sb.append(", code=").append(code); + sb.append(", type=").append(type); + sb.append(", startStationCode=").append(startStationCode); + sb.append(", startSectionCode=").append(startSectionCode); + sb.append(", endStationCode=").append(endStationCode); + sb.append(", endSectionCode=").append(endSectionCode); + sb.append(", right=").append(right); + sb.append(", destinationCode=").append(destinationCode); + sb.append(", remarks=").append(remarks); + sb.append(", sectionData=").append(sectionData); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/RunPlanRoutingExample.java b/src/main/java/club/joylink/rtss/entity/RunPlanRoutingExample.java new file mode 100644 index 000000000..7039844b1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/RunPlanRoutingExample.java @@ -0,0 +1,1092 @@ +package club.joylink.rtss.entity; + +import java.util.ArrayList; +import java.util.List; + +public class RunPlanRoutingExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public RunPlanRoutingExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andMapIdIsNull() { + addCriterion("map_id is null"); + return (Criteria) this; + } + + public Criteria andMapIdIsNotNull() { + addCriterion("map_id is not null"); + return (Criteria) this; + } + + public Criteria andMapIdEqualTo(Long value) { + addCriterion("map_id =", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotEqualTo(Long value) { + addCriterion("map_id <>", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThan(Long value) { + addCriterion("map_id >", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThanOrEqualTo(Long value) { + addCriterion("map_id >=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThan(Long value) { + addCriterion("map_id <", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThanOrEqualTo(Long value) { + addCriterion("map_id <=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdIn(List values) { + addCriterion("map_id in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotIn(List values) { + addCriterion("map_id not in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdBetween(Long value1, Long value2) { + addCriterion("map_id between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotBetween(Long value1, Long value2) { + addCriterion("map_id not between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andCodeIsNull() { + addCriterion("code is null"); + return (Criteria) this; + } + + public Criteria andCodeIsNotNull() { + addCriterion("code is not null"); + return (Criteria) this; + } + + public Criteria andCodeEqualTo(String value) { + addCriterion("code =", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotEqualTo(String value) { + addCriterion("code <>", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThan(String value) { + addCriterion("code >", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThanOrEqualTo(String value) { + addCriterion("code >=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThan(String value) { + addCriterion("code <", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThanOrEqualTo(String value) { + addCriterion("code <=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLike(String value) { + addCriterion("code like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotLike(String value) { + addCriterion("code not like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeIn(List values) { + addCriterion("code in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotIn(List values) { + addCriterion("code not in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeBetween(String value1, String value2) { + addCriterion("code between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotBetween(String value1, String value2) { + addCriterion("code not between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(String value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(String value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(String value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(String value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(String value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(String value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLike(String value) { + addCriterion("`type` like", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotLike(String value) { + addCriterion("`type` not like", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(String value1, String value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(String value1, String value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andStartStationCodeIsNull() { + addCriterion("start_station_code is null"); + return (Criteria) this; + } + + public Criteria andStartStationCodeIsNotNull() { + addCriterion("start_station_code is not null"); + return (Criteria) this; + } + + public Criteria andStartStationCodeEqualTo(String value) { + addCriterion("start_station_code =", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeNotEqualTo(String value) { + addCriterion("start_station_code <>", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeGreaterThan(String value) { + addCriterion("start_station_code >", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeGreaterThanOrEqualTo(String value) { + addCriterion("start_station_code >=", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeLessThan(String value) { + addCriterion("start_station_code <", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeLessThanOrEqualTo(String value) { + addCriterion("start_station_code <=", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeLike(String value) { + addCriterion("start_station_code like", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeNotLike(String value) { + addCriterion("start_station_code not like", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeIn(List values) { + addCriterion("start_station_code in", values, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeNotIn(List values) { + addCriterion("start_station_code not in", values, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeBetween(String value1, String value2) { + addCriterion("start_station_code between", value1, value2, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeNotBetween(String value1, String value2) { + addCriterion("start_station_code not between", value1, value2, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeIsNull() { + addCriterion("start_section_code is null"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeIsNotNull() { + addCriterion("start_section_code is not null"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeEqualTo(String value) { + addCriterion("start_section_code =", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeNotEqualTo(String value) { + addCriterion("start_section_code <>", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeGreaterThan(String value) { + addCriterion("start_section_code >", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeGreaterThanOrEqualTo(String value) { + addCriterion("start_section_code >=", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeLessThan(String value) { + addCriterion("start_section_code <", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeLessThanOrEqualTo(String value) { + addCriterion("start_section_code <=", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeLike(String value) { + addCriterion("start_section_code like", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeNotLike(String value) { + addCriterion("start_section_code not like", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeIn(List values) { + addCriterion("start_section_code in", values, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeNotIn(List values) { + addCriterion("start_section_code not in", values, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeBetween(String value1, String value2) { + addCriterion("start_section_code between", value1, value2, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeNotBetween(String value1, String value2) { + addCriterion("start_section_code not between", value1, value2, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeIsNull() { + addCriterion("end_station_code is null"); + return (Criteria) this; + } + + public Criteria andEndStationCodeIsNotNull() { + addCriterion("end_station_code is not null"); + return (Criteria) this; + } + + public Criteria andEndStationCodeEqualTo(String value) { + addCriterion("end_station_code =", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeNotEqualTo(String value) { + addCriterion("end_station_code <>", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeGreaterThan(String value) { + addCriterion("end_station_code >", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeGreaterThanOrEqualTo(String value) { + addCriterion("end_station_code >=", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeLessThan(String value) { + addCriterion("end_station_code <", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeLessThanOrEqualTo(String value) { + addCriterion("end_station_code <=", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeLike(String value) { + addCriterion("end_station_code like", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeNotLike(String value) { + addCriterion("end_station_code not like", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeIn(List values) { + addCriterion("end_station_code in", values, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeNotIn(List values) { + addCriterion("end_station_code not in", values, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeBetween(String value1, String value2) { + addCriterion("end_station_code between", value1, value2, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeNotBetween(String value1, String value2) { + addCriterion("end_station_code not between", value1, value2, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeIsNull() { + addCriterion("end_section_code is null"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeIsNotNull() { + addCriterion("end_section_code is not null"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeEqualTo(String value) { + addCriterion("end_section_code =", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeNotEqualTo(String value) { + addCriterion("end_section_code <>", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeGreaterThan(String value) { + addCriterion("end_section_code >", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeGreaterThanOrEqualTo(String value) { + addCriterion("end_section_code >=", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeLessThan(String value) { + addCriterion("end_section_code <", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeLessThanOrEqualTo(String value) { + addCriterion("end_section_code <=", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeLike(String value) { + addCriterion("end_section_code like", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeNotLike(String value) { + addCriterion("end_section_code not like", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeIn(List values) { + addCriterion("end_section_code in", values, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeNotIn(List values) { + addCriterion("end_section_code not in", values, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeBetween(String value1, String value2) { + addCriterion("end_section_code between", value1, value2, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeNotBetween(String value1, String value2) { + addCriterion("end_section_code not between", value1, value2, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andRightIsNull() { + addCriterion("`right` is null"); + return (Criteria) this; + } + + public Criteria andRightIsNotNull() { + addCriterion("`right` is not null"); + return (Criteria) this; + } + + public Criteria andRightEqualTo(Boolean value) { + addCriterion("`right` =", value, "right"); + return (Criteria) this; + } + + public Criteria andRightNotEqualTo(Boolean value) { + addCriterion("`right` <>", value, "right"); + return (Criteria) this; + } + + public Criteria andRightGreaterThan(Boolean value) { + addCriterion("`right` >", value, "right"); + return (Criteria) this; + } + + public Criteria andRightGreaterThanOrEqualTo(Boolean value) { + addCriterion("`right` >=", value, "right"); + return (Criteria) this; + } + + public Criteria andRightLessThan(Boolean value) { + addCriterion("`right` <", value, "right"); + return (Criteria) this; + } + + public Criteria andRightLessThanOrEqualTo(Boolean value) { + addCriterion("`right` <=", value, "right"); + return (Criteria) this; + } + + public Criteria andRightIn(List values) { + addCriterion("`right` in", values, "right"); + return (Criteria) this; + } + + public Criteria andRightNotIn(List values) { + addCriterion("`right` not in", values, "right"); + return (Criteria) this; + } + + public Criteria andRightBetween(Boolean value1, Boolean value2) { + addCriterion("`right` between", value1, value2, "right"); + return (Criteria) this; + } + + public Criteria andRightNotBetween(Boolean value1, Boolean value2) { + addCriterion("`right` not between", value1, value2, "right"); + return (Criteria) this; + } + + public Criteria andDestinationCodeIsNull() { + addCriterion("destination_code is null"); + return (Criteria) this; + } + + public Criteria andDestinationCodeIsNotNull() { + addCriterion("destination_code is not null"); + return (Criteria) this; + } + + public Criteria andDestinationCodeEqualTo(String value) { + addCriterion("destination_code =", value, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeNotEqualTo(String value) { + addCriterion("destination_code <>", value, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeGreaterThan(String value) { + addCriterion("destination_code >", value, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeGreaterThanOrEqualTo(String value) { + addCriterion("destination_code >=", value, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeLessThan(String value) { + addCriterion("destination_code <", value, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeLessThanOrEqualTo(String value) { + addCriterion("destination_code <=", value, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeLike(String value) { + addCriterion("destination_code like", value, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeNotLike(String value) { + addCriterion("destination_code not like", value, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeIn(List values) { + addCriterion("destination_code in", values, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeNotIn(List values) { + addCriterion("destination_code not in", values, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeBetween(String value1, String value2) { + addCriterion("destination_code between", value1, value2, "destinationCode"); + return (Criteria) this; + } + + public Criteria andDestinationCodeNotBetween(String value1, String value2) { + addCriterion("destination_code not between", value1, value2, "destinationCode"); + return (Criteria) this; + } + + public Criteria andRemarksIsNull() { + addCriterion("remarks is null"); + return (Criteria) this; + } + + public Criteria andRemarksIsNotNull() { + addCriterion("remarks is not null"); + return (Criteria) this; + } + + public Criteria andRemarksEqualTo(String value) { + addCriterion("remarks =", value, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksNotEqualTo(String value) { + addCriterion("remarks <>", value, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksGreaterThan(String value) { + addCriterion("remarks >", value, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksGreaterThanOrEqualTo(String value) { + addCriterion("remarks >=", value, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksLessThan(String value) { + addCriterion("remarks <", value, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksLessThanOrEqualTo(String value) { + addCriterion("remarks <=", value, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksLike(String value) { + addCriterion("remarks like", value, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksNotLike(String value) { + addCriterion("remarks not like", value, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksIn(List values) { + addCriterion("remarks in", values, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksNotIn(List values) { + addCriterion("remarks not in", values, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksBetween(String value1, String value2) { + addCriterion("remarks between", value1, value2, "remarks"); + return (Criteria) this; + } + + public Criteria andRemarksNotBetween(String value1, String value2) { + addCriterion("remarks not between", value1, value2, "remarks"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/RunPlanRunlevel.java b/src/main/java/club/joylink/rtss/entity/RunPlanRunlevel.java new file mode 100644 index 000000000..ae0158bb8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/RunPlanRunlevel.java @@ -0,0 +1,264 @@ +package club.joylink.rtss.entity; + +import java.io.Serializable; + +/** + * run_plan_runlevel + * @author + */ +public class RunPlanRunlevel implements Serializable { + private Long id; + + /** + * 地图id + */ + private Long mapId; + + /** + * 用户id + */ + private Long userId; + + /** + * 起始车站 + */ + private String startStationCode; + + /** + * 起始站台 + */ + private String startSectionCode; + + /** + * 终点车站 + */ + private String endStationCode; + + /** + * 终点站台 + */ + private String endSectionCode; + + /** + * 方向 + */ + private Boolean right; + + /** + * 距离(厘米) + */ + private Float distance; + + /** + * 等级一 + */ + private Integer level1; + + /** + * 等级二 + */ + private Integer level2; + + /** + * 等级三 + */ + private Integer level3; + + /** + * 等级四 + */ + private Integer level4; + + /** + * 等级五 + */ + private Integer level5; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getMapId() { + return mapId; + } + + public void setMapId(Long mapId) { + this.mapId = mapId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getStartStationCode() { + return startStationCode; + } + + public void setStartStationCode(String startStationCode) { + this.startStationCode = startStationCode; + } + + public String getStartSectionCode() { + return startSectionCode; + } + + public void setStartSectionCode(String startSectionCode) { + this.startSectionCode = startSectionCode; + } + + public String getEndStationCode() { + return endStationCode; + } + + public void setEndStationCode(String endStationCode) { + this.endStationCode = endStationCode; + } + + public String getEndSectionCode() { + return endSectionCode; + } + + public void setEndSectionCode(String endSectionCode) { + this.endSectionCode = endSectionCode; + } + + public Boolean getRight() { + return right; + } + + public void setRight(Boolean right) { + this.right = right; + } + + public Float getDistance() { + return distance; + } + + public void setDistance(Float distance) { + this.distance = distance; + } + + public Integer getLevel1() { + return level1; + } + + public void setLevel1(Integer level1) { + this.level1 = level1; + } + + public Integer getLevel2() { + return level2; + } + + public void setLevel2(Integer level2) { + this.level2 = level2; + } + + public Integer getLevel3() { + return level3; + } + + public void setLevel3(Integer level3) { + this.level3 = level3; + } + + public Integer getLevel4() { + return level4; + } + + public void setLevel4(Integer level4) { + this.level4 = level4; + } + + public Integer getLevel5() { + return level5; + } + + public void setLevel5(Integer level5) { + this.level5 = level5; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + RunPlanRunlevel other = (RunPlanRunlevel) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getStartStationCode() == null ? other.getStartStationCode() == null : this.getStartStationCode().equals(other.getStartStationCode())) + && (this.getStartSectionCode() == null ? other.getStartSectionCode() == null : this.getStartSectionCode().equals(other.getStartSectionCode())) + && (this.getEndStationCode() == null ? other.getEndStationCode() == null : this.getEndStationCode().equals(other.getEndStationCode())) + && (this.getEndSectionCode() == null ? other.getEndSectionCode() == null : this.getEndSectionCode().equals(other.getEndSectionCode())) + && (this.getRight() == null ? other.getRight() == null : this.getRight().equals(other.getRight())) + && (this.getDistance() == null ? other.getDistance() == null : this.getDistance().equals(other.getDistance())) + && (this.getLevel1() == null ? other.getLevel1() == null : this.getLevel1().equals(other.getLevel1())) + && (this.getLevel2() == null ? other.getLevel2() == null : this.getLevel2().equals(other.getLevel2())) + && (this.getLevel3() == null ? other.getLevel3() == null : this.getLevel3().equals(other.getLevel3())) + && (this.getLevel4() == null ? other.getLevel4() == null : this.getLevel4().equals(other.getLevel4())) + && (this.getLevel5() == null ? other.getLevel5() == null : this.getLevel5().equals(other.getLevel5())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getMapId() == null) ? 0 : getMapId().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getStartStationCode() == null) ? 0 : getStartStationCode().hashCode()); + result = prime * result + ((getStartSectionCode() == null) ? 0 : getStartSectionCode().hashCode()); + result = prime * result + ((getEndStationCode() == null) ? 0 : getEndStationCode().hashCode()); + result = prime * result + ((getEndSectionCode() == null) ? 0 : getEndSectionCode().hashCode()); + result = prime * result + ((getRight() == null) ? 0 : getRight().hashCode()); + result = prime * result + ((getDistance() == null) ? 0 : getDistance().hashCode()); + result = prime * result + ((getLevel1() == null) ? 0 : getLevel1().hashCode()); + result = prime * result + ((getLevel2() == null) ? 0 : getLevel2().hashCode()); + result = prime * result + ((getLevel3() == null) ? 0 : getLevel3().hashCode()); + result = prime * result + ((getLevel4() == null) ? 0 : getLevel4().hashCode()); + result = prime * result + ((getLevel5() == null) ? 0 : getLevel5().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", mapId=").append(mapId); + sb.append(", userId=").append(userId); + sb.append(", startStationCode=").append(startStationCode); + sb.append(", startSectionCode=").append(startSectionCode); + sb.append(", endStationCode=").append(endStationCode); + sb.append(", endSectionCode=").append(endSectionCode); + sb.append(", right=").append(right); + sb.append(", distance=").append(distance); + sb.append(", level1=").append(level1); + sb.append(", level2=").append(level2); + sb.append(", level3=").append(level3); + sb.append(", level4=").append(level4); + sb.append(", level5=").append(level5); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/RunPlanRunlevelExample.java b/src/main/java/club/joylink/rtss/entity/RunPlanRunlevelExample.java new file mode 100644 index 000000000..98d17b7b8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/RunPlanRunlevelExample.java @@ -0,0 +1,1102 @@ +package club.joylink.rtss.entity; + +import java.util.ArrayList; +import java.util.List; + +public class RunPlanRunlevelExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public RunPlanRunlevelExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andMapIdIsNull() { + addCriterion("map_id is null"); + return (Criteria) this; + } + + public Criteria andMapIdIsNotNull() { + addCriterion("map_id is not null"); + return (Criteria) this; + } + + public Criteria andMapIdEqualTo(Long value) { + addCriterion("map_id =", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotEqualTo(Long value) { + addCriterion("map_id <>", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThan(Long value) { + addCriterion("map_id >", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThanOrEqualTo(Long value) { + addCriterion("map_id >=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThan(Long value) { + addCriterion("map_id <", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThanOrEqualTo(Long value) { + addCriterion("map_id <=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdIn(List values) { + addCriterion("map_id in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotIn(List values) { + addCriterion("map_id not in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdBetween(Long value1, Long value2) { + addCriterion("map_id between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotBetween(Long value1, Long value2) { + addCriterion("map_id not between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andStartStationCodeIsNull() { + addCriterion("start_station_code is null"); + return (Criteria) this; + } + + public Criteria andStartStationCodeIsNotNull() { + addCriterion("start_station_code is not null"); + return (Criteria) this; + } + + public Criteria andStartStationCodeEqualTo(String value) { + addCriterion("start_station_code =", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeNotEqualTo(String value) { + addCriterion("start_station_code <>", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeGreaterThan(String value) { + addCriterion("start_station_code >", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeGreaterThanOrEqualTo(String value) { + addCriterion("start_station_code >=", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeLessThan(String value) { + addCriterion("start_station_code <", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeLessThanOrEqualTo(String value) { + addCriterion("start_station_code <=", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeLike(String value) { + addCriterion("start_station_code like", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeNotLike(String value) { + addCriterion("start_station_code not like", value, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeIn(List values) { + addCriterion("start_station_code in", values, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeNotIn(List values) { + addCriterion("start_station_code not in", values, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeBetween(String value1, String value2) { + addCriterion("start_station_code between", value1, value2, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartStationCodeNotBetween(String value1, String value2) { + addCriterion("start_station_code not between", value1, value2, "startStationCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeIsNull() { + addCriterion("start_section_code is null"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeIsNotNull() { + addCriterion("start_section_code is not null"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeEqualTo(String value) { + addCriterion("start_section_code =", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeNotEqualTo(String value) { + addCriterion("start_section_code <>", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeGreaterThan(String value) { + addCriterion("start_section_code >", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeGreaterThanOrEqualTo(String value) { + addCriterion("start_section_code >=", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeLessThan(String value) { + addCriterion("start_section_code <", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeLessThanOrEqualTo(String value) { + addCriterion("start_section_code <=", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeLike(String value) { + addCriterion("start_section_code like", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeNotLike(String value) { + addCriterion("start_section_code not like", value, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeIn(List values) { + addCriterion("start_section_code in", values, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeNotIn(List values) { + addCriterion("start_section_code not in", values, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeBetween(String value1, String value2) { + addCriterion("start_section_code between", value1, value2, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andStartSectionCodeNotBetween(String value1, String value2) { + addCriterion("start_section_code not between", value1, value2, "startSectionCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeIsNull() { + addCriterion("end_station_code is null"); + return (Criteria) this; + } + + public Criteria andEndStationCodeIsNotNull() { + addCriterion("end_station_code is not null"); + return (Criteria) this; + } + + public Criteria andEndStationCodeEqualTo(String value) { + addCriterion("end_station_code =", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeNotEqualTo(String value) { + addCriterion("end_station_code <>", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeGreaterThan(String value) { + addCriterion("end_station_code >", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeGreaterThanOrEqualTo(String value) { + addCriterion("end_station_code >=", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeLessThan(String value) { + addCriterion("end_station_code <", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeLessThanOrEqualTo(String value) { + addCriterion("end_station_code <=", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeLike(String value) { + addCriterion("end_station_code like", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeNotLike(String value) { + addCriterion("end_station_code not like", value, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeIn(List values) { + addCriterion("end_station_code in", values, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeNotIn(List values) { + addCriterion("end_station_code not in", values, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeBetween(String value1, String value2) { + addCriterion("end_station_code between", value1, value2, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndStationCodeNotBetween(String value1, String value2) { + addCriterion("end_station_code not between", value1, value2, "endStationCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeIsNull() { + addCriterion("end_section_code is null"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeIsNotNull() { + addCriterion("end_section_code is not null"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeEqualTo(String value) { + addCriterion("end_section_code =", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeNotEqualTo(String value) { + addCriterion("end_section_code <>", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeGreaterThan(String value) { + addCriterion("end_section_code >", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeGreaterThanOrEqualTo(String value) { + addCriterion("end_section_code >=", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeLessThan(String value) { + addCriterion("end_section_code <", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeLessThanOrEqualTo(String value) { + addCriterion("end_section_code <=", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeLike(String value) { + addCriterion("end_section_code like", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeNotLike(String value) { + addCriterion("end_section_code not like", value, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeIn(List values) { + addCriterion("end_section_code in", values, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeNotIn(List values) { + addCriterion("end_section_code not in", values, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeBetween(String value1, String value2) { + addCriterion("end_section_code between", value1, value2, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andEndSectionCodeNotBetween(String value1, String value2) { + addCriterion("end_section_code not between", value1, value2, "endSectionCode"); + return (Criteria) this; + } + + public Criteria andRightIsNull() { + addCriterion("`right` is null"); + return (Criteria) this; + } + + public Criteria andRightIsNotNull() { + addCriterion("`right` is not null"); + return (Criteria) this; + } + + public Criteria andRightEqualTo(Boolean value) { + addCriterion("`right` =", value, "right"); + return (Criteria) this; + } + + public Criteria andRightNotEqualTo(Boolean value) { + addCriterion("`right` <>", value, "right"); + return (Criteria) this; + } + + public Criteria andRightGreaterThan(Boolean value) { + addCriterion("`right` >", value, "right"); + return (Criteria) this; + } + + public Criteria andRightGreaterThanOrEqualTo(Boolean value) { + addCriterion("`right` >=", value, "right"); + return (Criteria) this; + } + + public Criteria andRightLessThan(Boolean value) { + addCriterion("`right` <", value, "right"); + return (Criteria) this; + } + + public Criteria andRightLessThanOrEqualTo(Boolean value) { + addCriterion("`right` <=", value, "right"); + return (Criteria) this; + } + + public Criteria andRightIn(List values) { + addCriterion("`right` in", values, "right"); + return (Criteria) this; + } + + public Criteria andRightNotIn(List values) { + addCriterion("`right` not in", values, "right"); + return (Criteria) this; + } + + public Criteria andRightBetween(Boolean value1, Boolean value2) { + addCriterion("`right` between", value1, value2, "right"); + return (Criteria) this; + } + + public Criteria andRightNotBetween(Boolean value1, Boolean value2) { + addCriterion("`right` not between", value1, value2, "right"); + return (Criteria) this; + } + + public Criteria andDistanceIsNull() { + addCriterion("distance is null"); + return (Criteria) this; + } + + public Criteria andDistanceIsNotNull() { + addCriterion("distance is not null"); + return (Criteria) this; + } + + public Criteria andDistanceEqualTo(Float value) { + addCriterion("distance =", value, "distance"); + return (Criteria) this; + } + + public Criteria andDistanceNotEqualTo(Float value) { + addCriterion("distance <>", value, "distance"); + return (Criteria) this; + } + + public Criteria andDistanceGreaterThan(Float value) { + addCriterion("distance >", value, "distance"); + return (Criteria) this; + } + + public Criteria andDistanceGreaterThanOrEqualTo(Float value) { + addCriterion("distance >=", value, "distance"); + return (Criteria) this; + } + + public Criteria andDistanceLessThan(Float value) { + addCriterion("distance <", value, "distance"); + return (Criteria) this; + } + + public Criteria andDistanceLessThanOrEqualTo(Float value) { + addCriterion("distance <=", value, "distance"); + return (Criteria) this; + } + + public Criteria andDistanceIn(List values) { + addCriterion("distance in", values, "distance"); + return (Criteria) this; + } + + public Criteria andDistanceNotIn(List values) { + addCriterion("distance not in", values, "distance"); + return (Criteria) this; + } + + public Criteria andDistanceBetween(Float value1, Float value2) { + addCriterion("distance between", value1, value2, "distance"); + return (Criteria) this; + } + + public Criteria andDistanceNotBetween(Float value1, Float value2) { + addCriterion("distance not between", value1, value2, "distance"); + return (Criteria) this; + } + + public Criteria andLevel1IsNull() { + addCriterion("level1 is null"); + return (Criteria) this; + } + + public Criteria andLevel1IsNotNull() { + addCriterion("level1 is not null"); + return (Criteria) this; + } + + public Criteria andLevel1EqualTo(Integer value) { + addCriterion("level1 =", value, "level1"); + return (Criteria) this; + } + + public Criteria andLevel1NotEqualTo(Integer value) { + addCriterion("level1 <>", value, "level1"); + return (Criteria) this; + } + + public Criteria andLevel1GreaterThan(Integer value) { + addCriterion("level1 >", value, "level1"); + return (Criteria) this; + } + + public Criteria andLevel1GreaterThanOrEqualTo(Integer value) { + addCriterion("level1 >=", value, "level1"); + return (Criteria) this; + } + + public Criteria andLevel1LessThan(Integer value) { + addCriterion("level1 <", value, "level1"); + return (Criteria) this; + } + + public Criteria andLevel1LessThanOrEqualTo(Integer value) { + addCriterion("level1 <=", value, "level1"); + return (Criteria) this; + } + + public Criteria andLevel1In(List values) { + addCriterion("level1 in", values, "level1"); + return (Criteria) this; + } + + public Criteria andLevel1NotIn(List values) { + addCriterion("level1 not in", values, "level1"); + return (Criteria) this; + } + + public Criteria andLevel1Between(Integer value1, Integer value2) { + addCriterion("level1 between", value1, value2, "level1"); + return (Criteria) this; + } + + public Criteria andLevel1NotBetween(Integer value1, Integer value2) { + addCriterion("level1 not between", value1, value2, "level1"); + return (Criteria) this; + } + + public Criteria andLevel2IsNull() { + addCriterion("level2 is null"); + return (Criteria) this; + } + + public Criteria andLevel2IsNotNull() { + addCriterion("level2 is not null"); + return (Criteria) this; + } + + public Criteria andLevel2EqualTo(Integer value) { + addCriterion("level2 =", value, "level2"); + return (Criteria) this; + } + + public Criteria andLevel2NotEqualTo(Integer value) { + addCriterion("level2 <>", value, "level2"); + return (Criteria) this; + } + + public Criteria andLevel2GreaterThan(Integer value) { + addCriterion("level2 >", value, "level2"); + return (Criteria) this; + } + + public Criteria andLevel2GreaterThanOrEqualTo(Integer value) { + addCriterion("level2 >=", value, "level2"); + return (Criteria) this; + } + + public Criteria andLevel2LessThan(Integer value) { + addCriterion("level2 <", value, "level2"); + return (Criteria) this; + } + + public Criteria andLevel2LessThanOrEqualTo(Integer value) { + addCriterion("level2 <=", value, "level2"); + return (Criteria) this; + } + + public Criteria andLevel2In(List values) { + addCriterion("level2 in", values, "level2"); + return (Criteria) this; + } + + public Criteria andLevel2NotIn(List values) { + addCriterion("level2 not in", values, "level2"); + return (Criteria) this; + } + + public Criteria andLevel2Between(Integer value1, Integer value2) { + addCriterion("level2 between", value1, value2, "level2"); + return (Criteria) this; + } + + public Criteria andLevel2NotBetween(Integer value1, Integer value2) { + addCriterion("level2 not between", value1, value2, "level2"); + return (Criteria) this; + } + + public Criteria andLevel3IsNull() { + addCriterion("level3 is null"); + return (Criteria) this; + } + + public Criteria andLevel3IsNotNull() { + addCriterion("level3 is not null"); + return (Criteria) this; + } + + public Criteria andLevel3EqualTo(Integer value) { + addCriterion("level3 =", value, "level3"); + return (Criteria) this; + } + + public Criteria andLevel3NotEqualTo(Integer value) { + addCriterion("level3 <>", value, "level3"); + return (Criteria) this; + } + + public Criteria andLevel3GreaterThan(Integer value) { + addCriterion("level3 >", value, "level3"); + return (Criteria) this; + } + + public Criteria andLevel3GreaterThanOrEqualTo(Integer value) { + addCriterion("level3 >=", value, "level3"); + return (Criteria) this; + } + + public Criteria andLevel3LessThan(Integer value) { + addCriterion("level3 <", value, "level3"); + return (Criteria) this; + } + + public Criteria andLevel3LessThanOrEqualTo(Integer value) { + addCriterion("level3 <=", value, "level3"); + return (Criteria) this; + } + + public Criteria andLevel3In(List values) { + addCriterion("level3 in", values, "level3"); + return (Criteria) this; + } + + public Criteria andLevel3NotIn(List values) { + addCriterion("level3 not in", values, "level3"); + return (Criteria) this; + } + + public Criteria andLevel3Between(Integer value1, Integer value2) { + addCriterion("level3 between", value1, value2, "level3"); + return (Criteria) this; + } + + public Criteria andLevel3NotBetween(Integer value1, Integer value2) { + addCriterion("level3 not between", value1, value2, "level3"); + return (Criteria) this; + } + + public Criteria andLevel4IsNull() { + addCriterion("level4 is null"); + return (Criteria) this; + } + + public Criteria andLevel4IsNotNull() { + addCriterion("level4 is not null"); + return (Criteria) this; + } + + public Criteria andLevel4EqualTo(Integer value) { + addCriterion("level4 =", value, "level4"); + return (Criteria) this; + } + + public Criteria andLevel4NotEqualTo(Integer value) { + addCriterion("level4 <>", value, "level4"); + return (Criteria) this; + } + + public Criteria andLevel4GreaterThan(Integer value) { + addCriterion("level4 >", value, "level4"); + return (Criteria) this; + } + + public Criteria andLevel4GreaterThanOrEqualTo(Integer value) { + addCriterion("level4 >=", value, "level4"); + return (Criteria) this; + } + + public Criteria andLevel4LessThan(Integer value) { + addCriterion("level4 <", value, "level4"); + return (Criteria) this; + } + + public Criteria andLevel4LessThanOrEqualTo(Integer value) { + addCriterion("level4 <=", value, "level4"); + return (Criteria) this; + } + + public Criteria andLevel4In(List values) { + addCriterion("level4 in", values, "level4"); + return (Criteria) this; + } + + public Criteria andLevel4NotIn(List values) { + addCriterion("level4 not in", values, "level4"); + return (Criteria) this; + } + + public Criteria andLevel4Between(Integer value1, Integer value2) { + addCriterion("level4 between", value1, value2, "level4"); + return (Criteria) this; + } + + public Criteria andLevel4NotBetween(Integer value1, Integer value2) { + addCriterion("level4 not between", value1, value2, "level4"); + return (Criteria) this; + } + + public Criteria andLevel5IsNull() { + addCriterion("level5 is null"); + return (Criteria) this; + } + + public Criteria andLevel5IsNotNull() { + addCriterion("level5 is not null"); + return (Criteria) this; + } + + public Criteria andLevel5EqualTo(Integer value) { + addCriterion("level5 =", value, "level5"); + return (Criteria) this; + } + + public Criteria andLevel5NotEqualTo(Integer value) { + addCriterion("level5 <>", value, "level5"); + return (Criteria) this; + } + + public Criteria andLevel5GreaterThan(Integer value) { + addCriterion("level5 >", value, "level5"); + return (Criteria) this; + } + + public Criteria andLevel5GreaterThanOrEqualTo(Integer value) { + addCriterion("level5 >=", value, "level5"); + return (Criteria) this; + } + + public Criteria andLevel5LessThan(Integer value) { + addCriterion("level5 <", value, "level5"); + return (Criteria) this; + } + + public Criteria andLevel5LessThanOrEqualTo(Integer value) { + addCriterion("level5 <=", value, "level5"); + return (Criteria) this; + } + + public Criteria andLevel5In(List values) { + addCriterion("level5 in", values, "level5"); + return (Criteria) this; + } + + public Criteria andLevel5NotIn(List values) { + addCriterion("level5 not in", values, "level5"); + return (Criteria) this; + } + + public Criteria andLevel5Between(Integer value1, Integer value2) { + addCriterion("level5 between", value1, value2, "level5"); + return (Criteria) this; + } + + public Criteria andLevel5NotBetween(Integer value1, Integer value2) { + addCriterion("level5 not between", value1, value2, "level5"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/RunPlanUserConfig.java b/src/main/java/club/joylink/rtss/entity/RunPlanUserConfig.java new file mode 100644 index 000000000..2fec69654 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/RunPlanUserConfig.java @@ -0,0 +1,104 @@ +package club.joylink.rtss.entity; + +import java.io.Serializable; + +/** + * run_plan_user_config + * @author + */ +public class RunPlanUserConfig implements Serializable { + private Long id; + + /** + * 所属地图id + */ + private Long mapId; + + /** + * 用户id + */ + private Long userId; + + /** + * 折返车站code + */ + private String config; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getMapId() { + return mapId; + } + + public void setMapId(Long mapId) { + this.mapId = mapId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getConfig() { + return config; + } + + public void setConfig(String config) { + this.config = config; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + RunPlanUserConfig other = (RunPlanUserConfig) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getConfig() == null ? other.getConfig() == null : this.getConfig().equals(other.getConfig())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getMapId() == null) ? 0 : getMapId().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getConfig() == null) ? 0 : getConfig().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", mapId=").append(mapId); + sb.append(", userId=").append(userId); + sb.append(", config=").append(config); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/RunPlanUserConfigExample.java b/src/main/java/club/joylink/rtss/entity/RunPlanUserConfigExample.java new file mode 100644 index 000000000..dd1c93440 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/RunPlanUserConfigExample.java @@ -0,0 +1,402 @@ +package club.joylink.rtss.entity; + +import java.util.ArrayList; +import java.util.List; + +public class RunPlanUserConfigExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public RunPlanUserConfigExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andMapIdIsNull() { + addCriterion("map_id is null"); + return (Criteria) this; + } + + public Criteria andMapIdIsNotNull() { + addCriterion("map_id is not null"); + return (Criteria) this; + } + + public Criteria andMapIdEqualTo(Long value) { + addCriterion("map_id =", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotEqualTo(Long value) { + addCriterion("map_id <>", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThan(Long value) { + addCriterion("map_id >", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThanOrEqualTo(Long value) { + addCriterion("map_id >=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThan(Long value) { + addCriterion("map_id <", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThanOrEqualTo(Long value) { + addCriterion("map_id <=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdIn(List values) { + addCriterion("map_id in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotIn(List values) { + addCriterion("map_id not in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdBetween(Long value1, Long value2) { + addCriterion("map_id between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotBetween(Long value1, Long value2) { + addCriterion("map_id not between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/services/runplan/IRunPlanParktimeService.java b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanParktimeService.java new file mode 100644 index 000000000..2a723d2c4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanParktimeService.java @@ -0,0 +1,22 @@ +package club.joylink.rtss.services.runplan; + +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanParktimeQueryVO; + +import java.util.List; + +public interface IRunPlanParktimeService { + + void createUserParktime(RunPlanParkingTimeVO parkingTimeVO); + + void updateUserParktime(Long id, RunPlanParkingTimeVO parkingTimeVO); + + void updateRefUserParktime(Long userId, Long mapId, List list); + + PageVO queryUserParktimes(Long userId, Long mapId, RunPlanParktimeQueryVO queryVO); + + List queryUserParktimes(Long userId, Long mapId); + + boolean isExisted(RunPlanParkingTimeVO parkingTimeVO); +} diff --git a/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRoutingService.java b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRoutingService.java new file mode 100644 index 000000000..1d3b9f20e --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRoutingService.java @@ -0,0 +1,32 @@ +package club.joylink.rtss.services.runplan; + +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingQueryVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingSection; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +public interface IRunPlanRoutingService { + + @Transactional + void createUserRouting(RunPlanRoutingVO routingVO); + + RunPlanRoutingVO getUserRouting(Long routingId); + + void updateUserRouting(Long routingId, RunPlanRoutingVO routingVO); + + void deleteUserRouting(Long routingId); + + PageVO queryPagedUserRouting(Long userId, Long mapId, RunPlanRoutingQueryVO queryVO); + + List getUserRoutingBy(Long userId, Long mapId); + + RunPlanRoutingVO queryUserRoutingBySDTNumber(Long userId, Long planId, String SDTNumber); + + RunPlanRoutingVO queryUserRoutingByCode(Long userId, Long mapId, String routingCode); + + List getRoutingSectionDataBy(Long userId, Long planId, String routingCode); + +} diff --git a/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRunlevelService.java b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRunlevelService.java new file mode 100644 index 000000000..3b8bad1aa --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanRunlevelService.java @@ -0,0 +1,21 @@ +package club.joylink.rtss.services.runplan; + +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunLevelQueryVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; + +import java.util.List; + +public interface IRunPlanRunlevelService { + void createUserRunlevel(RunPlanRunlevelVO runLevelVO); + + void update(Long id, RunPlanRunlevelVO runLevelVO); + + void updateRefLevels(Long userId, Long mapId, List list); + + PageVO queryUserRunLevels(Long userId, Long mapId, RunPlanRunLevelQueryVO queryVO); + + List queryUserRunLevels(Long userId, Long mapId); + + boolean isExisted(RunPlanRunlevelVO runLevelVO); +} diff --git a/src/main/java/club/joylink/rtss/services/runplan/IRunPlanUserConfigService.java b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanUserConfigService.java new file mode 100644 index 000000000..69347b871 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/runplan/IRunPlanUserConfigService.java @@ -0,0 +1,10 @@ +package club.joylink.rtss.services.runplan; + +import club.joylink.rtss.vo.client.runplan.user.RunPlanUserConfigVO; + +public interface IRunPlanUserConfigService { + + RunPlanUserConfigVO getConfig(Long userId, Long mapId); + + void saveConfig(Long userId, Long mapId, RunPlanUserConfigVO.Config config); +} diff --git a/src/main/java/club/joylink/rtss/services/runplan/RunPlanParktimeService.java b/src/main/java/club/joylink/rtss/services/runplan/RunPlanParktimeService.java new file mode 100644 index 000000000..88f185cc4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanParktimeService.java @@ -0,0 +1,103 @@ +package club.joylink.rtss.services.runplan; + +import club.joylink.rtss.dao.RunPlanParktimeDAO; +import club.joylink.rtss.dao.RunPlanRunlevelDAO; +import club.joylink.rtss.entity.RunPlanParktime; +import club.joylink.rtss.entity.RunPlanParktimeExample; +import club.joylink.rtss.entity.RunPlanRunlevel; +import club.joylink.rtss.entity.RunPlanRunlevelExample; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanParktimeQueryVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunLevelQueryVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.List; + +@Service +@Slf4j +public class RunPlanParktimeService implements IRunPlanParktimeService { + + @Autowired + private RunPlanParktimeDAO parktimeDAO; + + @Override + public void createUserParktime(RunPlanParkingTimeVO parkingTimeVO) { + BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(isExisted(parkingTimeVO)); + RunPlanParktime parktime = parkingTimeVO.convert2Entity(); + this.parktimeDAO.insert(parktime); + } + + @Override + public void updateUserParktime(Long id, RunPlanParkingTimeVO parkingTimeVO) { + RunPlanParktime parktime = this.getEntityById(id); + parktime.setParkingTime(parkingTimeVO.getParkingTime()); + this.parktimeDAO.updateByPrimaryKey(parktime); + } + + @Override + public void updateRefUserParktime(Long userId, Long mapId, List list) { + list.forEach(parkingTimeVO -> { + RunPlanParktime parktime = this.getEntityById(parkingTimeVO.getId()); + if (parktime.getMapId().equals(mapId) && parktime.getUserId().equals(userId)) { + parktime.setParkingTime(parkingTimeVO.getParkingTime()); + this.parktimeDAO.updateByPrimaryKeySelective(parktime); + } + }); + } + + @Override + public PageVO queryUserParktimes(Long userId, Long mapId, RunPlanParktimeQueryVO queryVO) { + PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + RunPlanParktimeExample example = new RunPlanParktimeExample(); + RunPlanParktimeExample.Criteria criteria = example.createCriteria(); + criteria.andMapIdEqualTo(mapId).andUserIdEqualTo(userId); + if (StringUtils.hasText(queryVO.getStationCode())) { + criteria.andStationCodeEqualTo(queryVO.getStationCode()); + } + if (StringUtils.hasText(queryVO.getSectionCode())) { + criteria.andSectionCodeEqualTo(queryVO.getSectionCode()); + } + Page page = (Page) this.parktimeDAO.selectByExample(example); + List timeVOS = RunPlanParkingTimeVO.convert2VOList(page.getResult()); + return PageVO.convert(page, timeVOS); + } + + @Override + public List queryUserParktimes(Long userId, Long mapId) { + RunPlanParktimeExample example = new RunPlanParktimeExample(); + RunPlanParktimeExample.Criteria criteria = example.createCriteria(); + criteria.andMapIdEqualTo(mapId).andUserIdEqualTo(userId); + List list = this.parktimeDAO.selectByExample(example); + List timeVOS = RunPlanParkingTimeVO.convert2VOList(list); + return timeVOS; + } + + @Override + public boolean isExisted(RunPlanParkingTimeVO parkingTimeVO) { + RunPlanParktimeExample example = new RunPlanParktimeExample(); + example.createCriteria() + .andMapIdEqualTo(parkingTimeVO.getMapId()) + .andUserIdEqualTo(parkingTimeVO.getUserId()) + .andStationCodeEqualTo(parkingTimeVO.getStationCode()) + .andSectionCodeEqualTo(parkingTimeVO.getSectionCode()); + if (this.parktimeDAO.countByExample(example) > 0) { + return true; + } + return false; + } + + private RunPlanParktime getEntityById(Long id) { + RunPlanParktime parktime = this.parktimeDAO.selectByPrimaryKey(id); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(parktime, + String.format("id为[%s]的用户定义运行等级数据不存在", id)); + return parktime; + } +} diff --git a/src/main/java/club/joylink/rtss/services/runplan/RunPlanRoutingService.java b/src/main/java/club/joylink/rtss/services/runplan/RunPlanRoutingService.java new file mode 100644 index 000000000..aaeadbe13 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanRoutingService.java @@ -0,0 +1,229 @@ +package club.joylink.rtss.services.runplan; + +import club.joylink.rtss.dao.RunPlanDraftDAO; +import club.joylink.rtss.dao.RunPlanRoutingDAO; +import club.joylink.rtss.entity.RunPlanDraft; +import club.joylink.rtss.entity.RunPlanRouting; +import club.joylink.rtss.entity.RunPlanRoutingExample; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.IMapService; +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.util.JsonUtils; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.map.MapVO; +import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; +import club.joylink.rtss.vo.client.runplan.RunPlanVO; +import club.joylink.rtss.vo.client.runplan.user.*; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class RunPlanRoutingService implements IRunPlanRoutingService { + + @Autowired + private RunPlanRoutingDAO runPlanRoutingDAO; + + @Autowired + private RunPlanDraftDAO runPlanDraftDAO; + + @Autowired + private IRunPlanRunlevelService planRunlevelService; + + @Autowired + private IRunPlanParktimeService planParktimeService; + + @Autowired + private IMapService iMapService; + + @Transactional + @Override + public void createUserRouting(RunPlanRoutingVO routingVO) { + BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(ifRoutingDataExist(routingVO)); + MapVO map = this.iMapService.getMapDetail(routingVO.getMapId()); + SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); + BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), + "地图基础数据校验不通过"); + Map 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()) { + routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.OUTBOUND); + } else if (endSection.isTransferTrack()) { + routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.INBOUND); + } else { + routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.LOOP); + } + RunPlanRouting routing = routingVO.convert2Entity(); + runPlanRoutingDAO.insert(routing); + generateUserRunlevels(routingVO, deviceMap); + generateUserParktimes(routingVO, deviceMap); + } + + @Override + public RunPlanRoutingVO getUserRouting(Long routingId) { + RunPlanRouting routing = getRunPlanRoutingData(routingId); + return RunPlanRoutingVO.convert2VO(routing); + } + + @Transactional + @Override + public void updateUserRouting(Long routingId, RunPlanRoutingVO routingVO) { +// BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(ifRoutingDataExist(routingVO)); + MapVO map = this.iMapService.getMapDetail(routingVO.getMapId()); + SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); + BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), + "地图基础数据校验不通过"); + Map 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()) { + routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.OUTBOUND); + } else if (endSection.isTransferTrack()) { + routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.INBOUND); + } else { + routingVO.setRoutingType(RunPlanRoutingVO.UserRoutingType.LOOP); + } + RunPlanRouting newRouting = routingVO.convert2Entity(); + newRouting.setId(routingId); + runPlanRoutingDAO.updateByPrimaryKeyWithBLOBs(newRouting); + generateUserRunlevels(routingVO, deviceMap); + generateUserParktimes(routingVO, deviceMap); + } + + private void generateUserParktimes(RunPlanRoutingVO routingVO, Map deviceMap) { + List parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(routingVO); + parkingTimeVOS.forEach(p -> { + if (!((Section) deviceMap.get(p.getSectionCode())).isTransferTrack() && !planParktimeService.isExisted(p)) { + planParktimeService.createUserParktime(p); + } + }); + } + + private void generateUserRunlevels(RunPlanRoutingVO routingVO, Map deviceMap) { + + List 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()); + Float distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); + l.setDistance(distance); + l.generateDefaultRunLevel(); + planRunlevelService.createUserRunlevel(l); + } + }); + } + + @Override + public void deleteUserRouting(Long routingId) { + runPlanRoutingDAO.deleteByPrimaryKey(routingId); + } + + @Override + public PageVO queryPagedUserRouting(Long userId, Long mapId, RunPlanRoutingQueryVO queryVO) { + PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + RunPlanRoutingExample example = new RunPlanRoutingExample(); + example.setOrderByClause("id"); + RunPlanRoutingExample.Criteria criteria = example.createCriteria(); + criteria.andMapIdEqualTo(mapId).andUserIdEqualTo(userId); + if (StringUtils.hasText(queryVO.getStartStationCode())) { + criteria.andStartStationCodeEqualTo(queryVO.getStartStationCode()); + } + if (StringUtils.hasText(queryVO.getEndStationCode())) { + criteria.andEndStationCodeEqualTo(queryVO.getEndStationCode()); + } + if (StringUtils.hasText(queryVO.getStartSectionCode())) { + criteria.andStartSectionCodeEqualTo(queryVO.getStartSectionCode()); + } + if (StringUtils.hasText(queryVO.getEndSectionCode())) { + criteria.andEndSectionCodeEqualTo(queryVO.getEndSectionCode()); + } + Page page = (Page) runPlanRoutingDAO.selectByExampleWithBLOBs(example); + List routingVOList = page.getResult().stream().map(RunPlanRoutingVO::convert2VO).collect(Collectors.toList()); + return PageVO.convert(page, routingVOList); + } + + @Override + public List getUserRoutingBy(Long userId, Long mapId) { + RunPlanRoutingExample example = new RunPlanRoutingExample(); + example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId); + List runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example); + return RunPlanRoutingVO.convert2VOList(runPlanRoutings); + } + + @Override + public RunPlanRoutingVO queryUserRoutingBySDTNumber(Long userId, Long planId, String SDTNumber) { + RunPlanVO planVO = this.getRunPlanById(planId); + RunPlanTripVO trip = planVO.getTripList().stream() + .filter(tripVO -> tripVO.getSDTNumberNew().equals(SDTNumber)) + .findFirst() + .orElseThrow(() -> BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception()); + RunPlanRoutingExample example = new RunPlanRoutingExample(); + example.createCriteria().andMapIdEqualTo(planVO.getMapId()).andUserIdEqualTo(userId).andStartSectionCodeEqualTo(trip.getStartSectionCode()).andEndSectionCodeEqualTo(trip.getEndSectionCode()); + List runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example); + if (CollectionUtils.isEmpty(runPlanRoutings)) return null; + return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0)); + } + + @Override + public RunPlanRoutingVO queryUserRoutingByCode(Long userId, Long mapId, String routingCode) { + RunPlanRoutingExample example = new RunPlanRoutingExample(); + example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId).andCodeEqualTo(routingCode); + List runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example); + if (CollectionUtils.isEmpty(runPlanRoutings)) return null; + return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0)); + } + + @Override + public List 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 runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example); + if (CollectionUtils.isEmpty(runPlanRoutings)) return Collections.emptyList(); + return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0)).getParkSectionCodeList(); + } + + private boolean ifRoutingDataExist(RunPlanRoutingVO routingVO) { + return runPlanRoutingDAO.countUserRoutingBySectionData(routingVO.getUserId(), routingVO.getMapId(), JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList())) > 0; + } + + private RunPlanRouting getRunPlanRoutingData(Long routingId) { + RunPlanRouting routing = runPlanRoutingDAO.selectByPrimaryKey(routingId); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(routing); + return routing; + } + + private RunPlanVO getRunPlanById(Long planId) { + RunPlanDraft runPlanDraft = this.runPlanDraftDAO.selectByPrimaryKey(planId); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanDraft); + RunPlanVO runPlanVO = new RunPlanVO(runPlanDraft); + if (StringUtils.hasText(runPlanDraft.getTrips())) { + runPlanVO.setTripList(JsonUtils.read(runPlanDraft.getTrips(), JsonUtils.getCollectionType(List.class, RunPlanTripVO.class))); + } else { + runPlanVO.setTripList(new ArrayList<>()); + } + return runPlanVO; + } +} diff --git a/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java b/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java new file mode 100644 index 000000000..20eee43e4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java @@ -0,0 +1,102 @@ +package club.joylink.rtss.services.runplan; + +import club.joylink.rtss.dao.RunPlanRunlevelDAO; +import club.joylink.rtss.entity.DraftMapRunLevel; +import club.joylink.rtss.entity.DraftMapRunLevelExample; +import club.joylink.rtss.entity.RunPlanRunlevel; +import club.joylink.rtss.entity.RunPlanRunlevelExample; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.map.newmap.MapRunLevelQueryVO; +import club.joylink.rtss.vo.client.map.newmap.MapStationRunLevelVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunLevelQueryVO; +import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.List; + +@Service +@Slf4j +public class RunPlanRunlevelService implements IRunPlanRunlevelService { + + @Autowired + private RunPlanRunlevelDAO runPlanRunlevelDAO; + + @Override + public void createUserRunlevel(RunPlanRunlevelVO runLevelVO) { + BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(isExisted(runLevelVO)); + RunPlanRunlevel runLevel = runLevelVO.convert2Entity(); + this.runPlanRunlevelDAO.insert(runLevel); + } + + @Override + public void update(Long id, RunPlanRunlevelVO runLevelVO) { + RunPlanRunlevel runLevel = this.getEntityById(id); + runLevelVO.updateLevel(runLevel); + this.runPlanRunlevelDAO.updateByPrimaryKey(runLevel); + } + + @Override + public void updateRefLevels(Long userId, Long mapId, List list) { + list.forEach(runLevelVO -> { + RunPlanRunlevel runLevel = this.getEntityById(runLevelVO.getId()); + if (runLevel.getMapId().equals(mapId) && runLevel.getUserId().equals(userId)) { + runLevelVO.updateLevel(runLevel); + this.runPlanRunlevelDAO.updateByPrimaryKeySelective(runLevel); + } + }); + } + + @Override + public PageVO queryUserRunLevels(Long userId, Long mapId, RunPlanRunLevelQueryVO queryVO) { + PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + RunPlanRunlevelExample example = new RunPlanRunlevelExample(); + RunPlanRunlevelExample.Criteria criteria = example.createCriteria(); + criteria.andMapIdEqualTo(mapId).andUserIdEqualTo(userId); + if (StringUtils.hasText(queryVO.getStartSectionCode())) { + criteria.andStartSectionCodeEqualTo(queryVO.getStartSectionCode()); + } + if (StringUtils.hasText(queryVO.getEndSectionCode())) { + criteria.andEndSectionCodeEqualTo(queryVO.getEndSectionCode()); + } + Page page = (Page) this.runPlanRunlevelDAO.selectByExample(example); + List runLevels = RunPlanRunlevelVO.convert2VOList(page.getResult()); + return PageVO.convert(page, runLevels); + } + + @Override + public List queryUserRunLevels(Long userId, Long mapId) { + RunPlanRunlevelExample example = new RunPlanRunlevelExample(); + RunPlanRunlevelExample.Criteria criteria = example.createCriteria(); + criteria.andMapIdEqualTo(mapId).andUserIdEqualTo(userId); + List list = this.runPlanRunlevelDAO.selectByExample(example); + List runLevels = RunPlanRunlevelVO.convert2VOList(list); + return runLevels; + } + + @Override + public boolean isExisted(RunPlanRunlevelVO runLevelVO) { + RunPlanRunlevelExample example = new RunPlanRunlevelExample(); + example.createCriteria() + .andMapIdEqualTo(runLevelVO.getMapId()) + .andUserIdEqualTo(runLevelVO.getUserId()) + .andStartSectionCodeEqualTo(runLevelVO.getStartSectionCode()) + .andEndSectionCodeEqualTo(runLevelVO.getEndSectionCode()); + if (this.runPlanRunlevelDAO.countByExample(example) > 0) { + return true; + } + return false; + } + + private RunPlanRunlevel getEntityById(Long id) { + RunPlanRunlevel runLevel = this.runPlanRunlevelDAO.selectByPrimaryKey(id); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runLevel, + String.format("id为[%s]的用户定义运行等级数据不存在", id)); + return runLevel; + } +} diff --git a/src/main/java/club/joylink/rtss/services/runplan/RunPlanUserConfigService.java b/src/main/java/club/joylink/rtss/services/runplan/RunPlanUserConfigService.java new file mode 100644 index 000000000..d12106f28 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanUserConfigService.java @@ -0,0 +1,51 @@ +package club.joylink.rtss.services.runplan; + +import club.joylink.rtss.dao.RunPlanUserConfigDAO; +import club.joylink.rtss.entity.RunPlanUserConfig; +import club.joylink.rtss.entity.RunPlanUserConfigExample; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.runplan.user.RunPlanUserConfigVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.List; + +@Service +@Slf4j +public class RunPlanUserConfigService implements IRunPlanUserConfigService { + + @Autowired + private RunPlanUserConfigDAO runPlanUserConfigDAO; + + @Override + public RunPlanUserConfigVO getConfig(Long userId, Long mapId) { + RunPlanUserConfigExample example = new RunPlanUserConfigExample(); + example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId); + List runPlanUserConfigs = runPlanUserConfigDAO.selectByExampleWithBLOBs(example); + if (CollectionUtils.isEmpty(runPlanUserConfigs)) return null; + return RunPlanUserConfigVO.convert2VO(runPlanUserConfigs.get(0)); + } + + @Override + public void saveConfig(Long userId, Long mapId, RunPlanUserConfigVO.Config config) { + RunPlanUserConfigExample example = new RunPlanUserConfigExample(); + example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId); + List runPlanUserConfigs = runPlanUserConfigDAO.selectByExampleWithBLOBs(example); + + if (CollectionUtils.isEmpty(runPlanUserConfigs)) { + RunPlanUserConfigVO configVO = new RunPlanUserConfigVO(); + configVO.setUserId(userId); + configVO.setMapId(mapId); + configVO.setConfig(config); + RunPlanUserConfig userConfig = configVO.convert2Entity(); + runPlanUserConfigDAO.insert(userConfig); + return; + } + RunPlanUserConfig userConfig = runPlanUserConfigs.get(0); + userConfig.setConfig(JsonUtils.writeValueAsString(config)); + runPlanUserConfigDAO.updateByPrimaryKeyWithBLOBs(userConfig); + } + +} diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParkingTimeVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParkingTimeVO.java new file mode 100644 index 000000000..1fe3e0c7e --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParkingTimeVO.java @@ -0,0 +1,87 @@ +package club.joylink.rtss.vo.client.runplan.user; + +import club.joylink.rtss.entity.RunPlanParktime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.springframework.util.CollectionUtils; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@ApiModel(value = "用户车站区段停站时间") +@Getter +@Setter +@NoArgsConstructor +public class RunPlanParkingTimeVO { + + public final static Integer PARKING_TIME = 30;//s + private Long id; + + private Long mapId; + + private Long userId; + + @ApiModelProperty(value = "车站code") + @NotBlank(message = "车站code不能为空") + private String stationCode; + + @ApiModelProperty(value = "站台轨/折返轨/转换轨区段code") + @NotBlank(message = "区段code不能为空") + private String sectionCode; + + @ApiModelProperty(value = "停站时间,单位秒(s)") + @NotNull(message = "停站时间不能为空") + private Integer parkingTime; + + + public RunPlanParktime convert2Entity() { + RunPlanParktime runPlanParktime = new RunPlanParktime(); + runPlanParktime.setId(this.id); + runPlanParktime.setMapId(this.mapId); + runPlanParktime.setUserId(this.userId); + runPlanParktime.setStationCode(this.stationCode); + runPlanParktime.setSectionCode(this.sectionCode); + runPlanParktime.setParkingTime(this.parkingTime); + return runPlanParktime; + } + + public static RunPlanParkingTimeVO convert2VO(RunPlanParktime runPlanParktime) { + RunPlanParkingTimeVO vo = new RunPlanParkingTimeVO(); + vo.setId(runPlanParktime.getId()); + vo.setMapId(runPlanParktime.getMapId()); + vo.setUserId(runPlanParktime.getUserId()); + vo.setStationCode(runPlanParktime.getStationCode()); + vo.setSectionCode(runPlanParktime.getSectionCode()); + vo.setParkingTime(runPlanParktime.getParkingTime()); + return vo; + } + + public static List convert2VOList(List list) { + List voList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(p -> voList.add(convert2VO(p))); + } + return voList; + } + + + public static List parkingTimeFromRouting(RunPlanRoutingVO routingVO) { + List parkSectionList = routingVO.getParkSectionCodeList(); + List list = new ArrayList<>(); + for (int i = 0; i < parkSectionList.size(); i++) { + RunPlanParkingTimeVO timeVO = new RunPlanParkingTimeVO(); + timeVO.setMapId(routingVO.getMapId()); + timeVO.setUserId(routingVO.getUserId()); + timeVO.setStationCode(parkSectionList.get(i).getStationCode()); + timeVO.setSectionCode(parkSectionList.get(i).getSectionCode()); + timeVO.setParkingTime(PARKING_TIME); + list.add(timeVO); + } + return list; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParktimeQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParktimeQueryVO.java new file mode 100644 index 000000000..2fa216885 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParktimeQueryVO.java @@ -0,0 +1,20 @@ +package club.joylink.rtss.vo.client.runplan.user; + +import club.joylink.rtss.vo.client.PageQueryVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@ApiModel(value = "停站时间查询vo") +public class RunPlanParktimeQueryVO extends PageQueryVO { + + @ApiModelProperty(value = "车站code") + private String stationCode; + + @ApiModelProperty(value = "停站区段code") + private String sectionCode; + +} diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingQueryVO.java new file mode 100644 index 000000000..80cef8d7e --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingQueryVO.java @@ -0,0 +1,25 @@ +package club.joylink.rtss.vo.client.runplan.user; + +import club.joylink.rtss.vo.client.PageQueryVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +@ApiModel +@Getter +@Setter +public class RunPlanRoutingQueryVO extends PageQueryVO { + + @ApiModelProperty(value = "起始车站code") + private String startStationCode; + + @ApiModelProperty(value = "起始站台区段code") + private String startSectionCode; + + @ApiModelProperty(value = "终到车站code") + private String endStationCode; + + @ApiModelProperty(value = "终到站台区段code") + private String endSectionCode; +} diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingSection.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingSection.java new file mode 100644 index 000000000..7c3917ff5 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingSection.java @@ -0,0 +1,40 @@ +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 +@AllArgsConstructor +@Getter +@Setter +public class RunPlanRoutingSection { + + @ApiModelProperty(value = "车站编号") + @NotBlank(message = "车站编号不能为空") + private String stationCode; + + @ApiModelProperty(value = "区段编号") + @NotBlank(message = "区段编号不能为空") + private String sectionCode; + + public static List from(List
viaSectionList) { + List voList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(viaSectionList)) { + for (Section section : viaSectionList) { + voList.add(new RunPlanRoutingSection(section.getStation().getCode(), section.getCode())); + } + } + return voList; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java new file mode 100644 index 000000000..81c78d162 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java @@ -0,0 +1,137 @@ +package club.joylink.rtss.vo.client.runplan.user; + +import club.joylink.rtss.entity.RunPlanRouting; +import club.joylink.rtss.util.JsonUtils; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@ApiModel(value = "运行图用户交路对象") +@Getter +@Setter +public class RunPlanRoutingVO { + + @ApiModelProperty(hidden = true) + private Long id; + + @ApiModelProperty(value = "地图ID") + @NotNull(message = "地图ID不能为空") + private Long mapId; + + @ApiModelProperty(value = "用户ID") + private Long userId; + + @ApiModelProperty(value = "交路名称") + private String name; + + @ApiModelProperty(value = "交路编号") + @NotBlank(message = "交路编号不能为空") + private String code; + + @ApiModelProperty(value = "交路类型",hidden = true) + private UserRoutingType routingType; + + @ApiModelProperty(value = "起始车站code") + private String startStationCode; + + @ApiModelProperty(value = "起始站台区段code") + private String startSectionCode; + + @ApiModelProperty(value = "终到车站code") + private String endStationCode; + + @ApiModelProperty(value = "终到站台区段code") + private String endSectionCode; + + @ApiModelProperty(value = "目的地码") + private String destinationCode; + + @ApiModelProperty(value = "方向(左向/右向)") + @NotNull(message = "方向不能为空") + private Boolean right; + + @ApiModelProperty(value = "经停车站区段编号列表") + @NotEmpty + @Valid + private List parkSectionCodeList; + + @ApiModelProperty(value = "描述") + private String remarks; + + + public RunPlanRoutingVO() { + this.parkSectionCodeList = new ArrayList<>(); + } + + public static RunPlanRoutingVO convert2VO(RunPlanRouting runPlanRouting) { + 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)); + return routingVO; + } + + public RunPlanRouting convert2Entity() { + RunPlanRouting routing = new RunPlanRouting(); + routing.setId(id); + routing.setMapId(mapId); + routing.setUserId(userId); + routing.setName(name); + routing.setCode(code); + routing.setType(routingType.name()); + routing.setStartStationCode(startStationCode); + routing.setStartSectionCode(startSectionCode); + routing.setEndStationCode(endStationCode); + routing.setEndSectionCode(endSectionCode); + routing.setRight(right); + routing.setDestinationCode(destinationCode); + routing.setRemarks(remarks); + routing.setSectionData(JsonUtils.writeValueAsString(parkSectionCodeList)); + return routing; + } + +// 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 convert2VOList(List runPlanRoutings){ + return runPlanRoutings.stream().map(RunPlanRoutingVO::convert2VO).collect(Collectors.toList()); + } + + public enum UserRoutingType{ + OUTBOUND, + INBOUND, + LOOP, + OTHER + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunLevelQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunLevelQueryVO.java new file mode 100644 index 000000000..8e268bc31 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunLevelQueryVO.java @@ -0,0 +1,20 @@ +package club.joylink.rtss.vo.client.runplan.user; + +import club.joylink.rtss.vo.client.PageQueryVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@ApiModel(value = "运行等级查询") +public class RunPlanRunLevelQueryVO extends PageQueryVO { + + @ApiModelProperty(value = "起始区段code") + private String startSectionCode; + + @ApiModelProperty(value = "终点区段code") + private String endSectionCode; + +} diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java new file mode 100644 index 000000000..05897446f --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java @@ -0,0 +1,185 @@ +package club.joylink.rtss.vo.client.runplan.user; + +import club.joylink.rtss.entity.RunPlanRunlevel; +import club.joylink.rtss.vo.client.map.newmap.MapRoutingDataVO; +import club.joylink.rtss.vo.client.map.newmap.MapRoutingSectionNewVO; +import club.joylink.rtss.vo.client.map.newmap.validate.RunLevelCreateCheck; +import club.joylink.rtss.vo.client.map.newmap.validate.RunLevelGenerateCheck; +import club.joylink.rtss.vo.client.map.newmap.validate.RunLevelUpdateCheck; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.springframework.util.CollectionUtils; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.PositiveOrZero; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@ApiModel(value = "运行计划站间运行等级") +@Getter +@Setter +@NoArgsConstructor +public class RunPlanRunlevelVO { + + public static final float L1_SPEED = 12f; //m/s + public static final float L2_SPEED = 10.5f; + public static final float L3_SPEED = 9f; + public static final float L4_SPEED = 7.5f; + public static final float L5_SPEED = 6f; + + private Long id; + + @NotNull(message = "地图id不能为空", groups = {RunLevelGenerateCheck.class, RunLevelCreateCheck.class}) + private Long mapId; + + private Long userId; + + @ApiModelProperty(value = "起始车站code") + @NotBlank(message = "起始车站code不能为空", groups = {RunLevelGenerateCheck.class, RunLevelCreateCheck.class, RunLevelUpdateCheck.class}) + private String startStationCode; + + @ApiModelProperty(value = "起始区段code") + @NotBlank(message = "起始区段code不能为空", groups = {RunLevelGenerateCheck.class, RunLevelCreateCheck.class, RunLevelUpdateCheck.class}) + private String startSectionCode; + + @ApiModelProperty(value = "终点车站code") + @NotBlank(message = "终点车站code不能为空", groups = {RunLevelGenerateCheck.class, RunLevelCreateCheck.class, RunLevelUpdateCheck.class}) + private String endStationCode; + + @ApiModelProperty(value = "终点区段code") + @NotBlank(message = "终点区段code不能为空", groups = {RunLevelGenerateCheck.class, RunLevelCreateCheck.class, RunLevelUpdateCheck.class}) + private String endSectionCode; + + @ApiModelProperty(value = "方向(左向/右向)") + @NotNull(message = "方向不能为空", groups = {RunLevelGenerateCheck.class, RunLevelCreateCheck.class, RunLevelUpdateCheck.class}) + private Boolean right; + + @ApiModelProperty(value = "距离/m") + @NotNull(message = "距离不能为空") + @PositiveOrZero + private Float distance; + + @ApiModelProperty(value = "等级一时间,单位秒(s)") + @NotNull(message = "等级一时间不能为空") + private Integer l1; + + @ApiModelProperty(value = "等级二时间,单位秒(s)") + @NotNull(message = "等级二时间不能为空") + @PositiveOrZero + private Integer l2; + + @ApiModelProperty(value = "等级三时间,单位秒(s)") + @NotNull(message = "等级三时间不能为空") + @PositiveOrZero + private Integer l3; + + @ApiModelProperty(value = "等级四时间,单位秒(s)") + @NotNull(message = "等级四时间不能为空") + @PositiveOrZero + private Integer l4; + + @ApiModelProperty(value = "等级五时间,单位秒(s)") + @NotNull(message = "等级五时间不能为空") + @PositiveOrZero + private Integer l5; + + public static List convert2VOList(List list) { + List voList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(runLevel -> voList.add(RunPlanRunlevelVO.convert2VO(runLevel))); + } + return voList; + } + + public static RunPlanRunlevelVO convert2VO(RunPlanRunlevel runLevel) { + RunPlanRunlevelVO runLevelVO = new RunPlanRunlevelVO(); + runLevelVO.setId(runLevel.getId()); + runLevelVO.setMapId(runLevel.getMapId()); + runLevelVO.setUserId(runLevel.getUserId()); + runLevelVO.setStartStationCode(runLevel.getStartStationCode()); + runLevelVO.setStartSectionCode(runLevel.getStartSectionCode()); + runLevelVO.setEndStationCode(runLevel.getEndStationCode()); + runLevelVO.setEndSectionCode(runLevel.getEndSectionCode()); + runLevelVO.setRight(runLevel.getRight()); + runLevelVO.setDistance(runLevel.getDistance()); + runLevelVO.setL1(runLevel.getLevel1()); + runLevelVO.setL2(runLevel.getLevel2()); + runLevelVO.setL3(runLevel.getLevel3()); + runLevelVO.setL4(runLevel.getLevel4()); + runLevelVO.setL5(runLevel.getLevel5()); + return runLevelVO; + } + + public RunPlanRunlevel convert2Entity() { + RunPlanRunlevel runLevel = new RunPlanRunlevel(); + runLevel.setId(id); + runLevel.setMapId(mapId); + runLevel.setUserId(userId); + runLevel.setStartStationCode(startStationCode); + runLevel.setStartSectionCode(startSectionCode); + runLevel.setEndStationCode(endStationCode); + runLevel.setEndSectionCode(endSectionCode); + runLevel.setRight(right); + runLevel.setDistance(distance); + runLevel.setLevel1(l1); + runLevel.setLevel2(l2); + runLevel.setLevel3(l3); + runLevel.setLevel4(l4); + runLevel.setLevel5(l5); + return runLevel; + } + + public void updateLevel(RunPlanRunlevel runLevel) { + runLevel.setLevel1(l1); + runLevel.setLevel2(l2); + runLevel.setLevel3(l3); + runLevel.setLevel4(l4); + runLevel.setLevel5(l5); + } + + + + public static List runLevelsFromRouting(RunPlanRoutingVO routingVO) { + List parkSectionList = routingVO.getParkSectionCodeList(); + List list = new ArrayList<>(); + for (int i = 0; i < parkSectionList.size()-1; i++) { + RunPlanRunlevelVO runlevelVO = new RunPlanRunlevelVO(); + runlevelVO.setMapId(routingVO.getMapId()); + runlevelVO.setUserId(routingVO.getUserId()); + runlevelVO.setRight(routingVO.getRight()); + runlevelVO.setStartStationCode(parkSectionList.get(i).getStationCode()); + runlevelVO.setEndStationCode(parkSectionList.get(i+1).getStationCode()); + runlevelVO.setStartSectionCode(parkSectionList.get(i).getSectionCode()); + runlevelVO.setEndSectionCode(parkSectionList.get(i+1).getSectionCode()); + list.add(runlevelVO); + } + return list; + } + + + public void generateDefaultRunLevel() { + Objects.requireNonNull(this.distance, "站间距离不能为空"); + this.l1 = Math.round(this.distance / L1_SPEED); + this.l2 = Math.round(this.distance / L2_SPEED); + this.l3 = Math.round(this.distance / L3_SPEED); + this.l4 = Math.round(this.distance / L4_SPEED); + this.l5 = Math.round(this.distance / L5_SPEED); + } + + @JsonIgnore + public int getLevelTime(int level){ + switch (level){ + case 1:return l1; + case 2:return l2; + case 4:return l4; + case 5:return l5; + default:return l3; + } + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanUserConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanUserConfigVO.java new file mode 100644 index 000000000..344fe81d1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanUserConfigVO.java @@ -0,0 +1,73 @@ +package club.joylink.rtss.vo.client.runplan.user; + +import club.joylink.rtss.entity.RunPlanUserConfig; +import club.joylink.rtss.util.JsonUtils; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.NonNull; +import lombok.Setter; +import org.springframework.util.CollectionUtils; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +@ApiModel(value = "运行图用户基础配置对象") +@Getter +@Setter +public class RunPlanUserConfigVO { + + @ApiModelProperty(hidden = true) + private Long id; + + @ApiModelProperty(value = "地图ID") + @NotNull(message = "地图ID不能为空") + private Long mapId; + + @ApiModelProperty(value = "用户ID") + private Long userId; + + @ApiModelProperty(value = "交路编号") + @NotNull(message = "交路编号不能为空") + private Config config; + + public static RunPlanUserConfigVO convert2VO(RunPlanUserConfig runPlanUserConfig) { + RunPlanUserConfigVO routingVO = new RunPlanUserConfigVO(); +// routingVO.setId(runPlanUserConfig.getId()); + routingVO.setMapId(runPlanUserConfig.getMapId()); +// routingVO.setUserId(runPlanUserConfig.getUserId()); + routingVO.setConfig(JsonUtils.read(runPlanUserConfig.getConfig(), Config.class)); + return routingVO; + } + + public RunPlanUserConfig convert2Entity() { + RunPlanUserConfig userConfig = new RunPlanUserConfig(); + userConfig.setId(id); + userConfig.setMapId(mapId); + userConfig.setUserId(userId); + userConfig.setConfig(JsonUtils.writeValueAsString(config)); + return userConfig; + } + + public static List convert2VOList(List userConfigs) { + return userConfigs.stream().map(RunPlanUserConfigVO::convert2VO).collect(Collectors.toList()); + } + + public boolean hasReentryData(){ + return Objects.nonNull(config) && !CollectionUtils.isEmpty(config.getRunPlanUserReentryData()); + } + + @Getter + @Setter + public static class Config{ + + /**运行车站折返配置数据:车站code->折返轨code*/ + @ApiModelProperty(value = "运行车站折返配置数据") + @NonNull + private Map runPlanUserReentryData; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java new file mode 100644 index 000000000..a2c07d3d0 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java @@ -0,0 +1,74 @@ +package club.joylink.rtss.vo.runplan.newdraw; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.springframework.util.StringUtils; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Positive; +import java.time.LocalTime; + +@ApiModel(value = "运行图生成输入参数") +@Getter +@Setter +public class RunPlanInputData { + + @ApiModelProperty(value = "表号") + @NotBlank + private String serviceNumber; + + + /**出库交路code*/ + @ApiModelProperty(value = "出库交路code") + @NotBlank(message= "出库交路不能为空") + private String outboundRouting; + /**回库交路code*/ + @ApiModelProperty(value = "入库交路code") + @NotBlank(message= "入库交路不能为空") + private String inboundRouting; + + /**运行环路*/ + + /**环路1-运行交路code*/ + @ApiModelProperty(value = "运行交路code") + @NotBlank(message= "环路不能为空") + private String runningRouting1; + + /**环路2-运行交路code*/ + @ApiModelProperty(value = "运行交路code") + @NotBlank(message= "环路不能为空") + private String runningRouting2; + + /**运营开始时间*/ + @ApiModelProperty(value = "开始时间") + @NotNull(message = "开始时间不能为空") + private LocalTime beginTime; + /**运营结束时间*/ + @ApiModelProperty(value = "结束时间") + @NotNull(message = "结束时间不能为空") + private LocalTime overTime; + +// /**折返时间*/ +// @ApiModelProperty(value = "折返时间") +// private int reentryTime = 150; + +// /**发车间隔,s*/ +// @ApiModelProperty(value = "发车间隔,s") +// @Positive +// private int departureInterval = 180 ; + + /**运行等级默认-站间运行时间*/ + private int runLevel = 3; + + public boolean hasOutbound(){ + return StringUtils.hasText(outboundRouting); + } + public boolean hasInbound(){ + return StringUtils.hasText(inboundRouting); + } + +} diff --git a/src/main/resources/mybatis/mapper/RunPlanParktimeDAO.xml b/src/main/resources/mybatis/mapper/RunPlanParktimeDAO.xml new file mode 100644 index 000000000..cab5721b7 --- /dev/null +++ b/src/main/resources/mybatis/mapper/RunPlanParktimeDAO.xml @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, map_id, user_id, station_code, section_code, parking_time + + + + + delete from run_plan_parktime + where id = #{id,jdbcType=BIGINT} + + + delete from run_plan_parktime + + + + + + insert into run_plan_parktime (map_id, user_id, station_code, + section_code, parking_time) + values (#{mapId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{stationCode,jdbcType=VARCHAR}, + #{sectionCode,jdbcType=VARCHAR}, #{parkingTime,jdbcType=INTEGER}) + + + insert into run_plan_parktime + + + map_id, + + + user_id, + + + station_code, + + + section_code, + + + parking_time, + + + + + #{mapId,jdbcType=BIGINT}, + + + #{userId,jdbcType=BIGINT}, + + + #{stationCode,jdbcType=VARCHAR}, + + + #{sectionCode,jdbcType=VARCHAR}, + + + #{parkingTime,jdbcType=INTEGER}, + + + + + + update run_plan_parktime + + + id = #{record.id,jdbcType=BIGINT}, + + + map_id = #{record.mapId,jdbcType=BIGINT}, + + + user_id = #{record.userId,jdbcType=BIGINT}, + + + station_code = #{record.stationCode,jdbcType=VARCHAR}, + + + section_code = #{record.sectionCode,jdbcType=VARCHAR}, + + + parking_time = #{record.parkingTime,jdbcType=INTEGER}, + + + + + + + + update run_plan_parktime + set id = #{record.id,jdbcType=BIGINT}, + map_id = #{record.mapId,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT}, + station_code = #{record.stationCode,jdbcType=VARCHAR}, + section_code = #{record.sectionCode,jdbcType=VARCHAR}, + parking_time = #{record.parkingTime,jdbcType=INTEGER} + + + + + + update run_plan_parktime + + + map_id = #{mapId,jdbcType=BIGINT}, + + + user_id = #{userId,jdbcType=BIGINT}, + + + station_code = #{stationCode,jdbcType=VARCHAR}, + + + section_code = #{sectionCode,jdbcType=VARCHAR}, + + + parking_time = #{parkingTime,jdbcType=INTEGER}, + + + where id = #{id,jdbcType=BIGINT} + + + update run_plan_parktime + set map_id = #{mapId,jdbcType=BIGINT}, + user_id = #{userId,jdbcType=BIGINT}, + station_code = #{stationCode,jdbcType=VARCHAR}, + section_code = #{sectionCode,jdbcType=VARCHAR}, + parking_time = #{parkingTime,jdbcType=INTEGER} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/RunPlanRoutingDAO.xml b/src/main/resources/mybatis/mapper/RunPlanRoutingDAO.xml new file mode 100644 index 000000000..b27645d23 --- /dev/null +++ b/src/main/resources/mybatis/mapper/RunPlanRoutingDAO.xml @@ -0,0 +1,421 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, map_id, user_id, `name`, code, `type`, start_station_code, start_section_code, + end_station_code, end_section_code, `right`, destination_code, remarks + + + section_data + + + + + + delete from run_plan_routing + where id = #{id,jdbcType=BIGINT} + + + delete from run_plan_routing + + + + + + insert into run_plan_routing (map_id, user_id, `name`, + code, `type`, start_station_code, + start_section_code, end_station_code, end_section_code, + `right`, destination_code, remarks, + section_data) + values (#{mapId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, + #{code,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{startStationCode,jdbcType=VARCHAR}, + #{startSectionCode,jdbcType=VARCHAR}, #{endStationCode,jdbcType=VARCHAR}, #{endSectionCode,jdbcType=VARCHAR}, + #{right,jdbcType=BIT}, #{destinationCode,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, + #{sectionData,jdbcType=LONGVARCHAR}) + + + insert into run_plan_routing + + + map_id, + + + user_id, + + + `name`, + + + code, + + + `type`, + + + start_station_code, + + + start_section_code, + + + end_station_code, + + + end_section_code, + + + `right`, + + + destination_code, + + + remarks, + + + section_data, + + + + + #{mapId,jdbcType=BIGINT}, + + + #{userId,jdbcType=BIGINT}, + + + #{name,jdbcType=VARCHAR}, + + + #{code,jdbcType=VARCHAR}, + + + #{type,jdbcType=VARCHAR}, + + + #{startStationCode,jdbcType=VARCHAR}, + + + #{startSectionCode,jdbcType=VARCHAR}, + + + #{endStationCode,jdbcType=VARCHAR}, + + + #{endSectionCode,jdbcType=VARCHAR}, + + + #{right,jdbcType=BIT}, + + + #{destinationCode,jdbcType=VARCHAR}, + + + #{remarks,jdbcType=VARCHAR}, + + + #{sectionData,jdbcType=LONGVARCHAR}, + + + + + + update run_plan_routing + + + id = #{record.id,jdbcType=BIGINT}, + + + map_id = #{record.mapId,jdbcType=BIGINT}, + + + user_id = #{record.userId,jdbcType=BIGINT}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + code = #{record.code,jdbcType=VARCHAR}, + + + `type` = #{record.type,jdbcType=VARCHAR}, + + + start_station_code = #{record.startStationCode,jdbcType=VARCHAR}, + + + start_section_code = #{record.startSectionCode,jdbcType=VARCHAR}, + + + end_station_code = #{record.endStationCode,jdbcType=VARCHAR}, + + + end_section_code = #{record.endSectionCode,jdbcType=VARCHAR}, + + + `right` = #{record.right,jdbcType=BIT}, + + + destination_code = #{record.destinationCode,jdbcType=VARCHAR}, + + + remarks = #{record.remarks,jdbcType=VARCHAR}, + + + section_data = #{record.sectionData,jdbcType=LONGVARCHAR}, + + + + + + + + update run_plan_routing + set id = #{record.id,jdbcType=BIGINT}, + map_id = #{record.mapId,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT}, + `name` = #{record.name,jdbcType=VARCHAR}, + code = #{record.code,jdbcType=VARCHAR}, + `type` = #{record.type,jdbcType=VARCHAR}, + start_station_code = #{record.startStationCode,jdbcType=VARCHAR}, + start_section_code = #{record.startSectionCode,jdbcType=VARCHAR}, + end_station_code = #{record.endStationCode,jdbcType=VARCHAR}, + end_section_code = #{record.endSectionCode,jdbcType=VARCHAR}, + `right` = #{record.right,jdbcType=BIT}, + destination_code = #{record.destinationCode,jdbcType=VARCHAR}, + remarks = #{record.remarks,jdbcType=VARCHAR}, + section_data = #{record.sectionData,jdbcType=LONGVARCHAR} + + + + + + update run_plan_routing + set id = #{record.id,jdbcType=BIGINT}, + map_id = #{record.mapId,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT}, + `name` = #{record.name,jdbcType=VARCHAR}, + code = #{record.code,jdbcType=VARCHAR}, + `type` = #{record.type,jdbcType=VARCHAR}, + start_station_code = #{record.startStationCode,jdbcType=VARCHAR}, + start_section_code = #{record.startSectionCode,jdbcType=VARCHAR}, + end_station_code = #{record.endStationCode,jdbcType=VARCHAR}, + end_section_code = #{record.endSectionCode,jdbcType=VARCHAR}, + `right` = #{record.right,jdbcType=BIT}, + destination_code = #{record.destinationCode,jdbcType=VARCHAR}, + remarks = #{record.remarks,jdbcType=VARCHAR} + + + + + + update run_plan_routing + + + map_id = #{mapId,jdbcType=BIGINT}, + + + user_id = #{userId,jdbcType=BIGINT}, + + + `name` = #{name,jdbcType=VARCHAR}, + + + code = #{code,jdbcType=VARCHAR}, + + + `type` = #{type,jdbcType=VARCHAR}, + + + start_station_code = #{startStationCode,jdbcType=VARCHAR}, + + + start_section_code = #{startSectionCode,jdbcType=VARCHAR}, + + + end_station_code = #{endStationCode,jdbcType=VARCHAR}, + + + end_section_code = #{endSectionCode,jdbcType=VARCHAR}, + + + `right` = #{right,jdbcType=BIT}, + + + destination_code = #{destinationCode,jdbcType=VARCHAR}, + + + remarks = #{remarks,jdbcType=VARCHAR}, + + + section_data = #{sectionData,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + update run_plan_routing + set map_id = #{mapId,jdbcType=BIGINT}, + user_id = #{userId,jdbcType=BIGINT}, + `name` = #{name,jdbcType=VARCHAR}, + code = #{code,jdbcType=VARCHAR}, + `type` = #{type,jdbcType=VARCHAR}, + start_station_code = #{startStationCode,jdbcType=VARCHAR}, + start_section_code = #{startSectionCode,jdbcType=VARCHAR}, + end_station_code = #{endStationCode,jdbcType=VARCHAR}, + end_section_code = #{endSectionCode,jdbcType=VARCHAR}, + `right` = #{right,jdbcType=BIT}, + destination_code = #{destinationCode,jdbcType=VARCHAR}, + remarks = #{remarks,jdbcType=VARCHAR}, + section_data = #{sectionData,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=BIGINT} + + + update run_plan_routing + set map_id = #{mapId,jdbcType=BIGINT}, + user_id = #{userId,jdbcType=BIGINT}, + `name` = #{name,jdbcType=VARCHAR}, + code = #{code,jdbcType=VARCHAR}, + `type` = #{type,jdbcType=VARCHAR}, + start_station_code = #{startStationCode,jdbcType=VARCHAR}, + start_section_code = #{startSectionCode,jdbcType=VARCHAR}, + end_station_code = #{endStationCode,jdbcType=VARCHAR}, + end_section_code = #{endSectionCode,jdbcType=VARCHAR}, + `right` = #{right,jdbcType=BIT}, + destination_code = #{destinationCode,jdbcType=VARCHAR}, + remarks = #{remarks,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/RunPlanRunlevelDAO.xml b/src/main/resources/mybatis/mapper/RunPlanRunlevelDAO.xml new file mode 100644 index 000000000..2afa3e63c --- /dev/null +++ b/src/main/resources/mybatis/mapper/RunPlanRunlevelDAO.xml @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, map_id, user_id, start_station_code, start_section_code, end_station_code, end_section_code, + `right`, distance, level1, level2, level3, level4, level5 + + + + + delete from run_plan_runlevel + where id = #{id,jdbcType=BIGINT} + + + delete from run_plan_runlevel + + + + + + insert into run_plan_runlevel (map_id, user_id, start_station_code, + start_section_code, end_station_code, end_section_code, + `right`, distance, level1, level2, + level3, level4, level5 + ) + values (#{mapId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{startStationCode,jdbcType=VARCHAR}, + #{startSectionCode,jdbcType=VARCHAR}, #{endStationCode,jdbcType=VARCHAR}, #{endSectionCode,jdbcType=VARCHAR}, + #{right,jdbcType=BIT}, #{distance,jdbcType=REAL}, #{level1,jdbcType=INTEGER}, #{level2,jdbcType=INTEGER}, + #{level3,jdbcType=INTEGER}, #{level4,jdbcType=INTEGER}, #{level5,jdbcType=INTEGER} + ) + + + insert into run_plan_runlevel + + + map_id, + + + user_id, + + + start_station_code, + + + start_section_code, + + + end_station_code, + + + end_section_code, + + + `right`, + + + distance, + + + level1, + + + level2, + + + level3, + + + level4, + + + level5, + + + + + #{mapId,jdbcType=BIGINT}, + + + #{userId,jdbcType=BIGINT}, + + + #{startStationCode,jdbcType=VARCHAR}, + + + #{startSectionCode,jdbcType=VARCHAR}, + + + #{endStationCode,jdbcType=VARCHAR}, + + + #{endSectionCode,jdbcType=VARCHAR}, + + + #{right,jdbcType=BIT}, + + + #{distance,jdbcType=REAL}, + + + #{level1,jdbcType=INTEGER}, + + + #{level2,jdbcType=INTEGER}, + + + #{level3,jdbcType=INTEGER}, + + + #{level4,jdbcType=INTEGER}, + + + #{level5,jdbcType=INTEGER}, + + + + + + update run_plan_runlevel + + + id = #{record.id,jdbcType=BIGINT}, + + + map_id = #{record.mapId,jdbcType=BIGINT}, + + + user_id = #{record.userId,jdbcType=BIGINT}, + + + start_station_code = #{record.startStationCode,jdbcType=VARCHAR}, + + + start_section_code = #{record.startSectionCode,jdbcType=VARCHAR}, + + + end_station_code = #{record.endStationCode,jdbcType=VARCHAR}, + + + end_section_code = #{record.endSectionCode,jdbcType=VARCHAR}, + + + `right` = #{record.right,jdbcType=BIT}, + + + distance = #{record.distance,jdbcType=REAL}, + + + level1 = #{record.level1,jdbcType=INTEGER}, + + + level2 = #{record.level2,jdbcType=INTEGER}, + + + level3 = #{record.level3,jdbcType=INTEGER}, + + + level4 = #{record.level4,jdbcType=INTEGER}, + + + level5 = #{record.level5,jdbcType=INTEGER}, + + + + + + + + update run_plan_runlevel + set id = #{record.id,jdbcType=BIGINT}, + map_id = #{record.mapId,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT}, + start_station_code = #{record.startStationCode,jdbcType=VARCHAR}, + start_section_code = #{record.startSectionCode,jdbcType=VARCHAR}, + end_station_code = #{record.endStationCode,jdbcType=VARCHAR}, + end_section_code = #{record.endSectionCode,jdbcType=VARCHAR}, + `right` = #{record.right,jdbcType=BIT}, + distance = #{record.distance,jdbcType=REAL}, + level1 = #{record.level1,jdbcType=INTEGER}, + level2 = #{record.level2,jdbcType=INTEGER}, + level3 = #{record.level3,jdbcType=INTEGER}, + level4 = #{record.level4,jdbcType=INTEGER}, + level5 = #{record.level5,jdbcType=INTEGER} + + + + + + update run_plan_runlevel + + + map_id = #{mapId,jdbcType=BIGINT}, + + + user_id = #{userId,jdbcType=BIGINT}, + + + start_station_code = #{startStationCode,jdbcType=VARCHAR}, + + + start_section_code = #{startSectionCode,jdbcType=VARCHAR}, + + + end_station_code = #{endStationCode,jdbcType=VARCHAR}, + + + end_section_code = #{endSectionCode,jdbcType=VARCHAR}, + + + `right` = #{right,jdbcType=BIT}, + + + distance = #{distance,jdbcType=REAL}, + + + level1 = #{level1,jdbcType=INTEGER}, + + + level2 = #{level2,jdbcType=INTEGER}, + + + level3 = #{level3,jdbcType=INTEGER}, + + + level4 = #{level4,jdbcType=INTEGER}, + + + level5 = #{level5,jdbcType=INTEGER}, + + + where id = #{id,jdbcType=BIGINT} + + + update run_plan_runlevel + set map_id = #{mapId,jdbcType=BIGINT}, + user_id = #{userId,jdbcType=BIGINT}, + start_station_code = #{startStationCode,jdbcType=VARCHAR}, + start_section_code = #{startSectionCode,jdbcType=VARCHAR}, + end_station_code = #{endStationCode,jdbcType=VARCHAR}, + end_section_code = #{endSectionCode,jdbcType=VARCHAR}, + `right` = #{right,jdbcType=BIT}, + distance = #{distance,jdbcType=REAL}, + level1 = #{level1,jdbcType=INTEGER}, + level2 = #{level2,jdbcType=INTEGER}, + level3 = #{level3,jdbcType=INTEGER}, + level4 = #{level4,jdbcType=INTEGER}, + level5 = #{level5,jdbcType=INTEGER} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/RunPlanUserConfigDAO.xml b/src/main/resources/mybatis/mapper/RunPlanUserConfigDAO.xml new file mode 100644 index 000000000..f12b6af7c --- /dev/null +++ b/src/main/resources/mybatis/mapper/RunPlanUserConfigDAO.xml @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, map_id, user_id + + + config + + + + + + delete from run_plan_user_config + where id = #{id,jdbcType=BIGINT} + + + delete from run_plan_user_config + + + + + + insert into run_plan_user_config (map_id, user_id, config + ) + values (#{mapId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{config,jdbcType=LONGVARCHAR} + ) + + + insert into run_plan_user_config + + + map_id, + + + user_id, + + + config, + + + + + #{mapId,jdbcType=BIGINT}, + + + #{userId,jdbcType=BIGINT}, + + + #{config,jdbcType=LONGVARCHAR}, + + + + + + update run_plan_user_config + + + id = #{record.id,jdbcType=BIGINT}, + + + map_id = #{record.mapId,jdbcType=BIGINT}, + + + user_id = #{record.userId,jdbcType=BIGINT}, + + + config = #{record.config,jdbcType=LONGVARCHAR}, + + + + + + + + update run_plan_user_config + set id = #{record.id,jdbcType=BIGINT}, + map_id = #{record.mapId,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT}, + config = #{record.config,jdbcType=LONGVARCHAR} + + + + + + update run_plan_user_config + set id = #{record.id,jdbcType=BIGINT}, + map_id = #{record.mapId,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT} + + + + + + update run_plan_user_config + + + map_id = #{mapId,jdbcType=BIGINT}, + + + user_id = #{userId,jdbcType=BIGINT}, + + + config = #{config,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + update run_plan_user_config + set map_id = #{mapId,jdbcType=BIGINT}, + user_id = #{userId,jdbcType=BIGINT}, + config = #{config,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=BIGINT} + + + update run_plan_user_config + set map_id = #{mapId,jdbcType=BIGINT}, + user_id = #{userId,jdbcType=BIGINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file From 498d2b30790c9cd6ff9a798328920adc0b564b4b Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Wed, 9 Dec 2020 19:19:44 +0800 Subject: [PATCH 06/23] =?UTF-8?q?=E8=BF=9B=E8=B7=AF=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E7=9B=B4=E5=90=91=E8=BF=9B=E8=B7=AF=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9=E2=80=94=E2=80=94=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=BB=B6=E7=BB=AD=E4=BF=9D=E6=8A=A4=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/simulation/cbtc/data/map/Route.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java index 6b8aa50f7..ae67ec48d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java @@ -199,11 +199,11 @@ public class Route extends MapNamedElement { } } } - if (Objects.nonNull(this.overlap)) { - if (this.overlap.containRpSwitch()) { // 延续保护存在反位道岔 - return false; - } - } +// if (Objects.nonNull(this.overlap)) { +// if (this.overlap.containRpSwitch()) { // 延续保护存在反位道岔 +// return false; +// } +// } return true; } From 465ceed6012d584803281a1d7d424d93c47b7297 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Thu, 10 Dec 2020 13:58:19 +0800 Subject: [PATCH 07/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=9B=E8=B7=AF?= =?UTF-8?q?=E5=BB=B6=E7=BB=AD=E4=BF=9D=E6=8A=A4=E9=87=8D=E6=96=B0=E9=94=81?= =?UTF-8?q?=E9=97=AD=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/CI/service/RouteService.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java index 99e0bfd2f..7e7125e66 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java @@ -827,21 +827,14 @@ public class RouteService { return; } List
sectionList = route.getSectionList(); - for (Section section : sectionList) { - if (section.isLockedOn(right)) { - if (section.isSwitchTrack()) { - SwitchElement element = route.getRouteSwitchElement(section.getRelSwitch()); - if (!section.getRelSwitch().isOnPosition(element.isNormal())) { - overlapRelock = false; - } - } - } - } for (int i = 0; i < sectionList.size(); i++) { Section section = sectionList.get(i); if (!Objects.equals(route.getUnlockedSection(), section)) { continue; } + if (route.isLastRouteSection(section)) { + overlapRelock = false; + } Switch relSwitch = section.getRelSwitch(); if (section.isOccupied()) { // 区段逻辑占用,且有逻辑区段 @@ -874,7 +867,7 @@ public class RouteService { if (!section.isRouteLock() && (i + 1) < sectionList.size()) { // 区段已经解锁,更新解锁区段 route.updateUnlockedSection(sectionList.get(i+1)); - } else if (section.isRouteLock() && i + 1 >= sectionList.size()) { + } else if (section.isRouteLock() && (i + 1) >= sectionList.size()) { allUnlock = true; } } @@ -882,7 +875,8 @@ public class RouteService { route.normalUnlockOver(); simulation.getRepository().removeSettingRoute(route); log.debug(String.format("进路[%s(%s)-%s]解锁完毕,移除",route.getName(), route.getCode(), route.isTurnBack()?"Z":"B")); - } else { + } + if (overlapRelock) { // 延续保护重新锁闭 this.checkAndSetLockedRouteOverlap(simulation, route); } From 2d3a2f25ee1d3f62cc1986f7d4128f422ba8fb70 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Thu, 10 Dec 2020 15:38:41 +0800 Subject: [PATCH 08/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E4=B8=80=E9=94=AE=E9=A2=86=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../permission/GoodsController.java | 2 +- .../user/UserPermissionController.java | 6 +++ .../joylink/rtss/services/GoodsService.java | 24 ++++++++--- .../joylink/rtss/services/IGoodsService.java | 3 +- .../rtss/services/IPermissionService.java | 2 + .../rtss/services/IUserPermissionService.java | 8 ++++ .../rtss/services/PermissionService.java | 12 ++++-- .../rtss/services/UserPermissionService.java | 40 +++++++++++++++++-- 8 files changed, 82 insertions(+), 15 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/permission/GoodsController.java b/src/main/java/club/joylink/rtss/controller/permission/GoodsController.java index c845ab827..2453dd2c8 100644 --- a/src/main/java/club/joylink/rtss/controller/permission/GoodsController.java +++ b/src/main/java/club/joylink/rtss/controller/permission/GoodsController.java @@ -106,6 +106,6 @@ public class GoodsController { @ApiOperation(value = "根据权限ids查询权限包商品") @GetMapping(path = "/permissionIds") public GoodsVO findGoodsByPermissionIds(Long[] ids) { - return iGoodsService.findGoodsByPermissionIds(ids); + return iGoodsService.findGoodsByRelPermissionIds(ids); } } diff --git a/src/main/java/club/joylink/rtss/controller/user/UserPermissionController.java b/src/main/java/club/joylink/rtss/controller/user/UserPermissionController.java index 87f70c1f6..f5a4fb7c7 100644 --- a/src/main/java/club/joylink/rtss/controller/user/UserPermissionController.java +++ b/src/main/java/club/joylink/rtss/controller/user/UserPermissionController.java @@ -76,4 +76,10 @@ public class UserPermissionController { return iUserPermissionService.queryPersonalUserPermission(user); } + @ApiOperation("根据地图一键领取权限") + @PostMapping("/{mapId}/getPermissions") + public void getPermissions4Map(@PathVariable Long mapId, Integer count ,@RequestAttribute @ApiIgnore UserVO user) { + iUserPermissionService.getPermissions4Map(mapId, count, user); + } + } diff --git a/src/main/java/club/joylink/rtss/services/GoodsService.java b/src/main/java/club/joylink/rtss/services/GoodsService.java index eca1b719c..56faa3f6e 100644 --- a/src/main/java/club/joylink/rtss/services/GoodsService.java +++ b/src/main/java/club/joylink/rtss/services/GoodsService.java @@ -1,8 +1,5 @@ package club.joylink.rtss.services; -import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import com.github.pagehelper.Page; -import com.github.pagehelper.PageHelper; import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.SaleGoodsTypeEnum; import club.joylink.rtss.constants.StatusEnum; @@ -13,6 +10,7 @@ import club.joylink.rtss.entity.Permission; import club.joylink.rtss.entity.PermissionExample; import club.joylink.rtss.entity.SaleGoods; import club.joylink.rtss.entity.SaleGoodsExample; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.GoodsTryVO; import club.joylink.rtss.vo.client.PageVO; @@ -22,14 +20,19 @@ import club.joylink.rtss.vo.client.goods.GoodsVO; import club.joylink.rtss.vo.client.permission.PermissionQueryVO; import club.joylink.rtss.vo.client.permission.PermissionSelectVO; import club.joylink.rtss.vo.client.permission.PermissionVO; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; -import org.springframework.util.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.time.LocalDateTime; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @Service @@ -151,7 +154,7 @@ public class GoodsService implements IGoodsService { * 如果有权限包但没有对应的商品,返回一个只有permissionId和permissionName的goodsVO */ @Override - public GoodsVO findGoodsByPermissionIds(Long[] relPermissionIds) { + public GoodsVO findGoodsByRelPermissionIds(Long[] relPermissionIds) { List voList = iPermissionService.findPermissionByRelPermissionIds(Arrays.asList(relPermissionIds)); if (voList.isEmpty()) { return null; @@ -238,6 +241,15 @@ public class GoodsService implements IGoodsService { return goods != null; } + @Override + public List getByPermissionIds(List permissionIds) { + SaleGoodsExample example = new SaleGoodsExample(); + example.createCriteria().andPermissionIdIn(permissionIds); + List saleGoods = saleGoodsDAO.selectByExample(example); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(saleGoods); + return saleGoods.stream().map(GoodsVO::new).collect(Collectors.toList()); + } + public SaleGoods findEntity(Long id) { return saleGoodsDAO.selectByPrimaryKey(id); } diff --git a/src/main/java/club/joylink/rtss/services/IGoodsService.java b/src/main/java/club/joylink/rtss/services/IGoodsService.java index 392325b91..c71dac3bb 100644 --- a/src/main/java/club/joylink/rtss/services/IGoodsService.java +++ b/src/main/java/club/joylink/rtss/services/IGoodsService.java @@ -48,7 +48,7 @@ public interface IGoodsService { /** * 通过关联权限ids查询权限包商品 */ - GoodsVO findGoodsByPermissionIds(Long[] relPermissionIds); + GoodsVO findGoodsByRelPermissionIds(Long[] relPermissionIds); PageVO queryPagedGoodsByPermission(PermissionQueryVO queryVO); @@ -65,4 +65,5 @@ public interface IGoodsService { boolean isExist(Long goodsId); + List getByPermissionIds(List permissionIds); } diff --git a/src/main/java/club/joylink/rtss/services/IPermissionService.java b/src/main/java/club/joylink/rtss/services/IPermissionService.java index 5a8f54b92..ad0aeb4ce 100644 --- a/src/main/java/club/joylink/rtss/services/IPermissionService.java +++ b/src/main/java/club/joylink/rtss/services/IPermissionService.java @@ -54,4 +54,6 @@ public interface IPermissionService { * 根据mapId查询教学权限 */ Permission findTeachPermissionEntity(Long mapId); + + List getByMapId(Long mapId); } diff --git a/src/main/java/club/joylink/rtss/services/IUserPermissionService.java b/src/main/java/club/joylink/rtss/services/IUserPermissionService.java index 5c3e45f34..6dd6baeea 100644 --- a/src/main/java/club/joylink/rtss/services/IUserPermissionService.java +++ b/src/main/java/club/joylink/rtss/services/IUserPermissionService.java @@ -87,4 +87,12 @@ public interface IUserPermissionService { * 查询有效的用户教学权限 */ List findEntity(List userIds, Boolean valid); + + /** + * 给该用户领取该地图的权限 + * @param mapId + * @param count + * @param user + */ + void getPermissions4Map(Long mapId, Integer count, UserVO user); } diff --git a/src/main/java/club/joylink/rtss/services/PermissionService.java b/src/main/java/club/joylink/rtss/services/PermissionService.java index 81a05a330..4e2df8b89 100644 --- a/src/main/java/club/joylink/rtss/services/PermissionService.java +++ b/src/main/java/club/joylink/rtss/services/PermissionService.java @@ -459,7 +459,7 @@ public class PermissionService implements IPermissionService { example.createCriteria() .andRelPermissionsEqualTo(ids); List permissionList = permissionDAO.selectByExample(example); - List voList = permissionList.stream().map(permission -> new PermissionVO(permission)).collect(Collectors.toList()); + List voList = permissionList.stream().map(PermissionVO::new).collect(Collectors.toList()); return voList; } @@ -468,8 +468,7 @@ public class PermissionService implements IPermissionService { PermissionExample example = new PermissionExample(); example.createCriteria().andMapIdEqualTo(mapId); List permissionList = permissionDAO.selectByExample(example); - List voList = permissionList.stream().map(permission -> new PermissionVO(permission)).collect(Collectors.toList()); - return voList; + return permissionList.stream().map(PermissionVO::new).collect(Collectors.toList()); } /** @@ -535,6 +534,13 @@ public class PermissionService implements IPermissionService { } } + @Override + public List getByMapId(Long mapId) { + List permissions = findByMapId(mapId); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(permissions, String.format("地图[%s]下没有权限", mapId)); + return permissions; + } + /** * 根据mapId获取该地图下的综合演练权限 */ diff --git a/src/main/java/club/joylink/rtss/services/UserPermissionService.java b/src/main/java/club/joylink/rtss/services/UserPermissionService.java index 0c8459058..df68bdea4 100644 --- a/src/main/java/club/joylink/rtss/services/UserPermissionService.java +++ b/src/main/java/club/joylink/rtss/services/UserPermissionService.java @@ -1,9 +1,6 @@ package club.joylink.rtss.services; -import club.joylink.rtss.constants.MapPrdTypeEnum; -import club.joylink.rtss.constants.PermissionTypeEnum; -import club.joylink.rtss.constants.StatusEnum; -import club.joylink.rtss.constants.UserPermissionStatusEnum; +import club.joylink.rtss.constants.*; import club.joylink.rtss.dao.PermissionDAO; import club.joylink.rtss.dao.SysUserDAO; import club.joylink.rtss.dao.UserPermissionDAO; @@ -13,7 +10,11 @@ import club.joylink.rtss.entity.UserPermission; import club.joylink.rtss.entity.UserPermissionExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.UserVO; +import club.joylink.rtss.vo.client.OrganizationVO; import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.goods.GoodsVO; +import club.joylink.rtss.vo.client.order.OrderCreateVO; +import club.joylink.rtss.vo.client.order.OrderDetailCreateVO; import club.joylink.rtss.vo.client.permission.DistributeSelectVO; import club.joylink.rtss.vo.client.permission.PermissionQueryVO; import club.joylink.rtss.vo.client.permission.PermissionVO; @@ -27,6 +28,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -59,6 +61,9 @@ public class UserPermissionService implements IUserPermissionService { @Autowired private IOrderService iOrderService; + @Autowired + private IOrganizationService iOrganizationService; + @Override public PageVO queryPagedPermission(PermissionQueryVO queryVO) { List relDistributeIds = new ArrayList<>(); @@ -512,6 +517,33 @@ public class UserPermissionService implements IUserPermissionService { return userPermissionDAO.selectByExample(example); } + @Override + public void getPermissions4Map(Long mapId, Integer count, UserVO user) { + if (count == null || count == 0) { + return; + } + List organizations = iOrganizationService.queryOrganization(); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(organizations, "没有组织数据"); + + List permissions = iPermissionService.getByMapId(mapId); + List goods = iGoodsService.getByPermissionIds(permissions.stream().map(PermissionVO::getId).collect(Collectors.toList())); + List orderDetails = goods.stream().map(goodsVO -> new OrderDetailCreateVO(goodsVO.getId(), count)).collect(Collectors.toList()); + + OrderCreateVO orderCreate = new OrderCreateVO(); + orderCreate.setOrganizationId(48L); + orderCreate.setOrderType(SaleOrderTypeEnum.Internal_Distribution.getCode()); + orderCreate.setForever(true); + orderCreate.setStartTime(LocalDateTime.now()); + orderCreate.setPayStatus(SaleOrderPayStatusEnum.No_Need.getCode()); + orderCreate.setDetailCreateVOList(orderDetails); + //创建权限分发并领取权限 + String orderCode = iOrderService.createOrder(orderCreate, user); + iPermissionDistributeService.distributeFromOrder(orderCode, user); + DistributeVO distribute = iPermissionDistributeService.getByOrderCode(orderCode); + Long distributeId = distribute.getId(); + iPermissionDistributeService.getUserPermission(distributeId, user); + } + private List findByUserId(Long userId) { UserPermissionExample example = new UserPermissionExample(); example.createCriteria().andUserIdEqualTo(userId); From 3e11fe642a307969c1626091a77a24881567665f Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Thu, 10 Dec 2020 15:55:41 +0800 Subject: [PATCH 09/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E8=AE=A1=E5=88=92=E5=A4=8D=E5=88=B6=E5=88=B0?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E5=9C=B0=E5=9B=BE=E5=8A=9F=E8=83=BD=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../publish/RunPlanDailyController.java | 6 ++++ .../rtss/services/ILoadPlanService.java | 8 +++++ .../rtss/services/LoadPlanService.java | 35 +++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/main/java/club/joylink/rtss/controller/publish/RunPlanDailyController.java b/src/main/java/club/joylink/rtss/controller/publish/RunPlanDailyController.java index 07298a172..26c891ab9 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/RunPlanDailyController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/RunPlanDailyController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import javax.validation.constraints.NotNull; +import java.util.List; @Api(tags = {"每日运行计划接口"}) @RestController @@ -78,4 +79,9 @@ public class RunPlanDailyController { public RunPlanEChartsDataVO selectDiagramData(@PathVariable Long planId) { return this.iDailyRunPlanService.selectDiagramData(planId); } + + @PostMapping(path = "/{id}/copyToMaps") + public void copyLoadPlanToMaps(@PathVariable Long id, @RequestBody List mapIds) { + this.iLoadPlanService.copyToMaps(id, mapIds); + } } diff --git a/src/main/java/club/joylink/rtss/services/ILoadPlanService.java b/src/main/java/club/joylink/rtss/services/ILoadPlanService.java index bb5e3e25a..5835edcb7 100644 --- a/src/main/java/club/joylink/rtss/services/ILoadPlanService.java +++ b/src/main/java/club/joylink/rtss/services/ILoadPlanService.java @@ -6,6 +6,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanLoadQueryVO; import club.joylink.rtss.vo.client.runplan.RunPlanLoadVO; import java.time.LocalDate; +import java.util.List; /** * 运行图加载计划服务 @@ -77,4 +78,11 @@ public interface ILoadPlanService { RunPlanLoadVO findCommonLoadPlanOfMap(Long mapId); void deleteByTemplateId(Long templateId); + + /** + * 相同线路数据(不同皮肤)运行加载计划及运行图数据拷贝 + * @param id + * @param mapIds + */ + void copyToMaps(Long id, List mapIds); } diff --git a/src/main/java/club/joylink/rtss/services/LoadPlanService.java b/src/main/java/club/joylink/rtss/services/LoadPlanService.java index ae12780d3..53c59bcf2 100644 --- a/src/main/java/club/joylink/rtss/services/LoadPlanService.java +++ b/src/main/java/club/joylink/rtss/services/LoadPlanService.java @@ -1,8 +1,10 @@ package club.joylink.rtss.services; import club.joylink.rtss.dao.RunPlanLoadDAO; +import club.joylink.rtss.dao.RunPlanTemplateDAO; import club.joylink.rtss.entity.RunPlanLoad; import club.joylink.rtss.entity.RunPlanLoadExample; +import club.joylink.rtss.entity.RunPlanTemplate; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; @@ -25,6 +27,9 @@ import java.util.stream.Collectors; @Service public class LoadPlanService implements ILoadPlanService { + @Autowired + private RunPlanTemplateDAO runPlanTemplateDAO; + @Autowired private RunPlanLoadDAO runPlanLoadDAO; @@ -232,4 +237,34 @@ public class LoadPlanService implements ILoadPlanService { .andTemplatePlanIdEqualTo(templateId); this.runPlanLoadDAO.deleteByExample(example); } + + @Transactional + @Override + public void copyToMaps(Long id, List mapIds) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(mapIds); + RunPlanLoad runPlanLoad = this.runPlanLoadDAO.selectByPrimaryKey(id); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanLoad); + Long templatePlanId = runPlanLoad.getTemplatePlanId(); + RunPlanTemplate runPlanTemplate = this.runPlanTemplateDAO.selectByPrimaryKey(templatePlanId); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanTemplate); + for (Long mapId : mapIds) { + if (Objects.equals(mapId, runPlanLoad.getMapId())) { + continue; + } + RunPlanTemplate template = new RunPlanTemplate(); + template.setMapId(mapId); + template.setName(runPlanTemplate.getName()); + template.setCreatorId(runPlanTemplate.getCreatorId()); + template.setCreateTime(runPlanTemplate.getCreateTime()); + template.setStatus(runPlanTemplate.getStatus()); + template.setTrips(runPlanTemplate.getTrips()); + this.runPlanTemplateDAO.insert(template); + Long templateId = template.getId(); + RunPlanLoad loadPlan = new RunPlanLoad(); + loadPlan.setTemplatePlanId(templateId); + loadPlan.setMapId(mapId); + loadPlan.setCreatorId(runPlanLoad.getCreatorId()); + this.runPlanLoadDAO.insert(loadPlan); + } + } } From 6f09c205b0f4af3d9d7d0f4e1a1baa147addf2ed Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Thu, 10 Dec 2020 17:24:10 +0800 Subject: [PATCH 10/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9ATS=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E8=BF=9B=E8=B7=AFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/ATS/service/AtsRouteSettingService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java index 47e6d4fcd..2ca2dcbd8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java @@ -299,6 +299,12 @@ public class AtsRouteSettingService { } } } + } else { + for (Route route : triggerList) { + if (this.isAtsTrigger(simulation, train, route, false, trainList)) { + return route; + } + } } } else { return triggerList.get(0); From 38149a54dc24069b8097ec65d85876edda77f0d5 Mon Sep 17 00:00:00 2001 From: DU Date: Thu, 10 Dec 2020 17:57:13 +0800 Subject: [PATCH 11/23] =?UTF-8?q?=E7=94=9F=E6=88=90=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E5=90=8C=E8=BF=90=E8=90=A5=E8=B7=AF=E7=BA=BF=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/services/RunPlanDraftService.java | 12 +- .../vo/runplan/newdraw/RunPlanGenerator.java | 110 ++++++++++++------ .../vo/runplan/newdraw/RunPlanInputData.java | 17 +-- 3 files changed, 88 insertions(+), 51 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 60af9bedf..9e64db4d8 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -499,10 +499,18 @@ public class RunPlanDraftService implements IRunPlanDraftService { @Override @Transactional - public void generateRunPlanService(Long userId,Long planId, RunPlanInputData inputData) { + public void generateRunPlanService(Long userId, Long planId, RunPlanInputData inputData) { RunPlanVO planVO = getRunPlanById(planId); MapVO mapVO = this.iMapService.getMapDetail(planVO.getMapId()); - List newTripList = runPlanGenerator.generatorTrips(userId,inputData, mapVO); + if (Objects.nonNull(inputData.getDepartureInterval())) { + String max = planVO.getTripList().stream().map(RunPlanTripVO::getServiceNumber).max(Comparator.naturalOrder()).orElse("0"); + // 当前已有最大服务号 + int maxServiceNumber = Integer.parseInt(max); + inputData.setServiceNumber(String.format("%03d", ++maxServiceNumber)); + Integer departureInterval = inputData.getDepartureInterval() < 60 ? 180 : inputData.getDepartureInterval(); + inputData.setDepartureInterval(departureInterval); + } + List newTripList = runPlanGenerator.generatorTrips(userId,inputData,mapVO); BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(CollectionUtils.isEmpty(newTripList),String.format("生成服务号%s运行图数据失败",inputData.getServiceNumber())); planVO.getTripList().addAll(newTripList); RunPlanDraft planDraft = planVO.convert2Draft(); diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java index f8bd30b99..7695a5146 100644 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java @@ -16,17 +16,14 @@ import club.joylink.rtss.vo.runplan.newdraw.mainstack.DrawHarbinRunPlan; import club.joylink.rtss.vo.runplan.newdraw.mainstack.DrawRunPlan; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.time.LocalTime; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -68,8 +65,7 @@ public class RunPlanGenerator { 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), - "发车时间过早,建议晚于上午两点"); + BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(inputData.getBeginTime().isAfter(beginTimeOffset), "发车时间过早,建议晚于上午两点"); inputData.setBeginTime(beginTimeOffset); inputData.setOverTime(inputData.getOverTime().minusHours(OFFSET_TIME_HOURS)); @@ -86,10 +82,6 @@ public class RunPlanGenerator { RunPlanRoutingVO running2Routing = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), inputData.getRunningRouting2()); //构建环路 和 出入库关系 - //出库关联某环路 - RunPlanRoutingVO outboundRefRunningRouting = null; - //回库关联某环路 - RunPlanRoutingVO inboundRefRunningRouting = null; //验证 出库和入库 一端折返轨 一段转换轨,验证环路 两端折返轨 ,环路是否闭环 或出入库跟环路是否衔接 boolean isLoop = running1Routing.getParkSectionCodeList().get(0).getStationCode().equals(running2Routing.getParkSectionCodeList().get(running2Routing.getParkSectionCodeList().size() - 1).getStationCode()) @@ -98,24 +90,32 @@ public class RunPlanGenerator { 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()); - if (outToRun1) { - outboundRefRunningRouting = running1Routing; - } else if (outToRun2) { - outboundRefRunningRouting = running2Routing; - } else { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("出库交路 无法与环路交路相接"); - } 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()); - if (inToRun1) { - inboundRefRunningRouting = running1Routing; - } else if (inToRun2) { - inboundRefRunningRouting = running2Routing; + + //出库关联环路某交楼 + 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 { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("出库交路 无法与环路交路相接"); } - //查站间运行等级 List levels = runPlanRunlevelService.queryUserRunLevels(userId, mapVO.getId()); Map runLevelMap = levels.stream().collect(Collectors.toMap(runLevelVO -> String.format("%s-%s", runLevelVO.getStartSectionCode(), runLevelVO.getEndSectionCode()), runLevelVO -> runLevelVO.getLevelTime(inputData.getRunLevel()))); @@ -132,11 +132,29 @@ public class RunPlanGenerator { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("折返轨未设置"); } - LinkedList tripList = new LinkedList<>(); + List 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() * 2).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 runLevelMap, Map parkTimeMap, Map userReentryData, List tripList, ServiceTempResult serviceResult) { + LinkedList serviceTripList = new LinkedList<>(); int initTripNumber = 1; - TempResult temp = new TempResult(initTripNumber, inputData.getBeginTime()); + TripTempResult temp = new TripTempResult(initTripNumber, inputData.getBeginTime()); //构建出库车次 - buildServiceTrips(inputData.getServiceNumber(), mapVO, outboundRouting, true, runLevelMap, parkTimeMap, userReentryData, tripList, temp); + buildServiceTrips(inputData.getServiceNumber(), mapVO, outboundRouting, true, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + //计算出库车次运行所需时间 int size = inboundRouting.getParkSectionCodeList().size(); int inboundTripRunTime = 40; @@ -150,23 +168,32 @@ public class RunPlanGenerator { //构建环路车次 boolean loop = false; while (temp.getLastStationDepartTime().plusSeconds(80 + inboundTripRunTime).isBefore(inputData.getOverTime())) { - buildServiceTrips(inputData.getServiceNumber(), mapVO, outboundRefRunningRouting, null, runLevelMap, parkTimeMap, userReentryData, tripList, temp); - if (!loop && outboundRefRunningRouting == inboundRefRunningRouting) { - loop = true; - continue; + if (same) { + if (!loop) { + buildServiceTrips(inputData.getServiceNumber(), mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + loop = true; + } else { + buildServiceTrips(inputData.getServiceNumber(), mapVO, other, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + buildServiceTrips(inputData.getServiceNumber(), mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + } } else { - buildServiceTrips(inputData.getServiceNumber(), mapVO, inboundRefRunningRouting, null, runLevelMap, parkTimeMap, userReentryData, tripList, temp); - loop = false; + buildServiceTrips(inputData.getServiceNumber(), mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + buildServiceTrips(inputData.getServiceNumber(), mapVO, other, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); } } //构建回库计划 - buildServiceTrips(inputData.getServiceNumber(), mapVO, inboundRouting, false, runLevelMap, parkTimeMap, userReentryData, tripList, temp); - return tripList; + buildServiceTrips(inputData.getServiceNumber(), 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(String serviceNumber, MapVO mapVO, RunPlanRoutingVO routing, Boolean outbound, Map runLevelMap, Map parkTimeMap, Map userReentryData, - LinkedList tripList, TempResult tempResult) { + LinkedList tripList, TripTempResult tempResult) { String startReentrySectionCode = userReentryData.get(routing.getStartStationCode()); String endReentrySectionCode = userReentryData.get(routing.getEndStationCode()); MapSectionNewVO endReentrySection = null; @@ -199,7 +226,7 @@ public class RunPlanGenerator { tempResult.getLastStationDepartTime() : (CollectionUtils.isEmpty(tripTimeList) ? (Objects.equals(tripList.getLast().getEndSectionCode(), runPlanTripTimeVO.getSectionCode()) ? - tripList.getLast().getStartTime() : tempResult.getLastStationDepartTime().plusSeconds(80)) : tempResult.getLastStationDepartTime().plusSeconds(runLevelMap.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode())))); + tripList.getLast().getEndTime() : tempResult.getLastStationDepartTime().plusSeconds(80)) : 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); @@ -250,7 +277,7 @@ public class RunPlanGenerator { @Getter @Setter @AllArgsConstructor - private class TempResult { + private class TripTempResult { private int tripNumber; private LocalTime lastStationDepartTime; @@ -259,6 +286,15 @@ public class RunPlanGenerator { } } + @Getter + @Setter + @AllArgsConstructor + @NoArgsConstructor + private class ServiceTempResult { + private LocalTime preServiceDepartTime; + private LocalTime firstRoundTripTime; + } + private DrawRunPlan drawRunPlanOf(int runLevel, MapVO mapVO) { DrawRunPlan drawRunPlan; switch (mapVO.getLineCode()) { diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java index a2c07d3d0..0fc4ecff6 100644 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java @@ -7,6 +7,7 @@ import lombok.Getter; import lombok.Setter; import org.springframework.util.StringUtils; +import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; @@ -18,10 +19,8 @@ import java.time.LocalTime; public class RunPlanInputData { @ApiModelProperty(value = "表号") - @NotBlank private String serviceNumber; - /**出库交路code*/ @ApiModelProperty(value = "出库交路code") @NotBlank(message= "出库交路不能为空") @@ -31,8 +30,7 @@ public class RunPlanInputData { @NotBlank(message= "入库交路不能为空") private String inboundRouting; - /**运行环路*/ - + /*运行环路*/ /**环路1-运行交路code*/ @ApiModelProperty(value = "运行交路code") @NotBlank(message= "环路不能为空") @@ -52,14 +50,9 @@ public class RunPlanInputData { @NotNull(message = "结束时间不能为空") private LocalTime overTime; -// /**折返时间*/ -// @ApiModelProperty(value = "折返时间") -// private int reentryTime = 150; - -// /**发车间隔,s*/ -// @ApiModelProperty(value = "发车间隔,s") -// @Positive -// private int departureInterval = 180 ; + /**发车间隔,s*/ + @ApiModelProperty(value = "发车间隔,s") + private Integer departureInterval ; /**运行等级默认-站间运行时间*/ private int runLevel = 3; From c6fff223122b3823634ec0b14810bfcd59423ec2 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Thu, 10 Dec 2020 18:17:10 +0800 Subject: [PATCH 12/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=89=E7=BB=B4?= =?UTF-8?q?=E7=AB=99=E5=8F=B0TDT=E7=8A=B6=E6=80=81=E6=94=B6=E9=9B=86?= =?UTF-8?q?=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/SimulationMainThread.java | 1 + .../Joylink3DMessageService.java | 27 ++++++++ .../cbtc/data/SimulationDataRepository.java | 21 ++++++ .../simulation/cbtc/data/vo/TdtStatusVO.java | 66 +++++++++++++++++++ .../rtss/vo/client/WebSocketMessageType.java | 2 + .../client/factory/SocketMessageFactory.java | 14 ++-- 6 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TdtStatusVO.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java index 386ba5802..82bf1ad8a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java @@ -412,6 +412,7 @@ public class SimulationMainThread { } case MESSAGE_3D: { this.joylink3DMessageService.collectAndSendTrainHmiDisplayMessage(simulation); + this.joylink3DMessageService.tdtStatusCollectAndSend(simulation); break; } case TRAIN_POSITION_3D: { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java index 05b2990b2..2f2f039e5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java @@ -7,7 +7,9 @@ import club.joylink.rtss.simulation.cbtc.communication.vo.*; import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; +import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.status.TrainStatus; +import club.joylink.rtss.simulation.cbtc.data.vo.TdtStatusVO; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; @@ -57,6 +59,29 @@ public class Joylink3DMessageService { } } + public void tdtStatusCollectAndSend(Simulation simulation) { + List list = new ArrayList<>(); + SimulationDataRepository repository = simulation.getRepository(); + for (Stand stand : repository.getStandList()) { + if (!stand.isSmall()) { + TdtStatusVO statusVO = repository.queryTdtStatus(stand.getCode()); + if (Objects.isNull(statusVO)) { + statusVO = new TdtStatusVO(stand); + repository.addTdtStatus(statusVO); + list.add(statusVO); + } else { + if (statusVO.compareAndChange(stand)) { + list.add(statusVO); + } + } + TdtStatusVO tdtStatusVO = new TdtStatusVO(stand); + list.add(tdtStatusVO); + } + } + SocketMessageVO message = SocketMessageFactory.buildTrainIsAbout2ArriveMessage(simulation.getGroup(), list); + this.stompMessageService.sendToUser(simulation.getSimulationUserIds(), message); + } + /** * 构建并发送列车状态信息 * @@ -305,4 +330,6 @@ public class Joylink3DMessageService { Set users = simulation.getSimulationUserIds(); this.collectAndSend3DInitDeviceList(simulation, users); } + + } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java index c230d2f9e..e5c8de1b6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java @@ -9,6 +9,7 @@ import club.joylink.rtss.simulation.cbtc.data.status.IbpStatus; import club.joylink.rtss.simulation.cbtc.data.status.TrainStatus; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; +import club.joylink.rtss.simulation.cbtc.data.vo.TdtStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; @@ -77,6 +78,13 @@ public class SimulationDataRepository { */ private Map trainHmiMap = new ConcurrentHashMap<>(); + /** + * TDT(train depart timer)状态数据 + * key-站台code + * val-tdt状态对象 + */ + private Map tdtStatusMap = new ConcurrentHashMap<>(); + /** * ATS监控的列车信息map * key-车组号 @@ -643,6 +651,7 @@ public class SimulationDataRepository { // 清空设备状态 this.deviceInfoMap.clear(); this.trainHmiMap.clear(); + this.tdtStatusMap.clear(); } /** @@ -904,6 +913,18 @@ public class SimulationDataRepository { this.trainHmiMap.remove(code); } + public TdtStatusVO queryTdtStatus(String code) { + return this.tdtStatusMap.get(code); + } + + public void addTdtStatus(TdtStatusVO tdtStatusVO) { + this.tdtStatusMap.put(tdtStatusVO.getStandCode(), tdtStatusVO); + } + + public void removeTdtStatus(String code) { + this.tdtStatusMap.remove(code); + } + /** * 获取该车站某个方向的相邻车站 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TdtStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TdtStatusVO.java new file mode 100644 index 000000000..1d878acba --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TdtStatusVO.java @@ -0,0 +1,66 @@ +package club.joylink.rtss.simulation.cbtc.data.vo; + +import club.joylink.rtss.simulation.cbtc.data.map.Stand; +import lombok.Getter; +import lombok.Setter; + +import java.util.Objects; + +@Getter +@Setter +public class TdtStatusVO { + /** + * 站台code + */ + private String standCode; + /** + * 是否扣车 + */ + private boolean hold; + /** + * 是否跳停 + */ + private boolean jump; + /** + * 倒计时剩余时间 + */ + private int remain; + /** + * 是否有停靠列车 + */ + private boolean parking; + + public TdtStatusVO(Stand stand) { + this.standCode = stand.getCode(); + boolean trainParking = stand.isTrainParking(); + this.parking = trainParking; + if (trainParking) { + this.remain = stand.getRemainTime() / 1000; + } + this.hold = stand.isHoldTrain(); + this.jump = stand.isJumpStop(); + } + + public boolean compareAndChange(Stand stand) { + boolean change = false; + boolean trainParking = stand.isTrainParking(); + if (!Objects.equals(this.parking, trainParking)) { + change = true; + this.parking = trainParking; + } + int remainTime = stand.getRemainTime() / 1000; + if (trainParking && !Objects.equals(this.remain, remainTime)) { + change = true; + this.remain = remainTime; + } + if (!Objects.equals(this.jump, stand.isJumpStop())) { + change = true; + this.jump = stand.isJumpStop(); + } + if (!Objects.equals(this.hold, stand.isHoldTrain())) { + change = true; + this.hold = stand.isHoldTrain(); + } + return change; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java index 9b7e931af..79338105c 100644 --- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java +++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java @@ -141,6 +141,8 @@ public enum WebSocketMessageType { DeviceCtrl_3D, /** 列车即将进站消息 */ BeAbout2Arrive_3D, + /** 列车即将进站消息 */ + TDT_3D, /** 3D设备故障设置消息 */ Device_Fault_Set_3D, /** 3D设备故障解决消息 */ diff --git a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java index 65bff510c..2b2593011 100644 --- a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java +++ b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java @@ -6,10 +6,7 @@ import club.joylink.rtss.simulation.cbtc.communication.vo.TrainPosition; import club.joylink.rtss.simulation.cbtc.conversation.Conversation; import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage; import club.joylink.rtss.simulation.cbtc.data.status.IbpStatus; -import club.joylink.rtss.simulation.cbtc.data.vo.ConversationSocketMessageVO; -import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO; -import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO; -import club.joylink.rtss.simulation.cbtc.data.vo.TrainIsAbout2ArriveVO; +import club.joylink.rtss.simulation.cbtc.data.vo.*; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationUser; import club.joylink.rtss.vo.client.SocketMessageVO; @@ -139,6 +136,7 @@ public class SocketMessageFactory { } case Device_Load_Destroy_3D: case DeviceCtrl_3D: + case TDT_3D: case BeAbout2Arrive_3D: { topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group)); topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group)); @@ -320,6 +318,14 @@ public class SocketMessageFactory { return build(WebSocketMessageType.BeAbout2Arrive_3D, group, arriveVO); } + /** + * 构建列车即将到站消息 + * @return + */ + public static SocketMessageVO> buildTrainIsAbout2ArriveMessage(String group, List list) { + return build(WebSocketMessageType.TDT_3D, group, list); + } + /** * 构建VR同步消息 */ From 5e0b04251172a9368ab793a629615ff061f2fb17 Mon Sep 17 00:00:00 2001 From: DU Date: Thu, 10 Dec 2020 18:46:16 +0800 Subject: [PATCH 13/23] =?UTF-8?q?=E7=94=9F=E6=88=90=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=8A=98=E8=BF=94=E6=97=B6=E9=97=B4=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/runplan/newdraw/RunPlanGenerator.java | 40 +++++++++---------- .../vo/runplan/newdraw/RunPlanInputData.java | 4 ++ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java index 7695a5146..62edfd20e 100644 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java @@ -153,11 +153,11 @@ public class RunPlanGenerator { int initTripNumber = 1; TripTempResult temp = new TripTempResult(initTripNumber, inputData.getBeginTime()); //构建出库车次 - buildServiceTrips(inputData.getServiceNumber(), mapVO, outboundRouting, true, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + buildServiceTrips(inputData, mapVO, outboundRouting, true, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); //计算出库车次运行所需时间 int size = inboundRouting.getParkSectionCodeList().size(); - int inboundTripRunTime = 40; + 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); @@ -167,22 +167,22 @@ public class RunPlanGenerator { } //构建环路车次 boolean loop = false; - while (temp.getLastStationDepartTime().plusSeconds(80 + inboundTripRunTime).isBefore(inputData.getOverTime())) { + while (temp.getLastStationDepartTime().plusSeconds(inputData.getReentryTime() + inboundTripRunTime).isBefore(inputData.getOverTime())) { if (same) { if (!loop) { - buildServiceTrips(inputData.getServiceNumber(), mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + buildServiceTrips(inputData, mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); loop = true; } else { - buildServiceTrips(inputData.getServiceNumber(), mapVO, other, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); - buildServiceTrips(inputData.getServiceNumber(), mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + buildServiceTrips(inputData, mapVO, other, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + buildServiceTrips(inputData, mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); } } else { - buildServiceTrips(inputData.getServiceNumber(), mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); - buildServiceTrips(inputData.getServiceNumber(), mapVO, other, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + buildServiceTrips(inputData, mapVO, outRef, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + buildServiceTrips(inputData, mapVO, other, null, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); } } //构建回库计划 - buildServiceTrips(inputData.getServiceNumber(), mapVO, inboundRouting, false, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); + buildServiceTrips(inputData, mapVO, inboundRouting, false, runLevelMap, parkTimeMap, userReentryData, serviceTripList, temp); if (Objects.isNull(serviceResult.getFirstRoundTripTime())) { serviceResult.setFirstRoundTripTime(serviceTripList.get(1).getEndTime()); @@ -191,7 +191,7 @@ public class RunPlanGenerator { tripList.addAll(serviceTripList); } - private void buildServiceTrips(String serviceNumber, MapVO mapVO, RunPlanRoutingVO routing, Boolean outbound, + private void buildServiceTrips(RunPlanInputData inputData, MapVO mapVO, RunPlanRoutingVO routing, Boolean outbound, Map runLevelMap, Map parkTimeMap, Map userReentryData, LinkedList tripList, TripTempResult tempResult) { String startReentrySectionCode = userReentryData.get(routing.getStartStationCode()); @@ -206,7 +206,7 @@ public class RunPlanGenerator { } RunPlanTripVO tripVO = new RunPlanTripVO(routing, startReentrySection, endReentrySection); setDirectionCode(mapVO, tripVO); - tripVO.setServiceNumber(serviceNumber); + tripVO.setServiceNumber(inputData.getServiceNumber()); tripVO.setTripNumber(tripVO.getDirectionCode() + String.format("%03d", tempResult.getTripNumber())); tripVO.setIsReentry(true); if (Objects.nonNull(outbound)) { @@ -226,13 +226,13 @@ public class RunPlanGenerator { tempResult.getLastStationDepartTime() : (CollectionUtils.isEmpty(tripTimeList) ? (Objects.equals(tripList.getLast().getEndSectionCode(), runPlanTripTimeVO.getSectionCode()) ? - tripList.getLast().getEndTime() : tempResult.getLastStationDepartTime().plusSeconds(80)) : tempResult.getLastStationDepartTime().plusSeconds(runLevelMap.get(tripTimeList.getLast().getSectionCode() + "-" + 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); - setTripRunTime(tripVO, tripTimeList); + setTripTerminalTime(tripVO, tripTimeList, inputData.getReentryTime()); tripList.add(tripVO); tempResult.incrementTripNumber(); } @@ -253,24 +253,24 @@ public class RunPlanGenerator { } } - private void setTripRunTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList) { - setTripStartTime(runPlanTripVO, tripTimeList); - setTripEndTime(runPlanTripVO, tripTimeList); + private void setTripTerminalTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList, int reentryTime) { + setTripStartTime(runPlanTripVO, tripTimeList, reentryTime); + setTripEndTime(runPlanTripVO, tripTimeList, reentryTime); } - private void setTripEndTime(RunPlanTripVO lastRunPlanTrip, LinkedList tripTimeList) { + private void setTripEndTime(RunPlanTripVO lastRunPlanTrip, LinkedList tripTimeList, int reentryTime) { if (Objects.equals(lastRunPlanTrip.getEndSectionCode(), tripTimeList.getLast().getSectionCode())) { lastRunPlanTrip.setEndTime(tripTimeList.getLast().getDepartureTime()); } else { - lastRunPlanTrip.setEndTime(tripTimeList.getLast().getDepartureTime().plusSeconds(40)); + lastRunPlanTrip.setEndTime(tripTimeList.getLast().getDepartureTime().plusSeconds(reentryTime / 2)); } } - private void setTripStartTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList) { + private void setTripStartTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList, int reentryTime) { if (Objects.equals(runPlanTripVO.getStartSectionCode(), tripTimeList.getFirst().getSectionCode())) { runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime()); } else { - runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime().minusSeconds(40)); + runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime().minusSeconds(reentryTime / 2)); } } diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java index 0fc4ecff6..547c646d5 100644 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInputData.java @@ -54,6 +54,10 @@ public class RunPlanInputData { @ApiModelProperty(value = "发车间隔,s") private Integer departureInterval ; + /**折返时间*/ + @ApiModelProperty(value = "折返时间") + private int reentryTime = 80; + /**运行等级默认-站间运行时间*/ private int runLevel = 3; From c40fea801021dab722b4011a5995aca66ede9174 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Fri, 11 Dec 2020 09:12:10 +0800 Subject: [PATCH 14/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/constants/Project.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/club/joylink/rtss/constants/Project.java b/src/main/java/club/joylink/rtss/constants/Project.java index f4463b6c6..8b5ddd977 100644 --- a/src/main/java/club/joylink/rtss/constants/Project.java +++ b/src/main/java/club/joylink/rtss/constants/Project.java @@ -8,10 +8,16 @@ public enum Project { DEFAULT, /** 西铁院定制项目 */ XTY, - /** 南铁院定制项目 */ + /** 南铁院项目 */ NTY, - /** 西安地铁定制项目 */ + /** 南铁院云端定制项目 */ + NTYC, + /** 南铁院本地定制项目 */ + NTYL, + /** 西安地铁运营公司项目 */ XADT, + /** 苏州电子信息学院项目 */ + SDY, /** 贵州装备职业学院项目 */ GZB, /** 哈尔滨项目 */ From dbe2f834320d3c902d2669cc29f829593ea32af9 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 11 Dec 2020 09:55:15 +0800 Subject: [PATCH 15/23] =?UTF-8?q?=E8=81=94=E9=94=81=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=B7=BB=E5=8A=A0<=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E5=9C=B0=E7=A0=81=E7=94=9F=E6=88=90>=EF=BC=8C=E5=8E=BB?= =?UTF-8?q?=E6=8E=89<=E4=BA=A4=E8=B7=AF=E6=95=B0=E6=8D=AE=E7=94=9F?= =?UTF-8?q?=E6=88=90>=EF=BC=9B=E5=A4=B4=E7=A0=81=E8=BD=A6=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=85=BC=E5=AE=B9=E6=96=B0=E7=9B=AE=E7=9A=84=E5=9C=B0?= =?UTF-8?q?=E7=A0=81=E6=95=B0=E6=8D=AE=EF=BC=9B=E5=89=A7=E6=9C=AC=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=B7=BB=E5=8A=A0=E5=A4=B4=E7=A0=81=E8=BD=A6=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=EF=BC=9B<=E7=AD=9B=E9=80=89=E5=A4=B4=E7=A0=81?= =?UTF-8?q?=E8=BD=A6=E9=9C=80=E8=A6=81=E6=8E=92=E5=88=97=E7=9A=84=E8=BF=9B?= =?UTF-8?q?=E8=B7=AF>=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9=EF=BC=9B=E9=80=BB=E8=BE=91=E6=B3=A8?= =?UTF-8?q?=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DraftMapCiDataGeneratorImpl.java | 14 +- .../ATS/service/AtsRouteSettingService.java | 6 +- .../cbtc/ATS/service/AtsTrainService.java | 432 ++++++++++-------- .../cbtc/GroupSimulationService.java | 7 +- .../cbtc/GroupSimulationServiceImpl.java | 5 + .../cbtc/build/InterlockBuilder2.java | 50 +- .../cbtc/data/CalculateService.java | 166 +++++-- .../StorageSimulationDataRepository.java | 2 +- .../data/storage/vo/StorageTrainInfo.java | 15 +- .../simulation/cbtc/data/vo/TrainInfo.java | 46 +- .../message/UserSimulationStatsManager.java | 5 +- 11 files changed, 468 insertions(+), 280 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index 756e8fd88..aab41ce71 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -116,7 +116,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { List stationRunLevelList; public CiGenerateResult(List errMsgList, List approachList, List autoSignalList, List routeList, - List overlapList, List generateCycleList, List routingList, + List overlapList, List generateCycleList, /*List routingList,*/ List stationRunLevelList, List destinationCodeDefinitionList) { this.errMsgList = errMsgList; this.approachList = approachList; @@ -125,14 +125,14 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { this.overlapList = overlapList; this.cycleList = generateCycleList; this.destinationCodeDefinitionList = destinationCodeDefinitionList; - this.routingList = routingList; +// this.routingList = routingList; this.stationRunLevelList = stationRunLevelList; log.info(String.format("生成信号机接近区段数据[%s]条", approachList.size())); log.info(String.format("生成进路数据总计[%s]条", routeList.size())); log.info(String.format("生成延续保护数据[%s]条", overlapList.size())); log.info(String.format("生成自动信号数据[%s]条", autoSignalList.size())); log.info(String.format("生成自动折返数据[%s]条", generateCycleList.size())); - log.info(String.format("生成交路数据[%s]条", routingList.size())); +// log.info(String.format("生成交路数据[%s]条", routingList.size())); log.info(String.format("生成站间运行数据[%s]条", stationRunLevelList.size())); } @@ -142,7 +142,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { resultVO.setOverlapCount(this.overlapList.size()); resultVO.setCycleCount(this.cycleList.size()); resultVO.setAutoSignalCount(this.autoSignalList.size()); - resultVO.setRoutingCount(this.routingList.size()); +// resultVO.setRoutingCount(this.routingList.size()); resultVO.setStationRunlevelCount(this.stationRunLevelList.size()); resultVO.setDestinationCodeDefinitionCount(this.destinationCodeDefinitionList.size()); return resultVO; @@ -249,8 +249,8 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { autoSignal.getSignal().setAutoSignal(autoSignal); } - // 生成交路数据 - List generateRoutingList = this.generateRoutings(deviceMap, generatedRouteList, autoSignalList, errorList); +// // 生成交路数据 +// List generateRoutingList = this.generateRoutings(deviceMap, generatedRouteList, autoSignalList, errorList); // // 获取所有转换轨或者折返轨 @@ -323,7 +323,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { return new CiGenerateResult(errorList, approachList, autoSignalList, generatedRouteList, generatedOverlapList, - generateCycleList, generateRoutingList, generatedStationRunLevelList, destinationCodeDefinitionList); + generateCycleList, generatedStationRunLevelList, destinationCodeDefinitionList); } private Collection generateRouteLikeHa1(Signal signal, CodeGenerator routeCodeGenerator, diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java index 47e6d4fcd..238517f97 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java @@ -88,6 +88,10 @@ public class AtsRouteSettingService { Signal neededSignal = signal; List routePaths = new ArrayList<>(); if (Objects.nonNull(destDefinition)) { + // 如果已经到达目的地,返回 + if (Objects.equals(headSection, destDefinition.getSection())) { + return null; + } // 目的地定义存在,根据目的地定义查询路径,办理进路 // 判断是否终点站折返办理 if (train.isParking() && destDefinition.isLoop()) { // 列车停车,且目的地为环路运营 @@ -118,7 +122,7 @@ public class AtsRouteSettingService { Section eaStandSection = repository.getByCode(train.getEstimatedArriveStandTrack(), Section.class); List paths = repository.queryRoutePathsByEnd(eaStandSection); for (RoutePath path : paths) { - if (path.containsSection(headSection)) { + if (path.containsSection(headSection) && path.isRight() == right) { routePaths.add(path); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java index 28e1a08aa..1f673f4d7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.ATS.service; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.constant.TrainType; @@ -23,10 +24,7 @@ import org.springframework.util.CollectionUtils; import java.time.LocalTime; import java.time.temporal.ChronoUnit; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import java.util.*; /** * ATS列车服务 @@ -178,11 +176,11 @@ public class AtsTrainService { throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, String.format("不存在追踪的列车[%s]", groupNumber)); } - if (supervisedTrain.isPlanTrain()) { - if (!CollectionUtils.isEmpty(simulation.getRepository().getDestinationMap())) { - return; - } - } +// if (supervisedTrain.isPlanTrain()) { +// if (!CollectionUtils.isEmpty(simulation.getRepository().getDestinationMap())) { +// return; +// } +// } // Section targetSection = repository.querySectionByDestCode(destinationCode); // if (Objects.isNull(targetSection)) { // throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, @@ -196,17 +194,30 @@ public class AtsTrainService { */ private void setDestinationCode(Simulation simulation, String groupNumber, String serviceNumber, String tripNumber, String destinationCode, SimulationDataRepository repository, TrainInfo supervisedTrain) { + Boolean right = supervisedTrain.getRight(); + Section headSection = repository.getByCode(supervisedTrain.getNotNullPhysicalSection(), Section.class); Map destinationMap = repository.getDestinationMap(); - Section targetSection = repository.getByCode(supervisedTrain.getEstimatedArriveStandTrack(), Section.class); - Station targetStation = targetSection.getStation(); +// Section targetSection = repository.getByCode(supervisedTrain.getEstimatedArriveStandTrack(), Section.class); +// Station targetStation = targetSection.getStation(); if (!CollectionUtils.isEmpty(destinationMap)) { //有新版目的地码数据 DestinationCodeDefinition destinationCodeDefinition = destinationMap.get(destinationCode); if (destinationCodeDefinition == null) { throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("目的地码[%s]不存在", destinationCode)); } + Section destinationSection = destinationCodeDefinition.getSection(); + Section targetSection = null; + Station targetStation = null; + String estimatedArriveStandTrack = supervisedTrain.getEstimatedArriveStandTrack(); + if (estimatedArriveStandTrack != null) { + targetSection = repository.getByCode(estimatedArriveStandTrack, Section.class); + targetStation = targetSection.getStation(); + } + boolean stop = supervisedTrain.isStop(); switch (destinationCodeDefinition.getType()) { - case NORMAL_OPERATION: + case NORMAL_OPERATION: { + BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(targetStation, + String.format("列车[%s]目标区段为null", supervisedTrain.getGroupNumber())); Station leftStation = destinationCodeDefinition.getLeftStation(); Station rightStation = destinationCodeDefinition.getRightStation(); boolean beyondStationRage = @@ -223,28 +234,78 @@ public class AtsTrainService { } } break; + } case LAST_OPERATION: case NON_OPERATION: - case LAST_NON_OPERATION: - Boolean trainRight = supervisedTrain.getRight(); - if (trainRight == null) { + case LAST_NON_OPERATION: { + if (right == null) { throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("列车[%s]方向未知", groupNumber)); } + BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(targetSection, + String.format("列车[%s]目标区段为null", supervisedTrain.getGroupNumber())); Boolean destinationRight = destinationCodeDefinition.getRight(); - if (!targetSection.isTurnBackTrack() || !supervisedTrain.isStop()) { - if (!Objects.equals(trainRight, destinationRight)) { + if (!targetSection.isTurnBackTrack() || !stop) { + if (!Objects.equals(right, destinationRight)) { throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("列车方向与目的地码[%s]的方向相反", destinationCode)); } } - Station station = destinationCodeDefinition.getSection().getStation(); + Station station = destinationSection.getStation(); if ((destinationRight && targetStation.getSn() > station.getSn()) || (!destinationRight && targetStation.getSn() < station.getSn())) { throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("列车目标轨道[%s]超出目的地码[%s]的范围", targetSection, destinationCode)); } break; + } + case OTHER: + Set> pathSet = CalculateService.querySectionPaths2Destination(headSection, destinationSection, right, stop); + BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(pathSet, + String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode())); + //从找到的路径中筛选出最短路径 + List
path = null; + if (pathSet.size() == 1) { + path = pathSet.stream().findAny().get(); + } else if (pathSet.size() > 1) { + Optional> pathOptional = pathSet.stream() + .min(Comparator.comparingDouble(availablePath -> availablePath.stream().mapToDouble(Section::getLen).sum())); + path = pathOptional.get(); + } + BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(path, + String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode())); + supervisedTrain.setHeadPath(path); + //根据找到的路径更新目标区段--- + Section nextTarget = null; + int index = path.indexOf(headSection); + if (index == -1) + break; + for (int i = index; i < path.size(); i++) { + Section section = path.get(i); + if (section.isSpecialSection() + && supervisedTrain.isNotArriveAt(repository, new SectionPosition(section, section.getStopPointByDirection(right)))) { + List routePaths = repository.queryRoutePathsByEnd(section); + if (routePaths.stream().anyMatch(rp -> rp.containsSection(headSection))) { + nextTarget = section; + break; + } + } + } + if (nextTarget == null) { + nextTarget = path.get(path.size() - 1); + } + if (nextTarget.getCode().equals(estimatedArriveStandTrack)) { + break; + } + MapStationRunLevelVO runLevel = simulation.getBuildParams().getMap().getRunLevelByStartAndEndSection(estimatedArriveStandTrack, nextTarget.getCode()); + int runningTime = 0; + if (runLevel != null) { + runningTime = runLevel.getL3(); + } + supervisedTrain.updateEstimatedArriveInfo(nextTarget, simulation.getSystemTime().plusSeconds(runningTime).toLocalTime()); + this.onboardAtpApiService.updateNextStation(simulation, supervisedTrain.getGroupNumber(), + nextTarget.getStation().getCode(), nextTarget.getCode(), runningTime, true); + break; default: throw new SimulationException(SimulationExceptionType.System_Fault, String.format("无法识别的目的地码类型[%s]", destinationCodeDefinition.getType())); } @@ -312,11 +373,18 @@ public class AtsTrainService { Boolean trainRight = train.getRight(); TrainType type = train.getType(); String estimatedArriveStandTrack = train.getEstimatedArriveStandTrack(); - if (Objects.isNull(estimatedArriveStandTrack)) { - return; + Section targetSection = null; + Station targetStation = null; + if (estimatedArriveStandTrack != null) { + targetSection = repository.getByCode(estimatedArriveStandTrack, Section.class); + targetStation = targetSection.getStation(); } - Section targetSection = repository.getByCode(estimatedArriveStandTrack, Section.class); - Station targetStation = targetSection.getStation(); +// String estimatedArriveStandTrack = train.getEstimatedArriveStandTrack(); +// if (Objects.isNull(estimatedArriveStandTrack)) { +// return; +// } +// Section targetSection = repository.getByCode(estimatedArriveStandTrack, Section.class); +// Station targetStation = targetSection.getStation(); boolean stop = train.isStop(); Section nextTarget = null; long runningTime = 0; @@ -391,69 +459,6 @@ public class AtsTrainService { } break; } - /*case HEAD: { - if (train.isParking() && !stop) { - // 站台停站状态取消 - this.atsStandService.trainLeaveStand(headSection); - // 更新列车实际离开信息 - train.updateLeaveInfo(headSection, systemTime); - } - //目的地码更新条件检查 - Map destinationMap = repository.getDestinationMap(); - String destinationCode = train.getDestinationCode(); - if (!headTrainTargetUpdateConditionCheck(destinationMap, destinationCode, trainRight, stop, headSection, targetSection)) { - return; - } - //根据目的地码类型更新目标区段 - DestinationCodeDefinition destinationCodeDefinition = destinationMap.get(destinationCode); - switch (destinationCodeDefinition.getType()) { - case NORMAL_OPERATION: - if (destinationCodeDefinition.isBorder(targetStation)) { - //--- 需要站后折返 - boolean normalStandTrack = targetSection.isNormalStandTrack(); - if (!normalStandTrack) { - break; - } - boolean standOfTargetSectionIsRight = targetStation.isStandOfSectionRight(targetSection); - Station station = destinationCodeDefinition.getStationOf(standOfTargetSectionIsRight); - if (station.equals(targetStation)) { - List
parkSections = targetStation.getParkSectionListBy(!standOfTargetSectionIsRight); - Optional
normalSection = parkSections.stream().filter(Section::isNormalStandTrack).limit(1).findFirst(); - if (normalSection.isPresent()) - nextTarget = normalSection.get(); - train.startTurnBack(nextTarget); - this.onboardAtpApiService.startTurnBack(simulation, train.getGroupNumber(), - nextTarget.getCode()); - } - } else if (相邻车站是边界车站) { - if (需要站前折返) { - - } - } else { - 找相邻车站 - } - - - - break; - case LAST_OPERATION: - case NON_OPERATION: - case LAST_NON_OPERATION: - if (已经抵达或越过运行路径最后一个区段) { - if (有直达终点区段的进路路径) { - - } - } else { - if (相邻车站有位于运行路径上的站台轨) { - - } - } - break; - } - if (目标区段还没找到 && 并且相邻车站有值) { - - } - }*/ case HEAD: { if (train.isParking() && !stop) { // 站台停站状态取消 @@ -465,138 +470,163 @@ public class AtsTrainService { Map destinationMap = repository.getDestinationMap(); String destinationCode = train.getDestinationCode(); if (!CollectionUtils.isEmpty(destinationMap)) { //有目的地码定义数据 -// if (!this.targetUpdateConditionCheckOfNewDestination(destinationMap, destinationCode, trainRight, stop, headSection, targetSection)) { -// break; -// } - if (stop && (headSection.isTurnBackTrack() || headSection.isTransferTrack() || headSection.isStandTrack())) { - DestinationCodeDefinition destinationCodeDefinition = destinationMap.get(destinationCode); - if (destinationCodeDefinition == null) { - log.warn("目的地码[{}]没有数据", destinationCode); + if (!stop) + break; + if (trainRight == null) + break; + DestinationCodeDefinition destinationCodeDefinition = destinationMap.get(destinationCode); + if (destinationCodeDefinition == null) { + log.warn("目的地码[{}]没有数据", destinationCode); + break; + } + if (Objects.equals(destinationCodeDefinition.getSection(), headSection)) + break; + Section destinationSection = destinationCodeDefinition.getSection(); + Boolean destinationRight = destinationCodeDefinition.getRight(); + switch (destinationCodeDefinition.getType()) { + case NORMAL_OPERATION: { + if (Objects.isNull(estimatedArriveStandTrack)) { + return; + } + + Station leftStation = destinationCodeDefinition.getLeftStation(); + Station rightStation = destinationCodeDefinition.getRightStation(); + if (Math.min(leftStation.getSn(), rightStation.getSn()) > targetStation.getSn() + || targetStation.getSn() > Math.max(leftStation.getSn(), rightStation.getSn())) { //超出环路范围 + log.warn(String.format("仿真[%s]列车[%s]目标轨不在环路范围内", simulation.getGroup(), train.getGroupNumber())); + break; + } + Station station = destinationCodeDefinition.getStationOf(trainRight); + if (Objects.equals(station.getSn(), targetStation.getSn())) { //已经抵达同向边界车站 + if (targetSection.isNormalStandTrack()) { //如果是在站台轨,并开始折返 + List
turnBackList = targetStation.getTurnBackList(); + if (!CollectionUtils.isEmpty(turnBackList)) { + nextTarget = turnBackList.get(0); + // 站后折返 + train.startTurnBack(nextTarget); + // 开始折返 + this.onboardAtpApiService.startTurnBack(simulation, train.getGroupNumber(), + nextTarget.getCode()); + break; + } + } + } else { //未抵达同向边界车站 + Station adjacentStation = repository.findAdjacentStation(targetStation, trainRight); + Optional first; + if ((adjacentStation.equals(leftStation) + || adjacentStation.equals(rightStation)) + && destinationCodeDefinition.isFrontTurnBack(adjacentStation)) { //相邻站是环路的边界车站且是站前折返 + first = adjacentStation.getStandOf(!trainRight).stream().filter(stand -> !stand.isSmall()).limit(1).findFirst(); + } else { + first = adjacentStation.getStandOf(trainRight).stream().filter(stand -> !stand.isSmall()).limit(1).findFirst(); + } + if (first.isPresent()) { + nextTarget = first.get().getSection(); + } else { + log.warn(String.format("地图[%s]车站[%s]所有站台都是小站台", mapId, adjacentStation.getCode())); + } + } + if (targetSection.isTurnBackTrack()) { //如果是在折返轨,选择能到达的站台 + for (Stand stand : targetStation.getAllStandList()) { + Section section = stand.getSection(); + if (!CollectionUtils.isEmpty(repository.queryRoutePaths(targetSection, section))) { + nextTarget = section; + break; + } + } + } break; } - if (Objects.equals(destinationCodeDefinition.getSection(), headSection)) { - break; - } - if (!Objects.equals(targetSection, headSection)) { - break; - } - //-------------------- 列车停在目标轨 -------------------- - if (trainRight == null) { - break; - } - switch (destinationCodeDefinition.getType()) { - case NORMAL_OPERATION: - Station leftStation = destinationCodeDefinition.getLeftStation(); - Station rightStation = destinationCodeDefinition.getRightStation(); - if (Math.min(leftStation.getSn(), rightStation.getSn()) > targetStation.getSn() - || targetStation.getSn() > Math.max(leftStation.getSn(), rightStation.getSn())) { //超出环路范围 - log.warn(String.format("仿真[%s]列车[%s]目标轨不在环路范围内", simulation.getGroup(), train.getGroupNumber())); + case LAST_OPERATION: + case NON_OPERATION: + case LAST_NON_OPERATION: + if (Objects.isNull(estimatedArriveStandTrack)) { + return; + } + if (!targetSection.isTurnBackTrack()) { + if (!Objects.equals(trainRight, destinationRight)) { + log.warn(String.format("仿真[%s]列车[%s]目标轨方向和目的地码方向不同", simulation.getGroup(), train.getGroupNumber())); break; } - Station station = destinationCodeDefinition.getStationOf(trainRight); - if (Objects.equals(station.getSn(), targetStation.getSn())) { //已经抵达同向边界车站 - if (targetSection.isNormalStandTrack()) { //如果是在站台轨,并开始折返 - List
turnBackList = targetStation.getTurnBackList(); - if (!CollectionUtils.isEmpty(turnBackList)) { - nextTarget = turnBackList.get(0); - // 站后折返 - train.startTurnBack(nextTarget); - // 开始折返 - this.onboardAtpApiService.startTurnBack(simulation, train.getGroupNumber(), - nextTarget.getCode()); + //如果列车目标轨已经超出目的地码的对应区段 + if (trainRight) { + if (targetStation.getSn() >= destinationSection.getStation().getSn()) { + break; + } + } else { + if (targetStation.getSn() <= destinationSection.getStation().getSn()) { + break; + } + } + } + //-------------------------- 找下一目标轨 -------------------------- + Station adjacentStation = repository.findAdjacentStation(targetStation, destinationRight); + Section lastRunPathSection = destinationCodeDefinition.getLastSectionFromRunPath(); + //---运行路径最后一个区段存在,且列车没有越过时:找相邻车站并注意路径--- + if (lastRunPathSection != null) { + Station lastStationOnPath = lastRunPathSection.getStation(); + //如果列车目标车站没有到达/越过目的地码运行路径的最后一个车站 + if ((destinationRight && targetStation.getSn() < lastStationOnPath.getSn()) + || (!destinationRight && targetStation.getSn() > lastStationOnPath.getSn())) { + if (adjacentStation == null) { + break; + } + for (Stand stand : adjacentStation.getAllStandList()) { + if (destinationCodeDefinition.isOnThePath(stand.getSection())) { + nextTarget = stand.getSection(); break; } } - } else { //未抵达同向边界车站 - Station adjacentStation = repository.findAdjacentStation(targetStation, trainRight); - Optional first; - if ((adjacentStation.equals(leftStation) - || adjacentStation.equals(rightStation)) - && destinationCodeDefinition.isFrontTurnBack(adjacentStation)) { //相邻站是环路的边界车站且是站前折返 - first = adjacentStation.getStandOf(!trainRight).stream().filter(stand -> !stand.isSmall()).limit(1).findFirst(); - } else { - first = adjacentStation.getStandOf(trainRight).stream().filter(stand -> !stand.isSmall()).limit(1).findFirst(); - } - if (first.isPresent()) { - nextTarget = first.get().getSection(); - } else { - log.warn(String.format("地图[%s]车站[%s]所有站台都是小站台", mapId, adjacentStation.getCode())); - } } - if (targetSection.isTurnBackTrack()) { //如果是在折返轨,选择能到达的站台 - for (Stand stand : targetStation.getAllStandList()) { - Section section = stand.getSection(); - if (!CollectionUtils.isEmpty(repository.queryRoutePaths(targetSection, section))) { + } + //尝试找到直达终点的路径 + if (!CollectionUtils.isEmpty(repository.queryRoutePaths(targetSection, destinationSection))) { + nextTarget = destinationSection; + break; + } + //找到相邻车站的同向站台轨 + for (Stand stand : adjacentStation.getStandOf(destinationRight)) { + if (!stand.isSmall()) { + nextTarget = stand.getSection(); + break; + } + } + break; + case OTHER: + List
path = train.getHeadPath(); + if (path != null) { + int index = path.indexOf(headSection); + if (index == -1) { + break; + } + for (int i = index; i < path.size(); i++) { + Section section = path.get(i); + if (section.isSpecialSection() + && train.isNotArriveAt(repository, new SectionPosition(section, section.getStopPointByDirection(trainRight)))) { + List routePaths = repository.queryRoutePathsByEnd(section); + if (routePaths.stream().anyMatch(rp -> rp.containsSection(headSection))) { nextTarget = section; break; } } } - break; - case LAST_OPERATION: - case NON_OPERATION: - case LAST_NON_OPERATION: - Section destinationSection = destinationCodeDefinition.getSection(); - Boolean destinationRight = destinationCodeDefinition.getRight(); - if (!targetSection.isTurnBackTrack()) { - if (!Objects.equals(trainRight, destinationRight)) { - log.warn(String.format("仿真[%s]列车[%s]目标轨方向和目的地码方向不同", simulation.getGroup(), train.getGroupNumber())); - break; - } - //如果列车目标轨已经超出目的地码的对应区段 - if (trainRight) { - if (targetStation.getSn() >= destinationSection.getStation().getSn()) { - break; - } - } else { - if (targetStation.getSn() <= destinationSection.getStation().getSn()) { - break; - } - } + if (nextTarget == null) { + nextTarget = path.get(path.size() - 1); } - //-------------------------- 找下一目标轨 -------------------------- - Station adjacentStation = repository.findAdjacentStation(targetStation, destinationRight); - Section lastRunPathSection = destinationCodeDefinition.getLastSectionFromRunPath(); - //---运行路径最后一个区段存在,且列车没有越过时:找相邻车站并注意路径--- - if (lastRunPathSection != null) { - Station lastStationOnPath = lastRunPathSection.getStation(); - //如果列车目标车站没有到达/越过目的地码运行路径的最后一个车站 - if ((destinationRight && targetStation.getSn() < lastStationOnPath.getSn()) - || (!destinationRight && targetStation.getSn() > lastStationOnPath.getSn())) { - if (adjacentStation == null) { - break; - } - for (Stand stand : adjacentStation.getAllStandList()) { - if (destinationCodeDefinition.isOnThePath(stand.getSection())) { - nextTarget = stand.getSection(); - break; - } - } - } - } - //尝试找到直达终点的路径 - if (!CollectionUtils.isEmpty(repository.queryRoutePaths(targetSection, destinationSection))) { - nextTarget = destinationSection; - break; - } - //找到相邻车站的同向站台轨 - for (Stand stand : adjacentStation.getStandOf(destinationRight)) { - if (!stand.isSmall()) { - nextTarget = stand.getSection(); - break; - } - } - break; - } - if (nextTarget != null) { - MapStationRunLevelVO runLevel = simulation.getBuildParams().getMap().getRunLevelByStartAndEndSection(targetSection.getCode(), nextTarget.getCode()); - if (runLevel != null) { - runningTime = runLevel.getL3(); } - train.updateEstimatedArriveInfo(nextTarget, simulation.getSystemTime().plusSeconds(runningTime).toLocalTime()); - this.onboardAtpApiService.updateNextStation(simulation, train.getGroupNumber(), - nextTarget.getStation().getCode(), nextTarget.getCode(), runningTime, true); + break; + } + if (nextTarget != null) { + if (nextTarget.getCode().equals(estimatedArriveStandTrack)) { + return; } + MapStationRunLevelVO runLevel = simulation.getBuildParams().getMap().getRunLevelByStartAndEndSection(estimatedArriveStandTrack, nextTarget.getCode()); + if (runLevel != null) { + runningTime = runLevel.getL3(); + } + train.updateEstimatedArriveInfo(nextTarget, simulation.getSystemTime().plusSeconds(runningTime).toLocalTime()); + this.onboardAtpApiService.updateNextStation(simulation, train.getGroupNumber(), + nextTarget.getStation().getCode(), nextTarget.getCode(), runningTime, true); } } else { //没有目的地码定义数据 Section prePassed = null; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java index 15b08ce92..5c1050d88 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc; +import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; import club.joylink.rtss.simulation.cbtc.command.CommandInitiateVO; import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo; @@ -8,7 +9,6 @@ import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationUser; import club.joylink.rtss.simulation.cbtc.script.ScriptBO; -import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.fault.FaultRuleVO; @@ -315,4 +315,9 @@ public interface GroupSimulationService { * @param userVO */ void alarmConfirm(String group, List codes, UserVO userVO); + + /** + * 查询仿真 + */ + Simulation findSimulationByGroup(String group); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java index 5014dcd80..e81b87427 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -908,4 +908,9 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { .forEach(atsAlarm -> atsAlarm.confirm(userVO, simulation.getCorrectSystemTime())); this.applicationContext.publishEvent(new SimulationAlarmConfirmEvent(this, simulation, codes)); } + + @Override + public Simulation findSimulationByGroup(String group) { + return groupSimulationCache.findSimulationByGroup(group); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java index 9c3e69f70..c56bd4888 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java @@ -414,8 +414,8 @@ public class InterlockBuilder2 { checkBetweenRouteSameDirectionSignal(elementMap, errMsgList); // ------------交路start------------- - List routingList = checkAndBuildRouting(logicData.getRoutingList(), elementMap, errMsgList); - mapDataBuildResult.setRoutingList(routingList); +// List routingList = checkAndBuildRouting(logicData.getRoutingList(), elementMap, errMsgList); +// mapDataBuildResult.setRoutingList(routingList); // ------------交路end------------- // ------------站间运行等级start------------- @@ -424,31 +424,31 @@ public class InterlockBuilder2 { // ------------站间运行等级end------------- // ------------目的地码start------------- -// checkAndBuildDestinationCodeDefinition(elementMap, logicData.getDestinationCodeDefinitionList(), mapDataBuildResult.getDestinationMap(), errMsgList); + checkAndBuildDestinationCodeDefinition(elementMap, logicData.getDestinationCodeDefinitionList(), mapDataBuildResult.getDestinationMap(), errMsgList); // ------------目的地码end------------- - // 交路的经过区段校验 - for (Routing routing : routingList) { - List
viaSectionList = routing.getViaSectionList(); - for (int i = 1; i < viaSectionList.size(); i++) { - Section start = viaSectionList.get(i - 1); - Section end = viaSectionList.get(i); - boolean find = false; - for (StationRunLevel stationRunLevel : stationRunLevelList) { - if (Objects.equals(start, stationRunLevel.getStartSection()) && - Objects.equals(end, stationRunLevel.getEndSection())) { - find = true; - break; - } - } - if (!find) { - log.warn(String.format("交路[%s]中,从区段[%s(%s)]-区段[%s(%s)]的站间运行等级数据不存在", - routing.getName(), - start.getName(), start.getCode(), - end.getName(), end.getCode())); - } - } - } +// // 交路的经过区段校验 +// for (Routing routing : routingList) { +// List
viaSectionList = routing.getViaSectionList(); +// for (int i = 1; i < viaSectionList.size(); i++) { +// Section start = viaSectionList.get(i - 1); +// Section end = viaSectionList.get(i); +// boolean find = false; +// for (StationRunLevel stationRunLevel : stationRunLevelList) { +// if (Objects.equals(start, stationRunLevel.getStartSection()) && +// Objects.equals(end, stationRunLevel.getEndSection())) { +// find = true; +// break; +// } +// } +// if (!find) { +// log.warn(String.format("交路[%s]中,从区段[%s(%s)]-区段[%s(%s)]的站间运行等级数据不存在", +// routing.getName(), +// start.getName(), start.getCode(), +// end.getName(), end.getCode())); +// } +// } +// } // 根据站间运行等级数据构建路径单元 if (!errMsgList.isEmpty()) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java index 6f9ff0082..94edbb6d8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; @@ -7,10 +8,12 @@ import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import lombok.Getter; +import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.util.CollectionUtils; import java.util.*; +import java.util.stream.Collectors; @Slf4j public class CalculateService { @@ -57,11 +60,6 @@ public class CalculateService { /** * 根据开始位置、方向、距离计算到达的位置(不会超出正线轨道范围,不会冲过位置不合适道岔) - * - * @param startPosition - * @param right - * @param len - * @return */ public static SectionPosition calculateNextPositionByStartAndLen(SectionPosition startPosition, boolean right, float len) { @@ -75,11 +73,6 @@ public class CalculateService { /** * 计算起点到终点的距离(双方向)(有正负) - * - * @param startPosition - * @param endPosition - * @param right 正方向是否是右 - * @return */ public static Float calculateDistanceDoubleDirection(SectionPosition startPosition, SectionPosition endPosition, boolean right) { Float distance = calculateDistance(startPosition, endPosition, right); @@ -91,11 +84,6 @@ public class CalculateService { /** * 计算从起点到终点距离(单方向) - * - * @param startPosition - * @param endPosition - * @param right - * @return */ public static Float calculateDistance(SectionPosition startPosition, SectionPosition endPosition, boolean right) { // long start = System.currentTimeMillis(); @@ -241,12 +229,6 @@ public class CalculateService { /** * 递归计算起始区段到目标区段之间的距离 - * - * @param startSection 起始区段-站台轨/转换轨/折返轨 - * @param endSection 目标区段-站台轨/转换轨/折返轨 - * @param isRight 是否向右 - * @param frequency 递归频率1~51,不超过50次防止栈溢出,且不做过大站间数据设置,如果存在超大站间设置或有超过50个中间区段再修改此处 - * @return */ private static Float recursiveCalculate(Section startSection, Section endSection, boolean isRight, byte frequency) { if (startSection.equals(endSection)) { @@ -312,8 +294,6 @@ public class CalculateService { /** * 不包含起始区段的长度,未考虑出库或者折返、左右向停车点及列车长度 - * - * @return if is null:目标方向上找不到对应的区段 */ public static Float calculateDistance(Section startSection, Section endSection, boolean isRight) { byte frequency = 51; @@ -518,11 +498,6 @@ public class CalculateService { /** * 获取列车占用物理区段列表 - * - * @param headPosition - * @param tailPosition - * @param right - * @return */ public static List
getTrainOccupySection(SectionPosition headPosition, SectionPosition tailPosition, @@ -638,11 +613,6 @@ public class CalculateService { /** * 区段front是否区段base前方区段 - * - * @param base 基础区段 - * @param right 方向 - * @param front 前方区段 - * @return */ public static boolean isTargetSectionOnDirectionExist(Section base, boolean right, Section front) { Objects.requireNonNull(base); @@ -745,6 +715,129 @@ public class CalculateService { } } + /** + * 查找从startSection到destination的途径区段路径 + */ + public static Set> querySectionPaths2Destination(@NonNull Section startSection, @NonNull Section destination, + @NonNull Boolean right, @NonNull boolean stop) { + long start = System.currentTimeMillis(); + //从startSection开始寻找第一个同向信号机(如果是折返轨,两边的信号机都算),并记录途径区段 + List signals = new ArrayList<>(); + List
sections = new ArrayList<>(); //找到第一个同向信号机途径的区段 + Section section = startSection; + //如果已经停在折返轨,如果有已经/正在办理的进路,只要有进路办理那边的信号机,否则两边都要 + if (startSection.isTurnBackTrack() && stop) { //如果停在折返轨 + sections.add(startSection); + Signal signal1 = startSection.getSignalOf(right); + Signal signal2 = startSection.getSignalOf(!right); + BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(signal1 != null || signal2 != null, + String.format("折返轨[%s]两边都没有信号机", startSection.getCode())); + if (signal1 == null || signal2 == null) { //如果有一边信号机没有 + signals.add(signal1 != null ? signal1 : signal2); + } else { + List routeList1 = signal1.getRouteList(); + List routeList2 = signal2.getRouteList(); + BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(!CollectionUtils.isEmpty(routeList1) || !CollectionUtils.isEmpty(routeList2), + String.format("信号机[%s][%s]都没有进路", signal1.getCode(), signal2.getCode())); + if (CollectionUtils.isEmpty(routeList1) || CollectionUtils.isEmpty(routeList2)) { //如果有一边的信号机没有进路 + signals.add(!CollectionUtils.isEmpty(routeList1) ? signal1 : signal2); + } else { + boolean routes1HasSetting = routeList1.stream().anyMatch(route -> route.isLock() || route.isSetting()); + boolean routes2HasSetting = routeList2.stream().anyMatch(route -> route.isLock() || route.isSetting()); + if (routes1HasSetting || routes2HasSetting) { //如果有一边的信号机有进路排列 + signals.add(routes1HasSetting ? signal1 : signal2); + } else { //如果两边信号机都没有进路排列 + signals.add(signal1); + signals.add(signal2); + } + } + } + } else { + for (int i = 0; i < 10; i++) { + sections.add(section); + if (section.equals(destination)) { //在找第一个同向信号机的过程中找到目标区段 + Set> pathSet = new HashSet<>(); + pathSet.add(sections); + return pathSet; + } + Signal signal = section.getSignalOf(right); + if (signal != null) { + signals.add(signal); + break; + } + section = section.getNextRunningSectionOf(right); + if (section == null) { + return null; + } + } + if (CollectionUtils.isEmpty(signals)) { + log.warn(String.format("从区段[%s]向[%s]找10个区段,没有找到同向信号机", startSection.getCode(), right ? "右" : "左")); + return null; + } + } + //从同向信号机找进路,通过进路找目标区段,并且记录途径区段 + Set> pathSet = null; + for (Signal signal : signals) { + pathSet = findPath2DestinationAndRecordSections(destination, signal, sections, null); + if (!CollectionUtils.isEmpty(pathSet)) + break; + } + System.out.println(String.format("路径查找用时:%s", System.currentTimeMillis() - start)); + return pathSet; + } + + /** + * 从signal找到destination的进路,并记录途径区段 + * (用来找到某目的地码的路径) + * @param destination 目的地码对应的区段 + * @param followSettingRoute 是否要沿着已经/正在排列的进路找路径 + */ + private static Set> findPath2DestinationAndRecordSections(@NonNull Section destination, @NonNull Signal signal, + @NonNull List
sections, Boolean followSettingRoute) { + Set> pathSet = new HashSet<>(); + List routeList = signal.getRouteList(); + if (routeList == null) { + return pathSet; + } + boolean signalRight = signal.isRight(); + if (followSettingRoute == null || followSettingRoute) { + //如果信号机的进路中有已经锁闭或者正在排列的,从已经排列的进路找起 + List settingRoutes = routeList.stream().filter(route -> route.isLock() || route.isSetting()).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(settingRoutes)) { + routeList = settingRoutes; + followSettingRoute = true; + } else { + followSettingRoute = false; + } + } + //通过进路,递归寻找路径 + for (Route route : routeList) { + List
newSections = new ArrayList<>(sections); + boolean end = false; //当前路径是否结束 + for (Section section : route.getSectionList()) { + if (!section.isTurnBackTrack() && !section.isTransferTrack()) { //非折返轨和转换轨 + List standList = section.getStandList(); + if (!CollectionUtils.isEmpty(standList)) { + if (standList.stream().allMatch(stand -> stand.isRight() != signalRight)) { //区段关联站台都和信号机方向不一致 + end = true; + break; + } + } + } + newSections.add(section); + if (section.equals(destination)) { + pathSet.add(newSections); + end = true; + break; + } + } + if (!end) { + pathSet.addAll(findPath2DestinationAndRecordSections(destination, route.getDestination(), newSections, followSettingRoute)); + } + } + return pathSet; + } + /** * 计算下一个停车点的位置 */ @@ -781,9 +874,6 @@ public class CalculateService { /** * 追加长度的列车位置 - * - * @param train - * @param append 追加的长度 */ public TrainPositionInfo(VirtualRealityTrain train, float append) { this.headPosition = train.getHeadPosition(); @@ -795,10 +885,6 @@ public class CalculateService { /** * 两车碰撞检查 - * - * @param train1 - * @param train2 - * @return */ public static boolean isTrainPositionCollision(TrainPositionInfo train1, TrainPositionInfo train2) { // 计算车一占压的区段 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/StorageSimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/StorageSimulationDataRepository.java index 18594fa60..00415de26 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/StorageSimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/StorageSimulationDataRepository.java @@ -377,7 +377,7 @@ public class StorageSimulationDataRepository { //恢复ATS监控列车信息map if (Objects.nonNull(this.trainInfoList)) { for (StorageTrainInfo info : this.trainInfoList) { - repository.addTrainInfo(new TrainInfo(info)); + repository.addTrainInfo(info.convert2SimulationObj(repository)); } } // 使用中的列车恢复 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vo/StorageTrainInfo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vo/StorageTrainInfo.java index a60e29c8a..000c1a382 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vo/StorageTrainInfo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vo/StorageTrainInfo.java @@ -3,12 +3,17 @@ package club.joylink.rtss.simulation.cbtc.data.storage.vo; import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.constant.RunLevel; import club.joylink.rtss.simulation.cbtc.constant.TrainType; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.springframework.util.CollectionUtils; import java.time.LocalTime; +import java.util.List; +import java.util.stream.Collectors; @Getter @Setter @@ -105,6 +110,9 @@ public class StorageTrainInfo { /**备用车*/ private boolean backUp; + /** 头码车的路径 */ + private List headPath; + public StorageTrainInfo(TrainInfo info) { this.code = info.getCode(); this.groupNumber = info.getGroupNumber(); @@ -140,9 +148,12 @@ public class StorageTrainInfo { this.actualLeaveStandTrack = info.getActualLeaveStandTrack(); this.actualLeaveTime = info.getActualLeaveTime(); this.backUp = info.isBackUp(); + if (!CollectionUtils.isEmpty(info.getHeadPath())) { + this.headPath = info.getHeadPath().stream().map(MapElement::getCode).collect(Collectors.toList()); + } } - public TrainInfo convert2SimulationObj() { - return new TrainInfo(this); + public TrainInfo convert2SimulationObj(SimulationDataRepository repository) { + return new TrainInfo(this, repository); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java index 89a02fd86..e2db59f15 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java @@ -1,6 +1,9 @@ package club.joylink.rtss.simulation.cbtc.data.vo; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.constant.*; +import club.joylink.rtss.simulation.cbtc.data.CalculateService; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; @@ -10,11 +13,14 @@ import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; +import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalTime; +import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * ATS追踪的列车信息 @@ -136,6 +142,10 @@ public class TrainInfo extends MapElement { /**备用车*/ private boolean backUp; + /** 头码车的区段路径 */ + @Setter + private List
headPath; + public TrainInfo(String groupNumber) { super(groupNumber, DeviceType.TRAIN); this.groupNumber = groupNumber; @@ -157,7 +167,7 @@ public class TrainInfo extends MapElement { this.tripNumber = train.getTripNumber(); } - public TrainInfo(StorageTrainInfo info) { + public TrainInfo(StorageTrainInfo info, SimulationDataRepository repository) { this(info.getCode()); this.type = info.getType(); this.serviceNumber = info.getServiceNumber(); @@ -192,6 +202,9 @@ public class TrainInfo extends MapElement { this.actualLeaveStandTrack = info.getActualLeaveStandTrack(); this.actualLeaveTime = info.getActualLeaveTime(); this.backUp = info.isBackUp(); + if (!CollectionUtils.isEmpty(info.getHeadPath())) { + this.headPath = info.getHeadPath().stream().map(code -> repository.getByCode(code, Section.class)).collect(Collectors.toList()); + } } @Override @@ -388,4 +401,35 @@ public class TrainInfo extends MapElement { public String debugStr() { return String.format("%s", groupNumber); } + + /** + * 获取physicalSection并确保它不是null + */ + public String getNotNullPhysicalSection(){ + BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(physicalSection, String.format("列车[%s]所在物理区段为空", groupNumber)); + return physicalSection; + } + + /** + * 列车是否已经停在或超出目标位置(考虑误差) + */ + public boolean isNotArriveAt(SimulationDataRepository repository, SectionPosition targetPosition) { + //判断是否超出目标位置 + if (physicalSection == null) + return false; + boolean right = this.right; + boolean stop = isStop(); + Section headSection = repository.getByCode(physicalSection, Section.class); + float offset = headSection.getLen() * offsetp; + SectionPosition headPosition = new SectionPosition(headSection, offset); + SectionPosition max = CalculateService.calculateNextPositionByStartAndLen(targetPosition, + right, SimulationConstants.PARK_POINT_MAX_OFFSET); + SectionPosition min = CalculateService.calculateNextPositionByStartAndLen(targetPosition, + !right, SimulationConstants.PARK_POINT_MAX_OFFSET); + if (stop) { + return min.isAheadOf(headPosition, right); + } else { + return max.isAheadOf(headPosition, right); + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java index e654fc0cd..66a9eec0e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java @@ -70,7 +70,10 @@ public class UserSimulationStatsManager { * 用户将仿真所有订阅退订,则仿真使用记录暂停 */ public void unsubscribeAll(Long userId, String group) { - Simulation simulation = groupSimulationService.getSimulationByGroup(group); + Simulation simulation = groupSimulationService.findSimulationByGroup(group); + if (simulation == null) { + return; + } if (simulation.isScriptMakingSimulation() || simulation.isScriptPreviewSimulation()) { return; } From 5c41dae39b31822061422eaf5cdd3fb3a3695f2e Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 11 Dec 2020 09:58:49 +0800 Subject: [PATCH 16/23] =?UTF-8?q?<=E5=8F=91=E5=B8=83=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=BA=BF=E8=B7=AF=E6=9F=A5=E8=AF=A2=E6=97=A0?= =?UTF-8?q?=E6=95=88>bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/services/MapService.java | 3 +++ src/main/java/club/joylink/rtss/vo/client/MapQueryVO.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/club/joylink/rtss/services/MapService.java b/src/main/java/club/joylink/rtss/services/MapService.java index 1f5484797..49ae19bc6 100644 --- a/src/main/java/club/joylink/rtss/services/MapService.java +++ b/src/main/java/club/joylink/rtss/services/MapService.java @@ -189,6 +189,9 @@ public class MapService implements IMapService { if (StringUtils.hasText(queryVO.getCityCode())) { criteria.andCityCodeEqualTo(queryVO.getCityCode()); } + if (StringUtils.hasText(queryVO.getLineCode())) { + criteria.andLineCodeEqualTo(queryVO.getLineCode()); + } Page page = (Page) mapInfoDAO.selectByExample(example); List mapVOS = MapVO.convert2VOList(page.getResult()); return PageVO.convert(page, mapVOS); diff --git a/src/main/java/club/joylink/rtss/vo/client/MapQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/MapQueryVO.java index 408868d02..68abac662 100644 --- a/src/main/java/club/joylink/rtss/vo/client/MapQueryVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/MapQueryVO.java @@ -24,4 +24,6 @@ public class MapQueryVO extends PageQueryVO { */ @NotBlank(message="所属城市不能为空", groups= {DraftMapCreateCheck.class}) private String cityCode; + + private String lineCode; } From eaf72d9b54a5b386cbfd7889f054ab42f35f4450 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 11 Dec 2020 10:32:41 +0800 Subject: [PATCH 17/23] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E5=9B=BE=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E8=AE=A1=E5=88=92=E5=8F=AA=E6=9F=A5=E6=9C=89=E6=95=88?= =?UTF-8?q?=E7=9A=84=E5=9C=B0=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/services/LoadPlanService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/club/joylink/rtss/services/LoadPlanService.java b/src/main/java/club/joylink/rtss/services/LoadPlanService.java index 53c59bcf2..d8c4daa40 100644 --- a/src/main/java/club/joylink/rtss/services/LoadPlanService.java +++ b/src/main/java/club/joylink/rtss/services/LoadPlanService.java @@ -145,6 +145,9 @@ public class LoadPlanService implements ILoadPlanService { } if (Objects.nonNull(queryVO.getMapId())) { loadExampleCriteria.andMapIdEqualTo(queryVO.getMapId()); + } else { + List onlineMapIds = iMapService.queryOnlineMapInfos().stream().map(MapVO::getId).collect(Collectors.toList()); + loadExampleCriteria.andMapIdIn(onlineMapIds); } if(Objects.nonNull(queryVO.getTemplatePlanId())) { loadExampleCriteria.andTemplatePlanIdEqualTo(queryVO.getTemplatePlanId()); From 3cd7d4f58dc4f457f23b1a544ebcaf220d60ffe6 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 11 Dec 2020 11:07:48 +0800 Subject: [PATCH 18/23] =?UTF-8?q?=E8=81=94=E9=94=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E8=BF=9B=E8=B7=AFbug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/services/draftData/DraftMapCiDataGeneratorImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index aab41ce71..583e37fc2 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -453,7 +453,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { clickEnd = this.queryNearlySignalOf(start, sectionPath); } // 构建进路 - if (config.isRouteApartByOverlap() && overlapList.size() > 1) { + if (config.isRouteApartByOverlap() && overlapList != null && overlapList.size() > 1) { int index = 1; for (RouteOverlap routeOverlap : overlapList) { String code = routeCodeGenerator.next(); From 9911d0e109c2418b7c2ac80d9ea5a25725ff08c0 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 11 Dec 2020 13:37:38 +0800 Subject: [PATCH 19/23] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E5=9B=BE=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E8=AE=A1=E5=88=92=E6=9F=A5=E8=AF=A2bug=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/services/LoadPlanService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/services/LoadPlanService.java b/src/main/java/club/joylink/rtss/services/LoadPlanService.java index d8c4daa40..1ae3f91a6 100644 --- a/src/main/java/club/joylink/rtss/services/LoadPlanService.java +++ b/src/main/java/club/joylink/rtss/services/LoadPlanService.java @@ -136,7 +136,7 @@ public class LoadPlanService implements ILoadPlanService { @Override public PageVO queryPagedLoadPlan(RunPlanLoadQueryVO queryVO) { RunPlanLoadExample runPlanLoadExample = new RunPlanLoadExample(); - runPlanLoadExample.setOrderByClause(" load_time DESC"); + runPlanLoadExample.setOrderByClause(" load_time DESC, id"); RunPlanLoadExample.Criteria loadExampleCriteria = runPlanLoadExample.createCriteria(); if (Objects.nonNull(queryVO.getUserId())) { loadExampleCriteria.andUserIdEqualTo(queryVO.getUserId()); From ba2d75c0c04446fcaee585315d57eaab4b3e6aa8 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 11 Dec 2020 15:31:45 +0800 Subject: [PATCH 20/23] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/service/AtsRouteSettingService.java | 9 +++++++++ .../joylink/rtss/simulation/cbtc/data/map/MapConfig.java | 6 ++++++ .../joylink/rtss/vo/client/map/RealLineConfigVO.java | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java index 9057390ef..947833fd1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java @@ -20,6 +20,7 @@ import org.springframework.util.CollectionUtils; import java.time.LocalDateTime; import java.util.*; +import java.util.stream.Collectors; @Slf4j @Component @@ -35,6 +36,14 @@ public class AtsRouteSettingService { //根据一定规则清除掉冲突进路 this.filterConflictTrainRouteByPlanTime(simulation, waitSetList); + //如果进路区段有占用时不排列进路,筛选出没有区段占用的进路 + if (simulation.getRepository().getConfig().isDoNotSetRouteWhenSectionOccupied()) { + waitSetList = waitSetList.stream().filter(trainRoute -> { + Route route = trainRoute.getRoute(); + return route.getSectionList().stream().noneMatch(section -> section.isCtOccupied() || section.isNctOccupied()); + }).collect(Collectors.toList()); + } + // 执行进路排列 for (TrainRoute trainRoute : waitSetList) { Route route = trainRoute.getRoute(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java index f00ebf26c..866ae18e4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java @@ -131,6 +131,11 @@ public class MapConfig { */ private float urmAtpSpeed; + /** + * 当进路的区段占用时不排列进路 + */ + private boolean doNotSetRouteWhenSectionOccupied; + private Set needConfirmConnectMembers = Stream.of(DISPATCHER, STATION_SUPERVISOR, MAINTAINER, ELECTRIC_DISPATCHER).collect(Collectors.toSet()); @@ -158,6 +163,7 @@ public class MapConfig { setParkingSM(configVO.getParkingSM()); setRmAtpSpeed(configVO.getRmAtpSpeed() / 3.6f); setUrmAtpSpeed(configVO.getUrmAtpSpeed() / 3.6f); + setDoNotSetRouteWhenSectionOccupied(configVO.isDoNotSetRouteWhenSectionOccupied()); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/map/RealLineConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/map/RealLineConfigVO.java index ae8998aed..8e9a68d11 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/RealLineConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/RealLineConfigVO.java @@ -70,6 +70,11 @@ public class RealLineConfigVO { */ private boolean initSingleLockSwitch = false; + /** + * 当进路的区段占用时不排列进路 + */ + private boolean doNotSetRouteWhenSectionOccupied = false; + public static RealLineConfigVO parseJsonStr(String configData) { if (StringUtils.hasText(configData)) { return JsonUtils.read(configData, RealLineConfigVO.class); From ea90bc3d8b404a7d0558540a1744ecab89aeb2cf Mon Sep 17 00:00:00 2001 From: DU Date: Fri, 11 Dec 2020 15:33:16 +0800 Subject: [PATCH 21/23] =?UTF-8?q?=E9=80=9A=E7=94=A8=E5=8D=95=E4=B8=80?= =?UTF-8?q?=E7=8E=AF=E8=B7=AF=E5=B9=B3=E7=A8=B3=E8=BF=90=E8=A1=8C=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runplan/RunPlanDraftController.java | 4 +- .../rtss/services/IRunPlanDraftService.java | 2 +- .../rtss/services/RunPlanDraftService.java | 4 +- .../vo/runplan/newdraw/RunPlanGenerator.java | 240 +++++++++++-- .../rtss/vo/runplan/newdraw/RunPlanInput.java | 57 +-- .../newdraw/mainstack/DrawFuzhouRunPlan.java | 73 ---- .../newdraw/mainstack/DrawHarbinRunPlan.java | 73 ---- .../newdraw/mainstack/DrawRunPlan.java | 330 ------------------ 8 files changed, 240 insertions(+), 543 deletions(-) delete mode 100644 src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawFuzhouRunPlan.java delete mode 100644 src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawHarbinRunPlan.java delete mode 100644 src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawRunPlan.java diff --git a/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java index ddc5c9962..8a376ffad 100644 --- a/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java +++ b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java @@ -48,8 +48,8 @@ public class RunPlanDraftController { @ApiOperation(value = "自动生成运行图车次数据") @PostMapping(path = "/{id}") @Deprecated - public RunPlanEChartsDataVO create(@RequestBody @Validated RunPlanInput runPlanInput, @PathVariable Long id) { - return iRunPlanDraftService.createCommon(id,runPlanInput); + public RunPlanEChartsDataVO create(@RequestBody @Validated RunPlanInput runPlanInput, @PathVariable Long id,@ApiIgnore @RequestAttribute UserVO user) { + return iRunPlanDraftService.createCommon(id,runPlanInput,user); } @ApiOperation(value = "修改运行图名称") diff --git a/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java index 742e7558a..95b0e3716 100644 --- a/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java @@ -22,7 +22,7 @@ public interface IRunPlanDraftService { /** * 创建通用运行图车次数据 */ - RunPlanEChartsDataVO createCommon(Long runPlanId, RunPlanInput runPlanInput); + RunPlanEChartsDataVO createCommon(Long runPlanId, RunPlanInput runPlanInput,UserVO userVO); /** * 更新运行图名称 diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 9e64db4d8..c9b3add27 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -92,10 +92,10 @@ public class RunPlanDraftService implements IRunPlanDraftService { @Override @Transactional - public RunPlanEChartsDataVO createCommon(Long id, RunPlanInput runPlanInput) { + public RunPlanEChartsDataVO createCommon(Long id, RunPlanInput runPlanInput,UserVO userVO) { RunPlanDraft draftPlan = runPlanDraftDAO.selectByPrimaryKey(id); MapVO mapVO = this.iMapService.getMapDetail(draftPlan.getMapId()); - List runPlanTrips = runPlanGenerator.generatorTrips(runPlanInput, mapVO); + List runPlanTrips = runPlanGenerator.generatorTrips(userVO.getId(),runPlanInput, mapVO); draftPlan.setTrips(JsonUtils.writeValueAsString(runPlanTrips)); draftPlan.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01); runPlanDraftDAO.updateByPrimaryKeyWithBLOBs(draftPlan); diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java index 62edfd20e..5efcad180 100644 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java @@ -11,9 +11,6 @@ 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.newdraw.mainstack.DrawFuzhouRunPlan; -import club.joylink.rtss.vo.runplan.newdraw.mainstack.DrawHarbinRunPlan; -import club.joylink.rtss.vo.runplan.newdraw.mainstack.DrawRunPlan; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -44,7 +41,7 @@ public class RunPlanGenerator { private IRunPlanUserConfigService runPlanUserConfigService; - public List generatorTrips(RunPlanInput runPlanInput, MapVO mapVO) { + public List generatorTrips(Long userId, RunPlanInput runPlanInput, MapVO mapVO) { //校验发车停运时间 BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(runPlanInput.getOverTime().isAfter(runPlanInput.getBeginTime())); @@ -56,7 +53,210 @@ public class RunPlanGenerator { runPlanInput.setBeginTime(beginTimeOffset); runPlanInput.setOverTime(runPlanInput.getOverTime().minusHours(OFFSET_TIME_HOURS)); - return drawRunPlanOf(runPlanInput.getRunLevel(), mapVO).generatorTrips(runPlanInput, mapVO); + //检查环路 + 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 levels = runPlanRunlevelService.queryUserRunLevels(userId, mapVO.getId()); + Map runLevelTime = levels.stream().collect(Collectors.toMap(runLevelVO -> String.format("%s-%s", runLevelVO.getStartSectionCode(), runLevelVO.getEndSectionCode()), runLevelVO -> runLevelVO.getLevelTime(runPlanInput.getRunLevel()))); + //查停站时间 + List parkTimes = runPlanParktimeService.queryUserParktimes(userId, mapVO.getId()); + Map 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 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()))) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("折返轨未设置"); + } + + //生成车次 + LinkedList 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 tripList, ServiceTempResult tempResult, boolean isRight, Map runLevelTime, Map parkTime,Map userReentryData) { + String serviceNumber = String.format("%03d", initialServiceNum); + //服务首班车次 + boolean isFirstTrip = true; + + //初始化车次号,右行偶数,左行奇数 + int initTripNumber = isRight ? 0 : 1; + LocalTime lastTripEndTime = null;//一个车次终点时间 + LinkedList 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 tripTimeList = new LinkedList<>();//车次时刻表 +// if (isRight) { +// for (int r = 1; r <= stationNum; r++) { +// MapStationNewVO stoppingStation = runStationList.get(r - 1); +// RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); +// runPlanTripTimeVO.setStationCode(stoppingStation.getCode()); +// //TODO 需特别处理 +// MapStationStandNewVO stand = stoppingStation.getStandList().stream().filter(s -> s.isRight()).findFirst().get(); +// runPlanTripTimeVO.setSectionCode(stand.getStandTrackCode()); +// setTripTimeSectionCode(stoppingStation, runPlanTripTimeVO, isFirstTrip, isLastTrip); +// //TODO 折返时间和站间运行时间恒定值 后续根据运行等级进行处理时间 +// LocalTime arrivalTime = isFirstTripFirstStation ? initialServiceNum == 1 ? tempResult.getPreServiceDepartTime() : tempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()) : r == 1 ? lastTripEndTime.plusSeconds(runPlanInput.getReentryTime()) : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelTime.getOrDefault(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode(), 120)); +// runPlanTripTimeVO.setArrivalTime(arrivalTime); +// LocalTime departureTime = arrivalTime.plusSeconds(parkTime.getOrDefault(runPlanTripTimeVO.getSectionCode(), 30)); +// runPlanTripTimeVO.setDepartureTime(departureTime); +// tripTimeList.add(runPlanTripTimeVO); +// +// if (isFirstTripFirstStation) { +//// setTripStartSectionCode(runPlanTripVO, true); +//// runPlanTripVO.setIsOutbound(true); +// isFirstTripFirstStation = false; +// } +// if (r == stationNum) lastTripEndTime = departureTime; +// } +// } else { +// for (int l = stationNum; l > 0; l--) { +// MapStationNewVO stoppingStation = runStationList.get(l - 1); +// RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); +// runPlanTripTimeVO.setStationCode(stoppingStation.getCode()); +// //TODO 需特别处理 +// MapStationStandNewVO stand = stoppingStation.getStandList().stream().filter(s -> !s.isRight()).findFirst().get(); +// runPlanTripTimeVO.setSectionCode(stand.getStandTrackCode()); +// //TODO 折返时间和站间运行时间恒定值 后续根据运行等级进行处理时间 +// LocalTime arrivalTime = isFirstTripFirstStation ? initialServiceNum == 1 ? tempResult.getPreServiceDepartTime() : tempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()) : l == stationNum ? lastTripEndTime.plusSeconds(runPlanInput.getReentryTime()) : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelTime.getOrDefault(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode(), 120)); +// runPlanTripTimeVO.setArrivalTime(arrivalTime); +// LocalTime departureTime = arrivalTime.plusSeconds(parkTime.getOrDefault(runPlanTripTimeVO.getSectionCode(), 30)); +// runPlanTripTimeVO.setDepartureTime(departureTime); +// tripTimeList.add(runPlanTripTimeVO); +// +// if (isFirstTripFirstStation) { +//// setTripStartSectionCode(runPlanTripVO, false); +//// runPlanTripVO.setIsOutbound(true); +// isFirstTripFirstStation = false; +// } +// if (l == 1) lastTripEndTime = departureTime; +// } +// } + 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)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(); + tempTripList.add(runPlanTripVO); + if (tempTripList.size() > 50) { // 最快半小时跑一趟的一天车次数,如果大于这个,可能死循环,此时停止发车 + + break; + } + //or 向前推后两小时后,最多跑到凌晨,跑过有可能运行时间过大需特殊处理偏移时间或死循环,停止发车。 +// if(lastTripEndTime.isBefore(LocalTime.of(2,0,0))){ +// break; +// } + isRight = !isRight; + if (isFirstTrip) { + isFirstTrip = false; + } + + } while (lastTripEndTime.isBefore(runPlanInput.getOverTime())); + //设置服务号末班车次入库 + RunPlanTripVO lastrunPlanTrip = tempTripList.get(tempTripList.size() - 1); + lastrunPlanTrip.setIsInbound(true); + lastrunPlanTrip.setIsReentry(false); + LinkedList tripTimeList = (LinkedList) 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 tripList, Map runLevelTime, Map parkTime,Map 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); } @@ -140,7 +340,7 @@ public class RunPlanGenerator { 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() * 2).compareTo(serviceResult.firstRoundTripTime) <= 0); + } while (serviceResult.preServiceDepartTime.plusSeconds(inputData.getDepartureInterval()).compareTo(serviceResult.firstRoundTripTime) <= 0); } else { generateService(inputData, mapVO, outboundRouting, inboundRouting, outRef, same, other, runLevelMap, parkTimeMap, userReentryData, tripList, serviceResult); @@ -295,19 +495,19 @@ public class RunPlanGenerator { private LocalTime firstRoundTripTime; } - private DrawRunPlan drawRunPlanOf(int runLevel, MapVO mapVO) { - DrawRunPlan drawRunPlan; - switch (mapVO.getLineCode()) { - case "07": - drawRunPlan = new DrawHarbinRunPlan(runLevel, mapVO); - break; - case "02": - drawRunPlan = new DrawFuzhouRunPlan(runLevel, mapVO); - break; - default: - throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception(); - } - return drawRunPlan; - } +// private DrawRunPlan drawRunPlanOf(int runLevel, MapVO mapVO) { +// DrawRunPlan drawRunPlan; +// switch (mapVO.getLineCode()) { +// case "07": +// drawRunPlan = new DrawHarbinRunPlan(runLevel, mapVO); +// break; +// case "02": +// drawRunPlan = new DrawFuzhouRunPlan(runLevel, mapVO); +// break; +// default: +// throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception(); +// } +// return drawRunPlan; +// } } diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInput.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInput.java index f2f5a1270..bd84c5ce0 100644 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInput.java +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanInput.java @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; import java.time.LocalTime; @@ -15,67 +16,39 @@ import java.time.LocalTime; @Setter public class RunPlanInput { -// // 出库站 -// private String inboundStationCode; -// // 入库站 -// private String outboundStationCode; + /**环路1-运行交路code*/ + @ApiModelProperty(value = "运行交路code") + @NotBlank(message= "环路不能为空") + private String runningRouting1; + + /**环路2-运行交路code*/ + @ApiModelProperty(value = "运行交路code") + @NotBlank(message= "环路不能为空") + private String runningRouting2; - /**往返车站-左向起始站*/ - @ApiModelProperty(value = "左向起始站") - private String startStationCode; - /**往返车站-右向起始站*/ - @ApiModelProperty(value = "右向起始站") - private String endStationCode; /**折返时间*/ @ApiModelProperty(value = "折返时间") private int reentryTime; -// /**停站时间*/ -// @ApiModelProperty(value = "停站时间") -// private int parkedTime; + /**运行等级默认-站间运行时间*/ private int runLevel=3; + /**开始时间*/ @ApiModelProperty(value = "开始时间") @NotNull(message = "开始时间不能为空") private LocalTime beginTime; + /**结束时间*/ @ApiModelProperty(value = "结束时间") @NotNull(message = "结束时间不能为空") private LocalTime overTime; + /**间隔发车时间*/ @ApiModelProperty(value = "间隔时间") @Positive private int departureTimeInterval; + /**左右行,不设置为相向同时发车*/ @ApiModelProperty(value = "向左/向右") private Boolean right; -// /**初始服务号*/ -// @ApiModelProperty(value = "表号") -// @NotBlank -// @Length(min = 1, max = 3) -// private String initialServiceNumber; - -// private DepartureParam leftDepartureParam; -// private DepartureParam rightDepartureParam; -// // // 服务号数量 -//// private int serviceCount; -// -//// //同时发车 -//// private boolean simultaneousDepart; -// @Setter -// @Getter -// public class DepartureParam{ -//// /**左右行*/ -//// @ApiModelProperty(value = "向左/向右") -//// private boolean right; -// /**开始时间*/ -// @ApiModelProperty(value = "开始时间") -// @NotNull(message = "开始时间不能为空") -// private LocalTime beginTime; -// /**初始服务号*/ -// @ApiModelProperty(value = "表号") -// @NotBlank -// @Length(min = 1, max = 3) -// private String initialServiceNumber; -//} } diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawFuzhouRunPlan.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawFuzhouRunPlan.java deleted file mode 100644 index c3d9ea2f9..000000000 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawFuzhouRunPlan.java +++ /dev/null @@ -1,73 +0,0 @@ -package club.joylink.rtss.vo.runplan.newdraw.mainstack; - -import club.joylink.rtss.vo.client.map.MapVO; -import club.joylink.rtss.vo.client.map.newmap.MapStationNewVO; -import club.joylink.rtss.vo.client.map.newmap.MapStationStandNewVO; -import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; -import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; - -import java.util.List; -import java.util.stream.Collectors; - -public class DrawFuzhouRunPlan extends DrawRunPlan { - - public DrawFuzhouRunPlan(int runLevel, MapVO mapVO) { - super(runLevel,mapVO); - } - - @Override - public List filterMainStackStations(List ascStationList) { - return ascStationList.stream().filter((s)->{ - if(s.getName().equals("停车场")){ - return false; - } - if(s.getName().equals("车辆段")){ - return false; - } - return true; - - }).collect(Collectors.toList()); - } - - @Override - public List filterMainStackStands(List standList) { - -// return standList.stream().filter((s) -> { -// -// if (s.getName().equals("psd1504")) { //太平桥 -// return false; -// } -// return true; -// }).collect(Collectors.toList()); - return standList; - } - - @Override - void setTripStartSectionCode(RunPlanTripVO runPlanTripVO, boolean isRight, boolean isFirstTrip) { - if (isFirstTrip) { - runPlanTripVO.setStartSectionCode(isRight ? "T4" : "T305"); //TA0102:TA2125 - runPlanTripVO.setIsOutbound(true); - } else { - runPlanTripVO.setStartSectionCode(isRight ? "T10" : "T305"); //TA0108:TA2125 - } - } - - @Override - void setTripEndSectionInfo(RunPlanTripVO runPlanTripVO, boolean isRight, boolean isLastTrip) { - if (isLastTrip) { - runPlanTripVO.setEndSectionCode(isRight ? "T299" : "T3");//TA2126:TA0101 - runPlanTripVO.setDestinationCode(isRight ? "218" : "011");//TA2126:TA0101 - } else { - runPlanTripVO.setEndSectionCode(isRight ? "T305" : "T10");//TA2125:TA0108 - runPlanTripVO.setDestinationCode(isRight ? "219" : "012");//TA2125:TA0108 - } - } - - @Override - void setTripTimeSectionCode(MapStationNewVO stoppingStation, RunPlanTripTimeVO runPlanTripTime, boolean isFirstTrip, boolean isLastTrip) { -// if (Objects.equals("哈东站", stoppingStation.getName())) { -// runPlanTripTime.setSectionCode("T451");//G1805 -// } - } - -} diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawHarbinRunPlan.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawHarbinRunPlan.java deleted file mode 100644 index b6808a3c4..000000000 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawHarbinRunPlan.java +++ /dev/null @@ -1,73 +0,0 @@ -package club.joylink.rtss.vo.runplan.newdraw.mainstack; - -import club.joylink.rtss.vo.client.map.MapVO; -import club.joylink.rtss.vo.client.map.newmap.MapStationNewVO; -import club.joylink.rtss.vo.client.map.newmap.MapStationStandNewVO; -import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; -import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; - -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -public class DrawHarbinRunPlan extends DrawRunPlan { - - public DrawHarbinRunPlan(int runLevel, MapVO mapVO) { - super(runLevel,mapVO); - } - - @Override - public List filterMainStackStations(List ascStationList) { - return ascStationList.stream().filter((s)->{ - if(s.getName().equals("太平桥车辆段")){ - return false; - } - if(s.getName().equals("哈南停车场")){ - return false; - } - return true; - - }).collect(Collectors.toList()); - } - - @Override - public List filterMainStackStands(List standList) { - - return standList.stream().filter((s) -> { - - if (s.getName().equals("psd1504")) { //太平桥 - return false; - } - return true; - }).collect(Collectors.toList()); - } - - @Override - void setTripStartSectionCode(RunPlanTripVO runPlanTripVO, boolean isRight, boolean isFirstTrip) { - if (isFirstTrip) { - runPlanTripVO.setStartSectionCode(isRight ? "T11" : "T451"); //G2115:G1805 - runPlanTripVO.setIsOutbound(true); - } else { - runPlanTripVO.setStartSectionCode(isRight ? "T16" : "T451"); //G2116:G1805 - } - } - - @Override - void setTripEndSectionInfo(RunPlanTripVO runPlanTripVO, boolean isRight, boolean isLastTrip) { - if (isLastTrip) { - runPlanTripVO.setEndSectionCode(isRight ? "T451" : "T11");//G1805:G2115 - runPlanTripVO.setDestinationCode(isRight ? "181" : "213");//G1805:G2115 - } else { - runPlanTripVO.setEndSectionCode(isRight ? "T451" : "T16");//G1805:G2116 - runPlanTripVO.setDestinationCode(isRight ? "181" : "214");//G1805:G2116 - } - } - - @Override - void setTripTimeSectionCode(MapStationNewVO stoppingStation, RunPlanTripTimeVO runPlanTripTime, boolean isFirstTrip, boolean isLastTrip) { - if (Objects.equals("哈东站", stoppingStation.getName())) { - runPlanTripTime.setSectionCode("T451");//G1805 - } - } - -} diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawRunPlan.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawRunPlan.java deleted file mode 100644 index 4c08eb83e..000000000 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/mainstack/DrawRunPlan.java +++ /dev/null @@ -1,330 +0,0 @@ -package club.joylink.rtss.vo.runplan.newdraw.mainstack; - -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.RealLineConfigVO; -import club.joylink.rtss.vo.client.map.newmap.MapStationNewVO; -import club.joylink.rtss.vo.client.map.newmap.MapStationStandNewVO; -import club.joylink.rtss.vo.client.map.newmap.SectionParkingTimeVO; -import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; -import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.runplan.newdraw.RunPlanInput; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -import java.time.LocalTime; -import java.util.*; -import java.util.stream.Collectors; - -public abstract class DrawRunPlan { - - protected final Map parkTime; - protected final Map runLevelTime; - - protected DrawRunPlan(int runLevel, MapVO mapVO) { - - //停站时间map:key-区段code/value-停站时间s - parkTime = mapVO.getLogicDataNew().getParkingTimeList().stream().flatMap(parkingTimeVO -> parkingTimeVO.getParkingTimeVOList().stream()).collect(Collectors.toMap(SectionParkingTimeVO::getSectionCode, SectionParkingTimeVO::getParkingTime)); - //站间运行时间:key-起始区段-终点区段/value-时间 - runLevelTime = mapVO.getLogicDataNew().getRunLevelList().stream().collect(Collectors.toMap(runLevelVO -> String.format("%s-%s", runLevelVO.getStartSectionCode(), runLevelVO.getEndSectionCode()), runLevelVO -> runLevelVO.getLevelTime(runLevel))); - } - - public final List generatorTrips(RunPlanInput runPlanInput, MapVO mapVO) { - - //根据公里标升序的往返之间车站列表 - List runStationList = getMapStationNews(runPlanInput, mapVO); - - List tripList = new ArrayList<>(100); - //是否同时相向发车 - boolean opposite = Objects.isNull(runPlanInput.getRight()); - if (opposite) { - //相向发车 - int initialServiceNum = 1; - /*分别先发一辆车,计算控制左右发车服务号*/ - //上个服务号发车时刻 - //首班发车时间,首班车往返回来时间 来限定发车服务数量 - TempResult tempResultLeft = new TempResult(runPlanInput.getBeginTime(), null); - serviceNumberDepart(runPlanInput, runStationList, initialServiceNum++, tripList, tempResultLeft, false, mapVO.getConfigVO()); - - //上个服务号发车时刻 - //首班发车时间,首班车往返回来时间 来限定发车服务数量 - TempResult tempResultRight = new TempResult(runPlanInput.getBeginTime().minusSeconds(runPlanInput.getDepartureTimeInterval()), null); - serviceNumberDepart(runPlanInput, runStationList, initialServiceNum++, tripList, tempResultRight, true, mapVO.getConfigVO()); - - LocalTime firstRoundTripTimeLeft = tempResultLeft.getFirstRoundTripTime(); - LocalTime firstRoundTripTimeRight = tempResultRight.getFirstRoundTripTime(); - tempResultRight.setFirstRoundTripTime(firstRoundTripTimeLeft); - tempResultLeft.setFirstRoundTripTime(firstRoundTripTimeRight); - //暂时先定义发完左行,再发右行.. - do { - serviceNumberDepart(runPlanInput, runStationList, initialServiceNum++, tripList, tempResultLeft, false, mapVO.getConfigVO()); - } while (tempResultLeft.getPreServiceDepartTime().minusSeconds(runPlanInput.getReentryTime()).plusSeconds(runPlanInput.getDepartureTimeInterval() * 2).compareTo(tempResultLeft.getFirstRoundTripTime()) <= 0); - //发完左行,再发右行 - do { - serviceNumberDepart(runPlanInput, runStationList, initialServiceNum++, tripList, tempResultRight, true, mapVO.getConfigVO()); - } while (tempResultRight.getPreServiceDepartTime().minusSeconds(runPlanInput.getReentryTime()).plusSeconds(runPlanInput.getDepartureTimeInterval() * 2).compareTo(tempResultRight.getFirstRoundTripTime()) <= 0); - - - } else { - //单向发车 - allServiceNumberDepart(runPlanInput, runStationList, tripList, mapVO.getConfigVO()); - - } - return tripList; - } - - /** - * 单向发车 - */ - private void allServiceNumberDepart(RunPlanInput runPlanInput, List runStationList, List tripList, RealLineConfigVO lineConfigVO) { - - - //设置初始服务号 - int initialServiceNum = 1; - //上个服务号发车时刻 - //首班发车时间,首班车往返回来时间 来限定发车服务数量 - TempResult tempResult = new TempResult(runPlanInput.getBeginTime(), null); - do { - serviceNumberDepart(runPlanInput, runStationList, initialServiceNum++, tripList, tempResult, runPlanInput.getRight(), lineConfigVO); - } while (tempResult.getPreServiceDepartTime().minusSeconds(runPlanInput.getReentryTime()).plusSeconds(runPlanInput.getDepartureTimeInterval() * 2).compareTo(tempResult.getFirstRoundTripTime()) <= 0); - - } - - /** - * 根据公里标升序的车站列表 - */ - private List getMapStationNews(RunPlanInput runPlanInput, MapVO mapVO) { - //根据公里标升序的车站列表 - //TODO ?? 存在车库或车辆段公里标大于的相邻车站与出库后的第一个目标车站不一致 的问题 - List ascStationList = mapVO.findSortedAllStationListNew(); - BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(ascStationList); - // 获取站台 - List standList = mapVO.findAllStandListNew(); - BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(standList); - - /*获取运行往返正线上的车站列表*/ - List mainStackStations = filterMainStackStations(ascStationList); - for (MapStationNewVO station : mainStackStations) { - for (MapStationStandNewVO stand : filterMainStackStands(standList)) { - if (station.getCode().equals(stand.getStationCode())) { - station.addStand(stand); - } - } - } - //先不考虑特殊发车 - String startStationCode = runPlanInput.getStartStationCode();//起始车站code - String endStationCode = runPlanInput.getEndStationCode();//终点车站code - int startIndex = -1; - int endIndex = -1; - for (int i = 0, len = mainStackStations.size(); i < len; i++) { - if (startIndex != -1 && endIndex != -1) { - break; - } - if (startIndex == -1 && mainStackStations.get(i).getCode().equals(startStationCode)) { - startIndex = i; - } - if (endIndex == -1 && mainStackStations.get(i).getCode().equals(endStationCode)) { - endIndex = i; - } - } - if (startIndex > endIndex) { - return mainStackStations.subList(endIndex, startIndex + 1); - } - return mainStackStations.subList(startIndex, endIndex + 1); - } - - @Getter - @Setter - @AllArgsConstructor - private class TempResult { - private LocalTime preServiceDepartTime; - private LocalTime firstRoundTripTime; - } - - /** - * 服务号发车 - * - * @param runPlanInput - * @param runStationList - * @param initialServiceNum - * @param tripList - * @param tempResult - * @param isRight - */ - private void serviceNumberDepart(RunPlanInput runPlanInput, List runStationList, int initialServiceNum, List tripList, TempResult tempResult, boolean isRight, RealLineConfigVO lineConfigVO) { - String serviceNumber = String.format("%03d", initialServiceNum); - int stationNum =runStationList.size(); - - //服务首班车次 - boolean isFirstTrip = true; - //服务首班车次第一个计划到站 - boolean isFirstTripFirstStation = true; - - //服务末班车次 - boolean isLastTrip = false; - //首班右行 -// boolean isRight = Objects.nonNull(runPlanInput.getRightDepartureParam()); - //初始化车次号,右行偶数,左行奇数 - int initTripNumber = isRight ? 0 : 1; - LocalTime lastTripEndTime = null;//一个车次终点时间 - List tempTripList = new ArrayList<>(); - //根据运行时间判断结束末班车次 - do { - //本车次首发车时间 -// LocalTime departTime = startTime; - RunPlanTripVO runPlanTripVO = new RunPlanTripVO(); - runPlanTripVO.setServiceNumber(serviceNumber); - runPlanTripVO.setRight(isRight); - setDirectionCode(lineConfigVO.getUpRight(), runPlanTripVO); - runPlanTripVO.setIsReentry(true); - //车次号 - String tripNumber = String.format("%03d", initTripNumber++); - runPlanTripVO.setTripNumber(tripNumber); - setTripStartSectionCode(runPlanTripVO, isRight, isFirstTrip); - //首班右行方向 - LinkedList tripTimeList = new LinkedList<>();//车次时刻表 - if (isRight) { - for (int r = 1; r <= stationNum; r++) { - MapStationNewVO stoppingStation = runStationList.get(r - 1); - RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); - runPlanTripTimeVO.setStationCode(stoppingStation.getCode()); - //TODO 需特别处理 - MapStationStandNewVO stand = stoppingStation.getStandList().stream().filter(s -> s.isRight()).findFirst().get(); - runPlanTripTimeVO.setSectionCode(stand.getStandTrackCode()); - setTripTimeSectionCode(stoppingStation,runPlanTripTimeVO, isFirstTrip, isLastTrip); - //TODO 折返时间和站间运行时间恒定值 后续根据运行等级进行处理时间 - LocalTime arrivalTime = isFirstTripFirstStation ? initialServiceNum == 1 ? tempResult.getPreServiceDepartTime() : tempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()) : r == 1 ? lastTripEndTime.plusSeconds(runPlanInput.getReentryTime()) : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelTime.getOrDefault(tripTimeList.getLast().getSectionCode()+"-"+runPlanTripTimeVO.getSectionCode(),120)); - runPlanTripTimeVO.setArrivalTime(arrivalTime); - LocalTime departureTime = arrivalTime.plusSeconds(parkTime.getOrDefault(runPlanTripTimeVO.getSectionCode(),30)); - runPlanTripTimeVO.setDepartureTime(departureTime); - tripTimeList.add(runPlanTripTimeVO); - - if (isFirstTripFirstStation) { -// setTripStartSectionCode(runPlanTripVO, true); -// runPlanTripVO.setIsOutbound(true); - isFirstTripFirstStation = false; - } - if (r == stationNum) lastTripEndTime = departureTime; - } - } else { - for (int l = stationNum; l > 0; l--) { - MapStationNewVO stoppingStation = runStationList.get(l - 1); - RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); - runPlanTripTimeVO.setStationCode(stoppingStation.getCode()); - //TODO 需特别处理 - MapStationStandNewVO stand = stoppingStation.getStandList().stream().filter(s -> !s.isRight()).findFirst().get(); - runPlanTripTimeVO.setSectionCode(stand.getStandTrackCode()); - //TODO 折返时间和站间运行时间恒定值 后续根据运行等级进行处理时间 - LocalTime arrivalTime = isFirstTripFirstStation ? initialServiceNum == 1 ? tempResult.getPreServiceDepartTime() : tempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()) : l == stationNum ? lastTripEndTime.plusSeconds(runPlanInput.getReentryTime()) : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelTime.getOrDefault(tripTimeList.getLast().getSectionCode()+"-"+runPlanTripTimeVO.getSectionCode(),120)); - runPlanTripTimeVO.setArrivalTime(arrivalTime); - LocalTime departureTime = arrivalTime.plusSeconds(parkTime.getOrDefault(runPlanTripTimeVO.getSectionCode(),30)); - runPlanTripTimeVO.setDepartureTime(departureTime); - tripTimeList.add(runPlanTripTimeVO); - - if (isFirstTripFirstStation) { -// setTripStartSectionCode(runPlanTripVO, false); -// runPlanTripVO.setIsOutbound(true); - isFirstTripFirstStation = false; - } - if (l == 1) lastTripEndTime = departureTime; - } - } - runPlanTripVO.setTimeList(tripTimeList); -// //TODO 起始/结束区段未设置,需分别具体设置 - setTripEndSectionInfo(runPlanTripVO, isRight,false); - setTripRunTime(runPlanTripVO, tripTimeList); - - tempTripList.add(runPlanTripVO); - if (tempTripList.size() > 50) { // 最快半小时跑一趟的一天车次数,如果大于这个,可能死循环,此时停止发车 - - break; - } - //or 向前推后两小时后,最多跑到凌晨,跑过有可能运行时间过大需特殊处理偏移时间或死循环,停止发车。 -// if(lastTripEndTime.isBefore(LocalTime.of(2,0,0))){ -// break; -// } - isRight = !isRight; - if (isFirstTrip) { - isFirstTrip=false; - } - - } while (lastTripEndTime.isBefore(runPlanInput.getOverTime())); - //设置服务号末班车次入库 - RunPlanTripVO lastrunPlanTrip = tempTripList.get(tempTripList.size() - 1); - lastrunPlanTrip.setIsInbound(true); - lastrunPlanTrip.setIsReentry(false); - setTripEndSectionInfo(lastrunPlanTrip, lastrunPlanTrip.getRight(),true); - LinkedList tripTimeList = (LinkedList) lastrunPlanTrip.getTimeList(); - setTripEndTime(lastrunPlanTrip, tripTimeList); - tripList.addAll(tempTripList); - if (Objects.isNull(tempResult.getFirstRoundTripTime())) { - tempResult.setFirstRoundTripTime(Objects.isNull(runPlanInput.getRight()) ? ((RunPlanTripTimeVO) (((LinkedList) (tempTripList.get(0).getTimeList())).getLast())).getDepartureTime() : ((RunPlanTripTimeVO) (((LinkedList) (tempTripList.get(1).getTimeList())).getLast())).getDepartureTime()); - } - tempResult.setPreServiceDepartTime(((RunPlanTripTimeVO) (((LinkedList) (tempTripList.get(0).getTimeList())).getFirst())).getArrivalTime()); - } - - private void setTripEndTime(RunPlanTripVO lastrunPlanTrip, LinkedList tripTimeList) { - if (Objects.equals(lastrunPlanTrip.getEndSectionCode(), tripTimeList.getLast().getSectionCode())) { - lastrunPlanTrip.setEndTime(tripTimeList.getLast().getDepartureTime()); - } else { - lastrunPlanTrip.setEndTime(tripTimeList.getLast().getDepartureTime().plusSeconds(40)); - } - } - - private void setTripRunTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList) { - setTripStartTime(runPlanTripVO, tripTimeList); - //车次 结束区段和最后一个到站区段相同,那么车次结束时间就是最后一个车站到站时间 - setTripEndTime(runPlanTripVO, tripTimeList); - } - - private void setTripStartTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList) { - if (Objects.equals(runPlanTripVO.getStartSectionCode(), tripTimeList.getFirst().getSectionCode())) { - runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime()); - } else { - runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime().minusSeconds(40)); - } - } - - private void setDirectionCode(Boolean upRight, RunPlanTripVO runPlanTripVO) { - if (runPlanTripVO.getRight()) { - - if (upRight) { - runPlanTripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type02); - } else { - runPlanTripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type01); - } - } else { - if (upRight) { - runPlanTripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type01); - } else { - runPlanTripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type02); - } - } - - } - - /** - * 正线站 - */ - abstract List filterMainStackStations(List ascStationList); - - /** - * 正线站台 - */ - abstract List filterMainStackStands(List standList); - - /** - * 服务号 车次起始区段及出入库 - */ - abstract void setTripStartSectionCode(RunPlanTripVO runPlanTripVO, boolean isRight, boolean isFirstTrip); - - /** - * 服务号 车次结束区段和目的地 - */ - abstract void setTripEndSectionInfo(RunPlanTripVO runPlanTripVO, boolean isRight, boolean isLastTrip); - - /**车站停靠站台轨*/ - abstract void setTripTimeSectionCode(MapStationNewVO stoppingStation,RunPlanTripTimeVO runPlanTripTime, boolean isFirstTrip, boolean isLastTrip); -} From 28170a5c4c068962cb1cf715c202e7845cde8f5e Mon Sep 17 00:00:00 2001 From: DU Date: Fri, 11 Dec 2020 15:37:48 +0800 Subject: [PATCH 22/23] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=86=97=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/runplan/newdraw/RunPlanGenerator.java | 99 +++---------------- 1 file changed, 14 insertions(+), 85 deletions(-) diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java index 5efcad180..0ec6b47be 100644 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java @@ -86,12 +86,12 @@ public class RunPlanGenerator { //上个服务号发车时刻 //首班发车时间,首班车往返回来时间 来限定发车服务数量 ServiceTempResult tempResultLeft = new ServiceTempResult(runPlanInput.getBeginTime(), null); - serviceNumberDepart(mapVO,runPlanInput, running1Routing,running2Routing, initialServiceNum++, tripList, tempResultLeft, false, runLevelTime,parkTime,userReentryData); + 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); + serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResultRight, true, runLevelTime, parkTime, userReentryData); LocalTime firstRoundTripTimeLeft = tempResultLeft.getFirstRoundTripTime(); LocalTime firstRoundTripTimeRight = tempResultRight.getFirstRoundTripTime(); @@ -100,17 +100,17 @@ public class RunPlanGenerator { //暂时先定义发完左行,再发右行.. do { tempResultLeft.setPreServiceDepartTime(tempResultLeft.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval())); - serviceNumberDepart(mapVO,runPlanInput, running1Routing,running2Routing, initialServiceNum++, tripList, tempResultLeft, false, runLevelTime,parkTime,userReentryData); + 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); + 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); + allServiceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, tripList, runLevelTime, parkTime, userReentryData); } return tripList; @@ -120,18 +120,15 @@ public class RunPlanGenerator { /** * 服务号发车 */ - private void serviceNumberDepart(MapVO mapVO, RunPlanInput runPlanInput, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, int initialServiceNum, LinkedList tripList, ServiceTempResult tempResult, boolean isRight, Map runLevelTime, Map parkTime,Map userReentryData) { + private void serviceNumberDepart(MapVO mapVO, RunPlanInput runPlanInput, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, int initialServiceNum, LinkedList tripList, ServiceTempResult tempResult, boolean isRight, Map runLevelTime, Map parkTime, Map userReentryData) { String serviceNumber = String.format("%03d", initialServiceNum); - //服务首班车次 - boolean isFirstTrip = true; - //初始化车次号,右行偶数,左行奇数 int initTripNumber = isRight ? 0 : 1; LocalTime lastTripEndTime = null;//一个车次终点时间 LinkedList tempTripList = new LinkedList<>(); //根据运行时间判断结束末班车次 do { - RunPlanRoutingVO routing = Objects.equals(running1Routing.getRight(),isRight)? running1Routing: running2Routing; + RunPlanRoutingVO routing = Objects.equals(running1Routing.getRight(), isRight) ? running1Routing : running2Routing; String startReentrySectionCode = userReentryData.get(routing.getStartStationCode()); String endReentrySectionCode = userReentryData.get(routing.getEndStationCode()); MapSectionNewVO endReentrySection = null; @@ -148,55 +145,9 @@ public class RunPlanGenerator { runPlanTripVO.setIsReentry(true); //车次号 String tripNumber = String.format("%03d", initTripNumber++); - runPlanTripVO.setTripNumber(runPlanTripVO.getDirectionCode()+tripNumber); + runPlanTripVO.setTripNumber(runPlanTripVO.getDirectionCode() + tripNumber); //首班右行方向 LinkedList tripTimeList = new LinkedList<>();//车次时刻表 -// if (isRight) { -// for (int r = 1; r <= stationNum; r++) { -// MapStationNewVO stoppingStation = runStationList.get(r - 1); -// RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); -// runPlanTripTimeVO.setStationCode(stoppingStation.getCode()); -// //TODO 需特别处理 -// MapStationStandNewVO stand = stoppingStation.getStandList().stream().filter(s -> s.isRight()).findFirst().get(); -// runPlanTripTimeVO.setSectionCode(stand.getStandTrackCode()); -// setTripTimeSectionCode(stoppingStation, runPlanTripTimeVO, isFirstTrip, isLastTrip); -// //TODO 折返时间和站间运行时间恒定值 后续根据运行等级进行处理时间 -// LocalTime arrivalTime = isFirstTripFirstStation ? initialServiceNum == 1 ? tempResult.getPreServiceDepartTime() : tempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()) : r == 1 ? lastTripEndTime.plusSeconds(runPlanInput.getReentryTime()) : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelTime.getOrDefault(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode(), 120)); -// runPlanTripTimeVO.setArrivalTime(arrivalTime); -// LocalTime departureTime = arrivalTime.plusSeconds(parkTime.getOrDefault(runPlanTripTimeVO.getSectionCode(), 30)); -// runPlanTripTimeVO.setDepartureTime(departureTime); -// tripTimeList.add(runPlanTripTimeVO); -// -// if (isFirstTripFirstStation) { -//// setTripStartSectionCode(runPlanTripVO, true); -//// runPlanTripVO.setIsOutbound(true); -// isFirstTripFirstStation = false; -// } -// if (r == stationNum) lastTripEndTime = departureTime; -// } -// } else { -// for (int l = stationNum; l > 0; l--) { -// MapStationNewVO stoppingStation = runStationList.get(l - 1); -// RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); -// runPlanTripTimeVO.setStationCode(stoppingStation.getCode()); -// //TODO 需特别处理 -// MapStationStandNewVO stand = stoppingStation.getStandList().stream().filter(s -> !s.isRight()).findFirst().get(); -// runPlanTripTimeVO.setSectionCode(stand.getStandTrackCode()); -// //TODO 折返时间和站间运行时间恒定值 后续根据运行等级进行处理时间 -// LocalTime arrivalTime = isFirstTripFirstStation ? initialServiceNum == 1 ? tempResult.getPreServiceDepartTime() : tempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()) : l == stationNum ? lastTripEndTime.plusSeconds(runPlanInput.getReentryTime()) : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelTime.getOrDefault(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode(), 120)); -// runPlanTripTimeVO.setArrivalTime(arrivalTime); -// LocalTime departureTime = arrivalTime.plusSeconds(parkTime.getOrDefault(runPlanTripTimeVO.getSectionCode(), 30)); -// runPlanTripTimeVO.setDepartureTime(departureTime); -// tripTimeList.add(runPlanTripTimeVO); -// -// if (isFirstTripFirstStation) { -//// setTripStartSectionCode(runPlanTripVO, false); -//// runPlanTripVO.setIsOutbound(true); -// isFirstTripFirstStation = false; -// } -// if (l == 1) lastTripEndTime = departureTime; -// } -// } routing.getParkSectionCodeList().forEach(runPlanRoutingSection -> { RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO(); runPlanTripTimeVO.setStationCode(runPlanRoutingSection.getStationCode()); @@ -205,7 +156,7 @@ public class RunPlanGenerator { tempResult.getPreServiceDepartTime() : (CollectionUtils.isEmpty(tripTimeList) ? (Objects.equals(tempTripList.getLast().getEndSectionCode(), runPlanTripTimeVO.getSectionCode()) ? - tempTripList.getLast().getEndTime() :((LinkedList)tempTripList.getLast().getTimeList()).getLast().getDepartureTime().plusSeconds(runPlanInput.getReentryTime())) : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelTime.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode())))); + tempTripList.getLast().getEndTime() : ((LinkedList) 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); }); @@ -217,14 +168,7 @@ public class RunPlanGenerator { break; } - //or 向前推后两小时后,最多跑到凌晨,跑过有可能运行时间过大需特殊处理偏移时间或死循环,停止发车。 -// if(lastTripEndTime.isBefore(LocalTime.of(2,0,0))){ -// break; -// } isRight = !isRight; - if (isFirstTrip) { - isFirstTrip = false; - } } while (lastTripEndTime.isBefore(runPlanInput.getOverTime())); //设置服务号末班车次入库 @@ -232,10 +176,10 @@ public class RunPlanGenerator { lastrunPlanTrip.setIsInbound(true); lastrunPlanTrip.setIsReentry(false); LinkedList tripTimeList = (LinkedList) lastrunPlanTrip.getTimeList(); - setTripEndTime(lastrunPlanTrip, tripTimeList,runPlanInput.getReentryTime()); + setTripEndTime(lastrunPlanTrip, tripTimeList, runPlanInput.getReentryTime()); tripList.addAll(tempTripList); if (Objects.isNull(tempResult.getFirstRoundTripTime())) { - tempResult.setFirstRoundTripTime( ((RunPlanTripTimeVO) (((LinkedList) (tempTripList.get(0).getTimeList())).getLast())).getDepartureTime()); + tempResult.setFirstRoundTripTime(((RunPlanTripTimeVO) (((LinkedList) (tempTripList.get(0).getTimeList())).getLast())).getDepartureTime()); } tempResult.setPreServiceDepartTime(((RunPlanTripTimeVO) (((LinkedList) (tempTripList.get(0).getTimeList())).getFirst())).getArrivalTime()); } @@ -243,7 +187,7 @@ public class RunPlanGenerator { /** * 单向发车 */ - private void allServiceNumberDepart(MapVO mapVO, RunPlanInput runPlanInput, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing,LinkedList tripList, Map runLevelTime, Map parkTime,Map userReentryData) { + private void allServiceNumberDepart(MapVO mapVO, RunPlanInput runPlanInput, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, LinkedList tripList, Map runLevelTime, Map parkTime, Map userReentryData) { //设置初始服务号 @@ -252,10 +196,10 @@ public class RunPlanGenerator { //首班发车时间,首班车往返回来时间 来限定发车服务数量 ServiceTempResult tempResult = new ServiceTempResult(runPlanInput.getBeginTime(), null); do { - if(initialServiceNum != 1){ + if (initialServiceNum != 1) { tempResult.setPreServiceDepartTime(tempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval())); } - serviceNumberDepart(mapVO, runPlanInput, running1Routing,running2Routing, initialServiceNum++, tripList, tempResult, runPlanInput.getRight(), runLevelTime, parkTime,userReentryData); + 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); } @@ -495,19 +439,4 @@ public class RunPlanGenerator { private LocalTime firstRoundTripTime; } -// private DrawRunPlan drawRunPlanOf(int runLevel, MapVO mapVO) { -// DrawRunPlan drawRunPlan; -// switch (mapVO.getLineCode()) { -// case "07": -// drawRunPlan = new DrawHarbinRunPlan(runLevel, mapVO); -// break; -// case "02": -// drawRunPlan = new DrawFuzhouRunPlan(runLevel, mapVO); -// break; -// default: -// throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception(); -// } -// return drawRunPlan; -// } - } From b552d94f38200f109cd2ced1b4cbeffc2c6524c0 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 11 Dec 2020 17:49:16 +0800 Subject: [PATCH 23/23] =?UTF-8?q?=E6=81=A2=E5=A4=8D<=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=94=80=E5=94=AE=E4=BA=BA=E5=91=98>=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/controller/user/UserController.java | 6 ++++++ .../java/club/joylink/rtss/services/ISysUserService.java | 5 +++++ .../java/club/joylink/rtss/services/SysUserService.java | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/src/main/java/club/joylink/rtss/controller/user/UserController.java b/src/main/java/club/joylink/rtss/controller/user/UserController.java index b619a9b46..7399a7c07 100644 --- a/src/main/java/club/joylink/rtss/controller/user/UserController.java +++ b/src/main/java/club/joylink/rtss/controller/user/UserController.java @@ -128,4 +128,10 @@ public class UserController { public List getClasses(@PathVariable String projectCode){ return this.iClassStudentUserService.getClassesByProjectCode(projectCode); } + + @ApiOperation("查询销售人员") + @GetMapping("/seller") + public List querySellers(){ + return iSysUserService.querySellers(); + } } diff --git a/src/main/java/club/joylink/rtss/services/ISysUserService.java b/src/main/java/club/joylink/rtss/services/ISysUserService.java index b6a809c2c..0416843b1 100644 --- a/src/main/java/club/joylink/rtss/services/ISysUserService.java +++ b/src/main/java/club/joylink/rtss/services/ISysUserService.java @@ -291,4 +291,9 @@ public interface ISysUserService { void ensureExist(Long id); void superAdminUpdateUserInfo(UserVO updateUser, UserVO superAdmin); + + /** + * 查询所有的销售人员 + */ + List querySellers(); } diff --git a/src/main/java/club/joylink/rtss/services/SysUserService.java b/src/main/java/club/joylink/rtss/services/SysUserService.java index 13eba3299..fee5a25bf 100644 --- a/src/main/java/club/joylink/rtss/services/SysUserService.java +++ b/src/main/java/club/joylink/rtss/services/SysUserService.java @@ -742,6 +742,15 @@ public class SysUserService implements ISysUserService { } } + @Override + public List querySellers() { + SysUserExample example = new SysUserExample(); + example.setOrderByClause("id"); + example.createCriteria().andRolesLike(String.format("%%%s%%", BusinessConsts.ROLE_06)); + List users = sysUserDAO.selectByExample(example); + return UserVO.convert2BaseInfoVO(users); + } + private SysUser getEntity(Long id) { SysUser user = sysUserDAO.selectByPrimaryKey(id); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(user, String.format("id为[%s]的用户不存在", id));