pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/WebSocketMessage.java
@@ -17,13 +17,11 @@ @NoArgsConstructor @Builder @Schema(name="websocket消息基类") @JsonPropertyOrder({"type", "code", "content"}) @JsonPropertyOrder({"type", "content"}) public class WebSocketMessage<T> { @Schema(description = "数据类型") public String type; @Schema(description = "数据编码") public String code;//数据编码,具体数据具体定义其编码,可以为空 @Schema(description = "数据") public T content; pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketHeartBeat.java
@@ -24,7 +24,6 @@ public static String getHeartBeatMessage() { WebSocketMessage vo = new WebSocketMessage() ; vo.type = WebSocketMessage.TYPE_HEARTBEAT ; vo.code = "" ;//心跳数据编码就是空字符串 vo.content = DateTime.yyyy_MM_dd_HH_mm_ss() ; return JSON.toJSONString(vo) ; } pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java
@@ -1,10 +1,12 @@ package com.dy.pipIrrRemote.msCenter; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.dy.common.contant.Constant; import com.dy.common.multiDataSource.DataSourceContext; import com.dy.common.util.NumUtil; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.WebSocketMessage; import com.dy.pipIrrRemote.largeScreen.WebSocketServer; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.tags.Tag; @@ -64,14 +66,25 @@ jo.put("intakeNum", intakeNum) ; } } try { WebSocketServer.sendAllMessage(jo.toJSONString()); }catch (Exception e){ log.error("推送消息失败", e) ; } } } sendByWebSocket(list) ; } return null ; } /** * 推送消息 * @param list */ private void sendByWebSocket(List<JSONObject> list){ WebSocketMessage vo = new WebSocketMessage() ; vo.type = WebSocketMessage.TYPE_JSON ; vo.content = list ; try { WebSocketServer.sendAllMessage(JSON.toJSONString(vo)); }catch (Exception e){ log.error("推送消息失败", e) ; } } }