From aea7379082d3a9d53a35f62e8ff435254be8d213 Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期二, 04 十一月 2025 19:46:59 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/YiWuProject
---
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java | 120 ++++++++++++++++++++++++++++++++++-------------------------
1 files changed, 69 insertions(+), 51 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 c65abed..39a87d4 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
@@ -1,24 +1,35 @@
package com.mes.job;
import cn.hutool.json.JSONObject;
+import cn.smallbun.screw.core.util.CollectionUtils;
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;
import com.mes.downglassinfo.service.DownGlassInfoService;
+import com.mes.downglassinfo.service.DownGlassTaskService;
import com.mes.downstorage.service.DownStorageCageService;
import com.mes.downworkstation.entity.DownWorkstation;
import com.mes.downworkstation.service.DownWorkstationService;
+import com.mes.glassinfo.entity.GlassInfo;
+import com.mes.glassinfo.service.GlassInfoService;
import com.mes.tools.DateUtil;
import com.mes.tools.WebSocketServer;
+import com.mes.tools.WebSocketUtils;
+import com.mes.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
+import javax.annotation.Resource;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -34,6 +45,18 @@
private DownStorageCageService downStorageCageService;
@Autowired
private DownGlassInfoService downGlassInfoService;
+ @Autowired
+ private DownGlassTaskService downGlassTaskService;
+ @Autowired
+ private GlassInfoService glassInfoService;
+ @Resource
+ private WebSocketUtils webSocketUtils;
+
+ @Value("${mes.scan.ip}")
+ private String scanIp;
+
+ @Value("${mes.scan.port}")
+ private Integer scanPort;
@Autowired
private RedisUtil redisUtil;
@@ -43,18 +66,11 @@
log.info("鍙戦�佸伐浣嶇幓鐠冧俊鎭�");
JSONObject jsonObject = new JSONObject();
- List<DownWorkstation> data = downWorkstationService.getoneDownWorkstations(1, 6);
+ List<DownWorkstation> data = downWorkstationService.list();
jsonObject.append("params", data);
log.info(jsonObject.toString());
- ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unloadglass");
- if (sendwServer != null) {
- for (WebSocketServer webserver : sendwServer) {
- if (webserver != null && webserver.session.isOpen()) {
- log.info("宸插彂閫�");
- webserver.sendMessage(jsonObject.toString());
- }
- }
- }
+ webSocketUtils.sendToWeb("unloadglass", jsonObject);
+
}
@Scheduled(fixedDelay = 1000)
@@ -64,14 +80,7 @@
List<Map<String, Object>> glassinfodata = downWorkstationService.getTotalGlassDimensionsByWorkstation(1, 3);
jsonObject2.append("glassinfo", glassinfodata);
log.info(jsonObject2.toString());
- ArrayList<WebSocketServer> sendwServer2 = WebSocketServer.sessionMap.get("unloadglass2");
- if (sendwServer2 != null) {
- for (WebSocketServer webserver : sendwServer2) {
- if (webserver != null && webserver.session.isOpen()) {
- webserver.sendMessage(jsonObject2.toString());
- }
- }
- }
+ webSocketUtils.sendToWeb("unloadglass2", jsonObject2);
}
@Scheduled(fixedDelay = 1000)
@@ -81,14 +90,7 @@
List<Map<String, Object>> glassinfodata2 = downWorkstationService.getTotalGlassDimensionsByWorkstation(4, 6);
jsonObject3.append("glassinfo2", glassinfodata2);
log.info(jsonObject3.toString());
- ArrayList<WebSocketServer> sendwServer3 = WebSocketServer.sessionMap.get("unloadglass3");
- if (sendwServer3 != null) {
- for (WebSocketServer webserver : sendwServer3) {
- if (webserver != null && webserver.session.isOpen()) {
- webserver.sendMessage(jsonObject3.toString());
- }
- }
- }
+ webSocketUtils.sendToWeb("unloadglass3", jsonObject3);
}
@Scheduled(fixedDelay = 2000)
@@ -98,14 +100,7 @@
List<Map<String, Object>> list = downStorageCageService.selectDownStorageCages();
jsonObject4.append("params2", list);
log.info(jsonObject4.toString());
- ArrayList<WebSocketServer> sendwServer4 = WebSocketServer.sessionMap.get("downcache");
- if (sendwServer4 != null) {
- for (WebSocketServer webserver : sendwServer4) {
- if (webserver != null && webserver.session.isOpen()) {
- webserver.sendMessage(jsonObject4.toString());
- }
- }
- }
+ webSocketUtils.sendToWeb("downcache", jsonObject4);
}
@Scheduled(fixedDelay = 2000)
@@ -135,7 +130,7 @@
jsonObject4.append("downGlassInfos", downGlassInfos);
jsonObject4.append("engineerIdList", engineerIdList);
- //閽㈠寲寮�鍏�
+ //鎵撳嵃寮�鍏�
boolean autoPrint = false;
if (redisUtil.getCacheObject("autoPrint") == null) {
redisUtil.setCacheObject("autoPrint", false);
@@ -143,15 +138,19 @@
autoPrint = redisUtil.getCacheObject("autoPrint");
}
jsonObject4.append("autoPrint", autoPrint);
-
- ArrayList<WebSocketServer> sendwServer4 = WebSocketServer.sessionMap.get("unloadglass");
- if (sendwServer4 != null) {
- for (WebSocketServer webserver : sendwServer4) {
- if (webserver != null && webserver.session.isOpen()) {
- webserver.sendMessage(jsonObject4.toString());
- }
- }
+ //浜哄伐涓嬬墖浣嶇疆鏈�鍚庝竴鐗�
+ DownGlassTask takeGlass = downGlassTaskService.getOne(
+ new QueryWrapper<DownGlassTask>()
+ .select("Top 1 *")
+ .eq("end_cell", Const.G13_WORK_STATION)
+ .lt("task_status", Const.UNLOAD_GLASS_DOWN)
+ .orderByAsc("id")
+ );
+ if (takeGlass != null) {
+ jsonObject4.append("takeGlass", takeGlass);
}
+
+ webSocketUtils.sendToWeb("unloadglass", jsonObject4);
}
@Scheduled(fixedDelay = 1000)
@@ -160,14 +159,33 @@
//姝e湪杩涜鐨勪换鍔�
List<DownWorkstation> downWorkstation = downWorkstationService.getoneDownWorkstations(1, 6);
jsonObject.append("downWorkstation", downWorkstation);
- ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unLoadGlassIsRun");
- if (sendwServer != null) {
- for (WebSocketServer webserver : sendwServer) {
- if (webserver != null) {
- webserver.sendMessage(jsonObject.toString());
- } else {
- log.info("unLoadGlassIsRun is closed");
+ List<DownGlassTask> downGlassTask = downGlassTaskService.selectOutTaskCache();
+ jsonObject.append("downGlassTask", downGlassTask);
+
+ webSocketUtils.sendToWeb("unLoadGlassIsRun", jsonObject);
+ }
+
+ @Scheduled(fixedDelay = Long.MAX_VALUE)
+ public void scanCodeTask() {
+ log.info("鎵弿浠诲姟宸插惎鍔�");
+ while (true) {
+ JSONObject jsonObject = new JSONObject();
+ try (Socket socket = new Socket(scanIp, scanPort);
+ BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
+ // 鎺ユ敹鏈嶅姟鍣ㄥ搷搴�
+ log.info("绛夊緟鎵爜涓�......");
+ String glassId = in.readLine();
+ log.info("鎵弿鍒扮殑鐜荤拑id锛歿}", glassId);
+ //鎸夌収鐜荤拑id鑾峰彇鐜荤拑淇℃伅杩斿洖缁欏墠绔晫闈紝鍏蜂綋闇�瑕佸摢浜涙暟鎹緟纭
+ GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>()
+ .eq(GlassInfo::getGlassId, glassId).last("limit 1"));
+ if (null == glassInfo) {
+ log.info("鎸夌収鐜荤拑id锛歿}锛屾棤娉曟壘鍒扮幓鐠冧俊鎭�", glassId);
+ return;
}
+ webSocketUtils.sendToWeb("scanGlass", glassInfo);
+ } catch (Exception exception) {
+ log.info("璇诲彇寮傚父锛屽師鍥犱负{}", exception.getMessage());
}
}
}
--
Gitblit v1.8.0