From 33434cc72b423afa36f6bfaa6ff07919336d8978 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期五, 22 八月 2025 15:18:45 +0800
Subject: [PATCH] 1、websocket更新

---
 hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java |   29 +++++++----------------------
 1 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java
index 588bda2..9523529 100644
--- a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java
+++ b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java
@@ -12,6 +12,7 @@
 import com.mes.rawglassdetails.entity.RawGlassStorageDetails;
 import com.mes.rawglassstation.service.RawGlassStorageStationService;
 import com.mes.tools.WebSocketServer;
+import com.mes.tools.WebSocketUtils;
 import com.mes.uppattenusage.entity.UpPattenUsage;
 import com.mes.uppattenusage.service.UpPattenUsageService;
 import com.mes.utils.RedisUtil;
@@ -54,6 +55,9 @@
     private static final String LOAD_GLASS_DEVICE_ONE_TASK = "load_glass_device_one_task";
 
     private static final String LOAD_GLASS_DEVICE_TWO_TASK = "load_glass_device_two_task";
+
+    @Resource
+    private WebSocketUtils webSocketUtils;
 
     /**
      * fixedRate : 涓婁竴涓皟鐢ㄥ紑濮嬪悗鍐嶆璋冪敤鐨勫欢鏃讹紙涓嶇敤绛夊緟涓婁竴娆¤皟鐢ㄥ畬鎴愶級
@@ -169,22 +173,13 @@
             List<RawGlassStorageDetails> stationList = rawGlassStorageDetailList.stream().filter(item -> item.getDeviceId() == stationCell).collect(Collectors.toList());
             jsonObject.append("stationList", stationList);
 
-            ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get(webSocketName);
-            if (sendwServer != null) {
-                for (WebSocketServer webserver : sendwServer) {
-                    if (webserver != null) {
-                        webserver.sendMessage(jsonObject.toString());
-                    } else {
-                        log.info("loadGlass is closed");
-                    }
-                }
-            }
+            webSocketUtils.sendToWeb(webSocketName, jsonObject);
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
- 
+
     //    @Scheduled(fixedDelay = 5000)
     public void loadGlassStatus() {
         JSONObject jsonObject = new JSONObject();
@@ -192,17 +187,7 @@
         String inkageStatus = plcParameterObject.getPlcParameter("InkageStatus").getValue();
 //        String inkageStatus ="1";
         jsonObject.append("InkageStatus", inkageStatus);
-
-        ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("loadGlass");
-        if (sendwServer != null) {
-            for (WebSocketServer webserver : sendwServer) {
-                if (webserver != null) {
-                    webserver.sendMessage(jsonObject.toString());
-                } else {
-                    log.info("loadGlass is closed");
-                }
-            }
-        }
+        webSocketUtils.sendToWeb("loadGlass", jsonObject);
     }
 
 

--
Gitblit v1.8.0