From c51c2a38142865cf43d33ceb5bc72b0283a110c2 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 05 九月 2024 10:42:23 +0800
Subject: [PATCH] Merge branch 'master' of http://bore.pub:10439/r/HangZhouMes
---
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 56 insertions(+), 1 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 c154291..6a17f8a 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,6 +1,7 @@
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;
@@ -13,14 +14,20 @@
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 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 java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -38,7 +45,14 @@
private DownGlassInfoService downGlassInfoService;
@Autowired
private DownGlassTaskService downGlassTaskService;
+ @Autowired
+ private GlassInfoService glassInfoService;
+ @Value("${mes.scan.ip}")
+ private String scanIp;
+
+ @Value("${mes.scan.port}")
+ private Integer scanPort;
@Autowired
private RedisUtil redisUtil;
@@ -48,7 +62,7 @@
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");
@@ -148,6 +162,16 @@
autoPrint = redisUtil.getCacheObject("autoPrint");
}
jsonObject4.append("autoPrint", autoPrint);
+ //浜哄伐涓嬬墖浣嶇疆鏈�鍚庝竴鐗�
+ DownGlassTask takeGlass = downGlassTaskService.getOne(
+ new QueryWrapper<DownGlassTask>()
+ .select("Top 1 *")
+ .eq("end_cell", Const.G13_WORK_STATION)
+ .lt("task_status", Const.UNLOAD_GLASS_DOWN)
+ .orderByDesc("id")
+ );
+ jsonObject4.append("takeGlass", takeGlass);
+
ArrayList<WebSocketServer> sendwServer4 = WebSocketServer.sessionMap.get("unloadglass");
if (sendwServer4 != null) {
@@ -178,4 +202,35 @@
}
}
}
+
+ @Scheduled(fixedDelay = Long.MAX_VALUE)
+ public void scanCodeTask() {
+ log.info("鎵弿浠诲姟宸插惎鍔�");
+ while (true) {
+ new Thread(() -> {
+ try (Socket socket = new Socket(scanIp, scanPort);
+ BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
+ // 鎺ユ敹鏈嶅姟鍣ㄥ搷搴�
+ String response;
+ log.info("绛夊緟鎵爜涓�......");
+ while ((response = in.readLine()) != null) {
+ log.info("鎵弿鍒扮殑鐜荤拑id锛歿}", response);
+ List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("scanCode");
+ if (CollectionUtils.isNotEmpty(sendwServer)) {
+ //鎸夌収鐜荤拑id鑾峰彇鐜荤拑淇℃伅杩斿洖缁欏墠绔晫闈紝鍏蜂綋闇�瑕佸摢浜涙暟鎹緟纭
+ GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>()
+ .eq(GlassInfo::getGlassId, response).last("limit 1"));
+ if (null == glassInfo) {
+ log.info("鎸夌収鐜荤拑id锛歿}锛屾棤娉曟壘鍒扮幓鐠冧俊鎭�", response);
+ } else {
+ sendwServer.get(0).sendMessage(glassInfo.toString());
+ }
+ }
+ }
+ } catch (Exception exception) {
+ log.info("璇诲彇寮傚父锛屽師鍥犱负{}", exception.getMessage());
+ }
+ }).start();
+ }
+ }
}
--
Gitblit v1.8.0