【分路不良状态逻辑判断】

This commit is contained in:
weizhihong 2022-05-20 19:04:59 +08:00
parent 67f61cb9de
commit 84730c2a23
4 changed files with 54 additions and 0 deletions

View File

@ -110,6 +110,45 @@ public class AtsSectionService {
Collections.sort(shuntingTypeList); Collections.sort(shuntingTypeList);
// 设置区段的不良类型 // 设置区段的不良类型
Section section = simulation.getRepository().getByCode(sectionCode, Section.class); Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
// 是否是计轴区段道岔区段
boolean isSwitchSection = section.isAxleCounter() || section.getParent() != null;
if (isSwitchSection) {
Section targetSection = section.isAxleCounter() ? section : section.getParent();
setSectionShuntingType(targetSection, shuntingTypeList);
} else { // 不是直接添加
section.setShuntingTypeList(shuntingTypeList); section.setShuntingTypeList(shuntingTypeList);
} }
}
/**
* 给区段设置分路不良类型
*
* @param section 区段
* @param shuntingTypeList 分路不良列表
*/
private void setSectionShuntingType(Section section, List<Section.ShuntingType> shuntingTypeList) {
section.getLogicList().forEach(logicSection -> {
// 岔前分路不良定位分路不良反位分路不良
Section.ShuntingType shuntingType = getShuntingType(logicSection);
logicSection.setShuntingTypeList(shuntingTypeList);
logicSection.setBadShunt(shuntingTypeList.contains(shuntingType));
});
section.setShuntingTypeList(shuntingTypeList);
}
/**
* 区段分路不良类型
*
* @param section 区段
* @return 分路不良类型
*/
private Section.ShuntingType getShuntingType(Section section) {
if (section.getRelSwitch().isA(section)) {
return Section.ShuntingType.SWITCH_FRONT_SHUNTING;
} else if (section.getRelSwitch().isB(section)) {
return Section.ShuntingType.FIXED_POSITION_SHUNTING;
} else {
return Section.ShuntingType.REVERSE_POSITION_SHUNTING;
}
}
} }

View File

@ -256,6 +256,11 @@ public class Section extends DelayUnlockDevice {
*/ */
private boolean closed; private boolean closed;
/**
* 分路不良状态
*/
private boolean badShunt;
@Override @Override
public void reset() { public void reset() {
super.reset(); super.reset();

View File

@ -106,6 +106,8 @@ public class SectionStatus extends DeviceStatus {
private List<Section.ShuntingType> shuntingTypeList; private List<Section.ShuntingType> shuntingTypeList;
private boolean badShunt;
public SectionStatus(Section section) { public SectionStatus(Section section) {
super(section.getCode(), section.getDeviceType()); super(section.getCode(), section.getDeviceType());
this.blockade = section.isBlockade(); this.blockade = section.isBlockade();
@ -126,6 +128,7 @@ public class SectionStatus extends DeviceStatus {
this.remain = section.getRemain(); this.remain = section.getRemain();
this.fault = section.getFault() == null ? null : section.getFault().toString(); this.fault = section.getFault() == null ? null : section.getFault().toString();
this.shuntingTypeList = section.getShuntingTypeList(); this.shuntingTypeList = section.getShuntingTypeList();
this.badShunt = section.isBadShunt();
} }
@Override @Override
@ -224,6 +227,11 @@ public class SectionStatus extends DeviceStatus {
this.shuntingTypeList = section.getShuntingTypeList(); this.shuntingTypeList = section.getShuntingTypeList();
status.setShuntingTypeList(this.shuntingTypeList); status.setShuntingTypeList(this.shuntingTypeList);
} }
if (!Objects.equals(this.badShunt, section.isBadShunt())) {
change = true;
this.badShunt = section.isBadShunt();
status.setBadShunt(this.badShunt);
}
return change; return change;
} }

View File

@ -97,6 +97,8 @@ public class SectionStatusVO extends DeviceStatusVO {
private List<Section.ShuntingType> shuntingTypeList; private List<Section.ShuntingType> shuntingTypeList;
private Boolean badShunt;
public SectionStatusVO(Section section) { public SectionStatusVO(Section section) {
super(section.getCode(), section.getDeviceType()); super(section.getCode(), section.getDeviceType());
} }