【车站模式申请消息返回格式修改】

This commit is contained in:
weizhihong 2023-02-16 14:10:18 +08:00
parent 8cfa715e37
commit 3cc442b0fa
2 changed files with 43 additions and 27 deletions

View File

@ -666,32 +666,48 @@ public class AtsStationService {
/** /**
* 发送申请转换操作模式申请 * 发送申请转换操作模式申请
* @param simulation * @param simulation
* @param station
*/ */
public void replyOperationMode(Simulation simulation, Station station) { public void replyOperationMode(Simulation simulation) {
Station.OperationModeApplication modeApplication = station.getOperationModeApplication(); List<Station> stationList = simulation.getRepository().getStationList();
if (modeApplication == null) { // 需要给用户发送的申请列表
return; Map<String, List<Map<String,Object>>> userMessageMap = new HashMap<>(stationList.size());
} stationList.stream().filter(station -> {
// 申请超过两分钟 Station.OperationModeApplication modeApplication = station.getOperationModeApplication();
if (simulation.getCorrectSystemTime().isAfter(modeApplication.getApplyDateTime().plusMinutes(2))) { if (modeApplication== null) {
station.setOperationModeApplication(null); return false;
return; }
} if (CollectionUtils.isEmpty(modeApplication.getApprovalMember())) {
if (CollectionUtils.isEmpty(modeApplication.getApprovalMember())) { return false;
return; }
} // 申请超过两分钟
Set<String> userSet = modeApplication.getApprovalMember().stream() if (simulation.getCorrectSystemTime().isAfter(modeApplication.getApplyDateTime().plusMinutes(2))) {
.filter(m -> !m.isRobot()).map(club.joylink.rtss.simulation.SimulationMember::getUserId).collect(Collectors.toSet()); station.setOperationModeApplication(null);
if (!CollectionUtils.isEmpty(userSet)) { return false;
Map<String, Object> messageMap = new HashMap<>(); }
messageMap.put("source", modeApplication.getSource()); return true;
messageMap.put("target", modeApplication.getTarget()); }).forEach(station -> {
messageMap.put("applyMember", modeApplication.getApplicationMember().getId()); Station.OperationModeApplication modeApplication = station.getOperationModeApplication();
messageMap.put("applyDateTime", modeApplication.getApplyDateTime()); Set<String> userSet = modeApplication.getApprovalMember().stream().filter(m -> !m.isRobot())
SocketMessageVO<Map<String, Object>> socketMessageVO = .map(club.joylink.rtss.simulation.SimulationMember::getUserId).collect(Collectors.toSet());
SocketMessageFactory.build(WebSocketMessageType.Simulation_Operation_Mode_Apply, simulation.getId(), messageMap); if (!CollectionUtils.isEmpty(userSet)) {
stompMessageService.sendToUser(userSet, socketMessageVO); Map<String, Object> messageMap = new HashMap<>();
messageMap.put("code", station.getCode());
messageMap.put("source", modeApplication.getSource());
messageMap.put("target", modeApplication.getTarget());
messageMap.put("applyMember", modeApplication.getApplicationMember().getId());
messageMap.put("applyDateTime", modeApplication.getApplyDateTime());
for (String userId : userSet) {
if (!userMessageMap.containsKey(userId)) {
userMessageMap.put(userId, new ArrayList<>());
}
userMessageMap.get(userId).add(messageMap);
}
}
});
if (!CollectionUtils.isEmpty(userMessageMap)) {
userMessageMap.forEach((k, v) ->
stompMessageService.sendToUser(k,
SocketMessageFactory.build(WebSocketMessageType.Simulation_Operation_Mode_Apply, simulation.getId(), v)));
} }
} }

View File

@ -64,10 +64,10 @@ public class CiLogic {
// 区间灯点灯逻辑 // 区间灯点灯逻辑
if (simulation.getRepository().getConfig().isRailway()) { if (simulation.getRepository().getConfig().isRailway()) {
// 车站站控操作模式转换
atsStationService.replyOperationMode(simulation);
// 车站 // 车站
simulation.getRepository().getStationList().stream().forEach(station -> { simulation.getRepository().getStationList().stream().forEach(station -> {
// 车站站控操作模式转换
atsStationService.replyOperationMode(simulation, station);
// 允许自律状态刷新 // 允许自律状态刷新
station.refreshAllowAutonomyStatus(); station.refreshAllowAutonomyStatus();
// 发辅助按钮倒计时刷新 // 发辅助按钮倒计时刷新