From 61cae17b15d6a7d256e25ce42f0a4ef4163fd088 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 11 九月 2025 15:54:03 +0800
Subject: [PATCH] 1、删除未修改的大屏程序
---
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java | 207 ++++++++++++++++++++++++++-------------------------
1 files changed, 105 insertions(+), 102 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 b210c53..ce4b783 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,12 +17,11 @@
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;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.scheduling.TaskScheduler;
-import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -33,7 +31,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.*;
import java.util.stream.Collectors;
@Slf4j
@@ -50,13 +47,6 @@
private DownGlassTaskService downGlassTaskService;
@Autowired
private GlassInfoService glassInfoService;
- private final ExecutorService scanCodeThreadPool = new ThreadPoolExecutor(
- 10, // core pool size
- 20, // maximum pool size
- 60L, TimeUnit.SECONDS,
- new LinkedBlockingQueue<>()
- );
- private final ExecutorService isRunThreadPool = Executors.newFixedThreadPool(5);
@Value("${mes.scan.ip}")
private String scanIp;
@@ -67,16 +57,28 @@
@Autowired
private RedisUtil redisUtil;
- @Scheduled(fixedDelay = 2000)
+ @Scheduled(fixedDelay = 3000)
public void sendDownWorkstations() {
- log.info("鍙戦�佸伐浣嶇幓鐠冧俊鎭�");
- JSONObject jsonObject = new JSONObject();
- List<DownWorkstation> data = downWorkstationService.list();
- jsonObject.append("params", data);
- log.info(jsonObject.toString());
+ JSONObject jsonObject = new JSONObject();
ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unloadglass");
if (sendwServer != null) {
+ log.info("鍙戦�佸伐浣嶇幓鐠冧俊鎭�");
+ List<DownWorkstation> data = downWorkstationService.list();
+ List<DownGlassTask> downGlassTasks = downGlassTaskService.list(
+ new LambdaQueryWrapper<DownGlassTask>()
+ .eq(DownGlassTask::getEndCell, 7)
+ .eq(DownGlassTask::getTaskType, 3)
+ .lt(DownGlassTask::getTaskStatus, 3)
+ );
+ DownWorkstation downWorkstation = new DownWorkstation();
+ downWorkstation.setWorkstationId(7);
+ downWorkstation.setEnableState(1);
+ downWorkstation.setRacksNumber(downGlassTasks.size());
+ downWorkstation.setTotalQuantity(downGlassTasks.size());
+ data.add(downWorkstation);
+ jsonObject.append("params", data);
+ log.info(jsonObject.toString());
for (WebSocketServer webserver : sendwServer) {
if (webserver != null && webserver.session.isOpen()) {
log.info("宸插彂閫�");
@@ -86,15 +88,16 @@
}
}
- @Scheduled(fixedDelay = 1000)
+ @Scheduled(fixedDelay = 3000)
public void sendGlassInfoData() {
- log.info("鍙戦�佸伐浣嶆樉绀哄浘淇℃伅1");
- JSONObject jsonObject2 = new JSONObject();
- 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) {
+ log.info("鍙戦�佸伐浣嶆樉绀哄浘淇℃伅1");
+ JSONObject jsonObject2 = new JSONObject();
+ List<Map<String, Object>> glassinfodata = downWorkstationService.getTotalGlassDimensionsByWorkstation(1, 3);
+ jsonObject2.append("glassinfo", glassinfodata);
+ log.info(jsonObject2.toString());
for (WebSocketServer webserver : sendwServer2) {
if (webserver != null && webserver.session.isOpen()) {
webserver.sendMessage(jsonObject2.toString());
@@ -103,15 +106,14 @@
}
}
- @Scheduled(fixedDelay = 1000)
+ @Scheduled(fixedDelay = 3000)
public void sendGlassInfoData2() {
- log.info("鍙戦�佸伐浣嶆樉绀哄浘淇℃伅2");
- JSONObject jsonObject3 = new JSONObject();
- 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) {
+ log.info("鍙戦�佸伐浣嶆樉绀哄浘淇℃伅2");
+ JSONObject jsonObject3 = new JSONObject();
+ List<Map<String, Object>> glassinfodata2 = downWorkstationService.getTotalGlassDimensionsByWorkstation(4, 6);
+ jsonObject3.append("glassinfo2", glassinfodata2);
for (WebSocketServer webserver : sendwServer3) {
if (webserver != null && webserver.session.isOpen()) {
webserver.sendMessage(jsonObject3.toString());
@@ -120,7 +122,7 @@
}
}
- @Scheduled(fixedDelay = 2000)
+ @Scheduled(fixedDelay = 3000)
public void sendDownStorageCages() {
log.info("鍙戦�佺紦瀛樼幓鐠冧俊鎭�");
JSONObject jsonObject4 = new JSONObject();
@@ -137,54 +139,57 @@
}
}
- @Scheduled(fixedDelay = 2000)
+ @Scheduled(fixedDelay = 3000)
public void sendDownGlassInfo() {
- DownGlassInfoRequest request = redisUtil.getCacheObject("downGlassRequest");
- if (null == request) {
- request = new DownGlassInfoRequest();
- }
- if (request.getBeginDate() == null) {
- request.setBeginDate(DateUtil.getBeginDate());
- request.setEndDate(DateUtil.getEndDate());
- }
- log.info("鍙戦�佸綋鍓嶆鍦ㄦ墽琛屽伐绋嬪凡钀芥灦鐨勭幓鐠冧俊鎭�");
- LambdaQueryWrapper<DownGlassInfo> wrapper = new LambdaQueryWrapper<DownGlassInfo>()
- .between(null != request.getBeginDate(), DownGlassInfo::getGmtCreate, request.getBeginDate(), request.getEndDate())
- .eq(StringUtils.isNotBlank(request.getEngineerId()), DownGlassInfo::getEngineerId, request.getEngineerId());
- if (null == request.getWorkStationId() || 0 == request.getWorkStationId()) {
- wrapper.in(DownGlassInfo::getWorkStationId, Const.WORK_STATION_ALL);
- } else {
- wrapper.eq(DownGlassInfo::getWorkStationId, request.getWorkStationId());
- }
- List<DownGlassInfo> downGlassInfos = downGlassInfoService.list(wrapper);
-// Map<Integer, List<DownGlassInfo>> listMap = downGlassInfos.stream().collect(Collectors.groupingBy(DownGlassInfo::getWorkStationId));
- List<Object> engineerIdListTemp = downGlassInfoService.listObjs(new QueryWrapper<DownGlassInfo>().select("distinct engineer_id"));
- List<String> engineerIdList = engineerIdListTemp.stream().map(String::valueOf).collect(Collectors.toList());
- JSONObject jsonObject4 = new JSONObject();
- jsonObject4.append("downGlassInfos", downGlassInfos);
- jsonObject4.append("engineerIdList", engineerIdList);
-
- //閽㈠寲寮�鍏�
- boolean autoPrint = false;
- if (redisUtil.getCacheObject("autoPrint") == null) {
- redisUtil.setCacheObject("autoPrint", false);
- } else {
- 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) {
+ DownGlassInfoRequest request = redisUtil.getCacheObject("downGlassRequest");
+ if (null == request) {
+ request = new DownGlassInfoRequest();
+ }
+ if (request.getBeginDate() == null) {
+ request.setBeginDate(DateUtil.getBeginDate());
+ request.setEndDate(DateUtil.getEndDate());
+ }
+ log.info("鍙戦�佸綋鍓嶆鍦ㄦ墽琛屽伐绋嬪凡钀芥灦鐨勭幓鐠冧俊鎭�");
+ LambdaQueryWrapper<DownGlassInfo> wrapper = new LambdaQueryWrapper<DownGlassInfo>()
+ .between(null != request.getBeginDate(), DownGlassInfo::getGmtCreate, request.getBeginDate(), request.getEndDate())
+ .eq(StringUtils.isNotBlank(request.getEngineerId()), DownGlassInfo::getEngineerId, request.getEngineerId());
+ if (null == request.getWorkStationId() || 0 == request.getWorkStationId()) {
+ wrapper.in(DownGlassInfo::getWorkStationId, Const.WORK_STATION_ALL);
+ } else {
+ wrapper.eq(DownGlassInfo::getWorkStationId, request.getWorkStationId());
+ }
+ List<DownGlassInfo> downGlassInfos = downGlassInfoService.list(wrapper);
+// Map<Integer, List<DownGlassInfo>> listMap = downGlassInfos.stream().collect(Collectors.groupingBy(DownGlassInfo::getWorkStationId));
+ List<Object> engineerIdListTemp = downGlassInfoService.listObjs(new QueryWrapper<DownGlassInfo>().select("distinct engineer_id"));
+ List<String> engineerIdList = engineerIdListTemp.stream().map(String::valueOf).collect(Collectors.toList());
+ JSONObject jsonObject4 = new JSONObject();
+ jsonObject4.append("downGlassInfos", downGlassInfos);
+ jsonObject4.append("engineerIdList", engineerIdList);
+
+ //鎵撳嵃寮�鍏�
+ boolean autoPrint = false;
+ if (redisUtil.getCacheObject("autoPrint") == null) {
+ redisUtil.setCacheObject("autoPrint", false);
+ } else {
+ 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)
+ .eq("task_type", 3)
+ .lt("task_status", Const.UNLOAD_GLASS_DOWN)
+ .orderByAsc("id")
+ );
+ if (takeGlass != null) {
+ jsonObject4.append("takeGlass", takeGlass);
+ }
+
for (WebSocketServer webserver : sendwServer4) {
if (webserver != null && webserver.session.isOpen()) {
webserver.sendMessage(jsonObject4.toString());
@@ -195,52 +200,50 @@
@Scheduled(fixedDelay = 1000)
public void isRun() {
- isRunThreadPool.execute(() -> {
+ ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unLoadGlassIsRun");
+ if (sendwServer != null) {
JSONObject jsonObject = new JSONObject();
//姝e湪杩涜鐨勪换鍔�
List<DownWorkstation> downWorkstation = downWorkstationService.getoneDownWorkstations(1, 6);
jsonObject.append("downWorkstation", downWorkstation);
List<DownGlassTask> downGlassTask = downGlassTaskService.selectOutTaskCache();
jsonObject.append("downGlassTask", downGlassTask);
- 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");
- }
+ for (WebSocketServer webserver : sendwServer) {
+ if (webserver != null) {
+ webserver.sendMessage(jsonObject.toString());
+ } else {
+ log.info("unLoadGlassIsRun is closed");
}
}
- });
-
+ }
}
- @Async
@Scheduled(fixedDelay = Long.MAX_VALUE)
public void scanCodeTask() {
- JSONObject jsonObject = new JSONObject();
log.info("鎵弿浠诲姟宸插惎鍔�");
while (true) {
- try (Socket socket = new Socket(scanIp, scanPort);
- BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
+ JSONObject jsonObject = new JSONObject();
+ try (Socket socket = new Socket(scanIp, scanPort)) {
+ socket.setSoTimeout(1000);
+ BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
// 鎺ユ敹鏈嶅姟鍣ㄥ搷搴�
-// socket.setSoTimeout(1000);
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 {
- jsonObject.append("scanGlass",glassInfo);
- sendwServer.get(0).sendMessage(jsonObject.toString());
+ 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());
}
}
+ }
} catch (Exception exception) {
log.info("璇诲彇寮傚父锛屽師鍥犱负{}", exception.getMessage());
}
--
Gitblit v1.8.0