|
@@ -23,6 +23,7 @@ import javax.annotation.Resource;
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
@@ -77,7 +78,7 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
|
public void execMqOeLogic(MqDto mqDto, String key) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
|
|
|
Gson gson = new Gson();
|
|
|
MqEnum mqEnum = mqDto.getType();
|
|
|
- ConcurrentHashMap<String, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
|
|
|
+ ConcurrentHashMap<Long, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
|
|
|
// if (MqEnum.WEBSOCKET_OFFLINE_LOG.ordinal() == mqEnum.ordinal()) {//下线
|
|
|
// JSONArray jsonArray = JSONArray.parseArray(String.valueOf(mqDto.getBody()));
|
|
|
// Set<String> examStudentIdentitySet = jsonArray.toJavaObject(Set.class);
|
|
@@ -95,76 +96,73 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
|
|
|
// } else
|
|
|
if (MqEnum.WEBSOCKET_MONITOR_FINISH_LOG.ordinal() == mqEnum.ordinal()) {//强制离线交卷
|
|
|
Set examRecordId = JacksonUtil.readJson(String.valueOf(mqDto.getBody()), Set.class);
|
|
|
- webSocketMap.forEach((k, v) -> {
|
|
|
examRecordId.forEach(s -> {
|
|
|
Long recordId = Long.parseLong(String.valueOf(s));
|
|
|
- if (v.getRecordId().longValue() == recordId.longValue()) {
|
|
|
+ if (Objects.nonNull(webSocketMap.get(recordId))) {
|
|
|
+ WebSocketOeServer webSocketOeServer = webSocketMap.get(recordId);
|
|
|
Map map = new HashMap<>();
|
|
|
map.put("form", mqDto.getObjName());
|
|
|
map.put(SystemConstant.RECORD_ID, recordId);
|
|
|
map.put(SystemConstant.MESSAGE, FinishTypeEnum.valueOf(String.valueOf(mqDto.getProperties().get("type"))).getCode());
|
|
|
WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.invigilate_stop_exam.name(), map);
|
|
|
- v.sendMessage(websocketDto);
|
|
|
+ webSocketOeServer.sendMessage(websocketDto);
|
|
|
}
|
|
|
});
|
|
|
- });
|
|
|
} else if (MqEnum.WEBSOCKET_HAND_FINISH_LOG.ordinal() == mqEnum.ordinal()) {//手动交卷
|
|
|
Set examRecordId = JacksonUtil.readJson(String.valueOf(mqDto.getBody()), Set.class);
|
|
|
- webSocketMap.forEach((k, v) -> {
|
|
|
examRecordId.forEach(s -> {
|
|
|
Long recordId = Long.parseLong(String.valueOf(s));
|
|
|
- if (v.getRecordId().longValue() == recordId.longValue()) {
|
|
|
+ if (Objects.nonNull(webSocketMap.get(recordId))) {
|
|
|
+ WebSocketOeServer webSocketOeServer = webSocketMap.get(recordId);
|
|
|
Map map = new HashMap<>();
|
|
|
map.put(SystemConstant.RECORD_ID, recordId);
|
|
|
- map.put(SystemConstant.MESSAGE, recordId);
|
|
|
+ map.put(SystemConstant.MESSAGE, FinishTypeEnum.valueOf(String.valueOf(mqDto.getProperties().get("type"))).getCode());
|
|
|
WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.invigilate_stop_exam.name(), map);
|
|
|
- v.sendMessage(websocketDto);
|
|
|
+ webSocketOeServer.sendMessage(websocketDto);
|
|
|
}
|
|
|
});
|
|
|
- });
|
|
|
} else if (MqEnum.WEBSOCKET_WARNING_FINISH_LOG.ordinal() == mqEnum.ordinal()) {//预警交卷
|
|
|
Set examRecordId = JacksonUtil.readJson(String.valueOf(mqDto.getBody()), Set.class);
|
|
|
- webSocketMap.forEach((k, v) -> {
|
|
|
examRecordId.forEach(s -> {
|
|
|
Long recordId = Long.parseLong(String.valueOf(s));
|
|
|
- if (v.getRecordId().longValue() == recordId.longValue()) {
|
|
|
+ if (Objects.nonNull(webSocketMap.get(recordId))) {
|
|
|
+ WebSocketOeServer webSocketOeServer = webSocketMap.get(recordId);
|
|
|
Map map = new HashMap<>();
|
|
|
map.put(SystemConstant.RECORD_ID, recordId);
|
|
|
map.put(SystemConstant.BREACH_STATUS, recordId);
|
|
|
WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.invigilate_stop_exam.name(), map);
|
|
|
- v.sendMessage(websocketDto);
|
|
|
+ webSocketOeServer.sendMessage(websocketDto);
|
|
|
}
|
|
|
});
|
|
|
- });
|
|
|
} else if (MqEnum.WEBSOCKET_IM_CLUSTERING_LOG.ordinal() == mqEnum.ordinal()) {//点对点消息
|
|
|
JSONArray jsonArray = JSONArray.parseArray(String.valueOf(mqDto.getBody()));
|
|
|
Set<String> examStudentIdentitySet = jsonArray.toJavaObject(Set.class);
|
|
|
log.info("examStudentIdentitySet:{}", JacksonUtil.parseJson(examStudentIdentitySet));
|
|
|
- webSocketMap.forEach((k, v) -> {
|
|
|
- examStudentIdentitySet.forEach(s -> {
|
|
|
- if (k.contains(s)) {
|
|
|
- Map map = new HashMap<>();
|
|
|
- map.put("message", k);
|
|
|
- WebsocketDto websocketDto = new WebsocketDto("message", map);
|
|
|
- v.sendMessage(websocketDto);
|
|
|
- return;
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
+// webSocketMap.forEach((k, v) -> {
|
|
|
+// examStudentIdentitySet.forEach(s -> {
|
|
|
+// if (k.contains(s)) {
|
|
|
+// Map map = new HashMap<>();
|
|
|
+// map.put("message", k);
|
|
|
+// WebsocketDto websocketDto = new WebsocketDto("message", map);
|
|
|
+// v.sendMessage(websocketDto);
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// });
|
|
|
+// });
|
|
|
} else if (MqEnum.WEBSOCKET_IM_BROADCASTING_LOG.ordinal() == mqEnum.ordinal()) {//广播消息
|
|
|
JSONArray jsonArray = JSONArray.parseArray(String.valueOf(mqDto.getBody()));
|
|
|
Set<String> examStudentIdentitySet = jsonArray.toJavaObject(Set.class);
|
|
|
log.info("examStudentIdentitySet:{}", JacksonUtil.parseJson(examStudentIdentitySet));
|
|
|
- webSocketMap.forEach((k, v) -> {
|
|
|
- examStudentIdentitySet.forEach(s -> {
|
|
|
- if (k.contains(s)) {
|
|
|
- Map map = new HashMap<>();
|
|
|
- map.put("message", k);
|
|
|
- WebsocketDto websocketDto = new WebsocketDto("message", map);
|
|
|
- v.sendMessage(websocketDto);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
+// webSocketMap.forEach((k, v) -> {
|
|
|
+// examStudentIdentitySet.forEach(s -> {
|
|
|
+// if (k.contains(s)) {
|
|
|
+// Map map = new HashMap<>();
|
|
|
+// map.put("message", k);
|
|
|
+// WebsocketDto websocketDto = new WebsocketDto("message", map);
|
|
|
+// v.sendMessage(websocketDto);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// });
|
|
|
}
|
|
|
mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
|
|
|
TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
|