联锁侧防数据生成、保存、仿真构建

This commit is contained in:
walker-sheng 2021-01-13 18:42:17 +08:00
parent ca313ad48c
commit 8eb906de23
17 changed files with 244 additions and 253 deletions

View File

@ -0,0 +1,4 @@
ALTER TABLE `draft_map_route_flank_protection`
DROP COLUMN `station_code`,
DROP COLUMN `number`;

View File

@ -22,16 +22,6 @@ public class DraftMapRouteFlankProtection implements Serializable {
*/
private String code;
/**
* 所属联锁站唯一编码
*/
private String stationCode;
/**
* 编号
*/
private String number;
/**
* 名称
*/

View File

@ -314,146 +314,6 @@ public class DraftMapRouteFlankProtectionExample {
return (Criteria) this;
}
public Criteria andStationCodeIsNull() {
addCriterion("station_code is null");
return (Criteria) this;
}
public Criteria andStationCodeIsNotNull() {
addCriterion("station_code is not null");
return (Criteria) this;
}
public Criteria andStationCodeEqualTo(String value) {
addCriterion("station_code =", value, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeNotEqualTo(String value) {
addCriterion("station_code <>", value, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeGreaterThan(String value) {
addCriterion("station_code >", value, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeGreaterThanOrEqualTo(String value) {
addCriterion("station_code >=", value, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeLessThan(String value) {
addCriterion("station_code <", value, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeLessThanOrEqualTo(String value) {
addCriterion("station_code <=", value, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeLike(String value) {
addCriterion("station_code like", value, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeNotLike(String value) {
addCriterion("station_code not like", value, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeIn(List<String> values) {
addCriterion("station_code in", values, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeNotIn(List<String> values) {
addCriterion("station_code not in", values, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeBetween(String value1, String value2) {
addCriterion("station_code between", value1, value2, "stationCode");
return (Criteria) this;
}
public Criteria andStationCodeNotBetween(String value1, String value2) {
addCriterion("station_code not between", value1, value2, "stationCode");
return (Criteria) this;
}
public Criteria andNumberIsNull() {
addCriterion("`number` is null");
return (Criteria) this;
}
public Criteria andNumberIsNotNull() {
addCriterion("`number` is not null");
return (Criteria) this;
}
public Criteria andNumberEqualTo(String value) {
addCriterion("`number` =", value, "number");
return (Criteria) this;
}
public Criteria andNumberNotEqualTo(String value) {
addCriterion("`number` <>", value, "number");
return (Criteria) this;
}
public Criteria andNumberGreaterThan(String value) {
addCriterion("`number` >", value, "number");
return (Criteria) this;
}
public Criteria andNumberGreaterThanOrEqualTo(String value) {
addCriterion("`number` >=", value, "number");
return (Criteria) this;
}
public Criteria andNumberLessThan(String value) {
addCriterion("`number` <", value, "number");
return (Criteria) this;
}
public Criteria andNumberLessThanOrEqualTo(String value) {
addCriterion("`number` <=", value, "number");
return (Criteria) this;
}
public Criteria andNumberLike(String value) {
addCriterion("`number` like", value, "number");
return (Criteria) this;
}
public Criteria andNumberNotLike(String value) {
addCriterion("`number` not like", value, "number");
return (Criteria) this;
}
public Criteria andNumberIn(List<String> values) {
addCriterion("`number` in", values, "number");
return (Criteria) this;
}
public Criteria andNumberNotIn(List<String> values) {
addCriterion("`number` not in", values, "number");
return (Criteria) this;
}
public Criteria andNumberBetween(String value1, String value2) {
addCriterion("`number` between", value1, value2, "number");
return (Criteria) this;
}
public Criteria andNumberNotBetween(String value1, String value2) {
addCriterion("`number` not between", value1, value2, "number");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;

View File

@ -63,6 +63,11 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
for (RouteOverlap routeOverlap : result.getOverlapList()) {
overlapVOList.add(MapOverlapVO.fromBO(routeOverlap));
}
// 侧防
List<MapRouteFlankProtectionNewVO> flsVOList = new ArrayList<>();
for (RouteFls routeFls : result.getFlsList()) {
flsVOList.add(MapRouteFlankProtectionNewVO.fromBO(routeFls));
}
// 自动进路
List<MapAutoSignalNewVO> autoSignalNewVOList = new ArrayList<>();
for (AutoSignal autoSignal : result.getAutoSignalList()) {
@ -79,7 +84,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
// 删除旧联锁数据保存新联锁数据
this.draftMapService.cleanAndSaveCiData(mapId, approachSectionVOList,
routeVOList, overlapVOList, autoSignalNewVOList,
routeVOList, overlapVOList, flsVOList, autoSignalNewVOList,
autoReentryVOList,destinationCodeDefinitionVOList, result.getRoutingList(),result.getStationRunLevelList());
return result.convert2VO();
@ -110,6 +115,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
private List<AutoSignal> autoSignalList;
private List<Route> routeList;
private List<RouteOverlap> overlapList;
private List<RouteFls> flsList;
private List<Cycle> cycleList;
private List<DestinationCodeDefinition> destinationCodeDefinitionList;
@ -117,13 +123,14 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
List<MapStationRunLevelVO> stationRunLevelList;
public CiGenerateResult(List<String> errMsgList, List<Signal> approachList, List<AutoSignal> autoSignalList, List<Route> routeList,
List<RouteOverlap> overlapList, List<Cycle> generateCycleList, /*List<MapRoutingDataVO> routingList,*/
List<RouteOverlap> overlapList, List<RouteFls> flsList, List<Cycle> generateCycleList, /*List<MapRoutingDataVO> routingList,*/
List<MapStationRunLevelVO> stationRunLevelList, List<DestinationCodeDefinition> destinationCodeDefinitionList) {
this.errMsgList = errMsgList;
this.approachList = approachList;
this.autoSignalList = autoSignalList;
this.routeList = routeList;
this.overlapList = overlapList;
this.flsList = flsList;
this.cycleList = generateCycleList;
this.destinationCodeDefinitionList = destinationCodeDefinitionList;
// this.routingList = routingList;
@ -131,6 +138,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
log.info(String.format("生成信号机接近区段数据[%s]条", approachList.size()));
log.info(String.format("生成进路数据总计[%s]条", routeList.size()));
log.info(String.format("生成延续保护数据[%s]条", overlapList.size()));
log.info(String.format("生成侧防数据[%s]条", flsList.size()));
log.info(String.format("生成自动信号数据[%s]条", autoSignalList.size()));
log.info(String.format("生成自动折返数据[%s]条", generateCycleList.size()));
// log.info(String.format("生成交路数据[%s]条", routingList.size()));
@ -155,7 +163,6 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
List<String> errorList = new ArrayList<>();
List<AutoSignal> autoSignalList = new ArrayList<>();
List<Route> generatedRouteList = new ArrayList<>();
List<RouteFls> flsList = new ArrayList<>();
CodeGenerator autoSignalGenerator = new CodeGenerator("AutoSignal");
CodeGenerator routeCodeGenerator = new CodeGenerator("Route");
CodeGenerator overlapCodeGenerator = new CodeGenerator("Overlap");
@ -212,6 +219,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
generatedRouteList.stream().filter(route -> route.isGuide()).count()));
}
// 生成侧防,构建进路侧防关系
List<RouteFls> flsList = new ArrayList<>();
if (config.isGenerateFls()) {
Map<String, RouteFls> flsMap = this.generateFls(switchList);
for (Route route : generatedRouteList) {
@ -356,7 +364,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
}
return new CiGenerateResult(errorList, approachList,
autoSignalList, generatedRouteList, generatedOverlapList,
autoSignalList, generatedRouteList, generatedOverlapList, flsList,
generateCycleList, generatedStationRunLevelList, destinationCodeDefinitionList);
}
@ -1137,6 +1145,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
startSection = c.getLeftSection();
}
Stack<Section> sectionStack = new Stack<>();
Section pre = null;
sectionStack.push(startSection);
int i = 0;
while (!sectionStack.isEmpty() && i < 100) {
@ -1146,16 +1155,32 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
if (Objects.nonNull(oppositeSignal)) { // 找到反向信号机
Section firstSection = oppositeSignal.getSection().getSectionOf(oppositeSignal.isRight());
RouteFls.FlsElement flsElement;
if (firstSection.isSwitchTrack() && !Objects.equals(aSwitch, firstSection.getRelSwitch())) {
flsElement = new RouteFls.FlsElement(oppositeSignal, new SwitchElement(firstSection.getRelSwitch(), true));
Switch relSwitch = firstSection.getRelSwitch();
if (firstSection.isSwitchTrack() && !Objects.equals(aSwitch, relSwitch)) {
boolean normal = true;
if (pre != null &&
((relSwitch.isC(pre) && relSwitch.isA(firstSection)) ||
relSwitch.isC(firstSection) && relSwitch.isA(pre))) {
normal = false;
}
flsElement = new RouteFls.FlsElement(oppositeSignal, new SwitchElement(relSwitch, normal));
} else {
flsElement = new RouteFls.FlsElement(oppositeSignal);
}
fls.addLevel1(flsElement);
pre = null;
} else { // 未找到取下一区段入栈
Section next = section.getSectionOf(right);
if (next != null) {
sectionStack.push(next);
if (next.isSwitchTrack() && next.getRelSwitch().isC(next)) {
// C区段一级侧防为此道岔定位
RouteFls.FlsElement flsElement = new RouteFls.FlsElement(new SwitchElement(next.getRelSwitch(), true));
fls.addLevel1(flsElement);
pre = null;
} else {
sectionStack.push(next);
pre = section;
}
} else {
if (section.isSwitchTrack() && section.getSectionOf(!right) != null) {
// 非尽头道岔区段
@ -1163,8 +1188,10 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
if (relSwitch.isA(section)) {
sectionStack.push(relSwitch.getC());
sectionStack.push(relSwitch.getB());
pre = section;
} else {
sectionStack.push(relSwitch.getA());
pre = section;
}
}
}
@ -1218,7 +1245,13 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
} else { // 未找到取下一区段入栈
Section next = section.getSectionOf(right);
if (next != null) {
sectionStack.push(next);
if (next.isSwitchTrack() && next.getRelSwitch().isC(next)) {
// C区段一级侧防为此道岔定位
RouteFls.FlsElement flsElement = new RouteFls.FlsElement(new SwitchElement(next.getRelSwitch(), true));
fls.addLevel1(flsElement);
} else {
sectionStack.push(next);
}
} else {
if (section.isSwitchTrack() && section.getSectionOf(!right) != null) {
// 非尽头道岔区段

View File

@ -25,14 +25,6 @@ public class DraftMapFlankProtectionServiceImpl implements DraftMapFlankProtecti
public void create(MapRouteFlankProtectionNewVO flankProtectionNewVO) {
// 编号/名称查重
DraftMapRouteFlankProtectionExample example = new DraftMapRouteFlankProtectionExample();
example.createCriteria()
.andMapIdEqualTo(flankProtectionNewVO.getMapId())
.andStationCodeEqualTo(flankProtectionNewVO.getStationCode())
.andNumberEqualTo(flankProtectionNewVO.getNumber());
example.or()
.andMapIdEqualTo(flankProtectionNewVO.getMapId())
.andStationCodeEqualTo(flankProtectionNewVO.getStationCode())
.andNameEqualTo(flankProtectionNewVO.getName());
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(
this.draftMapRouteFlankProtectionDAO.countByExample(example) == 0,
"编号或名称重复");
@ -47,15 +39,9 @@ public class DraftMapFlankProtectionServiceImpl implements DraftMapFlankProtecti
DraftMapRouteFlankProtectionExample example = new DraftMapRouteFlankProtectionExample();
DraftMapRouteFlankProtectionExample.Criteria criteria = example.createCriteria()
.andMapIdEqualTo(mapId);
if (StringUtils.hasText(queryVO.getStationCode())) {
criteria.andStationCodeEqualTo(queryVO.getStationCode());
}
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
if (StringUtils.hasText(queryVO.getNumber())) {
criteria.andNumberEqualTo(queryVO.getNumber());
}
Page<DraftMapRouteFlankProtection> fpPageList = (Page<DraftMapRouteFlankProtection>) this.draftMapRouteFlankProtectionDAO.selectByExample(example);
return PageVO.convert(fpPageList, MapRouteFlankProtectionNewVO.convert2VOList(fpPageList.getResult()));
}

View File

@ -19,6 +19,7 @@ public interface DraftMapService {
* @param approachVOList
* @param routeVOList
* @param overlapVOList
* @param flsVOList
* @param autoSignalVOList
* @param autoReentryVOList
* @param destinationCodeDefinitionVOList
@ -27,7 +28,7 @@ public interface DraftMapService {
List<MapSignalApproachSectionVO> approachVOList,
List<MapRouteNewVO> routeVOList,
List<MapOverlapVO> overlapVOList,
List<MapAutoSignalNewVO> autoSignalVOList,
List<MapRouteFlankProtectionNewVO> flsVOList, List<MapAutoSignalNewVO> autoSignalVOList,
List<MapAutoReentryVO> autoReentryVOList,
List<MapDestinationCodeDefinitionVO> destinationCodeDefinitionVOList,
List<MapRoutingDataVO> generatedRoutingList,

View File

@ -27,6 +27,9 @@ public class DraftMapServiceImpl implements DraftMapService {
@Autowired
private DraftMapRouteDAO draftMapRouteDAO;
@Autowired
private DraftMapRouteFlankProtectionDAO draftMapRouteFlankProtectionDAO;
@Autowired
private DraftMapAutoSignalDAO draftMapAutoSignalDAO;
@ -52,6 +55,7 @@ public class DraftMapServiceImpl implements DraftMapService {
List<MapSignalApproachSectionVO> approachVOList,
List<MapRouteNewVO> routeVOList,
List<MapOverlapVO> overlapVOList,
List<MapRouteFlankProtectionNewVO> flsVOList,
List<MapAutoSignalNewVO> autoSignalVOList,
List<MapAutoReentryVO> autoReentryVOList,
List<MapDestinationCodeDefinitionVO> destinationCodeDefinitionVOList,
@ -61,6 +65,7 @@ public class DraftMapServiceImpl implements DraftMapService {
this.cleanMapApproachSection(mapId);
this.cleanMapRoute(mapId);
this.cleanMapOverlap(mapId);
this.cleanMapFls(mapId);
this.cleanMapAutoSignal(mapId);
this.cleanMapCycle(mapId);
this.cleanMapRouting(mapId);
@ -69,6 +74,7 @@ public class DraftMapServiceImpl implements DraftMapService {
this.saveMapApproachSection(mapId, approachVOList);
this.saveMapRoute(mapId, routeVOList);
this.saveMapOverlap(mapId, overlapVOList);
this.saveMapFls(mapId, flsVOList);
this.saveMapAutoSignal(mapId, autoSignalVOList);
this.saveMapCycle(mapId, autoReentryVOList);
this.saveMapRouting(mapId, generatedRoutingList);
@ -110,6 +116,16 @@ public class DraftMapServiceImpl implements DraftMapService {
}
}
private void saveMapFls(Long mapId, List<MapRouteFlankProtectionNewVO> flsVOList) {
if (!CollectionUtils.isEmpty(flsVOList)) {
for (MapRouteFlankProtectionNewVO flsVO : flsVOList) {
flsVO.setMapId(mapId);
DraftMapRouteFlankProtection entity = flsVO.convert2Draft();
this.draftMapRouteFlankProtectionDAO.insert(entity);
}
}
}
@Transactional
public void saveMapRoute(Long mapId, List<MapRouteNewVO> routeVOList) {
if (!CollectionUtils.isEmpty(routeVOList)) {
@ -161,6 +177,13 @@ public class DraftMapServiceImpl implements DraftMapService {
this.draftMapOverlapDAO.deleteByExample(example);
}
private void cleanMapFls(Long mapId) {
DraftMapRouteFlankProtectionExample example = new DraftMapRouteFlankProtectionExample();
example.createCriteria()
.andMapIdEqualTo(mapId);
this.draftMapRouteFlankProtectionDAO.deleteByExample(example);
}
private void cleanMapRoute(Long mapId) {
DraftMapRouteExample example = new DraftMapRouteExample();
example.createCriteria()

View File

@ -28,6 +28,10 @@ public class InterlockBuilder2 {
SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult) {
Map<String, MapElement> elementMap = mapDataBuildResult.getDeviceMap();
List<String> errMsgList = mapDataBuildResult.getErrMsgList();
// ------------侧防start-------------
Map<String, RouteFls> flsMap = checkAndBuildRouteFls(logicData.getFlankProtectionList(), elementMap);
// ------------侧防end-------------
// ------------延续保护start-------------
List<MapOverlapVO> overlapList = logicData.getOverlapList();
for (MapOverlapVO mapOverlapVO : overlapList) {
@ -65,6 +69,16 @@ public class InterlockBuilder2 {
errMsgList.add(String.format("延续保护[%s(%s)]区段数据异常:%s",
routeOverlap.getName(), routeOverlap.getCode(), errmsg));
}
List<String> flsCodeList = sectionPathVO.getFlsList();
List<RouteFls> flsList = new ArrayList<>();
if (!CollectionUtils.isEmpty(flsCodeList)) {
for (String code : flsCodeList) {
RouteFls routeFls = flsMap.get(code);
Objects.requireNonNull(routeFls, String.format("code为[%s]的进路侧防不存在", code));
flsList.add(routeFls);
}
}
sectionPath.setFlsList(flsList);
pathList.add(sectionPath);
}
}
@ -165,6 +179,17 @@ public class InterlockBuilder2 {
}
route.setSectionList(sectionPath.getSectionList());
route.setSwitchList(sectionPath.getSwitchList());
// 侧防
List<RouteFls> flsList = new ArrayList<>();
route.setFlsList(flsList);
List<String> flsCodeList = mapRouteVO.getFlsList();
if (!CollectionUtils.isEmpty(flsCodeList)) {
for (String code : flsCodeList) {
RouteFls routeFls = flsMap.get(code);
Objects.requireNonNull(routeFls, String.format("code为[%s]的进路侧防不存在", code));
flsList.add(routeFls);
}
}
// 进路站台屏蔽门紧急停车按钮
List<Stand> standList = new ArrayList<>();
List<PSD> psdList = new ArrayList<>();
@ -458,6 +483,39 @@ public class InterlockBuilder2 {
buildRoutePathFromStationRunLevel(stationRunLevelList, mapDataBuildResult, errMsgList);
}
private static Map<String, RouteFls> checkAndBuildRouteFls(List<MapRouteFlankProtectionNewVO> flankProtectionList, Map<String, MapElement> elementMap) {
Map<String, RouteFls> map = new HashMap<>();
for (MapRouteFlankProtectionNewVO fpVO : flankProtectionList) {
RouteFls routeFls = new RouteFls(fpVO.getCode(), new SwitchElement((Switch) elementMap.get(fpVO.getSource().getSwitchCode()), fpVO.getSource().isNormal()));
List<RouteFls.FlsElement> level1List = checkAndBuildFlsElementList(fpVO.getLevel1List(), elementMap);
routeFls.setLevel1List(level1List);
List<RouteFls.FlsElement> level2List = checkAndBuildFlsElementList(fpVO.getLevel2List(), elementMap);
routeFls.setLevel2List(level2List);
map.put(routeFls.getCode(), routeFls);
}
return map;
}
private static List<RouteFls.FlsElement> checkAndBuildFlsElementList(List<MapRouteFlankProtectionNewVO.Level> levelVOList, Map<String, MapElement> elementMap) {
List<RouteFls.FlsElement> list = new ArrayList<>();
if (levelVOList != null) {
for (MapRouteFlankProtectionNewVO.Level level : levelVOList) {
MapCISwitchVO protectSwitch = level.getProtectSwitch();
if (protectSwitch != null) {
list.add(new RouteFls.FlsElement(new SwitchElement((Switch) elementMap.get(protectSwitch.getSwitchCode()), protectSwitch.isNormal())));
} else {
Signal signal = (Signal) elementMap.get(level.getProtectSignal());
SwitchElement flsElement = null;
if (level.getAreaSwitch() != null) {
flsElement = new SwitchElement((Switch) elementMap.get(level.getAreaSwitch().getSwitchCode()), level.getAreaSwitch().isNormal());
}
list.add(new RouteFls.FlsElement(signal, flsElement));
}
}
}
return list;
}
private static void checkAndBuildDestinationCodeDefinition(Map<String, MapElement> elementMap,
List<MapDestinationCodeDefinitionVO> destinationCodeDefinitionList,
Map<String, DestinationCodeDefinition> destinationMap, List<String> errMsgList) {

View File

@ -11,7 +11,11 @@ import java.util.List;
*/
@Getter
@Setter
public class RouteFls extends MapNamedElement {
public class RouteFls {
/** 设备唯一编号 */
private String code;
private String name;
/**
* 所防护的道岔位置
@ -23,7 +27,8 @@ public class RouteFls extends MapNamedElement {
private List<FlsElement> level2List;
public RouteFls(String code, SwitchElement base) {
super(code, buildName(base), DeviceType.FLANK_PROTECTION);
this.code = code;
this.name = buildName(base);
this.base = base;
}
@ -42,11 +47,6 @@ public class RouteFls extends MapNamedElement {
return this.level1List != null && !this.level1List.isEmpty();
}
@Override
public void reset() {
}
/**
* 侧防元件
*/
@ -65,7 +65,7 @@ public class RouteFls extends MapNamedElement {
private Signal pSignal;
/**
* 侧防区域元件
* 侧防区域元件与防护信号共同构成防护无法单独生效
*/
private SwitchElement fpae;

View File

@ -63,6 +63,11 @@ public class Section extends MayOutOfOrderDevice {
*/
private boolean axleCounter;
/**
* 是否岔心
*/
private boolean crossing;
/**
* 虚拟真实计轴器
*/

View File

@ -43,6 +43,13 @@ public class SectionPath {
this.sectionList = sectionList;
}
public SectionPath(boolean right, List<SwitchElement> switchList, List<Section> sectionList, List<RouteFls> flsList) {
this.right = right;
this.switchList = switchList;
this.sectionList = sectionList;
this.flsList = flsList;
}
public SectionPath cloneNew() {
return new SectionPath(this.right, new ArrayList<>(this.switchList), new ArrayList<>(this.sectionList));
}

View File

@ -269,10 +269,17 @@ public class Switch extends MayOutOfOrderDevice {
*/
public Switch queryLinkedSwitch() {
Section section = this.getC().getSwitchSectionConnectedSection();
if (Objects.nonNull(section) && section.isSwitchTrack()) {
if (Objects.equals(section.getRelSwitch().getC(), section)) { // 是另一个道岔的C区段则是联动道岔
if (Objects.nonNull(section)) {
if (section.isSwitchTrack() && Objects.equals(section.getRelSwitch().getC(), section)) { // 是另一个道岔的C区段则是联动道岔
return section.getRelSwitch();
}
if (Objects.nonNull(section.getParent()) && section.getParent().isCrossing()) {
if (Objects.equals(section.getRightSection(), this.getC())) {
return section.getLeftSection().getRelSwitch();
} else if (Objects.equals(section.getLeftSection(), this.getC())) {
return section.getRightSection().getRelSwitch();
}
}
}
return null;
}

View File

@ -33,7 +33,7 @@ public class MapCISwitchVO {
return voList;
}
private static MapCISwitchVO from(SwitchElement switchElement) {
public static MapCISwitchVO from(SwitchElement switchElement) {
MapCISwitchVO vo = new MapCISwitchVO();
vo.setSwitchCode(switchElement.getASwitch().getCode());
vo.setNormal(switchElement.isNormal());

View File

@ -1,9 +1,13 @@
package club.joylink.rtss.vo.client.map.newmap;
import club.joylink.rtss.entity.DraftMapRouteFlankProtection;
import club.joylink.rtss.simulation.cbtc.data.map.RouteFls;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import club.joylink.rtss.entity.DraftMapRouteFlankProtection;
import club.joylink.rtss.util.JsonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@ -33,23 +37,18 @@ public class MapRouteFlankProtectionNewVO {
@NotBlank(message = "code不能为空")
private String code;
@ApiModelProperty(value = "所属联锁站")
@NotBlank(message = "所属联锁站编码不能为空")
private String stationCode;
@ApiModelProperty(value = "编号")
@NotBlank(message = "编号不能为空")
private String number;
@ApiModelProperty(value = "名称")
@NotBlank(message = "名称不能为空")
private String name;
// 需要防护的道岔位置
private MapCISwitchVO source;
@ApiModelProperty(value = "一级")
private Level level1;
private List<Level> level1List;
@ApiModelProperty(value = "二级")
private Level level2;
private List<Level> level2List;
public static MapRouteFlankProtectionNewVO convert2VO(DraftMapRouteFlankProtection fp) {
MapRouteFlankProtectionNewVO read;
@ -58,8 +57,6 @@ public class MapRouteFlankProtectionNewVO {
} else {
read = new MapRouteFlankProtectionNewVO();
read.setCode(fp.getCode());
read.setStationCode(fp.getStationCode());
read.setNumber(fp.getNumber());
read.setName(fp.getName());
}
read.setId(fp.getId());
@ -75,6 +72,37 @@ public class MapRouteFlankProtectionNewVO {
return voList;
}
public static MapRouteFlankProtectionNewVO fromBO(RouteFls routeFls) {
MapRouteFlankProtectionNewVO vo = new MapRouteFlankProtectionNewVO();
vo.code = routeFls.getCode();
vo.name = routeFls.getName();
vo.source = MapCISwitchVO.from(routeFls.getBase());
vo.level1List = Level.convertBO2VOList(routeFls.getLevel1List());
vo.level2List = Level.convertBO2VOList(routeFls.getLevel2List());
return vo;
}
public DraftMapRouteFlankProtection convert2Draft() {
DraftMapRouteFlankProtection db = new DraftMapRouteFlankProtection();
db.setMapId(this.mapId);
db.setCode(this.code);
db.setName(this.name);
db.setDetailData(getJsonData());
return db;
}
@JsonIgnore
private String getJsonData() {
Long id = this.getId();
Long mapId = this.getMapId();
this.setId(null);
this.setMapId(null);
String json = JsonUtils.writeValueAsString(this);
this.setId(id);
this.setMapId(mapId);
return json;
}
@Getter
@Setter
@NoArgsConstructor
@ -89,14 +117,37 @@ public class MapRouteFlankProtectionNewVO {
@ApiModelProperty(value = "侧防区域元件")
private MapCISwitchVO areaSwitch;
public static List<Level> convertBO2VOList(List<RouteFls.FlsElement> level1List) {
List<Level> list = new ArrayList<>();
for (RouteFls.FlsElement flsElement : level1List) {
list.add(fromBO(flsElement));
}
return list;
}
public static Level fromBO(RouteFls.FlsElement flsElement) {
Level level = new Level();
SwitchElement pSwitch = flsElement.getPSwitch();
if (pSwitch != null) {
level.protectSwitch = MapCISwitchVO.from(pSwitch);
}
Signal pSignal = flsElement.getPSignal();
if (pSignal != null) {
level.protectSignal = pSignal.getCode();
}
SwitchElement fpae = flsElement.getFpae();
if (fpae != null) {
level.areaSwitch = MapCISwitchVO.from(fpae);
}
return level;
}
}
public DraftMapRouteFlankProtection toDB() {
DraftMapRouteFlankProtection fp = new DraftMapRouteFlankProtection();
fp.setMapId(this.getMapId());
fp.setCode(this.getCode());
fp.setStationCode(this.getStationCode());
fp.setNumber(this.getNumber());
fp.setName(this.getName());
this.id = null;
this.mapId = null;

View File

@ -1,14 +1,15 @@
package club.joylink.rtss.vo.client.map.newmap;
import club.joylink.rtss.entity.DraftMapRoute;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.entity.DraftMapRoute;
import club.joylink.rtss.util.JsonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
@ -123,15 +124,8 @@ public class MapRouteNewVO {
@ApiModelProperty(value="进路道岔数据列表")
private List<MapCISwitchVO> routeSwitchList;
/**
* 进路侧防道岔列表
*/
@Valid
@ApiModelProperty(value = "进路侧防道岔列表")
private List<MapCISwitchVO> routeFlankProtectionList;
@ApiModelProperty(value = "进路侧防列表")
private List<String> flankProtectionList;
private List<String> flsList;
/**
* 延续保护code
@ -169,7 +163,6 @@ public class MapRouteNewVO {
public MapRouteNewVO() {
this.routeSectionList = new ArrayList<>();
this.routeSwitchList = new ArrayList<>();
this.routeFlankProtectionList = new ArrayList<>();
// this.psdList = new ArrayList<>();
// this.espList = new ArrayList<>();
this.stationStandList = new ArrayList<>();
@ -205,6 +198,9 @@ public class MapRouteNewVO {
vo.setFlt(route.isFlt());
vo.setRouteSectionList(route.getSectionList().stream().map(Section::getCode).collect(Collectors.toList()));
vo.setRouteSwitchList(MapCISwitchVO.convertBO2VOList(route.getSwitchList()));
if (!CollectionUtils.isEmpty(route.getFlsList())) {
vo.setFlsList(route.getFlsList().stream().map(RouteFls::getCode).collect(Collectors.toList()));
}
if (Objects.nonNull(route.getOverlap())) {
vo.setOverlapCode(route.getOverlap().getCode());
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.vo.client.map.newmap;
import club.joylink.rtss.simulation.cbtc.data.map.RouteFls;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.SectionPath;
import lombok.Getter;
@ -22,6 +23,8 @@ public class MapSectionPathVO {
private List<MapCISwitchVO> switchPositionList;
private List<String> flsList;
public MapSectionPathVO(boolean right, List<String> sectionList, List<MapCISwitchVO> switchPositionList) {
this.right = right;
this.sectionList = sectionList;
@ -46,6 +49,9 @@ public class MapSectionPathVO {
vo.setRight(sectionPath.isRight());
vo.setSectionList(sectionList);
vo.setSwitchPositionList(MapCISwitchVO.convertBO2VOList(sectionPath.getSwitchList()));
if (!CollectionUtils.isEmpty(sectionPath.getFlsList())) {
vo.setFlsList(sectionPath.getFlsList().stream().map(RouteFls::getCode).collect(Collectors.toList()));
}
return vo;
}
}

View File

@ -5,8 +5,6 @@
<id column="id" jdbcType="BIGINT" property="id" />
<result column="map_id" jdbcType="BIGINT" property="mapId" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="station_code" jdbcType="VARCHAR" property="stationCode" />
<result column="number" jdbcType="VARCHAR" property="number" />
<result column="name" jdbcType="VARCHAR" property="name" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="club.joylink.rtss.entity.DraftMapRouteFlankProtection">
@ -71,7 +69,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, map_id, code, station_code, `number`, `name`
id, map_id, code, `name`
</sql>
<sql id="Blob_Column_List">
detail_data
@ -141,12 +139,10 @@
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.DraftMapRouteFlankProtection" useGeneratedKeys="true">
insert into draft_map_route_flank_protection (map_id, code, station_code,
`number`, `name`, detail_data
)
values (#{mapId,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{stationCode,jdbcType=VARCHAR},
#{number,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{detailData,jdbcType=LONGVARCHAR}
)
insert into draft_map_route_flank_protection (map_id, code, `name`,
detail_data)
values (#{mapId,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{detailData,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.DraftMapRouteFlankProtection" useGeneratedKeys="true">
insert into draft_map_route_flank_protection
@ -157,12 +153,6 @@
<if test="code != null">
code,
</if>
<if test="stationCode != null">
station_code,
</if>
<if test="number != null">
`number`,
</if>
<if test="name != null">
`name`,
</if>
@ -177,12 +167,6 @@
<if test="code != null">
#{code,jdbcType=VARCHAR},
</if>
<if test="stationCode != null">
#{stationCode,jdbcType=VARCHAR},
</if>
<if test="number != null">
#{number,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
@ -209,12 +193,6 @@
<if test="record.code != null">
code = #{record.code,jdbcType=VARCHAR},
</if>
<if test="record.stationCode != null">
station_code = #{record.stationCode,jdbcType=VARCHAR},
</if>
<if test="record.number != null">
`number` = #{record.number,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
@ -231,8 +209,6 @@
set id = #{record.id,jdbcType=BIGINT},
map_id = #{record.mapId,jdbcType=BIGINT},
code = #{record.code,jdbcType=VARCHAR},
station_code = #{record.stationCode,jdbcType=VARCHAR},
`number` = #{record.number,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
detail_data = #{record.detailData,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
@ -244,8 +220,6 @@
set id = #{record.id,jdbcType=BIGINT},
map_id = #{record.mapId,jdbcType=BIGINT},
code = #{record.code,jdbcType=VARCHAR},
station_code = #{record.stationCode,jdbcType=VARCHAR},
`number` = #{record.number,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -260,12 +234,6 @@
<if test="code != null">
code = #{code,jdbcType=VARCHAR},
</if>
<if test="stationCode != null">
station_code = #{stationCode,jdbcType=VARCHAR},
</if>
<if test="number != null">
`number` = #{number,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
@ -279,8 +247,6 @@
update draft_map_route_flank_protection
set map_id = #{mapId,jdbcType=BIGINT},
code = #{code,jdbcType=VARCHAR},
station_code = #{stationCode,jdbcType=VARCHAR},
`number` = #{number,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
detail_data = #{detailData,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
@ -289,8 +255,6 @@
update draft_map_route_flank_protection
set map_id = #{mapId,jdbcType=BIGINT},
code = #{code,jdbcType=VARCHAR},
station_code = #{stationCode,jdbcType=VARCHAR},
`number` = #{number,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>