From 384698a3568b3ab723843b4e48fdd188c3640aa0 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 08 八月 2024 15:51:01 +0800
Subject: [PATCH] Merge branch 'master' of http://bore.pub:10439/r/HangZhouMes
---
hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java | 51 ++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java
index 3f108b5..4a9356e 100644
--- a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java
+++ b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java
@@ -1,6 +1,6 @@
package com.mes.job;
import cn.hutool.json.JSONObject;
-import com.mes.temperingglass.service.TemperingAgoService;
+import com.mes.temperingglass.service.TemperingGlassInfoService;
import com.mes.temperingglass.entity.TemperingGlassInfo;
import com.mes.tools.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
@@ -19,7 +19,7 @@
public class PlcTemperingGlassTask {
@Autowired
- private TemperingAgoService temperingAgoService;
+ private TemperingGlassInfoService temperingAgoService;
/**
* fixedRate : 涓婁竴涓皟鐢ㄥ紑濮嬪悗鍐嶆璋冪敤鐨勫欢鏃讹紙涓嶇敤绛夊緟涓婁竴娆¤皟鐢ㄥ畬鎴愶級
* fixedDelay : 涓婁竴涓皟鐢ㄧ粨鏉熷悗鍐嶆璋冪敤鐨勫欢鏃�
@@ -30,23 +30,34 @@
JSONObject jsonObject = new JSONObject();
//姝e湪绛夊緟杩涚墖鐨勭幓鐠�
List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlass();
- jsonObject.append("waitingGlass", waitingGlass);
+ if(waitingGlass!=null){
+ jsonObject.append("waitingGlass", waitingGlass);
+ }
+
//鑾峰彇鏁村湪鐐変腑鐨勪袱涓増鍥緄d
List<TemperingGlassInfo> layoutId = temperingAgoService.selectLayoutId();
//杩涚倝涓殑鐜荤拑
- List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(0).getTemperingLayoutId());
- jsonObject.append("intoGlass", intoGlass);
- //杩涚倝涓殑绗簩涓増鍥�
- if (layoutId.size() > 1) {
- List<TemperingGlassInfo> intoGlass2 = temperingAgoService.selectIntoGlass(layoutId.get(1).getTemperingLayoutId());
- jsonObject.append("intoGlass2", intoGlass2);
+ if(!layoutId.isEmpty()) {
+ List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(0));
+ jsonObject.append("intoGlass", intoGlass);
+ //杩涚倝涓殑绗簩涓増鍥�
+ if (layoutId.size() > 1) {
+ List<TemperingGlassInfo> intoGlass2 = temperingAgoService.selectIntoGlass(layoutId.get(1));
+ jsonObject.append("intoGlass2", intoGlass2);
+ }
}
//鍑虹倝鍚庣殑鐜荤拑
List<TemperingGlassInfo> outGlass = temperingAgoService.selectOutGlass();
- jsonObject.append("outGlass", outGlass);
+ if(outGlass!=null){
+ jsonObject.append("outGlass", outGlass);
+ }
+
//杩囨棆杞彴閽㈠寲鍚庣殑鐜荤拑
List<TemperingGlassInfo> overGlass = temperingAgoService.selectOverGlass();
- jsonObject.append("overGlass", overGlass);
+ if (outGlass != null) {
+ jsonObject.append("overGlass", overGlass);
+ }
+
ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingGlass");
if (sendwServer != null) {
@@ -59,5 +70,23 @@
}
}
}
+ @Scheduled(fixedDelay = 1000)
+ public void temperingIsRun(){
+ JSONObject jsonObject = new JSONObject();
+ //姝e湪杩涜鐨勪换鍔�
+ List<TemperingGlassInfo>temperingTaskType=temperingAgoService.selectTaskType();
+ jsonObject.append("temperingTaskType", temperingTaskType);
+ ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingIsRun");
+ if (sendwServer != null) {
+ for (WebSocketServer webserver : sendwServer) {
+ if (webserver != null) {
+ webserver.sendMessage(jsonObject.toString());
+ } else {
+ log.info("Home is closed");
+ }
+ }
+ }
+ }
+
}
\ No newline at end of file
--
Gitblit v1.8.0