新仿真通用对象构建添加进路、延续保护进路

This commit is contained in:
walker-sheng 2021-04-19 16:01:46 +08:00
parent dbd2d0f22e
commit 13b6581f09
15 changed files with 318 additions and 25 deletions

View File

@ -1,10 +1,12 @@
package club.joylink.rtss.services.check;
import club.joylink.rtss.vo.client.map.MapSwitchVO;
import club.joylink.rtss.vo.client.map.MapVO;
import club.joylink.rtss.vo.client.map.newmap.MapGraphDataNewVO;
import club.joylink.rtss.vo.client.map.newmap.MapSectionNewVO;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
@ -17,22 +19,26 @@ public class MapDataCheckService {
public List<String> check(MapVO mapVO) {
List<String> errMsgList = new ArrayList<>();
MapGraphDataNewVO graphDataNew = mapVO.getGraphDataNew();
errMsgList.addAll(this.checkSection(graphDataNew));
this.checkSwitch(mapVO);
Map<String, MapSectionNewVO> sectionMap = new HashMap<>();
errMsgList.addAll(this.checkSection(graphDataNew, sectionMap));
Map<String, MapSwitchVO> switchMap = new HashMap<>();
errMsgList.addAll(this.checkSwitch(graphDataNew, switchMap));
return errMsgList;
}
private void checkSwitch(MapVO mapVO) {
private List<String> checkSwitch(MapGraphDataNewVO graphDataNew, Map<String, MapSwitchVO> switchMap) {
List<String> errMsgList = new ArrayList<>();
List<MapSwitchVO> switchList = graphDataNew.getSwitchList();
return errMsgList;
}
private List<String> checkSection(MapGraphDataNewVO graphDataVO) {
private List<String> checkSection(MapGraphDataNewVO graphDataVO, Map<String, MapSectionNewVO> sectionMap) {
List<String> errMsgList = new ArrayList<>();
List<MapSectionNewVO> sectionList = graphDataVO.getSectionList();
if (CollectionUtils.isEmpty(sectionList)) {
return errMsgList;
}
Map<String, MapSectionNewVO> sectionMap = new HashMap<>();
for (MapSectionNewVO sectionVO : sectionList) {
if (sectionMap.containsKey(sectionVO.getCode())) {
errMsgList.add(String.format("存在code重复的区段[%s]", sectionVO.getCode()));
@ -69,6 +75,54 @@ public class MapDataCheckService {
}
}
}
for (MapSectionNewVO sectionVO : sectionList) {
if (sectionVO.getType().equals("01") && sectionVO.getType().equals("03")) { // 物理区段和道岔区段
if (StringUtils.hasText(sectionVO.getLeftSectionCode())) {
MapSectionNewVO left = sectionMap.get(sectionVO.getLeftSectionCode());
if (left == null) {
errMsgList.add(String.format("区段[%s]的左关联区段[%s]不存在", sectionVO.getCode(), sectionVO.getLeftSectionCode()));
}
}
if (StringUtils.hasText(sectionVO.getRightSectionCode())) {
MapSectionNewVO right = sectionMap.get(sectionVO.getRightSectionCode());
if (right == null) {
errMsgList.add(String.format("区段[%s]的右关联区段[%s]不存在", sectionVO.getCode(), sectionVO.getRightSectionCode()));
}
}
}
if (sectionVO.getType().equals("02") && sectionVO.getType().equals("03")) {// 物理区段逻辑区段和道岔区段
if (!StringUtils.hasText(sectionVO.getParentCode())) {
errMsgList.add(String.format("%s区段[%s]无关联物理区段", sectionVO.getType().equals("02")?"逻辑":"道岔", sectionVO.getCode()));
} else {
MapSectionNewVO parent = sectionMap.get(sectionVO.getParentCode());
if (parent == null) {
errMsgList.add(String.format("逻辑区段[%s]关联的物理区段[%s]不存在", sectionVO.getCode(), sectionVO.getParentCode()));
}
}
}
if (sectionVO.getType().equals("04")) {
List<String> list = sectionVO.getRelevanceSectionList();
for (String code : list) {
MapSectionNewVO relate = sectionMap.get(code);
if (relate == null) {
errMsgList.add(String.format("道岔计轴区段[%s]关联的区段[%s]不存在", sectionVO.getCode(), code));
}
}
}
if (sectionVO.getType().equals("05")) {
List<String> list = sectionVO.getRelateSectionList();
for (String code : list) {
MapSectionNewVO relate = sectionMap.get(code);
if (relate == null) {
errMsgList.add(String.format("岔心[%s]关联的区段[%s]不存在", sectionVO.getCode(), code));
} else {
if (!sectionVO.getCode().equals(relate.getParentCode())) {
errMsgList.add(String.format("岔心[%s]关联的区段[%s]所属岔心不是此岔心", sectionVO.getCode(), code));
}
}
}
}
}
return errMsgList;
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation;
import club.joylink.rtss.simulation.operation.SimulationOperationDispatcher;
import club.joylink.rtss.simulation.vo.SimulationInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

View File

@ -0,0 +1,10 @@
package club.joylink.rtss.simulation.rt.repo;
import lombok.Getter;
@Getter
public class CommonEsp extends CommonDevice {
public CommonEsp(String id, String name) {
super(id, name);
}
}

View File

@ -0,0 +1,24 @@
package club.joylink.rtss.simulation.rt.repo;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@Getter
public class CommonOverlap extends CommonDevice {
CommonSignal start;
CommonSection section;//开始解锁区段
List<TrackWay> pathElementList;
int releaseTime; // 延续保护解锁时间
public CommonOverlap(String id, String name) {
super(id, name);
this.pathElementList = new ArrayList<>();
}
public void addPath(TrackWay trackWay) {
this.pathElementList.add(trackWay);
}
}

View File

@ -0,0 +1,10 @@
package club.joylink.rtss.simulation.rt.repo;
import lombok.Getter;
@Getter
public class CommonPsd extends CommonDevice {
public CommonPsd(String id, String name) {
super(id, name);
}
}

View File

@ -12,6 +12,8 @@ public class CommonRepository {
Map<String, CommonSignal> signalMap;
Map<String, CommonStation> stationMap;
Map<String, CommonStand> standMap;
Map<String, CommonRoute> routeMap;
Map<String, CommonOverlap> overlapMap;
public CommonRepository() {
this.sectionMap = new HashMap<>();

View File

@ -29,9 +29,118 @@ public class CommonRepositoryBuilder {
public static CommonRepository buildFrom(MapVO mapVO) {
MapGraphDataNewVO graphData = mapVO.getGraphDataNew();
CommonRepository commonRepository = buildFrom(graphData);
MapLogicDataNewVO logicData = mapVO.getLogicDataNew();
buildRoute(logicData, commonRepository);
buildOverlap(logicData, commonRepository);
return commonRepository;
}
private static void buildOverlap(MapLogicDataNewVO logicData, CommonRepository commonRepository) {
List<MapOverlapVO> overlapList = logicData.getOverlapList();
Map<String, CommonOverlap> overlapMap = commonRepository.overlapMap;
Map<String, CommonSignal> signalMap = commonRepository.signalMap;
Map<String, CommonSection> sectionMap = commonRepository.sectionMap;
for (MapOverlapVO overlapVO : overlapList) {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(overlapMap.containsKey(overlapVO.getCode()),
String.format("存在code重复的延续保护进路[%s]", overlapVO.getCode()));
CommonOverlap commonOverlap = new CommonOverlap(overlapVO.getCode(), overlapVO.getName());
overlapMap.put(commonOverlap.id, commonOverlap);
CommonSignal signal = signalMap.get(overlapVO.getSignalCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(signal,
String.format("延续保护进路始端信号机[%s]不存在", overlapVO.getSignalCode()));
commonOverlap.start = signal;
CommonSection section = sectionMap.get(overlapVO.getUnlockSectionCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(section,
String.format("延续保护进路解锁区段[%s]不存在", overlapVO.getUnlockSectionCode()));
commonOverlap.section = section;
if (overlapVO.getUnlockTime() == null) {
commonOverlap.releaseTime = 45; // 暂时默认
} else {
commonOverlap.releaseTime = overlapVO.getUnlockTime();
}
List<MapSectionPathVO> pathList = overlapVO.getPathList();
for (MapSectionPathVO pathVO : pathList) {
commonOverlap.addPath(buildTrackWay(pathVO.getSectionList(), pathVO.getSwitchPositionList(),
signal.isRight(), commonRepository));
}
}
}
private static void buildRoute(MapLogicDataNewVO logicData, CommonRepository commonRepository) {
List<MapRouteNewVO> routeList = logicData.getRouteList();
Map<String, CommonSignal> signalMap = commonRepository.signalMap;
Map<String, CommonStand> standMap = commonRepository.standMap;
Map<String, CommonRoute> routeMap = commonRepository.routeMap;
for (MapRouteNewVO routeVO : routeList) {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(routeMap.containsKey(routeVO.getCode()),
String.format("存在code重复的进路[%s]", routeVO.getCode()));
CommonRoute commonRoute = new CommonRoute(routeVO.getCode(), routeVO.getName());
routeMap.put(commonRoute.getId(), commonRoute);
commonRoute.turnBack = routeVO.isTurnBack();
commonRoute.atp = routeVO.isAtp();
commonRoute.ground = routeVO.isGround();
commonRoute.guide = routeVO.isGuide();
commonRoute.ars = routeVO.isArs();
commonRoute.arc = routeVO.isArc();
commonRoute.flt = routeVO.isFlt();
CommonSignal start = signalMap.get(routeVO.getStartSignalCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(start,
String.format("进路[%s]的始端信号机[%s]不存在", routeVO.getStartSignalCode()));
commonRoute.start = start;
if (StringUtils.hasText(routeVO.getEndSignalCode())) {
CommonSignal end = signalMap.get(routeVO.getEndSignalCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(end,
String.format("进路[%s]的终端信号机[%s]不存在", routeVO.getEndSignalCode()));
commonRoute.end = end;
}
if (routeVO.getDelayReleaseTime() == null) {
commonRoute.releaseTime = 180; // 暂时给个默认值
} else {
commonRoute.releaseTime = routeVO.getDelayReleaseTime();
}
TrackWay trackWay = buildTrackWay(routeVO.getRouteSectionList(), routeVO.getRouteSwitchList(), start.isRight(), commonRepository);
commonRoute.pathElement = trackWay;
commonRoute.signalAspect = routeVO.getSignalAspect();
}
for (MapRouteNewVO routeVO : routeList) {
CommonRoute commonRoute = routeMap.get(routeVO.getCode());
List<String> conflictRouteList = routeVO.getConflictRouteList();
for (String code : conflictRouteList) {
CommonRoute conflict = routeMap.get(code);
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(conflict,
String.format("进路[%s]的敌对进路[%s]不存在", routeVO.getCode(), code));
commonRoute.addConflict(conflict);
}
}
}
private static TrackWay buildTrackWay(List<String> sectionList,
List<MapCISwitchVO> switchList,
boolean right, CommonRepository commonRepository) {
Map<String, CommonSection> sectionMap = commonRepository.sectionMap;
Map<String, CommonSwitch> switchMap = commonRepository.switchMap;
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(null != sectionList && sectionList.size() >= 1);
CommonSection start = sectionMap.get(sectionList.get(0));
CommonSection end = sectionMap.get(sectionList.get(sectionList.size() - 1));
TrackWay trackWay = new TrackWay(start, end, right);
for (String code : sectionList) {
CommonSection section = sectionMap.get(code);
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(section,
String.format("构建路径失败不存在code为[%s]的区段", code));
if (trackWay.getStart().equals(section) || trackWay.getEnd().equals(section)) {
continue;
}
trackWay.addSection(section);
}
for (MapCISwitchVO ciSwitchVO : switchList) {
CommonSwitch commonSwitch = switchMap.get(ciSwitchVO.getSwitchCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(commonSwitch,
String.format("构建路径失败不存在code为[%s]的道岔", ciSwitchVO.getSwitchCode()));
trackWay.addSwitchPosition(commonSwitch, ciSwitchVO.isNormal());
}
return trackWay;
}
private static void buildStationRelation(MapGraphDataNewVO graphData, CommonRepository commonRepository) {
Map<String, CommonSection> sectionMap = commonRepository.sectionMap;
Map<String, CommonSwitch> switchMap = commonRepository.switchMap;
@ -140,7 +249,8 @@ public class CommonRepositoryBuilder {
}
if (StringUtils.hasText(sectionVO.getRightSectionCode())) {
CommonSection right = sectionMap.get(sectionVO.getRightSectionCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(right);
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(right,
String.format("区段[%s]关联的右向区段[%s]不存在", commonSection.getId(), sectionVO.getRightSectionCode()));
commonSection.rightSection = right;
right.leftSection = commonSection;
}
@ -151,7 +261,8 @@ public class CommonRepositoryBuilder {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(parent,
String.format("区段[%s]的parentCode[%s]对应的区段不存在", commonSection.id, sectionVO.getParentCode()));
BusinessExceptionAssertEnum.DATA_ERROR
.assertTrue(parent.isCrossSection() || parent.isNormalAxleSection() || parent.isSwitchAxleSection());
.assertTrue(parent.isCrossSection() || parent.isNormalAxleSection() || parent.isSwitchAxleSection(),
String.format("区段[%s]的所属区段[%s]不是岔心/道岔计轴区段/物理区段",commonSection.getId(), sectionVO.getParentCode()));
commonSection.setParent(parent);
}
}
@ -160,7 +271,8 @@ public class CommonRepositoryBuilder {
private static void buildStand(MapGraphDataNewVO graphData, Map<String, CommonStand> standMap) {
List<MapStationStandNewVO> standList = graphData.getStationStandList();
for (MapStationStandNewVO standVO : standList) {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(standMap.containsKey(standVO.getCode()));
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(standMap.containsKey(standVO.getCode()),
String.format("存在code重复的站台[%s]", standVO.getCode()));
CommonStand commonStand = new CommonStand(standVO.getCode(), standVO.getName());
standMap.put(commonStand.id, commonStand);
}
@ -169,7 +281,8 @@ public class CommonRepositoryBuilder {
private static void buildStation(MapGraphDataNewVO graphData, Map<String, CommonStation> stationMap) {
List<MapStationNewVO> stationList = graphData.getStationList();
for (MapStationNewVO stationVO : stationList) {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(stationMap.containsKey(stationVO.getCode()));
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(stationMap.containsKey(stationVO.getCode()),
String.format("存在code重复的车站[%s]", stationVO.getCode()));
CommonStation commonStation = new CommonStation(stationVO.getCode(), stationVO.getName());
stationMap.put(commonStation.id, commonStation);
commonStation.ec = stationVO.isCentralized();
@ -180,7 +293,8 @@ public class CommonRepositoryBuilder {
private static void buildSignal(MapGraphDataNewVO graphData, Map<String, CommonSignal> signalMap) {
List<MapSignalNewVO> signalList = graphData.getSignalList();
for (MapSignalNewVO signalVO : signalList) {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(signalMap.containsKey(signalVO.getCode()));
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(signalMap.containsKey(signalVO.getCode()),
String.format("存在code重复的信号机[%s]", signalVO.getCode()));
CommonSignal commonSignal = new CommonSignal(signalVO.getCode(), signalVO.getUniqueName());
signalMap.put(commonSignal.id, commonSignal);
commonSignal.right = signalVO.isRight();
@ -190,7 +304,8 @@ public class CommonRepositoryBuilder {
private static void buildSection(MapGraphDataNewVO graphData, Map<String, CommonSection> sectionMap) {
List<MapSectionNewVO> sectionList = graphData.getSectionList();
for (MapSectionNewVO sectionVO : sectionList) {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(sectionMap.containsKey(sectionVO.getCode()));
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(sectionMap.containsKey(sectionVO.getCode()),
String.format("存在code重复的区段[%s]", sectionVO.getCode()));
CommonSection commonSection = new CommonSection(sectionVO.getCode(), sectionVO.getName());
sectionMap.put(commonSection.id, commonSection);
switch (sectionVO.getType()) {
@ -221,7 +336,8 @@ public class CommonRepositoryBuilder {
private static void buildSwitch(MapGraphDataNewVO graphData, Map<String, CommonSwitch> switchMap) {
@Valid List<MapSwitchVO> switchList = graphData.getSwitchList();
for (MapSwitchVO switchVO : switchList) {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(switchMap.containsKey(switchVO.getCode()));
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(switchMap.containsKey(switchVO.getCode()),
String.format("存在code重复的道岔[%s]", switchVO.getCode()));
CommonSwitch commonSwitch = new CommonSwitch(switchVO.getCode(), switchVO.getName());
switchMap.put(commonSwitch.id, commonSwitch);
}

View File

@ -0,0 +1,45 @@
package club.joylink.rtss.simulation.rt.repo;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@Getter
public class CommonRoute extends CommonDevice {
boolean turnBack;
/** 是否atp进路 */
boolean atp;
/** 是否联锁进路 */
boolean ground;
/** 是否引导进路 */
boolean guide;
boolean ars; // ATS自排
boolean arc; // 自动追踪/联锁自动触发
boolean flt; // 车队/自动进路
CommonSignal start;
int signalAspect; // 信号机显示(进路联锁规定)
CommonSignal end; // 可能为null
TrackWay pathElement; // 区段道岔路径
CommonOverlap overlap; // 延续保护进路
List<CommonRoute> conflictingList; // 敌对进路
List<CommonPsd> psdList;
List<CommonEsp> espList;
List<CommonStand> standList;
int releaseTime; // 进路延时解锁时间
public static final int CallOnSwitchTime = 30; // 引导信号从开放到关闭转换时间
public CommonRoute(String id, String name) {
super(id, name);
this.conflictingList = new ArrayList<>();
this.psdList = new ArrayList<>();
this.espList = new ArrayList<>();
this.standList = new ArrayList<>();
}
public void addConflict(CommonRoute conflict) {
this.conflictingList.add(conflict);
}
}

View File

@ -8,8 +8,8 @@ public class CommonSignal extends CommonDevice {
CommonStation station;
CommonStation ecStation;// 设备集中站
boolean right;//方向
CommonSection section;
int offset; // 单位mm
CommonSection section; // 所在区段
int offset; // 所在区段偏移量单位mm
public CommonSignal(String id, String name) {
super(id, name);

View File

@ -9,6 +9,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 从一个区段到另一个区段的路径可能有多条路径不同道岔走向这里表示某一路径
*/
@Getter
public class TrackWay implements Debug {
@ -67,13 +70,21 @@ public class TrackWay implements Debug {
}
public List<CommonSection> getAllSectionList() {
return new ArrayList<>(this.sectionMap.values());
List<CommonSection> list = new ArrayList<>();
list.add(this.start);
list.addAll(this.sectionList);
list.add(this.end);
return list;
}
public boolean containsSection(CommonSection section) {
return this.sectionMap.containsKey(section.id);
}
@Getter
public static class SwitchPosition {
CommonSwitch commonSwitch;
int position; // 1/2
int position; // 1-定位2-反位
public SwitchPosition(CommonSwitch commonSwitch, int position) {
this.commonSwitch = commonSwitch;

View File

@ -1,5 +1,7 @@
package club.joylink.rtss.simulation;
package club.joylink.rtss.simulation.vo;
import club.joylink.rtss.simulation.Simulation;
import club.joylink.rtss.simulation.SimulationUser;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@ -8,7 +10,6 @@ import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Getter

View File

@ -0,0 +1,17 @@
package club.joylink.rtss.simulation.vo;
import club.joylink.rtss.simulation.SimulationMember;
import lombok.Getter;
@Getter
public abstract class SimulationMemberVO {
String id;
String userId;
int sex;
public SimulationMemberVO(SimulationMember member) {
this.id = member.getId();
this.userId = member.getUserId();
this.sex = member.getSex();
}
}

View File

@ -0,0 +1,4 @@
package club.joylink.rtss.simulation.vo;
public class SimulationUserVO {
}

View File

@ -58,26 +58,21 @@ public class MapOverlapVO {
private String signalCode;
@ApiModelProperty(value = "是否右向", required = true)
private boolean right;
/**
* 解锁时间
*/
@ApiModelProperty(value = "解锁时间,秒级", required = true)
@NotNull(message = "解锁时间不存在")
private Integer unlockTime;
@ApiModelProperty(value = "是否触发模式", required = true)
private boolean trigger;
@ApiModelProperty(value = "延续保护触发区段路径列表")
private List<MapSectionPathVO> triggerPathList;
/**
* 延续保护线路列表
*/
@ApiModelProperty(value = "延续保护线路列表")
@NotEmpty(message="延续保护线路列表至少有一条")
private List<MapOverlapRelSectionSwitchVO> relSectionSwitchList;

View File

@ -122,16 +122,19 @@ public class MapRouteNewVO {
/** 是否引导进路 */
private boolean guide;
/**
* ATS自排
*/
private boolean ars;
/**
* 是否自动追踪/联锁自动触发
*/
@ApiModelProperty(value = "是否自动追踪/联锁自动触发")
private boolean arc;
/**
* 是否车队/联锁自动进路
*/
@ApiModelProperty(value = "是否车队/联锁自动进路")
private boolean flt;
/** 是否先锁闭——办理过程直接先锁闭区段 */