From 3c7d672fb7d6c34742fb7da6f66616ccf3be2c9a Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期五, 08 十一月 2024 14:50:11 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java |   40 ++++++++++++++++++++++------------------
 1 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java
index de467ff..baa53ca 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java
@@ -5,7 +5,6 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.mes.common.config.Const;
-import com.mes.common.utils.RedisUtil;
 import com.mes.downglassinfo.entity.DownGlassInfo;
 import com.mes.downglassinfo.entity.DownGlassTask;
 import com.mes.downglassinfo.entity.request.DownGlassInfoRequest;
@@ -18,6 +17,7 @@
 import com.mes.glassinfo.service.GlassInfoService;
 import com.mes.tools.DateUtil;
 import com.mes.tools.WebSocketServer;
+import com.mes.utils.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -154,7 +154,7 @@
         jsonObject4.append("downGlassInfos", downGlassInfos);
         jsonObject4.append("engineerIdList", engineerIdList);
 
-        //閽㈠寲寮�鍏�
+        //鎵撳嵃寮�鍏�
         boolean autoPrint = false;
         if (redisUtil.getCacheObject("autoPrint") == null) {
             redisUtil.setCacheObject("autoPrint", false);
@@ -168,9 +168,11 @@
                         .select("Top 1 *")
                         .eq("end_cell", Const.G13_WORK_STATION)
                         .lt("task_status", Const.UNLOAD_GLASS_DOWN)
-                        .orderByDesc("id")
+                        .orderByAsc("id")
         );
-        jsonObject4.append("takeGlass", takeGlass);
+        if(takeGlass!=null){
+            jsonObject4.append("takeGlass", takeGlass);
+        }
 
         ArrayList<WebSocketServer> sendwServer4 = WebSocketServer.sessionMap.get("unloadglass");
         if (sendwServer4 != null) {
@@ -204,24 +206,26 @@
 
     @Scheduled(fixedDelay = Long.MAX_VALUE)
     public void scanCodeTask() {
-        JSONObject jsonObject = new JSONObject();
+        log.info("鎵弿浠诲姟宸插惎鍔�");
         while (true) {
+            JSONObject jsonObject = new JSONObject();
             try (Socket socket = new Socket(scanIp, scanPort);
                  BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
                 // 鎺ユ敹鏈嶅姟鍣ㄥ搷搴�
-                socket.setSoTimeout(1000);
-                String response;
-                while ((response = in.readLine()) != null) {
-                    List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unloadglass");
-                    if (CollectionUtils.isNotEmpty(sendwServer)) {
-                        //鎸夌収鐜荤拑id鑾峰彇鐜荤拑淇℃伅杩斿洖缁欏墠绔晫闈紝鍏蜂綋闇�瑕佸摢浜涙暟鎹緟纭
-                        GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>()
-                                .eq(GlassInfo::getGlassId, response));
-                        if (null == glassInfo) {
-                            log.info("鎸夌収鐜荤拑id锛歿}锛屾棤娉曟壘鍒扮幓鐠冧俊鎭�", response);
-                        } else {
-                            jsonObject.append("scanGlass",glassInfo);
-                            sendwServer.get(0).sendMessage(jsonObject.toString());
+                log.info("绛夊緟鎵爜涓�......");
+                String glassId = in.readLine();
+                log.info("鎵弿鍒扮殑鐜荤拑id锛歿}", glassId);
+                List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unloadglass");
+                if (CollectionUtils.isNotEmpty(sendwServer)) {
+                    //鎸夌収鐜荤拑id鑾峰彇鐜荤拑淇℃伅杩斿洖缁欏墠绔晫闈紝鍏蜂綋闇�瑕佸摢浜涙暟鎹緟纭
+                    GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>()
+                            .eq(GlassInfo::getGlassId, glassId).last("limit 1"));
+                    if (null == glassInfo) {
+                        log.info("鎸夌収鐜荤拑id锛歿}锛屾棤娉曟壘鍒扮幓鐠冧俊鎭�", glassId);
+                    } else {
+                        for (WebSocketServer webserver : sendwServer) {
+                                jsonObject.append("scanGlass", glassInfo);
+                                webserver.sendMessage(jsonObject.toString());
                         }
                     }
                 }

--
Gitblit v1.8.0