From 3debb9073e9fde7ae118a8844ad54a86ee69cd44 Mon Sep 17 00:00:00 2001 From: zhoushihao <zsh19950802@163.com> Date: 星期四, 07 十一月 2024 09:48:00 +0800 Subject: [PATCH] 1、将原片相关代码提取到公共模块,解决模块间调用异常 --- 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