This commit is contained in:
tiger_zhou 2023-05-30 13:54:29 +08:00
commit 33dbc54fd9
12 changed files with 132 additions and 4 deletions

View File

@ -109,4 +109,14 @@ public class SimulationTrainingV2Controller {
public void jumpToStep(@PathVariable String group, @PathVariable Long stepId){
training2Service.jumpToStep(group, stepId);
}
/**
* 实训开始准备给实训参与人员发送准备开始执行
* @param group 仿真ID
* @param user 操作人
*/
@PostMapping("/{group}/prepare/start")
public void prepareStart(@PathVariable String group, @RequestAttribute AccountVO user, ScriptBO.Mode mode) {
training2Service.prepareStart(group, user, mode);
}
}

View File

@ -472,6 +472,7 @@ public class Training2PublishService {
List<PublishedTraining2WithBLOBs> training2WithBLOBsList = publishedDao.selectByExampleWithBLOBs(example);
Map<Long, List<PublishedTraining2WithBLOBs>> mapTrainingMap = training2WithBLOBsList.stream().peek(t -> {
t.setId(null);
t.setMapId(null);
t.setUpdateTime(null);
t.setCreateTime(null);
}).collect(Collectors.groupingBy(PublishedTraining2WithBLOBs::getMapId));

View File

@ -4,6 +4,7 @@ import club.joylink.rtss.dao.DraftTraining2DAO;
import club.joylink.rtss.dao.PublishedTraining2DAO;
import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.training2.index.IndexAlgorithmService;
import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher;
import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
@ -142,6 +143,7 @@ public class Training2Service {
if (training2 == null || !training2.isStarted() || training2.isFinish()) {
// 结束并移除运行任务
removeTrainingJob(simulation);
trainingStatusMessage(simulation, 0);
return;
}
// 获取运行步骤
@ -274,7 +276,7 @@ public class Training2Service {
// 创建者退出则清理实训
if (simulation.getCreator().getId().equals(user.getId())) {
training2.finish();
removeTrainingJob(simulation);
simulation.start();
}
} else {
return List.of();
@ -553,10 +555,27 @@ public class Training2Service {
} catch (Exception e) {
log.error("loadTrainingToStep is error", e);
training2.finish();
removeTrainingJob(simulation);
}
}
/**
* 实训准备开始
* @param group 仿真号
* @param user 操作人
*/
public void prepareStart(String group, AccountVO user, ScriptBO.Mode mode) {
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(simulation.getTraining2() != null, "未加载实训");
Map<String, Object> messageMap = new HashMap<>();
messageMap.put("id", simulation.getTraining2().getId());
messageMap.put("mode", mode);
SocketMessageVO<Map<String, Object>> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Training_Prepare_Start, simulation.getId(), messageMap);
Set<String> userIdSet = simulation.getSimulationUserIds().stream()
.filter(id -> !Objects.equals(id, user.getId().toString())).collect(Collectors.toSet());
stompMessageService.sendToUser(userIdSet, message);
}
/**
* 实训时创建仿真对象
*/
@ -911,6 +930,8 @@ public class Training2Service {
addTrainingJob(simulation, training2);
// 启动仿真
simulationLifeCycleService.resume(simulation);
// 发送开始消息
trainingStatusMessage(simulation, 1);
}
/**
@ -921,4 +942,14 @@ public class Training2Service {
simulation.getTraining2().setJumpToStep(null);
simulation.getTraining2().finish();
}
/**
* 实训状态消息
* @param simulation 仿真
* @param status 状态
*/
private void trainingStatusMessage(Simulation simulation, int status) {
SocketMessageVO<Integer> message = SocketMessageFactory.build(WebSocketMessageType.Simulation_Training_Status, simulation.getId(), status);
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
}
}

View File

@ -507,6 +507,7 @@ public class AtsStationService {
}
station.setInterlockMachineStarting(true);
station.setRestartTime(LocalTime.now());
station.setPowerUnlockButtonShow(true);
Station.Fault.INTERLOCK_FAULT.fix(station); //恢复联锁机故障
SimulationDataRepository repository = simulation.getRepository();
//该站范围内区段故障锁闭

View File

@ -555,6 +555,7 @@ public class CiApiServiceImpl2 implements CiApiService {
|| Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType()))
? true : deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()));
if (hasCTCFlag || powerOnFlag) {
deviceStation.setPowerUnlockButtonShow(false);
List<Section> sections = simulation.getRepository().getSectionList();
sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock);
return;

View File

@ -241,6 +241,11 @@ public class Station extends MayOutOfOrderDevice {
*/
private OperationModeApplication operationModeApplication;
/**
* 上电解锁按钮显示状态
*/
private boolean powerUnlockButtonShow;
@Override
public void reset() {
super.reset();
@ -270,6 +275,7 @@ public class Station extends MayOutOfOrderDevice {
planControl = true;
routeSetMode = RouteSetMode.Plan_Set_Route;
operationMode = OperationMode.Center;
powerUnlockButtonShow = false;
}
public List<Stand> getStandOf(boolean right) {

View File

@ -112,6 +112,16 @@ public class StationStatus extends DeviceStatus {
*/
private Station.OperationMode operationMode;
/**
* 车站故障状态
*/
private String fault;
/**
* 上电解锁按钮状态
*/
private Boolean powerUnlockButtonShow;
public StationStatus(Station station) {
super(station.getCode(), station.getDeviceType());
controlMode = station.getControlMode();
@ -135,6 +145,7 @@ public class StationStatus extends DeviceStatus {
planControl = station.isPlanControl();
routeSetMode = station.getRouteSetMode();
operationMode = station.getOperationMode();
powerUnlockButtonShow = station.isPowerUnlockButtonShow();
}
@Override
@ -242,6 +253,17 @@ public class StationStatus extends DeviceStatus {
this.operationMode = station.getOperationMode();
status.setOperationMode(station.getOperationMode());
}
String fault = station.getFault() == null ? null : station.getFault().toString();
if (!Objects.equals(this.fault, fault)) {
this.fault = fault;
status.setFault(fault);
change = true;
}
if (!Objects.equals(powerUnlockButtonShow, station.isPowerUnlockButtonShow())) {
this.powerUnlockButtonShow = station.isPowerUnlockButtonShow();
status.setPowerUnlockButtonShow(station.isPowerUnlockButtonShow());
change = true;
}
return change;
}
@ -266,6 +288,8 @@ public class StationStatus extends DeviceStatus {
statusVO.setPlanControl(planControl);
statusVO.setRouteSetMode(routeSetMode);
statusVO.setOperationMode(operationMode);
statusVO.setFault(fault);
statusVO.setPowerUnlockButtonShow(powerUnlockButtonShow);
return statusVO;
}
}

View File

@ -96,6 +96,17 @@ public class StationStatusVO extends DeviceStatusVO {
private Station.OperationMode operationMode;
/**
* 车站故障状态
*/
private String fault;
/**
* 上电解锁按钮显示状态
*/
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean powerUnlockButtonShow;
public StationStatusVO(Station station) {
super(station.getCode(), station.getDeviceType());
}

View File

@ -377,6 +377,14 @@ public enum WebSocketMessageType {
/**
* ------------ 新实训消息 -----------
*/
/**
* 实训准备开始其他成员加载实训内容消息
*/
Simulation_Training_Prepare_Start,
/**
* 实训开始结束状态
*/
Simulation_Training_Status,
/**
* 步骤开始时提示信息
*/
@ -395,7 +403,7 @@ public enum WebSocketMessageType {
/**
* 实训完成
*/
Simulation_Training_Finish
Simulation_Training_Finish,
/** ------------ 新实训消息 ----------- */
;
}

View File

@ -155,12 +155,14 @@ public class SocketMessageFactory {
break;
}
// 20220819
case Simulation_Training_Prepare_Start:
case Simulation_Training_Step_Tip:
case Simulation_Training_Step_Finish:
case Simulation_Training_Audio_MATCH_RESULT:
// case Simulation_Training_Operate_Error:
// case Simulation_Training_Operate_Finish:
case Simulation_Training_Finish: {
case Simulation_Training_Finish:
case Simulation_Training_Status: {
topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group));
topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));

View File

@ -254,6 +254,12 @@ public class MapGraphDataNewVO {
*/
private Map<Simulation.Type, List<MapClientVO>> mapClientVOMap = new HashMap<>();
/**
* 上电解锁按钮
*/
private List<MapPowerUnlockButtonVO> powerUnLockButtonList;
public MapGraphDataNewVO() {
this.bigScreenConfig = new BigScreenConfig();
this.generateConfig = new MapCiGenerateConfig();
@ -288,6 +294,7 @@ public class MapGraphDataNewVO {
this.arrowList = new ArrayList<>();
this.directionRodList = new ArrayList<>();
this.responderList = new ArrayList<>();
this.powerUnLockButtonList = new ArrayList<>();
}
public static MapGraphDataNewVO parse(String graphData) {

View File

@ -0,0 +1,26 @@
package club.joylink.rtss.vo.map.graph;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
/**
* 上电解锁按钮
*/
@Getter
@Setter
public class MapPowerUnlockButtonVO {
@NotBlank(message = "code不能为空")
private String code;
private String name;
/**
* 所属设备集中站code
*/
private String stationCode;
private Point position;
}