From c49dc2f40279bcc360948cea68dec69cf213b85f Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期一, 25 十二月 2023 15:33:34 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes

---
 springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java
index 73192ce..1598c96 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java
@@ -3,8 +3,10 @@
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import com.example.springboot.controller.HomeController;
+import com.example.springboot.mapper.HomeMapper;
 import org.apache.commons.io.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import com.example.springboot.service.StorageCageService;
 
 import java.io.*;
 import java.util.ArrayList;
@@ -18,6 +20,9 @@
 
 
 public class PlcParameter2 extends Thread {
+    @Autowired
+    StorageCageService StorageCageService  ;
+
 
     // 鐢ㄤ簬瀛樺偍搴旂敤绋嬪簭鐨勯厤缃俊鎭�
     private Configuration config;
@@ -39,7 +44,7 @@
             } catch (InterruptedException e) {
                 e.printStackTrace();
             }
-
+            StorageCageService = WebSocketServer.applicationContext.getBean(StorageCageService .class);
             //  id
             List<String> addressList1 = Arrays.asList(config.getProperty("Parameter2.id").split(","));
 
@@ -127,7 +132,7 @@
 //        jsonObject.set("message", "Hello, Parameter2!");
 //        sendwServer.sendMessage(jsonObject.toString());
 //      }
-            HomeController controller = new HomeController();
+//            HomeController controller = new HomeController();
             ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Parameter2");
             if (sendwServer != null) {
                 for (WebSocketServer webserver : sendwServer) {
@@ -182,19 +187,27 @@
                                             }
                                         }
                                     }
-
+//瀹屾垚鍑虹墖
+                                    boolean containsOne = data.stream().anyMatch(number -> number == 1);
                                     for (int i = 1; i <= 5; i++) {
                                         boolean value = sValue.get(i);
-                                        if (value) {
+                                        String id=paramlist.get(i);
+                                        //鍒ゆ柇鏄惁鑷姩鐘舵��
+                                       if(!containsOne) {
+                                     //鍒ゆ柇id鏄惁鍖呭惈鏁板瓧
+                                      if(id.matches(".*\\d.*")){
+                                          //鍒ゆ柇娓呮id鏄惁true
+                                          if (value) {
+                                           System.out.println(id);
                                             switch (i) {
                                                 case 1:
-                                                    controller.UpdateTask(0, 0, paramlist.get(i));
+                                                    StorageCageService.UpdateTask(2, 0, paramlist.get(i));
                                                     break;
                                                 case 2:
                                                 case 3:
                                                 case 4:
                                                 case 5:
-                                                    controller.UpdateTask(1, 0, paramlist.get(i));
+                                                    StorageCageService.UpdateTask(3, 0, paramlist.get(i));
                                                     break;
                                                 default:
                                                     // 澶勭悊绱㈠紩鍊间笉鍦ㄨ寖鍥村唴鐨勬儏鍐�
@@ -202,7 +215,8 @@
                                             }
                                         }
                                     }
-
+                                 }
+                                    }
                                     // 妫�鏌ュ竷灏斿�煎垪琛ㄦ槸鍚︿负绌�
                                     if (!sValue.isEmpty()) {
 
@@ -251,16 +265,16 @@
                                             }
                                         }
                                     }
-
+// 缁堟杩涚墖浠诲姟
                                     boolean Value1 = sValue.get(0);
                                     boolean Value2 = sValue.get(1);
 
                                     if (Value1) {
-                                        controller.EndTask(0);
+                                        StorageCageService.EndTask(0);
 
                                     }
                                     if (Value2) {
-                                        controller.EndTask(0);
+                                        StorageCageService.EndTask(1);
 
                                     }
                                     // 妫�鏌ュ竷灏斿�煎垪琛ㄦ槸鍚︿负绌�

--
Gitblit v1.8.0