From f68d3c71819feb59e7a227a5d992b059b900916c Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期五, 28 三月 2025 08:28:26 +0800
Subject: [PATCH] 修改报表,界面添加查询流程卡个数,调整推送数据到前端的间隔

---
 hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java |   83 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 68 insertions(+), 15 deletions(-)

diff --git a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java
index 863c349..9f5f086 100644
--- a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java
+++ b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java
@@ -1,8 +1,12 @@
 package com.mes.job;
 
 import cn.hutool.json.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.mes.common.config.Const;
+import com.mes.damage.entity.Damage;
+import com.mes.damage.service.DamageService;
+import com.mes.temperingglass.service.TemperingGlassInfoService;
 import com.mes.temperingglass.entity.TemperingGlassInfo;
-import com.mes.temperingglass.service.TemperingAgoService;
 import com.mes.tools.WebSocketServer;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +15,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author SNG-010
@@ -20,30 +25,56 @@
 public class PlcTemperingGlassTask {
 
     @Autowired
-    private TemperingAgoService temperingAgoService;
+    private TemperingGlassInfoService temperingAgoService;
+    @Autowired
+    private DamageService damageService;
+
     /**
      * fixedRate : 涓婁竴涓皟鐢ㄥ紑濮嬪悗鍐嶆璋冪敤鐨勫欢鏃讹紙涓嶇敤绛夊緟涓婁竴娆¤皟鐢ㄥ畬鎴愶級
      * fixedDelay : 涓婁竴涓皟鐢ㄧ粨鏉熷悗鍐嶆璋冪敤鐨勫欢鏃�
      */
 
     @Scheduled(fixedDelay = 1000)
-    public void loadGlassHome(){
+    public void temperingGlassHome() {
         JSONObject jsonObject = new JSONObject();
-        //姝e湪绛夊緟杩涚墖鐨勭幓鐠�
-        List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlass();
-        jsonObject.append("waitingGlass", waitingGlass);
-        //杩涚倝涓殑鐜荤拑
-        List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass();
-        jsonObject.append("intoGlass", intoGlass);
-        //鍑虹倝鍚庣殑鐜荤拑
-        List<TemperingGlassInfo> outGlass = temperingAgoService.selectOutGlass();
-        jsonObject.append("outGlass", outGlass);
-        //杩囨棆杞彴閽㈠寲鍚庣殑鐜荤拑
-        TemperingGlassInfo overGlass = temperingAgoService.selectOverGlass();
-        jsonObject.append("overGlass", overGlass);
+
 
         ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingGlass");
         if (sendwServer != null) {
+            //姝e湪绛夊緟杩涚墖鐨勭幓鐠�
+            List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlass();
+            if (waitingGlass != null) {
+                jsonObject.append("waitingGlass", waitingGlass);
+            }
+
+            //鑾峰彇鏁村湪鐐変腑鐨勪袱涓増鍥緄d
+            List<TemperingGlassInfo> layoutId = temperingAgoService.selectLayoutId();
+            //杩涚倝涓殑鐜荤拑
+            if (!layoutId.isEmpty()) {
+                for (int i = 0; i < layoutId.size(); i++) {
+                    List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(i));
+                    jsonObject.append("intoGlass" + (i + 1), intoGlass);
+                }
+//            List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(0));
+//            jsonObject.append("intoGlass", intoGlass);
+//            //杩涚倝涓殑绗簩涓増鍥�
+//            if (layoutId.size() > 1) {
+//                List<TemperingGlassInfo> intoGlass2 = temperingAgoService.selectIntoGlass(layoutId.get(1));
+//                jsonObject.append("intoGlass2", intoGlass2);
+//            }
+
+            }
+            //鍑虹倝鍚庣殑鐜荤拑
+            List<TemperingGlassInfo> outGlass = temperingAgoService.selectOutGlass();
+            if (outGlass != null) {
+                jsonObject.append("outGlass", outGlass);
+            }
+
+            //杩囨棆杞彴閽㈠寲鍚庣殑鐜荤拑
+            List<TemperingGlassInfo> overGlass = temperingAgoService.selectOverGlass();
+            if (outGlass != null) {
+                jsonObject.append("overGlass", overGlass);
+            }
             for (WebSocketServer webserver : sendwServer) {
                 if (webserver != null) {
                     webserver.sendMessage(jsonObject.toString());
@@ -54,4 +85,26 @@
         }
     }
 
+    @Scheduled(fixedDelay = 1000)
+    public void temperingIsRun() {
+        JSONObject jsonObject = new JSONObject();
+        //姝e湪杩涜鐨勪换鍔�
+        List<TemperingGlassInfo> temperingTaskType = temperingAgoService.selectTaskType();
+        jsonObject.append("temperingTaskType", temperingTaskType);
+
+
+        ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingIsRun");
+        if (sendwServer != null) {
+            for (WebSocketServer webserver : sendwServer) {
+                if (webserver != null) {
+                    webserver.sendMessage(jsonObject.toString());
+                } else {
+                    log.info("Home is closed");
+                }
+            }
+        }
+
+    }
+
+
 }
\ No newline at end of file

--
Gitblit v1.8.0