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);