【车站操作模式转换逻辑调整】
This commit is contained in:
parent
55c93799c2
commit
be8c515eea
@ -323,10 +323,6 @@ public class StationOperateHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 车站状态选择切换
|
* 车站状态选择切换
|
||||||
* @param simulation 仿真实体
|
|
||||||
* @param stationCode 车站编码
|
|
||||||
* @param routeSetMode 排路方式
|
|
||||||
* @param planControl 计划控制
|
|
||||||
*/
|
*/
|
||||||
@OperateHandlerMapping(type = Operation.Type.Station_Switch_Route_Set_Model)
|
@OperateHandlerMapping(type = Operation.Type.Station_Switch_Route_Set_Model)
|
||||||
public List<String> switchRouteSetModel(Simulation simulation, List<RouteModelParam> routeSetModeParams) {
|
public List<String> switchRouteSetModel(Simulation simulation, List<RouteModelParam> routeSetModeParams) {
|
||||||
|
@ -27,6 +27,7 @@ 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.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -616,6 +617,15 @@ public class AtsStationService {
|
|||||||
logList.add(String.format("车站【%s(%s)】 禁止转换", station.getName(), station.getCode()));
|
logList.add(String.format("车站【%s(%s)】 禁止转换", station.getName(), station.getCode()));
|
||||||
} else {
|
} else {
|
||||||
applyOperation.setApplyDateTime(simulation.getCorrectSystemTime());
|
applyOperation.setApplyDateTime(simulation.getCorrectSystemTime());
|
||||||
|
if (applyOperation.isCenterApplication()) { // 如果中心请求,需要车站同意
|
||||||
|
applyOperation.setApprovalMember(Arrays.asList(station.getController()));
|
||||||
|
} else { // 车站同意需要中心同意
|
||||||
|
applyOperation.setApprovalMember(
|
||||||
|
simulation.getSimulationMembers().stream()
|
||||||
|
.filter(s -> Objects.equals(s.getType(), SimulationMember.Type.DISPATCHER))
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
}
|
||||||
station.setOperationModeApplication(applyOperation);
|
station.setOperationModeApplication(applyOperation);
|
||||||
}
|
}
|
||||||
} else { // 非分散自律抛出异常
|
} else { // 非分散自律抛出异常
|
||||||
@ -654,7 +664,7 @@ public class AtsStationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 发送申请转换操作模式申请
|
||||||
* @param simulation
|
* @param simulation
|
||||||
* @param station
|
* @param station
|
||||||
*/
|
*/
|
||||||
@ -668,29 +678,27 @@ public class AtsStationService {
|
|||||||
station.setOperationModeApplication(null);
|
station.setOperationModeApplication(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SimulationMember simulationMember = null;
|
if (CollectionUtils.isEmpty(modeApplication.getApprovalMember())) {
|
||||||
if (modeApplication.isCenterApplication()) { // 如果中心请求
|
|
||||||
simulationMember = station.getController();
|
|
||||||
} else {
|
|
||||||
simulationMember = simulation.getSimulationMembers().stream()
|
|
||||||
.filter(s -> Objects.equals(s.getType(), SimulationMember.Type.DISPATCHER))
|
|
||||||
.findFirst().orElse(null);
|
|
||||||
}
|
|
||||||
if (simulationMember == null) {
|
|
||||||
return;
|
return;
|
||||||
} else if (simulationMember.isRobot()) {
|
}
|
||||||
doOperationModeSwitch(station);
|
Set<String> userSet = modeApplication.getApprovalMember().stream()
|
||||||
} else {
|
.filter(m -> !m.isRobot()).map(club.joylink.rtss.simulation.SimulationMember::getUserId).collect(Collectors.toSet());
|
||||||
SocketMessageVO<Station.OperationModeApplication> socketMessageVO =
|
if (!CollectionUtils.isEmpty(userSet)) {
|
||||||
SocketMessageFactory.build(WebSocketMessageType.Simulation_Operation_Mode_Apply, simulation.getId(), modeApplication);
|
Map<String, Object> messageMap = new HashMap<>();
|
||||||
stompMessageService.sendToUser(Set.of(simulationMember.getUserId()), socketMessageVO);
|
messageMap.put("source", modeApplication.getSource());
|
||||||
|
messageMap.put("target", modeApplication.getTarget());
|
||||||
|
messageMap.put("applyMember", modeApplication.getApplicationMember().getId());
|
||||||
|
messageMap.put("applyDateTime", modeApplication.getApplyDateTime());
|
||||||
|
SocketMessageVO<Map<String, Object>> socketMessageVO =
|
||||||
|
SocketMessageFactory.build(WebSocketMessageType.Simulation_Operation_Mode_Apply, simulation.getId(), messageMap);
|
||||||
|
stompMessageService.sendToUser(userSet, socketMessageVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作模式直接转换
|
* 操作模式直接转换
|
||||||
*/
|
*/
|
||||||
private void doOperationModeSwitch(Station station) {
|
public void doOperationModeSwitch(Station station) {
|
||||||
Station.OperationModeApplication applyOperation = station.getOperationModeApplication();
|
Station.OperationModeApplication applyOperation = station.getOperationModeApplication();
|
||||||
station.setOperationMode(applyOperation.getTarget());
|
station.setOperationMode(applyOperation.getTarget());
|
||||||
station.setOperationModeApplication(null);
|
station.setOperationModeApplication(null);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.CI;
|
package club.joylink.rtss.simulation.cbtc.CI;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStationService;
|
||||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiDeviceStatusCollector;
|
import club.joylink.rtss.simulation.cbtc.CI.device.CiDeviceStatusCollector;
|
||||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
|
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
|
||||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiService;
|
import club.joylink.rtss.simulation.cbtc.CI.device.CiService;
|
||||||
@ -36,6 +37,9 @@ public class CiLogic {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private StationDirectionService stationDirectionService;
|
private StationDirectionService stationDirectionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AtsStationService atsStationService;
|
||||||
|
|
||||||
public void runForTrainPosition(Simulation simulation){
|
public void runForTrainPosition(Simulation simulation){
|
||||||
// 采集真实设备状态
|
// 采集真实设备状态
|
||||||
deviceStatusCollector.collect(simulation);
|
deviceStatusCollector.collect(simulation);
|
||||||
@ -62,6 +66,8 @@ public class CiLogic {
|
|||||||
if (simulation.getRepository().getConfig().isRailway()) {
|
if (simulation.getRepository().getConfig().isRailway()) {
|
||||||
// 车站
|
// 车站
|
||||||
simulation.getRepository().getStationList().stream().forEach(station -> {
|
simulation.getRepository().getStationList().stream().forEach(station -> {
|
||||||
|
// 车站站控操作模式转换
|
||||||
|
atsStationService.replyOperationMode(simulation, station);
|
||||||
// 允许自律状态刷新
|
// 允许自律状态刷新
|
||||||
station.refreshAllowAutonomyStatus();
|
station.refreshAllowAutonomyStatus();
|
||||||
// 接、发辅助按钮倒计时刷新
|
// 接、发辅助按钮倒计时刷新
|
||||||
|
@ -595,8 +595,16 @@ public class Station extends MayOutOfOrderDevice {
|
|||||||
*/
|
*/
|
||||||
private OperationMode target;
|
private OperationMode target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请人
|
||||||
|
*/
|
||||||
private SimulationMember applicationMember;
|
private SimulationMember applicationMember;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批人
|
||||||
|
*/
|
||||||
|
private List<SimulationMember> approvalMember;
|
||||||
|
|
||||||
private LocalDateTime applyDateTime;
|
private LocalDateTime applyDateTime;
|
||||||
|
|
||||||
public OperationModeApplication(SimulationMember applicantMember, OperationMode source, OperationMode target) {
|
public OperationModeApplication(SimulationMember applicantMember, OperationMode source, OperationMode target) {
|
||||||
@ -642,6 +650,16 @@ public class Station extends MayOutOfOrderDevice {
|
|||||||
return stationApplication && centerToShunt();
|
return stationApplication && centerToShunt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批人全部是机器人
|
||||||
|
*/
|
||||||
|
public boolean isRobotApproval() {
|
||||||
|
if (CollectionUtils.isEmpty(approvalMember)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return approvalMember.stream().allMatch(SimulationMember::isRobot);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 中心与调车相互转换
|
* 中心与调车相互转换
|
||||||
*/
|
*/
|
||||||
|
@ -15,9 +15,11 @@ import lombok.Setter;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -196,6 +198,11 @@ public class StorageStation extends StorageStatusDevice {
|
|||||||
*/
|
*/
|
||||||
private String applicationMemberId;
|
private String applicationMemberId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批者ID
|
||||||
|
*/
|
||||||
|
private List<String> approvalMemberIds;
|
||||||
|
|
||||||
private LocalDateTime applyDateTime;
|
private LocalDateTime applyDateTime;
|
||||||
|
|
||||||
public static OperationModeApplicationStorage convert2Storage(Station.OperationModeApplication application) {
|
public static OperationModeApplicationStorage convert2Storage(Station.OperationModeApplication application) {
|
||||||
@ -207,13 +214,16 @@ public class StorageStation extends StorageStatusDevice {
|
|||||||
storage.setSource(application.getSource());
|
storage.setSource(application.getSource());
|
||||||
storage.setTarget(application.getTarget());
|
storage.setTarget(application.getTarget());
|
||||||
storage.setApplyDateTime(application.getApplyDateTime());
|
storage.setApplyDateTime(application.getApplyDateTime());
|
||||||
|
storage.setApprovalMemberIds(application.getApprovalMember().stream().map(SimulationMember::getId).collect(Collectors.toList()));
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Station.OperationModeApplication recover2Simulation(Simulation simulation){
|
public Station.OperationModeApplication recover2Simulation(Simulation simulation){
|
||||||
SimulationMember simulationMember = simulation.getSimulationMemberById(applicationMemberId);
|
SimulationMember simulationMember = simulation.getSimulationMemberById(applicationMemberId);
|
||||||
|
List<SimulationMember> approvalMember = approvalMemberIds.stream().map(simulation::getSimulationMemberById).collect(Collectors.toList());
|
||||||
Station.OperationModeApplication application =new Station.OperationModeApplication(simulationMember, source, target);
|
Station.OperationModeApplication application =new Station.OperationModeApplication(simulationMember, source, target);
|
||||||
application.setApplyDateTime(applyDateTime);
|
application.setApplyDateTime(applyDateTime);
|
||||||
|
application.setApprovalMember(approvalMember);
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,9 +570,16 @@ public class SimulationRobotService {
|
|||||||
if (simulation.getScript() != null && simulation.getScript().isBgSet()) {
|
if (simulation.getScript() != null && simulation.getScript().isBgSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
simulation.getRepository().getStationList().stream().filter(station -> station.getOperationModeApplication() != null)
|
// 实训场景模式,已设置背景处于编制状态的实训,不做自动转换处理
|
||||||
.forEach(station -> atsStationService.replyOperationMode(simulation, station));
|
Training2 training2 = simulation.getTraining2();
|
||||||
|
if (training2 != null && training2.isScene() && StringUtils.hasText(training2.getBgSceneJson()) && !training2.isRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
simulation.getRepository().getStationList().stream()
|
||||||
|
.filter(station -> station.getOperationModeApplication() != null && station.getOperationModeApplication().isRobotApproval())
|
||||||
|
.forEach(station -> atsStationService.doOperationModeSwitch(station));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doControlBySpeedCurve(Simulation simulation, VirtualRealityTrain train, SpeedCurve speedCurve, float remainDistance) {
|
private void doControlBySpeedCurve(Simulation simulation, VirtualRealityTrain train, SpeedCurve speedCurve, float remainDistance) {
|
||||||
if (speedCurve.equals(SpeedCurve.ZERO)) {
|
if (speedCurve.equals(SpeedCurve.ZERO)) {
|
||||||
this.doBreakMax(simulation, train);
|
this.doBreakMax(simulation, train);
|
||||||
|
Loading…
Reference in New Issue
Block a user