From f1916b183ebcff81c64bccae502a63b097c304f5 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期日, 18 八月 2024 12:42:16 +0800
Subject: [PATCH] 钢化界面添加显示人工拿走的玻璃信息

---
 hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java |   45 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 39 insertions(+), 6 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 4a9356e..acd2fcf 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,5 +1,10 @@
 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.tools.WebSocketServer;
@@ -10,6 +15,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author SNG-010
@@ -20,24 +26,27 @@
 
     @Autowired
     private TemperingGlassInfoService temperingAgoService;
+    @Autowired
+    private DamageService damageService;
+
     /**
      * fixedRate : 涓婁竴涓皟鐢ㄥ紑濮嬪悗鍐嶆璋冪敤鐨勫欢鏃讹紙涓嶇敤绛夊緟涓婁竴娆¤皟鐢ㄥ畬鎴愶級
      * fixedDelay : 涓婁竴涓皟鐢ㄧ粨鏉熷悗鍐嶆璋冪敤鐨勫欢鏃�
      */
 
     @Scheduled(fixedDelay = 1000)
-    public void temperingGlassHome(){
+    public void temperingGlassHome() {
         JSONObject jsonObject = new JSONObject();
         //姝e湪绛夊緟杩涚墖鐨勭幓鐠�
         List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlass();
-        if(waitingGlass!=null){
+        if (waitingGlass != null) {
             jsonObject.append("waitingGlass", waitingGlass);
         }
 
         //鑾峰彇鏁村湪鐐変腑鐨勪袱涓増鍥緄d
         List<TemperingGlassInfo> layoutId = temperingAgoService.selectLayoutId();
         //杩涚倝涓殑鐜荤拑
-        if(!layoutId.isEmpty()) {
+        if (!layoutId.isEmpty()) {
             List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(0));
             jsonObject.append("intoGlass", intoGlass);
             //杩涚倝涓殑绗簩涓増鍥�
@@ -48,7 +57,7 @@
         }
         //鍑虹倝鍚庣殑鐜荤拑
         List<TemperingGlassInfo> outGlass = temperingAgoService.selectOutGlass();
-        if(outGlass!=null){
+        if (outGlass != null) {
             jsonObject.append("outGlass", outGlass);
         }
 
@@ -57,7 +66,27 @@
         if (outGlass != null) {
             jsonObject.append("overGlass", overGlass);
         }
+        //褰撳墠閽㈠寲宸ョ▼鐨勬嬁璧版暟鎹�
+        LambdaQueryWrapper<TemperingGlassInfo> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.select(TemperingGlassInfo::getEngineerId)
+                .lt(TemperingGlassInfo::getState, Const.TEMPERING_END)
+                .groupBy(TemperingGlassInfo::getEngineerId);
 
+        List<String> engineerIds = temperingAgoService.list(queryWrapper)
+                .stream()
+                .map(TemperingGlassInfo::getEngineerId)
+                .distinct()
+                .collect(Collectors.toList());
+
+        List<Damage> temperingTakeGlassInfos = damageService.list(
+                new LambdaQueryWrapper<Damage>()
+                        .in(Damage::getEngineerId, engineerIds)
+                        .eq(Damage::getType, Const.GLASS_STATE_TAKE)
+                        .orderByAsc(Damage::getId)
+        );
+
+
+        jsonObject.append("temperingTakeGlassInfos", temperingTakeGlassInfos);
 
         ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingGlass");
         if (sendwServer != null) {
@@ -70,12 +99,15 @@
             }
         }
     }
+
     @Scheduled(fixedDelay = 1000)
-    public void temperingIsRun(){
+    public void temperingIsRun() {
         JSONObject jsonObject = new JSONObject();
         //姝e湪杩涜鐨勪换鍔�
-        List<TemperingGlassInfo>temperingTaskType=temperingAgoService.selectTaskType();
+        List<TemperingGlassInfo> temperingTaskType = temperingAgoService.selectTaskType();
         jsonObject.append("temperingTaskType", temperingTaskType);
+
+
         ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingIsRun");
         if (sendwServer != null) {
             for (WebSocketServer webserver : sendwServer) {
@@ -86,6 +118,7 @@
                 }
             }
         }
+
     }
 
 

--
Gitblit v1.8.0