Przeglądaj źródła

去掉所有伺服故障告警

wukai 8 miesięcy temu
rodzic
commit
57d550d72b

+ 10 - 11
ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/ApiServiceImpl.java

@@ -2,6 +2,7 @@ package com.ruoyi.biz.service.impl;
 
 import com.ruoyi.biz.domain.*;
 import com.ruoyi.biz.service.*;
+import com.ruoyi.biz.tools.Tools;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.utils.CacheUtils;
 import com.ruoyi.system.service.ISysConfigService;
@@ -159,17 +160,15 @@ public class ApiServiceImpl implements IApiService {
                     //不能跟上面判断合并,不然报空指针
                     continue;
                 }
-                for (int i = 1; i <= 26; i++) {
-                    if (i != 9 && i != 25 && i != 24) {
-                        //去掉电源故障和卷曲伺服故障和牵引伺服故障
-                        boolean flag = (boolean) map.get("Alarm_unit_" + i);
-                        if (flag) {
-                            IndexAlarm indexAlarm = new IndexAlarm();
-                            indexAlarm.setCode(device.getDeviceCode());
-                            indexAlarm.setName(device.getDeviceName());
-                            indexAlarm.setType(i);
-                            alarmList.add(indexAlarm);
-                        }
+                for (int i = 0; i < Tools.ALLOW_ALARM.length; i++) {
+                    //允许的告警编号
+                    boolean flag = (boolean) map.get("Alarm_unit_" + Tools.ALLOW_ALARM[i]);
+                    if (flag) {
+                        IndexAlarm indexAlarm = new IndexAlarm();
+                        indexAlarm.setCode(device.getDeviceCode());
+                        indexAlarm.setName(device.getDeviceName());
+                        indexAlarm.setType(i);
+                        alarmList.add(indexAlarm);
                     }
                 }
 

+ 4 - 4
ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/AsyncServiceImpl.java

@@ -369,8 +369,8 @@ public class AsyncServiceImpl {
         if (i == 1) {
             int j = 0;
             for (; j < index; j++) {
-                if ((j + 1) != 9 && (j + 1) != 25 && (j + 1) != 24) {
-                    //去掉电源故障和卷曲伺服故障和牵引伺服故障
+                //允许的告警编号
+                if (Tools.findAllow(j + 1)) {
                     boolean currV = curr.getBool(j + 12);
                     if (currV) {
                         flags[j] = false;
@@ -395,8 +395,8 @@ public class AsyncServiceImpl {
         }
         int j = 0;
         for (; j < index; j++) {
-            if ((j + 1) != 9 && (j + 1) != 25 && (j + 1) != 24) {
-                //去掉电源故障和卷曲伺服故障和牵引伺服故障
+            //允许的告警编号
+            if (Tools.findAllow(j + 1)) {
                 if (flags[j]) {
                     boolean currV = curr.getBool(j + 12);
                     boolean lastV = last.getBool(j + 12);

+ 45 - 1
ruoyi-admin/src/main/java/com/ruoyi/biz/tools/Tools.java

@@ -16,8 +16,52 @@ import java.util.*;
  * @date 2024/5/12 02:18
  */
 public class Tools {
-    public static void main(String[] args) {
+    /**
+     * 允许的告警编号
+     * Alarm_unit_1	BOOL	GB1伺服通讯故障
+     * Alarm_unit_2	BOOL	GB2伺服通讯故障
+     * Alarm_unit_3	BOOL	GB3伺服通讯故障
+     * Alarm_unit_4	BOOL	GB4伺服通讯故障
+     * Alarm_unit_5	BOOL	GB5伺服通讯故障
+     * Alarm_unit_6	BOOL	牵引伺服通讯故障
+     * Alarm_unit_7	BOOL	卷曲伺服通讯故障
+     * Alarm_unit_8	BOOL	断纱故障
+     * Alarm_unit_9	BOOL	电源故障
+     * Alarm_unit_10	BOOL	联动未完全啮合
+     * Alarm_unit_11	BOOL	米长到达
+     * Alarm_unit_12	BOOL	GB1剩余圈数报警
+     * Alarm_unit_13	BOOL	GB2剩余圈数报警
+     * Alarm_unit_14	BOOL	GB3剩余圈数报警
+     * Alarm_unit_15	BOOL	GB4剩余圈数报警
+     * Alarm_unit_16	BOOL	GB5剩余圈数报警
+     * Alarm_unit_17	BOOL	主轴变频掉线
+     * Alarm_unit_18	BOOL	主轴变频故障
+     * Alarm_unit_19	BOOL	GB1伺服故障
+     * Alarm_unit_20	BOOL	GB2伺服故障
+     * Alarm_unit_21	BOOL	GB3伺服故障
+     * Alarm_unit_22	BOOL	GB4伺服故障
+     * Alarm_unit_23	BOOL	GB5伺服故障
+     * Alarm_unit_24	BOOL	牵引伺服故障
+     * Alarm_unit_25	BOOL	卷曲伺服故障
+     * Alarm_unit_26	BOOL	拍照自停
+     * Alarm_unit_27	UINT	CCD位置报警信息显示
+     */
+    public static final int[] ALLOW_ALARM = {8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27};
 
+    /**
+     * 查找编号是否允许告警
+     *
+     * @param x 编号
+     * @return
+     */
+    public static boolean findAllow(int x) {
+        OptionalInt result = Arrays.stream(ALLOW_ALARM)
+                .filter(element -> element == x)
+                .findFirst();
+        return result.isPresent();
+    }
+
+    public static void main(String[] args) {
         int p = 12;
         LocalDateTime ldt = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
         System.err.println(ldt.plusHours(2 * p));