【上电逻辑修改、分路不良逻辑修改】

This commit is contained in:
weizhihong 2022-05-19 09:56:38 +08:00
parent 756d658b20
commit f654df112d
12 changed files with 53 additions and 114 deletions

View File

@ -13,6 +13,8 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@OperateHandler @OperateHandler
@Slf4j @Slf4j
public class SectionOperateHandler { public class SectionOperateHandler {
@ -172,7 +174,7 @@ public class SectionOperateHandler {
* @param types 分路不良类型列表 * @param types 分路不良类型列表
*/ */
@OperateHandlerMapping(type = Operation.Type.Section_Defective_Shunting) @OperateHandlerMapping(type = Operation.Type.Section_Defective_Shunting)
public void defectiveShunting(Simulation simulation, String sectionCode, String types) { public void defectiveShunting(Simulation simulation, String sectionCode, List<Section.ShuntingType> shuntingTypeList) {
atsSectionService.defectiveShunting(simulation, sectionCode, types); atsSectionService.defectiveShunting(simulation, sectionCode, shuntingTypeList);
} }
} }

View File

@ -319,17 +319,6 @@ public class StationOperateHandler {
atsStationService.specialStationControl(simulation, fromMember, stationCode, pressDown); atsStationService.specialStationControl(simulation, fromMember, stationCode, pressDown);
} }
/**
* 车站设置分路不良大铁
*
* @param simulation 仿真实体
* @param stationCode 车站编码
*/
@OperateHandlerMapping(type = Operation.Type.Station_Set_Defective_Shunting)
public void setDefectiveShunting(Simulation simulation, String stationCode) {
atsStationService.setDefectiveShunting(simulation, stationCode);
}
/** /**
* 上电解锁大铁 * 上电解锁大铁
* *
@ -338,6 +327,7 @@ public class StationOperateHandler {
*/ */
@OperateHandlerMapping(type = Operation.Type.Station_Power_On_Unlock_Railroad) @OperateHandlerMapping(type = Operation.Type.Station_Power_On_Unlock_Railroad)
public void powerOnUnlockRailroad(Simulation simulation, String stationCode) { public void powerOnUnlockRailroad(Simulation simulation, String stationCode) {
atsStationService.powerOnUnlockRailroad(simulation, stationCode); SimulationDataRepository repository = simulation.getRepository();
ciApiService.powerOnUnlock(simulation, repository.getByCode(stationCode, Station.class));
} }
} }

View File

@ -9,6 +9,8 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.Collections;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
@ -101,15 +103,13 @@ public class AtsSectionService {
* @param sectionCode 区段编码 * @param sectionCode 区段编码
* @param types 分路不良类型列表 * @param types 分路不良类型列表
*/ */
public void defectiveShunting(Simulation simulation, String sectionCode, String types) { public void defectiveShunting(Simulation simulation, String sectionCode, List<Section.ShuntingType> shuntingTypeList) {
if (StringUtils.isEmpty(sectionCode)) { if (StringUtils.isEmpty(sectionCode)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "区段不能为空"); throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "区段不能为空");
} }
Collections.sort(shuntingTypeList);
// 设置区段的不良类型 // 设置区段的不良类型
Section section = simulation.getRepository().getByCode(sectionCode, Section.class); Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
section.setDefectiveShuntingTypes(types); section.setShuntingTypeList(shuntingTypeList);
// 弹起车站的分路不良按钮
section.getStation().getDefectiveShuntingRemain().set(0);
section.getStation().setDefectiveShunting(false);
} }
} }

View File

@ -578,33 +578,4 @@ public class AtsStationService {
new OperationMessage(fromMember.getId(), new HashSet<>(Collections.singleton(fromMember)), new OperationMessage(fromMember.getId(), new HashSet<>(Collections.singleton(fromMember)),
operationType, null, true, Arrays.asList(stationCode))); operationType, null, true, Arrays.asList(stationCode)));
} }
/**
* 按下分路不良大铁
*
* @param simulation 仿真实体
* @param stationCode 车站编码
*/
public void setDefectiveShunting(Simulation simulation, String stationCode) {
if (StringUtils.isEmpty(stationCode)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "车站不能为空");
}
Station station = getStation(simulation, stationCode);
station.setDefectiveShunting(true);
station.getDefectiveShuntingRemain().set(15);
}
/**
* 上电解锁大铁
*
* @param simulation 仿真实体
* @param stationCode 车站编码
*/
public void powerOnUnlockRailroad(Simulation simulation, String stationCode) {
if (StringUtils.isEmpty(stationCode)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "车站不能为空");
}
List<Section> sectionList = simulation.getRepository().getSectionList();
sectionList.stream().filter(section -> stationCode.equals(section.getStation().getCode())).forEach(Section::faultUnlock);
}
} }

View File

@ -518,16 +518,24 @@ public class CiApiServiceImpl2 implements CiApiService {
station = station.getDeviceStation(); station = station.getDeviceStation();
} }
Station deviceStation = station; Station deviceStation = station;
if (Objects.nonNull(deviceStation.getRestartTime()) boolean restartFlag = Objects.nonNull(deviceStation.getRestartTime()) && deviceStation.getRestartTime().isBefore(LocalTime.now());
&& deviceStation.getRestartTime().isBefore(LocalTime.now()) // 是否大铁设备
&& ((Simulation.FunctionalType.LESSON.equals(simulation.getBuildParams().getFunctionalType()) boolean hasCTCFlag = simulation.getRepository().getConfig().isHasCTC();
|| Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType())) // 大铁异常提示语
? true : deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()))) { String exceptionMsg = hasCTCFlag ? "无效操作:车站未下电" : "无效操作或连锁机重启过8分钟需手动解锁";
List<Section> sections = simulation.getRepository().getSectionList(); // 是否需要重启
sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock); if (restartFlag) {
return; // 考试课程上电标识
boolean powerOnFlag = ((Simulation.FunctionalType.LESSON.equals(simulation.getBuildParams().getFunctionalType())
|| Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType()))
? true : deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()));
if (hasCTCFlag || powerOnFlag) {
List<Section> sections = simulation.getRepository().getSectionList();
sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock);
return;
}
} }
throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无效操作或连锁机重启过8分钟需手动解锁"); throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception(exceptionMsg);
} }
@Override @Override

View File

@ -55,11 +55,6 @@ public class CiLogic {
simulation.getRepository().getStationList().stream().forEach(station -> { simulation.getRepository().getStationList().stream().forEach(station -> {
// 允许自律状态刷新 // 允许自律状态刷新
station.refreshAllowAutonomyStatus(); station.refreshAllowAutonomyStatus();
// 分路不良倒计时
if (station.getDefectiveShuntingRemain().decrementAndGet() <= 0) {
station.setDefectiveShunting(false);
station.getDefectiveShuntingRemain().set(0);
}
// 发辅助按钮倒计时刷新 // 发辅助按钮倒计时刷新
station.getStationDirectionMap().values().stream() station.getStationDirectionMap().values().stream()
.filter(stationDirection -> stationDirection.getRemain().intValue() != 0) .filter(stationDirection -> stationDirection.getRemain().intValue() != 0)

View File

@ -166,7 +166,7 @@ public class Section extends DelayUnlockDevice {
/** /**
* 分路不良类型 * 分路不良类型
*/ */
private String defectiveShuntingTypes; private List<ShuntingType> shuntingTypeList;
// ------------------状态属性--------------------- // ------------------状态属性---------------------
@ -948,6 +948,7 @@ public class Section extends DelayUnlockDevice {
this.route = null; this.route = null;
this.overlapLock = false; this.overlapLock = false;
this.delayUnlock = false; this.delayUnlock = false;
this.shuntingTypeList = null;
} }
public boolean isLockedOn(boolean right) { public boolean isLockedOn(boolean right) {
@ -1407,4 +1408,17 @@ public class Section extends DelayUnlockDevice {
} }
} }
} }
/**
* 分路不良枚举类型
*/
public enum ShuntingType {
SECTION_SHUNTING, // 区段分路不良
SWITCH_FRONT_SHUNTING, // 岔前分路不良
FIXED_POSITION_SHUNTING,// 定位分路不良
REVERSE_POSITION_SHUNTING,// 反位分路不良
}
} }

View File

@ -196,16 +196,6 @@ public class Station extends MayOutOfOrderDevice {
*/ */
private boolean allowAutonomy; private boolean allowAutonomy;
/**
* 分路不良
*/
private boolean defectiveShunting;
/**
* 分路不良倒计时
*/
private AtomicInteger defectiveShuntingRemain = new AtomicInteger(0);
@Override @Override
public void reset() { public void reset() {

View File

@ -8,6 +8,7 @@ import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter; import lombok.Getter;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
@ -103,7 +104,7 @@ public class SectionStatus extends DeviceStatus {
private String fault; private String fault;
private String defectiveShuntingTypes; private List<Section.ShuntingType> shuntingTypeList;
public SectionStatus(Section section) { public SectionStatus(Section section) {
super(section.getCode(), section.getDeviceType()); super(section.getCode(), section.getDeviceType());
@ -124,7 +125,7 @@ public class SectionStatus extends DeviceStatus {
this.closed = section.isClosed(); this.closed = section.isClosed();
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.defectiveShuntingTypes = section.getDefectiveShuntingTypes(); this.shuntingTypeList = section.getShuntingTypeList();
} }
@Override @Override
@ -218,10 +219,10 @@ public class SectionStatus extends DeviceStatus {
status.setFault(fault); status.setFault(fault);
change = true; change = true;
} }
if (!Objects.equals(this.defectiveShuntingTypes, section.getDefectiveShuntingTypes())) { if (!Objects.equals(this.shuntingTypeList, section.getShuntingTypeList())) {
change = true; change = true;
this.defectiveShuntingTypes = section.getDefectiveShuntingTypes(); this.shuntingTypeList = section.getShuntingTypeList();
status.setDefectiveShuntingTypes(this.defectiveShuntingTypes); status.setShuntingTypeList(this.shuntingTypeList);
} }
return change; return change;
} }
@ -245,7 +246,7 @@ public class SectionStatus extends DeviceStatus {
statusVO.setDelayUnlock(delayUnlock); statusVO.setDelayUnlock(delayUnlock);
statusVO.setClosed(closed); statusVO.setClosed(closed);
statusVO.setFault(fault); statusVO.setFault(fault);
statusVO.setDefectiveShuntingTypes(this.defectiveShuntingTypes); statusVO.setShuntingTypeList(this.shuntingTypeList);
return statusVO; return statusVO;
} }

View File

@ -87,16 +87,6 @@ public class StationStatus extends DeviceStatus {
*/ */
private boolean allowAutonomy; private boolean allowAutonomy;
/**
* 分路不良
*/
private boolean defectiveBranch;
/**
* 分路不良倒计时
*/
private int defectiveBranchRemain;
public StationStatus(Station station) { public StationStatus(Station station) {
super(station.getCode(), station.getDeviceType()); super(station.getCode(), station.getDeviceType());
controlMode = station.getControlMode(); controlMode = station.getControlMode();
@ -114,8 +104,6 @@ public class StationStatus extends DeviceStatus {
sGuideMasterLock = station.isSGuideMasterLock(); sGuideMasterLock = station.isSGuideMasterLock();
xGuideMasterLock = station.isXGuideMasterLock(); xGuideMasterLock = station.isXGuideMasterLock();
allowAutonomy = station.isAllowAutonomy(); allowAutonomy = station.isAllowAutonomy();
defectiveBranch = station.isDefectiveShunting();
defectiveBranchRemain = station.getDefectiveShuntingRemain().get();
} }
@Override @Override
@ -199,16 +187,6 @@ public class StationStatus extends DeviceStatus {
allowAutonomy = station.isAllowAutonomy(); allowAutonomy = station.isAllowAutonomy();
status.setAllowAutonomy(allowAutonomy); status.setAllowAutonomy(allowAutonomy);
} }
if (!Objects.equals(defectiveBranch, station.isDefectiveShunting())) {
change = true;
defectiveBranch = station.isDefectiveShunting();
status.setDefectiveShunting(defectiveBranch);
}
if (defectiveBranchRemain != station.getDefectiveShuntingRemain().get()) {
change = true;
defectiveBranchRemain = station.getDefectiveShuntingRemain().get();
status.setDefectiveShuntingRemain(defectiveBranchRemain);
}
return change; return change;
} }
@ -230,8 +208,6 @@ public class StationStatus extends DeviceStatus {
statusVO.setSGuideMasterLock(sGuideMasterLock); statusVO.setSGuideMasterLock(sGuideMasterLock);
statusVO.setXGuideMasterLock(xGuideMasterLock); statusVO.setXGuideMasterLock(xGuideMasterLock);
statusVO.setAllowAutonomy(allowAutonomy); statusVO.setAllowAutonomy(allowAutonomy);
statusVO.setDefectiveShunting(defectiveBranch);
statusVO.setDefectiveShuntingRemain(defectiveBranchRemain);
return statusVO; return statusVO;
} }
} }

View File

@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
/** /**
* 区段状态 * 区段状态
*/ */
@ -93,7 +95,7 @@ public class SectionStatusVO extends DeviceStatusVO {
private Integer remain; private Integer remain;
private String defectiveShuntingTypes; private List<Section.ShuntingType> shuntingTypeList;
public SectionStatusVO(Section section) { public SectionStatusVO(Section section) {
super(section.getCode(), section.getDeviceType()); super(section.getCode(), section.getDeviceType());

View File

@ -87,16 +87,6 @@ public class StationStatusVO extends DeviceStatusVO {
private Boolean allowAutonomy; private Boolean allowAutonomy;
/**
* 分路不良
*/
private Boolean defectiveShunting;
/**
* 分路不良倒计时
*/
private Integer defectiveShuntingRemain;
public StationStatusVO(Station station) { public StationStatusVO(Station station) {
super(station.getCode(), station.getDeviceType()); super(station.getCode(), station.getDeviceType());
} }