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

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) {
List<Station> stationList = simulation.getRepository().getStationList();
// 需要给用户发送的申请列表
Map<String, List<Map<String,Object>>> userMessageMap = new HashMap<>(stationList.size());
stationList.stream().filter(station -> {
Station.OperationModeApplication modeApplication = station.getOperationModeApplication(); Station.OperationModeApplication modeApplication = station.getOperationModeApplication();
if (modeApplication == null) { if (modeApplication== null) {
return; return false;
}
if (CollectionUtils.isEmpty(modeApplication.getApprovalMember())) {
return false;
} }
// 申请超过两分钟 // 申请超过两分钟
if (simulation.getCorrectSystemTime().isAfter(modeApplication.getApplyDateTime().plusMinutes(2))) { if (simulation.getCorrectSystemTime().isAfter(modeApplication.getApplyDateTime().plusMinutes(2))) {
station.setOperationModeApplication(null); station.setOperationModeApplication(null);
return; return false;
} }
if (CollectionUtils.isEmpty(modeApplication.getApprovalMember())) { return true;
return; }).forEach(station -> {
} Station.OperationModeApplication modeApplication = station.getOperationModeApplication();
Set<String> userSet = modeApplication.getApprovalMember().stream() Set<String> userSet = modeApplication.getApprovalMember().stream().filter(m -> !m.isRobot())
.filter(m -> !m.isRobot()).map(club.joylink.rtss.simulation.SimulationMember::getUserId).collect(Collectors.toSet()); .map(club.joylink.rtss.simulation.SimulationMember::getUserId).collect(Collectors.toSet());
if (!CollectionUtils.isEmpty(userSet)) { if (!CollectionUtils.isEmpty(userSet)) {
Map<String, Object> messageMap = new HashMap<>(); Map<String, Object> messageMap = new HashMap<>();
messageMap.put("code", station.getCode());
messageMap.put("source", modeApplication.getSource()); messageMap.put("source", modeApplication.getSource());
messageMap.put("target", modeApplication.getTarget()); messageMap.put("target", modeApplication.getTarget());
messageMap.put("applyMember", modeApplication.getApplicationMember().getId()); messageMap.put("applyMember", modeApplication.getApplicationMember().getId());
messageMap.put("applyDateTime", modeApplication.getApplyDateTime()); messageMap.put("applyDateTime", modeApplication.getApplyDateTime());
SocketMessageVO<Map<String, Object>> socketMessageVO = for (String userId : userSet) {
SocketMessageFactory.build(WebSocketMessageType.Simulation_Operation_Mode_Apply, simulation.getId(), messageMap); if (!userMessageMap.containsKey(userId)) {
stompMessageService.sendToUser(userSet, socketMessageVO); 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();
// 发辅助按钮倒计时刷新 // 发辅助按钮倒计时刷新