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

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 station
*/
public void replyOperationMode(Simulation simulation, Station station) {
Station.OperationModeApplication modeApplication = station.getOperationModeApplication();
if (modeApplication == null) {
return;
}
// 申请超过两分钟
if (simulation.getCorrectSystemTime().isAfter(modeApplication.getApplyDateTime().plusMinutes(2))) {
station.setOperationModeApplication(null);
return;
}
if (CollectionUtils.isEmpty(modeApplication.getApprovalMember())) {
return;
}
Set<String> userSet = modeApplication.getApprovalMember().stream()
.filter(m -> !m.isRobot()).map(club.joylink.rtss.simulation.SimulationMember::getUserId).collect(Collectors.toSet());
if (!CollectionUtils.isEmpty(userSet)) {
Map<String, Object> messageMap = new HashMap<>();
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);
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();
if (modeApplication== null) {
return false;
}
if (CollectionUtils.isEmpty(modeApplication.getApprovalMember())) {
return false;
}
// 申请超过两分钟
if (simulation.getCorrectSystemTime().isAfter(modeApplication.getApplyDateTime().plusMinutes(2))) {
station.setOperationModeApplication(null);
return false;
}
return true;
}).forEach(station -> {
Station.OperationModeApplication modeApplication = station.getOperationModeApplication();
Set<String> userSet = modeApplication.getApprovalMember().stream().filter(m -> !m.isRobot())
.map(club.joylink.rtss.simulation.SimulationMember::getUserId).collect(Collectors.toSet());
if (!CollectionUtils.isEmpty(userSet)) {
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()) {
// 车站站控操作模式转换
atsStationService.replyOperationMode(simulation);
// 车站
simulation.getRepository().getStationList().stream().forEach(station -> {
// 车站站控操作模式转换
atsStationService.replyOperationMode(simulation, station);
// 允许自律状态刷新
station.refreshAllowAutonomyStatus();
// 发辅助按钮倒计时刷新