From e646435e049309673a8b44f38066833e6c661fc8 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Thu, 1 Sep 2022 13:57:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E5=8A=A1=E7=AE=A1=E7=90=86=E7=BB=88?= =?UTF-8?q?=E7=AB=AF=E5=8A=9F=E8=83=BD=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=8F=8A=E8=AE=A1=E5=88=92=E6=94=AF=E6=8C=81=E8=82=A1=E9=81=93?= =?UTF-8?q?=EF=BC=8C=E5=87=BA=E5=85=A5=E5=8F=A3=E4=B8=8E=E7=AB=99=E7=BB=86?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessExceptionAssertEnum.java | 2 +- .../cbtc/CTC/data/CascoControl.java | 9 + .../cbtc/CTC/data/CtcEffectRepository.java | 10 + .../cbtc/CTC/data/TrackSection.java | 11 +- .../fck/CtcManageIOGateOperateHandler.java | 2 +- .../cbtc/CTC/param/CtcRunPlanParam.java | 16 + .../cbtc/CTC/service/CTCService.java | 21 +- .../cbtc/CTC/service/CascoControlService.java | 289 +++++++++++++++--- .../CTC/service/runplan/CtcManageService.java | 46 ++- .../cbtc/build/SimulationBuilder.java | 63 +++- 10 files changed, 402 insertions(+), 67 deletions(-) diff --git a/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java b/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java index 4cfdfacc0..cdd11fe61 100644 --- a/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java +++ b/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java @@ -32,7 +32,7 @@ public enum BusinessExceptionAssertEnum implements BusinessExceptionAssert { OPERATION_REPEAT(10016, "operation repeat"), SIMULATION_EXCEPTION_FOR_SHOW(10017, ""), //错误信息用于展示给仿真用户 OPERATION_FAIL(10018, "操作失败"), - + STATION_DETAIL_NOT_FOUND_RD_PLAN_ITEM(10019,"站细卡控未找到对应的接发车计划"), DATA_ERROR(11000, "data error"), REPEAT_RUN_PLAN_FROM_CTC_UPDATE_DATA(11200,"repeat run plan"), diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CascoControl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CascoControl.java index a9a3de98e..4dcc2f6aa 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CascoControl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CascoControl.java @@ -8,6 +8,7 @@ import lombok.NoArgsConstructor; import java.util.ArrayList; import java.util.List; +import java.util.Objects; @Data @NoArgsConstructor @@ -17,6 +18,14 @@ public class CascoControl { private Route route; private List errorList = new ArrayList<>(); private String tripNum; +// private boolean force; + public CascoControl(Simulation simulation, Station station, Route route, String tripNum/*,Boolean force*/) { + this.simulation = simulation; + this.station = station; + this.route = route; + this.tripNum = tripNum; +// this.force = Objects.isNull(force) ? false : force.booleanValue(); + } public void addErrorMsg(String msg){ this.errorList.add(msg); 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 a52f7e2fe..7cfec11c3 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 @@ -73,6 +73,14 @@ public class CtcEffectRepository { */ private final Map updateReguarTrainLineMap = new ConcurrentHashMap<>(); + /** + * 股道更新区域(从生效区来的数据) + */ + private final Map updateStationTrackSectionMap = new ConcurrentHashMap<>(); + /** + * 出入口更新区域(从生效区来的数据) + */ + private final Map updateDoorMap = new ConcurrentHashMap<>(); /** * 获取生效区的运行计划 * @@ -576,5 +584,7 @@ public class CtcEffectRepository { this.doorRepository.clear(); this.regularTrainLineMap.clear(); updateReguarTrainLineMap.clear(); + updateStationTrackSectionMap.clear(); + this.updateDoorMap.clear(); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/TrackSection.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/TrackSection.java index fd46e4cea..02fcff98d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/TrackSection.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/TrackSection.java @@ -11,7 +11,7 @@ import lombok.Setter; @Setter @Getter @NoArgsConstructor -public class TrackSection { +public class TrackSection implements Cloneable { /** * 编码 */ @@ -122,4 +122,13 @@ public class TrackSection { public enum StandType { NO, LOW, HIGH } + + public TrackSection clone() { + try { + return (TrackSection) super.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + return null; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/operation/fck/CtcManageIOGateOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/operation/fck/CtcManageIOGateOperateHandler.java index 19ae2224b..bbc998abb 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/operation/fck/CtcManageIOGateOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/operation/fck/CtcManageIOGateOperateHandler.java @@ -46,7 +46,7 @@ public class CtcManageIOGateOperateHandler { @OperateHandlerMapping(type = Operation.Type.STATION_IO_GATE_PUBLISH) public void publist(Simulation simulation, String stationCode){ - ctcManageService.publishData(simulation, CtcRepository.CtcFZKType.STATION_DETAIL,stationCode); + ctcManageService.publishData(simulation, CtcRepository.CtcFZKType.IO_GATE,stationCode); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/param/CtcRunPlanParam.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/param/CtcRunPlanParam.java index 13eaac5fa..453792f3e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/param/CtcRunPlanParam.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/param/CtcRunPlanParam.java @@ -232,6 +232,7 @@ public class CtcRunPlanParam implements Cloneable { * 运行计划车次信息 * private String tripNumber; */ + this.tripNumber = tl.getArriveTipNum(); /** @@ -449,6 +450,21 @@ public class CtcRunPlanParam implements Cloneable { return p; } + +/* public boolean getTrackDiscordant(){ + if(Objects.isNull(trackDiscordant)){ + return false; + } + return this.trackDiscordant.booleanValue(); + } + + public boolean getEntryOutDiscordant(){ + if(Objects.isNull(entryOutDiscordant)){ + return false; + } + return this.entryOutDiscordant.booleanValue(); + }*/ + /** * 初始化车次信息 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java index 7e3960c50..38f5a9562 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java @@ -2,10 +2,7 @@ package club.joylink.rtss.simulation.cbtc.CTC.service; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; -import club.joylink.rtss.simulation.cbtc.CTC.data.CtcEffectRepository; -import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository; -import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; -import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence; +import club.joylink.rtss.simulation.cbtc.CTC.data.*; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.*; import org.springframework.beans.factory.annotation.Autowired; @@ -13,6 +10,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import javax.annotation.Resource; import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.*; @@ -23,7 +21,8 @@ import java.util.stream.Collectors; public class CTCService { @Autowired private CiApiService ciApiService; - + @Resource + private CascoControlService cascoControlService; /** * 创建了新的运行计划item */ @@ -161,7 +160,12 @@ public class CTCService { line.setAutoTrigger(trigger); } - + private List cascoControl(CascoControl cc,boolean force){ + if(Objects.equals(true,force)){ + return Collections.emptyList(); + } + return this.cascoControlService.checkCascoControlRoute(cc); + } /** * * @param simulation @@ -179,6 +183,11 @@ public class CTCService { List conflictInfo = new ArrayList<>(); CtcRepository ctcRepository = simulation.getCtcRepository(); + CascoControl cc = new CascoControl(simulation,station,route,tripNumber); + List errCCMsg = this.cascoControl(cc,Objects.isNull(force) ? false:force.booleanValue());//站细卡控 + if(Objects.equals(false,CollectionUtils.isEmpty(errCCMsg))){ + return errCCMsg; + } if (StringUtils.hasText(tripNumber) && !Objects.equals(true, force)) { //列车进路防错办 List lines = ctcRepository.findRouteSequenceLines(station.getCode(), tripNumber); if (!CollectionUtils.isEmpty(lines)) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CascoControlService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CascoControlService.java index 884116f61..b3b590d06 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CascoControlService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CascoControlService.java @@ -1,20 +1,27 @@ package club.joylink.rtss.simulation.cbtc.CTC.service; -import club.joylink.rtss.simulation.cbtc.CTC.data.CascoControl; -import club.joylink.rtss.simulation.cbtc.CTC.data.CtcEffectRepository; -import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository; -import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; +import club.joylink.rtss.exception.BusinessException; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection; +import club.joylink.rtss.simulation.cbtc.CTC.data.*; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.map.Route; +import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Station; +import com.google.common.base.Strings; +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.annotations.Case; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; +import java.util.*; + +import static club.joylink.rtss.simulation.cbtc.CTC.data.TrackSection.DirectionType; @Service @Slf4j @@ -29,59 +36,249 @@ public class CascoControlService { Station station = cc.getStation(); Simulation simulation = cc.getSimulation(); String stationCode = station.getCode(); + CtcRepository ctcRepository = simulation.getCtcRepository(); CtcEffectRepository effectRepository = ctcRepository.getCtcEffectRepository(); - Map runPlanLogMap = simulation.getCtcRepository().getSimulationRunPlanMap().get(stationCode); - Optional runPlanLogOptional = null; - if(Objects.nonNull(runPlanLogMap) && !runPlanLogMap.isEmpty()){ - runPlanLogOptional = this.checkForRunPlan(cc); + List errMsgList = cc.getErrorList(); + boolean isDepart = cc.getRoute().getType() == Route.Type.DEPARTURE; + CtcStationRunPlanLog runPlanLog; + try{ + //在TDCS界面创建进路如果车次号没有在计划中就直接返回,先按照之前的逻辑运行 + runPlanLog = this.checkForRunPlan(cc); + }catch (BusinessException e){ + log.error("站明检测失败 msg:" + e.getMessage(),e); + log.error(e.getMessage() + " errorCode:[{}]",e.getCode()); + return Collections.emptyList(); } -// List allRunPlanLogList = runPlanLogMap.values().stream().filter(d->d.getChangeType() == null && d.isSign()).collect(Collectors.toList()); + CtcStationRunPlanLog.RunPlanItem runPlan = this.findRunPlanFromPlan(isDepart,runPlanLog,errMsgList); + if(Objects.isNull(runPlan)){ + String depart = this.departToChar(isDepart); + String msg = String.format("未找到行车计划的接发车计划 车站[%s] 车次[%s] [%s]", runPlanLog.getStation().getCode(), runPlanLog.getTripNumber(),depart); + log.error(msg); + errMsgList.add(msg); + return errMsgList; + } + CtcEffectRepository.StationDoorRepository doorRepository = effectRepository.getUpdateDoorMap().get(stationCode); + CtcEffectRepository.StationTrackSectionRepository stationTrackRepository = effectRepository.getUpdateStationTrackSectionMap().get(stationCode); + CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository = effectRepository.getUpdateReguarTrainLineMap().get(stationCode); - CtcEffectRepository.StationDoorRepository doorRepository = effectRepository.getDoorRepository().get(stationCode); - if(Objects.nonNull(doorRepository)){ - if(runPlanLogOptional.isPresent()){ - - } - return cc.getErrorList(); + if(Objects.isNull(doorRepository)){ + String msg = String.format("未找到对应的出入口站细数据,车站[%s]",stationCode); + log.error(msg); + return Lists.newArrayList(msg); + } + if(Objects.isNull(stationTrackRepository)){ + String msg = String.format("未找到对应的股道站细数据,车站[%s]",stationCode); + log.error(msg); + return Lists.newArrayList(msg); } - - CtcEffectRepository.StationTrackSectionRepository stationTrackRepository = effectRepository.getStationTrackSectionMap().get(stationCode); - if(Objects.nonNull(stationTrackRepository)){ - - } - return null; + this.checkRegularTrainLine(isDepart,runPlan,regularTrainLineRepository,runPlanLog,errMsgList); + this.doorCheckDetail(isDepart,runPlan,doorRepository,runPlanLog,errMsgList); + this.checkStationTrackDetail(isDepart,runPlan,stationTrackRepository,runPlanLog,errMsgList); + return errMsgList; } - private Optional checkForRunPlan(/*List allRunPlanLogList,*/CascoControl cc){ - CtcStationRunPlanLog runPlanLog = cc.getSimulation().getCtcRepository().getRunPlan(cc.getStation().getCode(),cc.getTripNum()); - if(Objects.isNull(runPlanLog)){ - cc.addErrorMsg(String.format("未在计划中找到对应的车次[%s]",cc.getTripNum())); + private boolean trackAndDoor(Boolean d){ + return Objects.isNull(d) ? false: d.booleanValue(); + } + + /** + * 根据接发车获取行车计划的接发车计划 + * @param isDepart + * @param runPlanLog + * @param errMsgList + * @return + */ + private CtcStationRunPlanLog.RunPlanItem findRunPlanFromPlan(boolean isDepart,CtcStationRunPlanLog runPlanLog,List errMsgList){ + CtcStationRunPlanLog.RunPlanItem runPlan = runPlanLog.getArriveRunPlan(); + if(isDepart){ + runPlan = runPlanLog.getDepartRunPlan(); } - if(!Objects.isNull(runPlanLog.getChangeType()) && !runPlanLog.isSign()){ - cc.addErrorMsg(String.format("未在计划中找到对应的车次[%s]",cc.getTripNum())); - } - return Optional.of(runPlanLog); - /*Map tripNumMap = allRunPlanLogList.stream().collect(Collectors.toMap(CtcStationRunPlanLog::getTripNumber, Function.identity(),(v1,v2)->v1)); - CtcStationRunPlanLog runPlanLog = tripNumMap.get(cc.getTripNum()); - if(Objects.isNull(runPlanLog)){ - cc.addErrorMsg(String.format("未在计划中找到对应的车次[%s]",cc.getTripNum())); + /*if(Objects.isNull(runPlan)){ + String msg = String.format("未找到行车计划的接发车计划 车站[%s] 车次[%s] [%s]", runPlanLog.getStation().getCode(), runPlanLog.getTripNumber(),depart); + log.error(msg); + errMsgList.add(msg); + BusinessExceptionAssertEnum.STATION_DETAIL_NOT_FOUND_RD_PLAN_ITEM.assertNotNull(runPlan,msg); }*/ + return runPlan; } - private void checkCascoForStationTrack(CtcEffectRepository.StationTrackSectionRepository stationTrackRepository){ - + /** + * 根据车辆计划(接发车,车次)查找对应更新区的车辆固定径路数据 + * @param isDepart + * @param regularTrainLineRepository + * @param runPlanLog + * @param errMsg + */ + private void checkRegularTrainLine(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository,CtcStationRunPlanLog runPlanLog,List errMsg){ + if(Objects.isNull(regularTrainLineRepository) || Objects.equals(true,CollectionUtils.isEmpty(errMsg))){ + log.error(""); + return; + } + final String tripNum = runPlan.getTripNumber(); + RegularTrainLine rtl = regularTrainLineRepository.getDataMap().values().stream().filter(d->{ + String tmpNum = d.getArriveTipNum(); + if(isDepart){ + tmpNum = d.getLeaveTipNum(); + } + return Objects.equals(tripNum,tmpNum); + }).findFirst().orElse(null); + if(Objects.isNull(rtl)){ + return; + } + StationDirection sd = rtl.getEnter(); + if(isDepart){ + sd = rtl.getOut(); + } + if(Objects.equals(false,trackAndDoor(runPlanLog.getTrackDiscordant())) && !Objects.equals(runPlan.getTrackSection().getCode(),rtl.getMasterStand().getCode())){ + //股道不一致检测 + errMsg.add("股道固定径路不一致"); + } + if(Objects.equals(false,trackAndDoor(runPlanLog.getEntryOutDiscordant())) && !Objects.equals(runPlan.getStationDirection().getCode(),sd.getCode())){ + //出入口不一致检测 + errMsg.add("出入口固定径路不一致"); + } } - private void checkCascoForDoor(CtcEffectRepository.StationDoorRepository doorRepository,CtcStationRunPlanLog runPlanLog){ - CtcStationRunPlanLog.RunPlanItem departPlan = runPlanLog.getDepartRunPlan(); - CtcStationRunPlanLog.RunPlanItem arrivePlan = runPlanLog.getArriveRunPlan(); - if(Objects.nonNull(departPlan)){ + /** + * 获取对应的执行计划 + * @param cc + * @return + */ + private CtcStationRunPlanLog checkForRunPlan(CascoControl cc){ + String stationCode = cc.getStation().getCode(); + String tripNum = cc.getTripNum(); + CtcStationRunPlanLog runPlanLog = cc.getSimulation().getCtcRepository().getRunPlan(stationCode,tripNum); + return runPlanLog; + } + /** + * 检测接发计划与股道接发车方向是否一致 + * @param isDepart + * @param stationTrackRepository + * @param runPlanLog + * @param errMsg + */ + private void checkStationTrackDetail(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.StationTrackSectionRepository stationTrackRepository,CtcStationRunPlanLog runPlanLog,List errMsg){ + if(!CollectionUtils.isEmpty(errMsg)){ + return; + } + String departChar = this.departToChar(isDepart); + Section masterSection = runPlan.getTrackSection(); + TrackSection ts = stationTrackRepository.getDataMap().get(masterSection.getCode()); + if(Objects.isNull(ts)){ + String d = String.format("未找到对应的股道[%s],车站[%s],车号[%s],股道[%s]",departChar,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),masterSection.getCode()); + log.error(d); + errMsg.add(d); + return; } - if(Objects.nonNull(arrivePlan)){ + checkStationTrackForTransfinite(ts,runPlanLog,errMsg,departChar); + checkStationTrackForTrainType(ts,runPlanLog,errMsg); + } + + /** + * 行车计划股道超限检测 + * @param ts + * @param runPlanLog + * @param errMsg + * @param departChar + */ + private void checkStationTrackForTransfinite(TrackSection ts,CtcStationRunPlanLog runPlanLog,List errMsg,String departChar){ + if(Objects.isNull(runPlanLog.getTransfinite())){ + return; } + CtcStationRunPlanLog.TransfiniteType sTT = ts.getTransfinite(); + //大于一级超限 + boolean transfiniteThanMoreOne =(runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_TWO_LEVEL || + runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_SUPER); + //大于二级超限 + boolean trainfiniteThanMoreTwo = runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_SUPER; + String d = null; + if(sTT == CtcStationRunPlanLog.TransfiniteType.NO && runPlanLog.getTransfinite() != CtcStationRunPlanLog.TransfiniteType.NO){ + //股道不能超限,但是计划超限 + d = String.format("股道[%s],车站[%s],车次[%s],[%s],不支持超限,但行车计划超限[%s]",ts.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite()); + }else if(sTT == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_ONE_LEVEL && transfiniteThanMoreOne){ + //股道是一级超限,但是计划是二级或是超级 + d = String.format("股道[%s],车站[%s],车次[%s],[%s],一级超限,但行车计划超限[%s]",ts.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite()); + }else if(sTT == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_TWO_LEVEL && trainfiniteThanMoreTwo){ + //股道是二级超限,但是计划是超级 + d = String.format("股道[%s],车站[%s],车次[%s],[%s],二级超限,但行车计划超限[%s]",ts.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite()); + } + if(Objects.equals(false,Strings.isNullOrEmpty(d))){ + log.error(d); + errMsg.add(d); + } + } + + /** + * 行车计划股道列车类型检测 + * @param ts + * @param runPlanLog + * @param errMsg + */ + private void checkStationTrackForTrainType(TrackSection ts,CtcStationRunPlanLog runPlanLog,List errMsg){ + boolean trainTypeMatch = false; + TrackSection.TrainType tt = ts.getTrainType(); + switch (tt){ + case PASSENGER: + trainTypeMatch = Objects.equals(false,runPlanLog.isPassengerTrain()); + break; + case GOODS_VAN: + trainTypeMatch = Objects.equals(true,runPlanLog.isPassengerTrain()); + break; + default: + break; + } + if(trainTypeMatch){ + String d = String.format("计划列车类型与股道类型不匹配,股道[%s] 股道区段[%s] 设置列车类型[%s],列车类型[%s]",ts.getCode(),ts.getSectionCode(),tt,runPlanLog.isPassengerTrain()?"客":"货"); + errMsg.add(d); + } + } + + /** + * 计划与出入口检测明细 + * @param isDepart 是否是发车计划 + * @param doorRepository + * @param runPlanLog + */ + private void doorCheckDetail(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.StationDoorRepository doorRepository,CtcStationRunPlanLog runPlanLog,List errMsgList){ + if(!CollectionUtils.isEmpty(errMsgList)){ + return; + } + String depart = this.departToChar(isDepart); + StationDirection sd = runPlan.getStationDirection(); + StationDirection doorDir = doorRepository.getDataMap().get(sd.getCode()); + if(Objects.isNull(doorDir)){ + errMsgList.add(String.format("根据计划方向[%s] 没有找到出入口[%s]数据,车站[%s],车次[%s]" + ,depart,sd.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber())); + } + + boolean isTransfinite = Objects.nonNull(runPlanLog.getTransfinite()) && runPlanLog.getTransfinite() != CtcStationRunPlanLog.TransfiniteType.NO; + + if(!doorDir.isAllowOverrun() && isTransfinite){ + // 出入口不能超限,但是计划超限 + errMsgList.add(String.format("出入口[%s],[%s]不允许超限,但是计划超限,车站[%s],车次[%s]" + ,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber())); + return; + } + if(!doorDir.isTravelTrain() && Objects.equals(true,runPlanLog.isPassengerTrain())){ + //出入口不支持客车,但是计划是客车 + errMsgList.add(String.format("出入口[%s],[%s]不允许客车,车站[%s],车次[%s]" + ,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber())); + return; + } + + if(!doorDir.isGoodsTrain() && Objects.equals(false,runPlanLog.isPassengerTrain())){ + //出入口不支持货车,但是计划是货车 + errMsgList.add(String.format("出入口[%s],[%s]不允许货车,车站[%s],车次[%s]" + ,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber())); + return; + } + } + + private String departToChar(boolean isDepart){ + return isDepart ? "发":"接"; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/runplan/CtcManageService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/runplan/CtcManageService.java index 38b4c3c01..45d412a64 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/runplan/CtcManageService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/runplan/CtcManageService.java @@ -418,19 +418,53 @@ public class CtcManageService { */ public void stationUpdateFromEffect(Simulation simulation, String stationCode){ BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(Objects.isNull(stationCode), String.format("车站号不能为空")); - CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository(); - CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository = effectRepository.getRegularTrainLineMap().get(stationCode); + CtcEffectRepository repository = simulation.getCtcRepository().getCtcEffectRepository(); + CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository = repository.getRegularTrainLineMap().get(stationCode); boolean isEmptyData = Objects.isNull(regularTrainLineRepository) || regularTrainLineRepository.getDataMap().isEmpty(); - BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(isEmptyData, String.format("当前生效区没有数据,无法更新")); +// BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(isEmptyData, String.format("当前生效区没有数据,无法更新")); + CtcEffectRepository.StationTrackSectionRepository sourceStationTrack = repository.getStationTrackSectionMap().get(stationCode); + CtcEffectRepository.StationDoorRepository sourceDoor = repository.getDoorRepository().get(stationCode); + if(Objects.nonNull(sourceStationTrack)){ + CtcEffectRepository.StationTrackSectionRepository stationTrack = repository.getUpdateStationTrackSectionMap().get(stationCode); + if(Objects.isNull(stationTrack)){ + stationTrack = new CtcEffectRepository.StationTrackSectionRepository(); + repository.getUpdateStationTrackSectionMap().put(stationCode,stationTrack); + } + if(stationTrack.version() != sourceStationTrack.version()){ + stationTrack.resetVersion(sourceStationTrack.version()); + for (TrackSection value : sourceStationTrack.getDataMap().values()) { + stationTrack.save(value.clone()); + } + } + + } + if(Objects.nonNull(sourceDoor)){ + CtcEffectRepository.StationDoorRepository door = repository.getUpdateDoorMap().get(stationCode); + if(Objects.isNull(door)){ + door = new CtcEffectRepository.StationDoorRepository(); + repository.getUpdateDoorMap().put(stationCode,door); + } + if(door.version() != sourceDoor.version()){ + door.resetVersion(sourceDoor.version()); + for (StationDirection d : sourceDoor.getDataMap().values()) { + door.save(d.clone()); + } + } + + } + if(Objects.equals(true,isEmptyData)){ + return; + } CtcEffectRepository.RegularTrainLineRepository updateRepository = simulation.getCtcRepository().getCtcEffectRepository().getUpdateReguarTrainLineMap().get(stationCode); if(Objects.isNull(updateRepository)){ updateRepository = new CtcEffectRepository.RegularTrainLineRepository(); simulation.getCtcRepository().getCtcEffectRepository().getUpdateReguarTrainLineMap().put(stationCode,updateRepository); } + if(updateRepository.version() != regularTrainLineRepository.version()){ updateRepository.resetVersion(regularTrainLineRepository.version()); for (RegularTrainLine val : regularTrainLineRepository.getDataMap().values()) { - updateRepository.save(val); + updateRepository.save(val.clone()); } }else{ BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(true, String.format("当前生效区与更新区的版本一致,无法更新")); @@ -446,8 +480,12 @@ public class CtcManageService { public FZkVO> loadUpdateRegularTrainLineList(Simulation simulation, String stationCode){ BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(Objects.isNull(stationCode), String.format("车站号不能为空")); CtcEffectRepository repository = simulation.getCtcRepository().getCtcEffectRepository(); + CtcEffectRepository.RegularTrainLineRepository tLRepository = repository.getUpdateReguarTrainLineMap().get(stationCode); + + + List list = this.loadRegularTrainLineData(tLRepository); return FZkVO.of(CollectionUtils.isEmpty(list)?0:tLRepository.version(),list); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java index eb34db8eb..8ac858ea5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java @@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.cbtc.build; import club.joylink.rtss.entity.Ibp; import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection; import club.joylink.rtss.simulation.cbtc.CTC.data.*; + import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; @@ -349,36 +350,82 @@ public class SimulationBuilder { Map stationTrackRepositoryMap = ctcRepository.getCtcManageRepository().getTrackSectionRepository(); Map doorRepository = ctcRepository.getCtcManageRepository().getDoorRepository(); + Map effectStationTrackMap = ctcRepository.getCtcEffectRepository().getStationTrackSectionMap(); + Map effectDoorMap = ctcRepository.getCtcEffectRepository().getDoorRepository(); + + + Map updateStationTrackMap = ctcRepository.getCtcEffectRepository().getUpdateStationTrackSectionMap(); + Map updateDoorMap = ctcRepository.getCtcEffectRepository().getUpdateDoorMap(); + for (Station station : stationList) { String stationCode = station.getCode(); CtcEffectRepository.StationTrackSectionRepository rep = stationTrackRepositoryMap.get(stationCode); CtcEffectRepository.StationDoorRepository doorRep = doorRepository.get(stationCode); if(rep == null){ rep = new CtcEffectRepository.StationTrackSectionRepository(); + rep.incrementVersionOne(); stationTrackRepositoryMap.put(stationCode,rep); } if(doorRep == null){ doorRep = new CtcEffectRepository.StationDoorRepository(); + doorRep.incrementVersionOne(); doorRepository.put(stationCode,doorRep); } for (StationDirection sd : station.getStationDirectionMap().values()) { -// StationIOGate ioGate = new StationIOGate(); -// ioGate.setCode(sd.getCode()); -// ioGate.setIoName(sd.getName()); -// ioGate.setDirection(sd.getLabelEnum()); - doorRep.save(sd.clone()); } for (Stand stand : station.getAllStandList()) { TrackSection ts = new TrackSection(stand.getSection()); - rep.save(ts); } } - - + //复制编辑区的股道,出入口到生效,编辑区 + copyEditToTargetForStationTrack(stationTrackRepositoryMap,effectStationTrackMap); + copyEditToTargetForStationTrack(stationTrackRepositoryMap,updateStationTrackMap); + copyEditToTargetForDoor(doorRepository,effectDoorMap); + copyEditToTargetForDoor(doorRepository,updateDoorMap); } + private static void copyEditToTargetForStationTrack(Map source, Map target){ + for (Map.Entry entry : source.entrySet()) { + String stationCode = entry.getKey(); + CtcEffectRepository.StationTrackSectionRepository val = entry.getValue(); + CtcEffectRepository.StationTrackSectionRepository targetRepository = target.get(stationCode); + if(Objects.isNull(targetRepository)){ + targetRepository = new CtcEffectRepository.StationTrackSectionRepository(); + targetRepository.resetVersion(val.version()); + target.put(stationCode,targetRepository); + } + for (Map.Entry valEntry : val.getDataMap().entrySet()) { + String code = valEntry.getKey(); + TrackSection vals = valEntry.getValue(); + targetRepository.getDataMap().put(code,vals); + } + + } + } + private static void copyEditToTargetForDoor(Map source, Map target){ + for (Map.Entry entry : source.entrySet()) { + String stationCode = entry.getKey(); + CtcEffectRepository.StationDoorRepository val = entry.getValue(); + CtcEffectRepository.StationDoorRepository targetRepository = target.get(stationCode); + if(Objects.isNull(targetRepository)){ + targetRepository = new CtcEffectRepository.StationDoorRepository(); + targetRepository.resetVersion(val.version()); + target.put(stationCode,targetRepository); + } + for (Map.Entry valEntry : val.getDataMap().entrySet()) { + String code = valEntry.getKey(); + StationDirection vals = valEntry.getValue(); + targetRepository.getDataMap().put(code,vals); + } + + } + } + + + + public static List checkRunPlanAndBuildLostRoutePaths(Map> serverTripMap, Map> routePathMap) { Map errMsgMap = new HashMap<>();