From ad2cf148e0bc95f95bb758fe12acc5b664b2def5 Mon Sep 17 00:00:00 2001
From: clll <1320612696@qq.com>
Date: 星期一, 11 九月 2023 17:36:56 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.150:10101/r/CanadaMes

---
 springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
index 8f92c3b..1597562 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
@@ -31,7 +31,7 @@
         if (sendwServer != null) {
           sendwServer.sendMessage(jsonObject.toString());
         }
-
+        // 将读取到的plclist转为数组
         Short[] shuzu1 = plclist.toArray(new Short[0]);
         // Short[] shuzu1 = {
         // 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
@@ -83,10 +83,14 @@
         };
         alarmMapper = WebSocketServer.applicationContext.getBean(AlarmMapper.class);
         for (short i = 0; i < shuzu1.length; i++) {
+          // 查询结束时间为null的个数
           short result = alarmMapper.selectnullti(shuzu[i]);
+          // 读取PLC对应地址的值为1并且该地址没有结束时间为null的数据,添加一条新的报警信息
           if (shuzu1[i] == 1 && result == 0) {
-            // alarmMapper.Insertalarm(shuzu[i]);
-          } else if (shuzu1[i] == 0 && result > 0) {
+            alarmMapper.Insertalarm(shuzu[i]);
+          }
+          // 读取PLC对应地址的值为0并且该地址有结束时间为null的数据,修改该条数据的结束时间
+          else if (shuzu1[i] == 0 && result > 0) {
             alarmMapper.updatealarm(shuzu[i]);
           }
         }

--
Gitblit v1.8.0