Merge branch 'test-zhouyin' into test-training2-zhouyin

This commit is contained in:
tiger_zhou 2022-09-01 14:00:03 +08:00
commit 9d1677128f
10 changed files with 402 additions and 67 deletions

View File

@ -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"),

View File

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

View File

@ -73,6 +73,14 @@ public class CtcEffectRepository {
*/
private final Map<String,CtcEffectRepository.RegularTrainLineRepository> updateReguarTrainLineMap = new ConcurrentHashMap<>();
/**
* 股道更新区域从生效区来的数据
*/
private final Map<String, StationTrackSectionRepository> updateStationTrackSectionMap = new ConcurrentHashMap<>();
/**
* 出入口更新区域从生效区来的数据
*/
private final Map<String, CtcEffectRepository.StationDoorRepository> updateDoorMap = new ConcurrentHashMap<>();
/**
* 获取生效区的运行计划
*
@ -576,5 +584,7 @@ public class CtcEffectRepository {
this.doorRepository.clear();
this.regularTrainLineMap.clear();
updateReguarTrainLineMap.clear();
updateStationTrackSectionMap.clear();
this.updateDoorMap.clear();
}
}

View File

@ -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;
}
}

View File

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

View File

@ -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();
}*/
/**
* 初始化车次信息
*/

View File

@ -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<String> 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<String> conflictInfo = new ArrayList<>();
CtcRepository ctcRepository = simulation.getCtcRepository();
CascoControl cc = new CascoControl(simulation,station,route,tripNumber);
List<String> 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<RouteSequence.Line> lines = ctcRepository.findRouteSequenceLines(station.getCode(), tripNumber);
if (!CollectionUtils.isEmpty(lines)) {

View File

@ -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<String, CtcStationRunPlanLog> runPlanLogMap = simulation.getCtcRepository().getSimulationRunPlanMap().get(stationCode);
Optional<CtcStationRunPlanLog> runPlanLogOptional = null;
if(Objects.nonNull(runPlanLogMap) && !runPlanLogMap.isEmpty()){
runPlanLogOptional = this.checkForRunPlan(cc);
List<String> 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<CtcStationRunPlanLog> allRunPlanLogList = runPlanLogMap.values().stream().filter(d->d.getChangeType() == null && d.isSign()).collect(Collectors.toList());
CtcEffectRepository.StationDoorRepository doorRepository = effectRepository.getDoorRepository().get(stationCode);
if(Objects.nonNull(doorRepository)){
if(runPlanLogOptional.isPresent()){
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;
}
return cc.getErrorList();
CtcEffectRepository.StationDoorRepository doorRepository = effectRepository.getUpdateDoorMap().get(stationCode);
CtcEffectRepository.StationTrackSectionRepository stationTrackRepository = effectRepository.getUpdateStationTrackSectionMap().get(stationCode);
CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository = effectRepository.getUpdateReguarTrainLineMap().get(stationCode);
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<CtcStationRunPlanLog> checkForRunPlan(/*List<CtcStationRunPlanLog> 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();
}
if(!Objects.isNull(runPlanLog.getChangeType()) && !runPlanLog.isSign()){
cc.addErrorMsg(String.format("未在计划中找到对应的车次[%s]",cc.getTripNum()));
/**
* 根据接发车获取行车计划的接发车计划
* @param isDepart
* @param runPlanLog
* @param errMsgList
* @return
*/
private CtcStationRunPlanLog.RunPlanItem findRunPlanFromPlan(boolean isDepart,CtcStationRunPlanLog runPlanLog,List<String> errMsgList){
CtcStationRunPlanLog.RunPlanItem runPlan = runPlanLog.getArriveRunPlan();
if(isDepart){
runPlan = runPlanLog.getDepartRunPlan();
}
return Optional.of(runPlanLog);
/*Map<String,CtcStationRunPlanLog> 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;
}
/**
* 根据车辆计划接发车车次查找对应更新区的车辆固定径路数据
* @param isDepart
* @param regularTrainLineRepository
* @param runPlanLog
* @param errMsg
*/
private void checkRegularTrainLine(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository,CtcStationRunPlanLog runPlanLog,List<String> 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 checkCascoForStationTrack(CtcEffectRepository.StationTrackSectionRepository stationTrackRepository){
}
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;
}
if(Objects.nonNull(arrivePlan)){
/**
* 检测接发计划与股道接发车方向是否一致
* @param isDepart
* @param stationTrackRepository
* @param runPlanLog
* @param errMsg
*/
private void checkStationTrackDetail(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.StationTrackSectionRepository stationTrackRepository,CtcStationRunPlanLog runPlanLog,List<String> 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;
}
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<String> 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<String> 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<String> 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 ? "":"";
}
}

View File

@ -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<List<RegularTrainLineVO>> 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<RegularTrainLineVO> list = this.loadRegularTrainLineData(tLRepository);
return FZkVO.of(CollectionUtils.isEmpty(list)?0:tLRepository.version(),list);
}

View File

@ -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,35 +350,81 @@ public class SimulationBuilder {
Map<String, CtcEffectRepository.StationTrackSectionRepository> stationTrackRepositoryMap = ctcRepository.getCtcManageRepository().getTrackSectionRepository();
Map<String, CtcEffectRepository.StationDoorRepository> doorRepository = ctcRepository.getCtcManageRepository().getDoorRepository();
Map<String, CtcEffectRepository.StationTrackSectionRepository> effectStationTrackMap = ctcRepository.getCtcEffectRepository().getStationTrackSectionMap();
Map<String, CtcEffectRepository.StationDoorRepository> effectDoorMap = ctcRepository.getCtcEffectRepository().getDoorRepository();
Map<String, CtcEffectRepository.StationTrackSectionRepository> updateStationTrackMap = ctcRepository.getCtcEffectRepository().getUpdateStationTrackSectionMap();
Map<String, CtcEffectRepository.StationDoorRepository> 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<String, ? extends CtcEffectRepository.StationTrackSectionRepository> source, Map<String, CtcEffectRepository.StationTrackSectionRepository> target){
for (Map.Entry<String, ? extends CtcEffectRepository.StationTrackSectionRepository> 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<String, TrackSection> valEntry : val.getDataMap().entrySet()) {
String code = valEntry.getKey();
TrackSection vals = valEntry.getValue();
targetRepository.getDataMap().put(code,vals);
}
}
}
private static void copyEditToTargetForDoor(Map<String, ? extends CtcEffectRepository.StationDoorRepository> source, Map<String, CtcEffectRepository.StationDoorRepository> target){
for (Map.Entry<String, ? extends CtcEffectRepository.StationDoorRepository> 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<String, StationDirection> valEntry : val.getDataMap().entrySet()) {
String code = valEntry.getKey();
StationDirection vals = valEntry.getValue();
targetRepository.getDataMap().put(code,vals);
}
}
}
public static List<String> checkRunPlanAndBuildLostRoutePaths(Map<String, List<TripPlan>> serverTripMap,
Map<String, List<RoutePath>> routePathMap) {