From 3f3402576acd33ad6d43899888684958c19533ea Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 13 二月 2025 14:30:48 +0800
Subject: [PATCH] 完善websocket推送消息数据的数据结构

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/WebSocketMessage.java                            |    4 +---
 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketHeartBeat.java |    1 -
 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java   |   23 ++++++++++++++++++-----
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/WebSocketMessage.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/WebSocketMessage.java
index 87d8cb5..a996dec 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/WebSocketMessage.java
+++ b/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;
 
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketHeartBeat.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketHeartBeat.java
index b122c31..925f764 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketHeartBeat.java
+++ b/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) ;
     }
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java
index 839d8f0..114fc05 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java
+++ b/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) ;
+        }
+    }
 }

--
Gitblit v1.8.0