From 22d59b217f5041dc69f10ffa7fcef10d4ee75e82 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 11 Jul 2022 14:55:28 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E3=80=90=E5=88=97=E8=BD=A6=E8=A1=8C?= =?UTF-8?q?=E9=A9=B6=E6=97=B6=E5=8C=BA=E6=AE=B5=E5=8D=A0=E7=94=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81BUG=E3=80=91=20=E3=80=90=E8=AE=A1=E5=88=92=E4=B8=8B?= =?UTF-8?q?=E5=8F=91=E8=AE=A1=E5=88=92=E4=BF=A1=E6=81=AF=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATP/ground/AtpSectionService.java | 36 ++++++++++--------- .../ATS/operation/vo/CtcRunPlanParam.java | 12 +++++++ .../ATS/service/runplan/CtcZoneService.java | 27 +++++++++++--- .../cbtc/CTC/data/CtcEffectRepository.java | 13 +++++-- 4 files changed, 63 insertions(+), 25 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java index d11792ca9..b9af7ee8b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java @@ -227,25 +227,27 @@ public class AtpSectionService { // 道岔列表 List relSwitchList = section.getRelSwitchList(); // 反位情况下 + Switch relSwitch = null; if (relSwitchList.stream().anyMatch(Switch::isPosR)) { - Switch relSwitch = relSwitchList.stream().filter(Switch::isPosR).findFirst().orElse(null); - if (relSwitch != null) { - // 反位前区段列表 - Section nextSection = relSwitch.getA(); - do { - atpSectionList.add(0, nextSection); - nextSection = nextSection.getNextRunningSectionOf(!right); - } while (nextSection.getRelSwitch() != null && relSwitchList.contains(nextSection.getRelSwitch())); - - // 反位后区段列表 - nextSection = relSwitch.isPosN() ? relSwitch.getB() : relSwitch.getC(); - while (nextSection != null && relSwitchList.contains(nextSection.getRelSwitch())) { - atpSectionList.add(nextSection); - nextSection = nextSection.getNextRunningSectionOf(right); - } - } + relSwitch = relSwitchList.stream().filter(Switch::isPosR).findFirst().orElse(null); } else { - relSwitchList.forEach(relSwitch -> atpSectionList.addAll(relSwitch.getSectionsByPosition())); + relSwitch = relSwitchList.stream().filter(Switch::isPosN).findFirst().orElse(null); + //relSwitchList.forEach(relSwitch -> atpSectionList.addAll(relSwitch.getSectionsByPosition())); + } + if (relSwitch != null) { + // 反位前区段列表 + Section nextSection = relSwitch.getA(); + do { + atpSectionList.add(0, nextSection); + nextSection = nextSection.getNextRunningSectionOf(!right); + } while (nextSection.getRelSwitch() != null && relSwitchList.contains(nextSection.getRelSwitch())); + + // 反位后区段列表 + nextSection = relSwitch.isPosN() ? relSwitch.getB() : relSwitch.getC(); + while (nextSection != null && relSwitchList.contains(nextSection.getRelSwitch())) { + atpSectionList.add(nextSection); + nextSection = nextSection.getNextRunningSectionOf(right); + } } return atpSectionList; } 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 8bb733626..734660736 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 @@ -11,6 +11,7 @@ import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.concurrent.atomic.AtomicInteger; @Getter @Setter @@ -196,6 +197,16 @@ public class CtcRunPlanParam implements Cloneable { */ private RunType runType; + /** + * 数据版本 + */ + private AtomicInteger version = new AtomicInteger(0); + + /** + * 是否已发布 + */ + private boolean release; + /** * 删除时构造实体 * @@ -672,6 +683,7 @@ public class CtcRunPlanParam implements Cloneable { Map map = new HashMap<>(this.runPlanTaskMap.size()); map.putAll(this.runPlanTaskMap); clone.setRunPlanTaskMap(map); + clone.setVersion(new AtomicInteger(this.version.get())); return clone; } catch (CloneNotSupportedException e) { throw new AssertionError(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java index 43ca9996b..b356cf25d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java @@ -74,6 +74,7 @@ public class CtcZoneService { } else { runPlanParam.setDepartSectionCode(sectionCode); } + afterUpdate(runPlanParam); return runPlanParam; } @@ -94,6 +95,7 @@ public class CtcZoneService { } else { runPlanParam.setDepartTripNumber(tripNumber); } + afterUpdate(runPlanParam); return runPlanParam; } @@ -119,8 +121,8 @@ public class CtcZoneService { runPlanParam.setDepartTime(planTime); } runPlanParam.setDepartPlanTime(planTime); - } + afterUpdate(runPlanParam); return runPlanParam; } @@ -137,6 +139,7 @@ public class CtcZoneService { } runPlanParam.setDepartPlanTime(runPlanParam.getDepartPlanTime().plusMinutes(minutes)); } + afterUpdate(runPlanParam); return runPlanParam; } @@ -157,6 +160,7 @@ public class CtcZoneService { } else { runPlanParam.setDepartDirectionCode(directionCode); } + afterUpdate(runPlanParam); return runPlanParam; } @@ -177,6 +181,7 @@ public class CtcZoneService { } else { runPlanParam.setDepartStationCode(planStationCode); } + afterUpdate(runPlanParam); return runPlanParam; } @@ -304,10 +309,13 @@ public class CtcZoneService { CtcEffectRepository.StationRunPlanRepository runPlanRepository = ctcRepository.getEffectStationRunPlanMap(stationCode); List allList = new LinkedList<>(); runPlanRepository.getDataMap().forEach((runPlanCode, ctcRunPlanParam) -> { - CtcStationRunPlanLog runPlanLog = ctcRepository.getRunPlanByRunPlanCodeAndStationCode(stationCode, runPlanCode); - CtcRunPlanVO runPlanVO = CtcRunPlanVO.compareAndChange(ctcRunPlanParam, runPlanLog); - if (runPlanVO != null) { - allList.add(runPlanVO); + if (!ctcRunPlanParam.isRelease()) { + ctcRunPlanParam.setRelease(true); // 标记状态为已发布 + CtcStationRunPlanLog runPlanLog = ctcRepository.getRunPlanByRunPlanCodeAndStationCode(stationCode, runPlanCode); + CtcRunPlanVO runPlanVO = CtcRunPlanVO.compareAndChange(ctcRunPlanParam, runPlanLog); + if (runPlanVO != null) { + allList.add(runPlanVO); + } } }); if (!allList.isEmpty()) { @@ -321,4 +329,13 @@ public class CtcZoneService { }); } } + + /** + * 更新后操作 + * + * @param param 参数 + */ + private void afterUpdate(CtcRunPlanParam param) { + param.getVersion().incrementAndGet(); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java index f61f7575c..6354fd7b9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java @@ -102,11 +102,18 @@ public class CtcEffectRepository { effectRepository.setStationCode(stationCode); this.stationRunPlanMap.put(stationCode, effectRepository); } - // 增加版本 effectRepository.setUpdateTime(updateDateTime); - effectRepository.getVersion().incrementAndGet(); + CtcRunPlanParam oldPlan; + boolean change = false; for (Map.Entry v : runPlanMap.entrySet()) { - effectRepository.save(v.getValue().clone()); + oldPlan = effectRepository.query(v.getValue().getRunPlanCode()); + if (oldPlan == null || oldPlan.getVersion().get() < v.getValue().getVersion().get()) { + effectRepository.save(v.getValue().clone()); + change = true; + } + } + if (change) { // 增加版本 + effectRepository.getVersion().incrementAndGet(); } } } From eb1e384654663c066dc39df1c9b2acabfffd0875 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 11 Jul 2022 15:40:44 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E3=80=90=E5=B0=86=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E5=8F=91=E5=B8=83=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=8E=A5=E6=94=B6=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/operation/vo/CtcRunPlanParam.java | 4 ++-- .../runplan/CtcStationRunPlanLogService.java | 3 +++ .../cbtc/ATS/service/runplan/CtcZoneService.java | 3 +-- .../cbtc/CTC/data/CtcEffectRepository.java | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 5 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 734660736..5018c03b5 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 @@ -203,9 +203,9 @@ public class CtcRunPlanParam implements Cloneable { private AtomicInteger version = new AtomicInteger(0); /** - * 是否已发布 + * 是否已接收 */ - private boolean release; + private boolean receive; /** * 删除时构造实体 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 2e939202d..61ee183e8 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 @@ -270,7 +270,10 @@ public class CtcStationRunPlanLogService { if (CollectionUtils.isEmpty(ctcRunPlanVOList)) { return; } + CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository(); ctcRunPlanVOList.forEach(ctcRunPlanVO -> { + // 生效区接收状态修改 + effectRepository.receiveRunPlan(stationCode, ctcRunPlanVO.getRunPlanCode()); CtcRunPlanParam modifyParam = ctcRunPlanVO.getRunPlan(); CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository() .getRunPlanByRunPlanCodeAndStationCode(stationCode, ctcRunPlanVO.getRunPlanCode()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java index b356cf25d..1953b0373 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/runplan/CtcZoneService.java @@ -309,8 +309,7 @@ public class CtcZoneService { CtcEffectRepository.StationRunPlanRepository runPlanRepository = ctcRepository.getEffectStationRunPlanMap(stationCode); List allList = new LinkedList<>(); runPlanRepository.getDataMap().forEach((runPlanCode, ctcRunPlanParam) -> { - if (!ctcRunPlanParam.isRelease()) { - ctcRunPlanParam.setRelease(true); // 标记状态为已发布 + if (!ctcRunPlanParam.isReceive()) { // 对未接收的运行计划,进行对比,已接收的就不需要再做对比 CtcStationRunPlanLog runPlanLog = ctcRepository.getRunPlanByRunPlanCodeAndStationCode(stationCode, runPlanCode); CtcRunPlanVO runPlanVO = CtcRunPlanVO.compareAndChange(ctcRunPlanParam, runPlanLog); if (runPlanVO != null) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java index 6354fd7b9..73aaa4a3a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcEffectRepository.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.CTC.data; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam; import club.joylink.rtss.simulation.cbtc.CTC.data.vo.CtcRunPlanVO; import club.joylink.rtss.simulation.cbtc.data.map.StationDirection; @@ -263,6 +264,20 @@ public class CtcEffectRepository { return repository.query(code); } + /** + * 修改运行计划为接收状态 + * + * @param stationCode 车站编码 + * @param runPlanCode 运行计划编码 + */ + public void receiveRunPlan(String stationCode, String runPlanCode) { + StationRunPlanRepository repository = this.stationRunPlanMap.get(stationCode); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(repository); + CtcRunPlanParam runPlanParam = repository.query(runPlanCode); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanParam); + runPlanParam.setReceive(true); + } + /** * 阶段计划数据 */ @@ -496,7 +511,6 @@ public class CtcEffectRepository { } } - public void reset() { this.stationRunPlanMap.clear(); this.stationApplyRunPlanMap.clear(); From 18bdc532b1ff36f2a1d7c12a7a637f649716ac99 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 11 Jul 2022 17:42:30 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E3=80=90=E8=A1=8C=E8=BD=A6=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=BF=AE=E6=94=B9=E5=AE=9E=E9=99=85=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/operation/Operation.java | 5 ++ .../CtcStationRunPlanOperateHandler.java | 15 ++++++ .../runplan/CtcStationRunPlanLogService.java | 19 ++++++- .../cbtc/CTC/data/CtcStationRunPlanLog.java | 53 +++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index aeb971e1e..d004cc6f3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -980,6 +980,11 @@ public class Operation { * 设置终到车 */ CTC_LOG_SET_END_RUN_PLAN, + + /** + * 实际时间平移多少分钟 + */ + CTC_LOG_ACTUAL_TIME_ADD_MINUTE, /**************调度台******************/ /** * 调度台保存运行计划 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java index 9872f4da5..a23a4506a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java @@ -357,4 +357,19 @@ public class CtcStationRunPlanOperateHandler { public void setEndRunPlan(Simulation simulation, String stationCode, String runPlanCode, int status) { ctcStationRunPlanLogService.setEndRunPlan(simulation, stationCode, runPlanCode, status); } + + /** + * 修改实际时间 + * + * @param simulation 仿真 + * @param stationCode 车站编码 + * @param runPlanCode 运行计划编码 + * @param minutes 分钟数 + * @param model 接发 + */ + @OperateHandlerMapping(type = Operation.Type.CTC_LOG_ACTUAL_TIME_ADD_MINUTE) + public void actualTimeAddMinute(Simulation simulation, String stationCode, String runPlanCode, int minutes, StationDirection.ReceiveAndDeliverModel model) { + ctcStationRunPlanLogService.actualTimeAddMinute(simulation, stationCode, runPlanCode, minutes, model); + } + } 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 61ee183e8..627ed86e9 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 @@ -566,6 +566,24 @@ public class CtcStationRunPlanLogService { runPlanLog.setEndRunPlan(status == 1); } + /** + * 修改实际时间 + * + * @param simulation 仿真 + * @param stationCode 车站编码 + * @param runPlanCode 运行计划编码 + * @param minutes 分钟数 + * @param model 接发 + */ + public void actualTimeAddMinute(Simulation simulation, String stationCode, String runPlanCode, int minutes + , StationDirection.ReceiveAndDeliverModel model) { + CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanCode); + if (StationDirection.ReceiveAndDeliverModel.R.equals(model)) { + runPlanLog.arriveActualTime(minutes); + } + runPlanLog.departActualTime(minutes); + } + /** * 修改原始数据,并返回修改属性的对象 * @@ -766,5 +784,4 @@ public class CtcStationRunPlanLogService { }); } } - } 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 1d240814e..2c9e58f81 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 @@ -18,6 +18,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -334,6 +336,26 @@ public class CtcStationRunPlanLog { return (this.arriveRunPlan != null && this.arriveRunPlan.isElectrical()) || (this.departRunPlan != null && this.departRunPlan.isElectrical()); } + /** + * 到达实际时间增加minutes分钟 + * + * @param minutes 分钟数 + */ + public void arriveActualTime(int minutes) { + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(arriveRunPlan); + arriveRunPlan.actualAddMinute(minutes); + } + + /** + * 出发实际时间增加minutes分钟 + * + * @param minutes 分钟数 + */ + public void departActualTime(int minutes) { + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(departRunPlan); + departRunPlan.actualAddMinute(minutes); + } + @Setter @Getter public static class RunPlanItem { @@ -472,6 +494,37 @@ public class CtcStationRunPlanLog { public boolean isEffect() { return this.finish || RunPlanItem.WAIT.equals(this.adjacentMessage) || RunPlanItem.FINISH.equals(this.adjacentMessage); } + + /** + * 实际时间增加minute时间 + * + * @param minute 分钟数 + */ + public void actualAddMinute(int minute) { + LocalTime localTime = isValidDate(this.actualTime); + if (localTime != null) { + this.actualTime = localTime.toString(); + } + } + + /** + * 校验时间并返回时间 + * HH:mm (([0-1][0-9])|(2[0-3])):([0-5][0-9])$ + * yyyy-MM-dd HH:mm \\d{4}(\\-|\\/|.)\\d{1,2}\\1\\d{1,2} ([0-1]?[0-9]|2[0-3]):([0-5][0-9])$ + * yyyy-MM-dd HH:mm:ss \\d{4}(\\-|\\/|.)\\d{1,2}\\1\\d{1,2} ([0-1]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$ + * + * @param dateStr 时间字符串 + * @return 时间 + */ + private LocalTime isValidDate(String dateStr) { + Pattern datePattern = Pattern.compile("(([0-1][0-9])|(2[0-3])):([0-5][0-9])$"); + Matcher matcher = datePattern.matcher(dateStr); + if (matcher.find()) { + return LocalTime.parse(dateStr); + } else { + return null; + } + } } /** From f335e077508eff13d78c3b728a6db3b0d960624a Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 12 Jul 2022 13:51:19 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E3=80=90=E8=A1=8C=E8=BD=A6=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AE=BE=E7=BD=AE=E4=BB=BB=E5=8A=A1=E3=80=91=20?= =?UTF-8?q?=E3=80=90=E8=A1=8C=E8=BD=A6=E6=97=A5=E5=BF=97=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=82=A1=E9=81=93=E4=B8=80=E8=87=B4=E7=8A=B6=E6=80=81BUG?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CtcStationRunPlanOperateHandler.java | 6 ++-- .../runplan/CtcStationRunPlanLogService.java | 18 +++++----- .../cbtc/CTC/data/CtcStationRunPlanLog.java | 36 ++++++++++++------- .../CTC/data/vo/CtcStationRunPlanLogVO.java | 33 ++++++++--------- 4 files changed, 53 insertions(+), 40 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java index a23a4506a..7966fbc73 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/CtcStationRunPlanOperateHandler.java @@ -217,11 +217,11 @@ public class CtcStationRunPlanOperateHandler { * @param stationCode 车站编码 * @param runPlanCode 运行计划编码 * @param taskKey 任务Key - * @param status 是否设置 1 是 , 0 否 + * @param task 设置任务 */ @OperateHandlerMapping(type = Operation.Type.CTC_LOG_SET_TASK) - public void setTask(Simulation simulation, String stationCode, String runPlanCode, String taskKey, int status) { - ctcStationRunPlanLogService.setTask(simulation, stationCode, runPlanCode, taskKey, status); + public void setTask(Simulation simulation, String stationCode, String runPlanCode, String taskKey, CtcStationRunPlanLog.RunPlanTask task) { + ctcStationRunPlanLogService.setTask(simulation, stationCode, runPlanCode, taskKey, task); } /** 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 627ed86e9..2d6e0abcd 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 @@ -462,16 +462,18 @@ public class CtcStationRunPlanLogService { * @param simulation 仿真 * @param stationCode 车站编码 * @param runPlanCode 运行计划编码 - * @param taskKey 任务Key + * @param task 任务Key */ - public void setTask(Simulation simulation, String stationCode, String runPlanCode, String taskKey, int status) { - CtcStationRunPlanLog.RunPlanTask task = CtcStationRunPlanLog.RunPlanTask.getTaskByKey(taskKey); - BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(task); + public void setTask(Simulation simulation, String stationCode, String runPlanCode, String taskKey, CtcStationRunPlanLog.RunPlanTask task) { CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanCode); - if (status == 1) { // 设置 - runPlanLog.getRunPlanTaskItemMap().put(task.getOptionKey(), new CtcStationRunPlanLog.RunPlanTaskItem(task)); - } else { // 取消 - runPlanLog.getRunPlanTaskItemMap().remove(task.getOptionKey()); + CtcStationRunPlanLog.RunPlanTaskItem taskItem = runPlanLog.getRunPlanTaskItemMap().get(taskKey); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(taskItem); + if (CtcStationRunPlanLog.RunPlanTask.NO.equals(task)) { // 取消 + taskItem.setType(task); + } else if (task.getOptionKey().equals(taskKey)) { // 设置 + runPlanLog.getRunPlanTaskItemMap().put(taskKey, new CtcStationRunPlanLog.RunPlanTaskItem(task)); + } else { + BusinessExceptionAssertEnum.DATA_ERROR.exception("任务类型不匹配"); } } 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 2c9e58f81..e929b557a 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,15 +9,11 @@ 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.LocalDateTime; import java.time.LocalTime; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -186,12 +182,14 @@ public class CtcStationRunPlanLog { this.trackDiscordant = paramInfo.getTrackDiscordant(); // 运行股道与基本径路不一致 this.entryOutDiscordant = paramInfo.getEntryOutDiscordant(); // 出入口与基本径路不一致 this.transfinite = paramInfo.getTransfinite(); // 超限等级 - if (CollectionUtils.isEmpty(paramInfo.getRunPlanTaskMap())) { // 运行计划任务 - this.runPlanTaskItemMap = paramInfo.getRunPlanTaskMap().keySet().stream() - .collect(Collectors.toMap(RunPlanTask::getOptionKey, RunPlanTaskItem::new)); - } else { - this.runPlanTaskItemMap = new HashMap<>(0); - } + this.runPlanTaskItemMap = new HashMap<>(RunPlanTask.values().length); // 运行计划任务 + RunPlanTask.getOptionKeyList().forEach(key -> this.runPlanTaskItemMap.put(key, new RunPlanTaskItem(RunPlanTask.NO))); + paramInfo.getRunPlanTaskMap().forEach((k, v) -> { + if (v != null && v > 0) { + this.runPlanTaskItemMap.get(k.getOptionKey()).setType(k); + } + }); + // 删除状态 this.delete = paramInfo.getStatus() == -1; this.startRunPlan = paramInfo.getStartRunPlan() != null && paramInfo.getStartRunPlan(); this.endRunPlan = paramInfo.getEndRunPlan() != null && paramInfo.getEndRunPlan(); @@ -629,6 +627,8 @@ public class CtcStationRunPlanLog { */ @Getter public enum RunPlanTask { + // 空任务 + NO("", ""), // 技术停点 Technical_Stop_Point("stopPoint", "技术停点"), // 上水 @@ -678,9 +678,19 @@ public class CtcStationRunPlanLog { * @param key 唯一键 * @return 运行任务 */ - public static RunPlanTask getTaskByKey(String key) { + public static List getTaskByKey(String key) { return Arrays.stream(RunPlanTask.values()).filter(r -> r.getOptionKey().equals(key)) - .findFirst().orElseGet(null); + .collect(Collectors.toList()); + } + + /** + * 获取任务对应列key + * + * @return key列表 + */ + public static List getOptionKeyList() { + return Arrays.stream(RunPlanTask.values()).filter(r -> !StringUtils.isEmpty(r.getOptionKey())) + .map(r -> r.getOptionKey()).distinct().collect(Collectors.toList()); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcStationRunPlanLogVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcStationRunPlanLogVO.java index 259deed66..5b9d46aa8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcStationRunPlanLogVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/vo/CtcStationRunPlanLogVO.java @@ -5,6 +5,7 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; import lombok.Getter; import lombok.Setter; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.time.LocalTime; import java.util.*; @@ -81,7 +82,7 @@ public class CtcStationRunPlanLogVO { /** * 超限等级 */ - private String transfinite; + private CtcStationRunPlanLog.TransfiniteType transfinite; /** * 是否电力 @@ -155,7 +156,7 @@ public class CtcStationRunPlanLogVO { this.delete = ctcStationRunPlanLog.getDelete(); // 删除 this.keyTrains = ctcStationRunPlanLog.getKeyTrains(); // 重点列车 this.military = ctcStationRunPlanLog.getMilitary(); // 军用 - this.transfinite = ctcStationRunPlanLog.getTransfinite().getVal(); // 超限等级 + this.transfinite = ctcStationRunPlanLog.getTransfinite(); // 超限等级 this.trackDiscordant = ctcStationRunPlanLog.getTrackDiscordant(); // 运行股道与基本径路不一致 this.entryOutDiscordant = ctcStationRunPlanLog.getEntryOutDiscordant(); // 出入口与基本径路不一致 this.passenger = ctcStationRunPlanLog.getPassenger(); // 客运车 @@ -166,12 +167,12 @@ public class CtcStationRunPlanLogVO { this.departRunPlan = new RunPlanItem(ctcStationRunPlanLog.getDepartRunPlan()); } // 列车运行计划作业 - this.runPlanTaskItemMap = Arrays.stream(CtcStationRunPlanLog.RunPlanTask.values()) - .collect(Collectors.toMap(CtcStationRunPlanLog.RunPlanTask::getOptionKey, r -> EMPTY_STR)); - ctcStationRunPlanLog.getRunPlanTaskItemMap().forEach((k, v) -> this.runPlanTaskItemMap.put(k, v.getType().getOptionName())); + this.runPlanTaskItemMap = Arrays.stream(CtcStationRunPlanLog.RunPlanTask.values()).filter(r -> !StringUtils.isEmpty(r.getOptionKey())) + .collect(Collectors.toMap(CtcStationRunPlanLog.RunPlanTask::getOptionKey, r -> CtcStationRunPlanLog.RunPlanTask.NO.name())); + ctcStationRunPlanLog.getRunPlanTaskItemMap().forEach((k, v) -> this.runPlanTaskItemMap.put(k, v.getType().name())); List planPropertiesList = new LinkedList<>(); this.electrical = ctcStationRunPlanLog.isElectrical(); // 电力 - if (this.electrical != null) { + if (this.electrical) { planPropertiesList.add("电力;"); } this.planProperties = String.join("", planPropertiesList); @@ -202,7 +203,7 @@ public class CtcStationRunPlanLogVO { this.runPlanTaskItemMap.forEach((k, v) -> { // 新增的任务 : 删除的任务 CtcStationRunPlanLog.RunPlanTaskItem taskItem = runPlanLog.getRunPlanTaskItemMap().get(k); - String val = taskItem != null ? taskItem.getType().getOptionName() : EMPTY_STR; + String val = taskItem.getType().name(); if (!Objects.equals(val, v)) { modifyMap.put(k, val); this.runPlanTaskItemMap.put(k, val); @@ -233,7 +234,7 @@ public class CtcStationRunPlanLogVO { // 运行股道与基本径路不一致 if (!Objects.equals(this.trackDiscordant, runPlanLog.getTrackDiscordant())) { this.trackDiscordant = runPlanLog.getTrackDiscordant(); - changeCtcStationRunPlanLogVO.setTrackSectionCode(runPlanLog.getTrackSectionCode()); + changeCtcStationRunPlanLogVO.setTrackDiscordant(runPlanLog.getTrackDiscordant()); change = true; } // 出入口与基本径路不一致 @@ -243,9 +244,9 @@ public class CtcStationRunPlanLogVO { change = true; } // 超限等级 - if (!Objects.equals(this.transfinite, runPlanLog.getTransfinite().getVal())) { - this.transfinite = runPlanLog.getTransfinite().getVal(); - changeCtcStationRunPlanLogVO.setTransfinite(runPlanLog.getTransfinite().getVal()); + if (!Objects.equals(this.transfinite, runPlanLog.getTransfinite())) { + this.transfinite = runPlanLog.getTransfinite(); + changeCtcStationRunPlanLogVO.setTransfinite(runPlanLog.getTransfinite()); change = true; } // 记事 @@ -409,9 +410,9 @@ public class CtcStationRunPlanLogVO { change = true; } // 超限 - if (runPlanItem.getTransfinite() != null && !Objects.equals(paramInfo.getTransfinite(), runPlanItem.getTransfinite().getVal())) { - paramInfo.setTransfinite(runPlanItem.getTransfinite().getVal()); - changeRunItem.setTransfinite(runPlanItem.getTransfinite().getVal()); + if (runPlanItem.getTransfinite() != null && !Objects.equals(paramInfo.getTransfinite(), runPlanItem.getTransfinite())) { + paramInfo.setTransfinite(runPlanItem.getTransfinite()); + changeRunItem.setTransfinite(runPlanItem.getTransfinite()); change = true; } return change ? changeRunItem : null; // 没有变化返回null @@ -483,7 +484,7 @@ public class CtcStationRunPlanLogVO { /** * 超限等级 */ - private String transfinite; + private CtcStationRunPlanLog.TransfiniteType transfinite; public RunPlanItem() { } @@ -506,7 +507,7 @@ public class CtcStationRunPlanLogVO { this.adjacentMessageTime = runPlanItem.getAdjacentMessageTime(); this.finish = runPlanItem.isFinish(); this.electrical = runPlanItem.isElectrical(); - this.transfinite = runPlanItem.getTransfinite().getVal(); + this.transfinite = runPlanItem.getTransfinite(); } } } From 5e29e187a583f7e69e2df041391899e3ce21b8b8 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 12 Jul 2022 17:10:59 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E3=80=90=E6=8E=A5=E8=BE=85=E5=8A=A9?= =?UTF-8?q?=E5=90=8E=E7=BB=AD=E6=93=8D=E4=BD=9C=E4=BF=AE=E6=94=B9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/assist/StationDirectionService.java | 16 ++++++++++------ .../cbtc/data/map/StationDirection.java | 9 +++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/StationDirectionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/StationDirectionService.java index 2e3006d4e..6e5b90886 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/StationDirectionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/StationDirectionService.java @@ -130,17 +130,21 @@ public class StationDirectionService { * 接辅助按钮后续操作 */ private final ButtonThenInterface receiveAssistThen = (simulation, stationDirection) -> { - // 按下接辅助,弹起发辅助 - stationDirection.setDeliverAssistStatus(false); - // 重新设置倒计时时间 - stationDirection.getRemain().set(StationDirection.DEFAULT_RECEIVE_DELAY_TIME); + // 接辅助完成后,改变接方向 + stationDirection.setRunStatus(StationDirection.ReceiveAndDeliverModel.R); + // 邻站修改发方向 + StationDirection adjacentDirection = getRelativeStationDirection(simulation, stationDirection); + adjacentDirection.setRunStatus(StationDirection.ReceiveAndDeliverModel.D); + // 办理完成后 + stationDirection.resetAssistStatus(); + adjacentDirection.resetAssistStatus(); }; /** - * 接辅助按钮后续操作 + * 发辅助按钮后续操作 */ private final ButtonThenInterface deliverAssistThen = (simulation, stationDirection) -> { - // 按下发辅助,弹起发辅助 + // 按下发辅助,弹起接辅助 stationDirection.setReceiveAssistStatus(false); // 重新设置倒计时时间 stationDirection.getRemain().set(StationDirection.DEFAULT_DELIVER_DELAY_TIME); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationDirection.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationDirection.java index 179850d84..9943de434 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationDirection.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationDirection.java @@ -371,6 +371,15 @@ public class StationDirection extends MapNamedElement { return isChange; } + /** + * 重置辅助状态 + */ + public void resetAssistStatus() { + this.deliverAssistStatus = false; + this.receiveAssistStatus = false; + this.remain.set(0); + } + /** * 设置默认属性 */