From 3e16b48761ce81506627cda8673a96f591086a78 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 17 Jun 2022 10:17:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90=E8=A1=8C=E8=BD=A6=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runplan/CtcStationRunPlanLogService.java | 5 -- .../cbtc/CTC/data/CtcStationRunPlanLog.java | 80 ++++++++++++++++--- .../rtss/vo/client/ctc/CtcRunPlanVO.java | 28 +++++-- 3 files changed, 88 insertions(+), 25 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java index b1f3cf91c..f434fd237 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java @@ -322,11 +322,6 @@ public class CtcStationRunPlanLogService { change = change || modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), planParam, true); // 出发 change = change || modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), planParam, false); - // 存在不一样的选项 - long modifyNum = planParam.getRunPlanTaskList().stream().filter(task -> !runPlanLog.getRunPlanTaskList().contains(task)).count(); - if (modifyNum > 0 || (planParam.getRunPlanTaskList().size() != runPlanLog.getRunPlanTaskList().size())) { // 长度不一致直接赋值 - runPlanLog.setRunPlanTaskList(planParam.getRunPlanTaskList()); - } // 是否客运 if (planParam.getPassenger() != null && !Objects.equals(planParam.getPassenger(), runPlanLog.getPassenger())) { runPlanLog.setPassenger(planParam.getPassenger()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java index ee289be6d..ca4bebed1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java @@ -9,13 +9,14 @@ import club.joylink.rtss.simulation.cbtc.data.map.StationDirection; import lombok.Data; import lombok.Getter; import lombok.Setter; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalTime; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; /** * Ctc 车站运行计划日志 @@ -73,9 +74,9 @@ public class CtcStationRunPlanLog { private String planProperties; /** - * 列车运行计划作业 + * 列车运行作业 */ - private List runPlanTaskList = new ArrayList<>(); + private Map runPlanTaskItemMap; /** * 是否原始数据 @@ -117,9 +118,6 @@ public class CtcStationRunPlanLog { */ private TransfiniteType transfinite; - public CtcStationRunPlanLog() { - } - public CtcStationRunPlanLog(CtcRunPlanParam paramInfo) { this.planParam = paramInfo; this.code = paramInfo.getRunPlanCode(); @@ -127,20 +125,26 @@ public class CtcStationRunPlanLog { this.trackSectionCode = paramInfo.getTrackSectionCode(); this.remark = paramInfo.getRemark(); // 记事 this.lateReason = paramInfo.getLateReason(); // 晚点原因 - this.runPlanTaskList = paramInfo.getRunPlanTaskList(); this.passenger = paramInfo.getPassenger(); // 是否客运 this.keyTrains = paramInfo.getKeyTrains(); // 重点列车 this.military = paramInfo.getMilitary(); // 是否军用 this.trackDiscordant = paramInfo.getTrackDiscordant(); // 运行股道与基本径路不一致 this.entryOutDiscordant = paramInfo.getEntryOutDiscordant(); // 出入口与基本径路不一致 this.transfinite = paramInfo.getTransfinite(); // 超限等级 + if (CollectionUtils.isEmpty(paramInfo.getRunPlanTaskList())) { // 运行计划任务 + this.runPlanTaskItemMap = paramInfo.getRunPlanTaskList().stream() + .collect(Collectors.toMap(t -> t, t -> new RunPlanTaskItem(t))); + } else { + this.runPlanTaskItemMap = new HashMap<>(0); + } } public void reset() { this.remark = null; this.lateReason = null; this.planProperties = null; - this.runPlanTaskList = new ArrayList<>(); + // 运行任务复位 + this.runPlanTaskItemMap.forEach((k, v) -> v.reset()); if (this.arriveRunPlan != null) { this.arriveRunPlan.setRunModel(StationDirection.ReceiveAndDeliverModel.R); this.arriveRunPlan.reset(); @@ -336,9 +340,6 @@ public class CtcStationRunPlanLog { this.processTypeMap = new HashMap<>(ProcessType.values().length); } - public RunPlanItem() { - } - public void reset() { this.stationDirection = this.defaultStationDirection; this.station = this.defaultStation; @@ -455,7 +456,7 @@ public class CtcStationRunPlanLog { } /** - * 运行作业 + * 运行作业类型 */ public enum RunPlanTask { // 技术停点 @@ -500,6 +501,59 @@ public class CtcStationRunPlanLog { } } + /** + * 运行作业详细信息 + */ + @Getter + @Setter + public static class RunPlanTaskItem implements Cloneable { + private RunPlanTask type; + + private RunPlanTaskStatus status; + + public RunPlanTaskItem(RunPlanTask type) { + this.type = type; + this.status = RunPlanTaskStatus.NO; + } + + /** + * 判断是否变化 + * + * @param modifyItem 修改实体 + * @param statusItem 状态实体 + * @return 是否变化 + */ + public boolean compareAndChange(RunPlanTaskItem modifyItem, RunPlanTaskItem statusItem) { + boolean change = false; + if (!Objects.equals(modifyItem.getStatus(), this.status)) { + this.status = modifyItem.status; + statusItem.setStatus(modifyItem.getStatus()); + change = true; + } + return change; + } + + public void reset() { + this.status = RunPlanTaskStatus.NO; + } + + @Override + public RunPlanTaskItem clone() { + try { + return (RunPlanTaskItem) super.clone(); + } catch (CloneNotSupportedException e) { + throw new AssertionError(); + } + } + + /** + * 行车计划状态 + */ + public enum RunPlanTaskStatus { + NO + } + } + /** * 超限类型 */ diff --git a/src/main/java/club/joylink/rtss/vo/client/ctc/CtcRunPlanVO.java b/src/main/java/club/joylink/rtss/vo/client/ctc/CtcRunPlanVO.java index 60369ac31..542c4660c 100644 --- a/src/main/java/club/joylink/rtss/vo/client/ctc/CtcRunPlanVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/ctc/CtcRunPlanVO.java @@ -3,9 +3,11 @@ package club.joylink.rtss.vo.client.ctc; import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; import lombok.Getter; import lombok.Setter; +import org.springframework.util.CollectionUtils; import java.time.LocalTime; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; /** @@ -102,7 +104,7 @@ public class CtcRunPlanVO { /** * 列车运行计划作业 */ - private List runPlanTaskList; + private Map runPlanTaskItemMap; public CtcRunPlanVO(String stationCode, String code) { this.stationCode = stationCode; @@ -125,7 +127,7 @@ public class CtcRunPlanVO { this.trackDiscordant = ctcStationRunPlanLog.getTrackDiscordant(); // 运行股道与基本径路不一致 this.entryOutDiscordant = ctcStationRunPlanLog.getEntryOutDiscordant(); // 出入口与基本径路不一致 this.passenger = ctcStationRunPlanLog.getPassenger(); // 客运车 - this.runPlanTaskList = ctcStationRunPlanLog.getRunPlanTaskList(); // 列车运行计划作业 + this.runPlanTaskItemMap = ctcStationRunPlanLog.getRunPlanTaskItemMap(); // 列车运行计划作业 if (ctcStationRunPlanLog.getArriveRunPlan() != null) { // 到达计划 this.arriveRunPlan = new RunPlanItem(ctcStationRunPlanLog.getArriveRunPlan()); if (ctcStationRunPlanLog.getArriveRunPlan().getElectrical() != null) { @@ -158,10 +160,22 @@ public class CtcRunPlanVO { change = true; } // 存在不一样的选项 - long modifyNum = runPlanLog.getRunPlanTaskList().stream().filter(task -> !this.runPlanTaskList.contains(task)).count(); - if (modifyNum > 0 || (runPlanLog.getRunPlanTaskList().size() != this.runPlanTaskList.size())) { // 长度不一致直接赋值 - this.runPlanTaskList = runPlanLog.getRunPlanTaskList(); - changeCtcRunPlanVO.setRunPlanTaskList(runPlanLog.getRunPlanTaskList()); + Map modifyMap = new HashMap<>(); + runPlanLog.getRunPlanTaskItemMap().forEach((k, v) -> { + CtcStationRunPlanLog.RunPlanTaskItem statusItem = null; + if (!this.getRunPlanTaskItemMap().containsKey(k)) { + statusItem = v.clone(); + modifyMap.put(k, statusItem); + this.getRunPlanTaskItemMap().put(k, statusItem); + } else { + statusItem = new CtcStationRunPlanLog.RunPlanTaskItem(k); + if (this.getRunPlanTaskItemMap().get(k).compareAndChange(v, statusItem)) { + modifyMap.put(k, statusItem); + } + } + }); + if (runPlanLog.getRunPlanTaskItemMap().size() != this.getRunPlanTaskItemMap().size() || !CollectionUtils.isEmpty(modifyMap)) { + changeCtcRunPlanVO.setRunPlanTaskItemMap(modifyMap); change = true; } // 是否客运 From 1ca1b5372b7b8b95b06bb4df4631c3b2667ab281 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 17 Jun 2022 10:40:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E8=BF=90=E8=A1=8C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ATS/operation/vo/CtcRunPlanParam.java | 29 +++++++++++-------- .../runplan/CtcStationRunPlanLogService.java | 16 +++++----- .../cbtc/CTC/data/CtcStationRunPlanLog.java | 4 +-- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java index e2121ddf5..d054db380 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/CtcRunPlanParam.java @@ -4,12 +4,12 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; @Getter @@ -134,7 +134,7 @@ public class CtcRunPlanParam implements Cloneable { /** * 列车运行计划作业 */ - private List runPlanTaskList = new ArrayList<>(); + private Map runPlanTaskMap = new HashMap(); /** * 删除时构造实体 @@ -146,7 +146,7 @@ public class CtcRunPlanParam implements Cloneable { p.setRunPlanCode(this.runPlanCode); p.setStationCode(this.stationCode); p.setTripNumber(this.tripNumber); - p.setRunPlanTaskList(null); + p.setRunPlanTaskMap(null); return p; } @@ -232,10 +232,15 @@ public class CtcRunPlanParam implements Cloneable { change = true; } // 存在不一样的选项 - long modifyNum = modify.getRunPlanTaskList().stream().filter(task -> !this.runPlanTaskList.contains(task)).count(); - if (modifyNum > 0 || (this.runPlanTaskList.size() != modify.getRunPlanTaskList().size())) { // 长度不一致直接赋值 - this.runPlanTaskList = modify.getRunPlanTaskList(); - runPlanParam.setRunPlanTaskList(modify.getRunPlanTaskList()); + Map modifyMap = new HashMap<>(); + modify.getRunPlanTaskMap().forEach((k, v) -> { + if (!this.runPlanTaskMap.containsKey(k) || !Objects.equals(this.runPlanTaskMap.get(k), v)) { + modifyMap.put(k, v); + } + }); + if (this.runPlanTaskMap.size() != modify.getRunPlanTaskMap().size() || !CollectionUtils.isEmpty(modifyMap)) { + this.runPlanTaskMap.putAll(modify.getRunPlanTaskMap()); + runPlanParam.setRunPlanTaskMap(modifyMap); change = true; } return change ? runPlanParam : null; @@ -266,9 +271,9 @@ public class CtcRunPlanParam implements Cloneable { public CtcRunPlanParam clone() { try { CtcRunPlanParam clone = (CtcRunPlanParam) super.clone(); - List list = new ArrayList<>(this.runPlanTaskList.size()); - Collections.copy(list, this.runPlanTaskList); - clone.setRunPlanTaskList(list); + Map map = new HashMap(this.runPlanTaskMap.size()); + map.putAll(this.runPlanTaskMap); + clone.setRunPlanTaskMap(map); return clone; } catch (CloneNotSupportedException e) { throw new AssertionError(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java index f434fd237..d5e3d4ebc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcStationRunPlanLogService.java @@ -19,10 +19,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -484,9 +481,14 @@ public class CtcStationRunPlanLogService { original.setDepartDirectionCode(modify.getDepartDirectionCode()); } // 存在不一样的选项 - long modifyNum = modify.getRunPlanTaskList().stream().filter(task -> !original.getRunPlanTaskList().contains(task)).count(); - if (modifyNum > 0 || (original.getRunPlanTaskList().size() != modify.getRunPlanTaskList().size())) { // 长度不一致直接赋值 - original.setRunPlanTaskList(modify.getRunPlanTaskList()); + Map modifyMap = new HashMap<>(); + modify.getRunPlanTaskMap().forEach((k, v) -> { + if (!original.getRunPlanTaskMap().containsKey(k) && !Objects.equals(original.getRunPlanTaskMap().get(k), v)) { + modifyMap.put(k, v); + } + }); + if (original.getRunPlanTaskMap().size() != modify.getRunPlanTaskMap().size() || !CollectionUtils.isEmpty(modifyMap)) { + original.getRunPlanTaskMap().putAll(modify.getRunPlanTaskMap()); } if (!Objects.equals(original.getStatus(), modify.getStatus())) { original.setStatus(modify.getStatus()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java index ca4bebed1..512e83257 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java @@ -131,8 +131,8 @@ public class CtcStationRunPlanLog { this.trackDiscordant = paramInfo.getTrackDiscordant(); // 运行股道与基本径路不一致 this.entryOutDiscordant = paramInfo.getEntryOutDiscordant(); // 出入口与基本径路不一致 this.transfinite = paramInfo.getTransfinite(); // 超限等级 - if (CollectionUtils.isEmpty(paramInfo.getRunPlanTaskList())) { // 运行计划任务 - this.runPlanTaskItemMap = paramInfo.getRunPlanTaskList().stream() + if (CollectionUtils.isEmpty(paramInfo.getRunPlanTaskMap())) { // 运行计划任务 + this.runPlanTaskItemMap = paramInfo.getRunPlanTaskMap().keySet().stream() .collect(Collectors.toMap(t -> t, t -> new RunPlanTaskItem(t))); } else { this.runPlanTaskItemMap = new HashMap<>(0); From b2f464b6068a167e40268f0a21131c1a11afe10b Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 17 Jun 2022 10:53:06 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90=E7=A9=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java index 512e83257..f2f13c5b9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java @@ -144,7 +144,9 @@ public class CtcStationRunPlanLog { this.lateReason = null; this.planProperties = null; // 运行任务复位 - this.runPlanTaskItemMap.forEach((k, v) -> v.reset()); + if (!CollectionUtils.isEmpty(this.runPlanTaskItemMap)) { + this.runPlanTaskItemMap.forEach((k, v) -> v.reset()); + } if (this.arriveRunPlan != null) { this.arriveRunPlan.setRunModel(StationDirection.ReceiveAndDeliverModel.R); this.arriveRunPlan.reset();