From 4bc329686bfc2f7bd0ce468aef7036f8761a6441 Mon Sep 17 00:00:00 2001
From: clll <1320612696@qq.com>
Date: 星期一, 11 九月 2023 08:48:52 +0800
Subject: [PATCH] 添加为null判断

---
 springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java
index b641602..c7f169c 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java
@@ -16,19 +16,22 @@
       }
 
       List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.DBX0.0", 58);
+      if (plclist == null) {
 
-      JSONObject jsonObject = new JSONObject();
-      // jsonObject3.append("sig",
-      // new short[] { 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
-      // 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
-      // 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
-      // });
-      jsonObject.append("sig", plclist);
-      WebSocketServer sendwServer3 = WebSocketServer.sessionMap.get("Sign");
-      if (sendwServer3 != null) {
-        sendwServer3.sendMessage(jsonObject.toString());
+      } else {
+        JSONObject jsonObject = new JSONObject();
+        // jsonObject3.append("sig",
+        // new short[] { 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
+        // 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
+        // 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
+        // });
+        jsonObject.append("sig", plclist);
+        WebSocketServer sendwServer3 = WebSocketServer.sessionMap.get("Sign");
+        if (sendwServer3 != null) {
+          sendwServer3.sendMessage(jsonObject.toString());
+        }
+
       }
-
     }
   }
 }

--
Gitblit v1.8.0