Prechádzať zdrojové kódy

报警统计功能优化

shilin 1 rok pred
rodič
commit
89fadf9593

+ 2 - 0
alarm-custom/src/main/java/com/gyee/alarm/init/CacheContext.java

@@ -158,9 +158,11 @@ public class CacheContext implements CommandLineRunner {
     public static Map< String,Map<String, ProBasicStatusPoint>> pointdismap = new HashMap<>();
 
     public static Map<String, Map<String, PointData>> wtDataValueMap = new ConcurrentHashMap<>();// 设备实时数据
+
     public static Map<String,Map<String, PointData>> wpDataValueMap =new ConcurrentHashMap<>();// 场站实时数据
     public static Map<String,Map<String, PointData>> wsDataValueMap =new ConcurrentHashMap<>();// 升压站实时数据
     public static List<ProBasicEquipmentPoint> wtPointList = new ArrayList<>();// 设备测点集合
+
     public static List<ProBasicPowerstationPoint> wpPointList =new ArrayList<>(); //场站测点集合
     public static List<ProBasicPowerstationPoint> wsPointList =new ArrayList<>(); //升压站测点集合
     @Override

+ 1 - 1
alarm-custom/src/main/java/com/gyee/alarm/rule/AlarmFunction.java

@@ -137,7 +137,7 @@ public class AlarmFunction {
 
     protected PointData getTagInfo(String varName) {
         if (tagMap == null) {
-            if (thingType == DeviceTypeValue.WT) {
+            if (thingType == DeviceTypeValue.WT || thingType == DeviceTypeValue.IN) {
                 tagMap = CacheContext.wtDataValueMap.get(thingId);
             } else  if (thingType == DeviceTypeValue.WP) {
                 tagMap =  CacheContext.wpDataValueMap.get(thingId);

+ 28 - 17
alarm-custom/src/main/java/com/gyee/alarm/task/thread/AlarmThreadPool.java

@@ -10,12 +10,16 @@ import com.gyee.alarm.service.auto.IAlarmTsService;
 import com.gyee.common.model.PointData;
 import com.gyee.alarm.util.realtimesource.IEdosUtil;
 import com.gyee.common.model.StringUtils;
+import org.apache.logging.log4j.spi.CopyOnWrite;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.Serializable;
 import java.util.*;
 import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 public class AlarmThreadPool implements Callable<Integer>, Serializable {
 
@@ -59,11 +63,11 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
 //			while (runStarted)
 //			{
 
-            List<AlarmTag> saveAlarmTags = new ArrayList<>();
-            List<AlarmTag> updateAlarmTags = new ArrayList<>();
+            List<AlarmTag> saveAlarmTags =   new CopyOnWriteArrayList<>();
+            List<AlarmTag> updateAlarmTags  = new CopyOnWriteArrayList<>();
 
             StringBuilder sb = new StringBuilder();
-            Map<String, AlarmSimpleVo> map = new HashMap<>();
+            Map<String, AlarmSimpleVo> map = new ConcurrentHashMap<>();
             for (AlarmCustomTag alarm : alarmVoList) {
                 sb.append("'").append(alarm.getId().toLowerCase()).append("',");
             }
@@ -71,7 +75,7 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
             if (sb.length() > 0) {
                 ids = sb.substring(0, sb.length() - 1);
             }
-            List<AlarmSimpleVo> alarmls = new ArrayList<>();
+            List<AlarmSimpleVo> alarmls =  new CopyOnWriteArrayList<>();
             if (null != ids) {
                 alarmls = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.CT.getCode(), ids);
             }
@@ -87,8 +91,6 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
 
                 checkRule(saveAlarmTags, updateAlarmTags, vo,map);
 
-                logger.info( "新增报警数量:" + saveAlarmTags.size());
-                logger.info( "结束报警数量:" + updateAlarmTags.size());
             }
 
             if (!saveAlarmTags.isEmpty()) {
@@ -106,7 +108,8 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
 //					throw new RuntimeException(e);
 //				}
 //			}
-
+            logger.info(str+ "新增报警数量:" + saveAlarmTags.size());
+            logger.info(str+ "结束报警数量:" + updateAlarmTags.size());
         } catch (Exception e) {
 
             e.printStackTrace();
@@ -131,41 +134,48 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
                 alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.WT, ar.getDeviceid());
 
 
+            }else if (ar.getDevicetype().equals(DeviceTypeValue.IN.getCode())) {
+                alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.IN, ar.getDeviceid());
+
+
             } else if (ar.getDevicetype().equals(DeviceTypeValue.BT.getCode())) {
                 alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.BT, ar.getStationid());
-
             }
 
             try {
 
                 Object obj = alarmFunction.explain();
+
                 if (obj instanceof Boolean) {
 
-					Boolean endStatus=null;
+
+                    AtomicBoolean endStatus = new AtomicBoolean(true);
+
 					if(map.containsKey(ar.getId().toLowerCase()))
 					{
 						AlarmSimpleVo vo=map.get(ar.getId().toLowerCase());
 
-						if(StringUtils.notEmp(vo.getEndts()))
-						{
-							endStatus=true;
-						}else
+                        if(StringUtils.notEmp(vo.getEndts()))
+                        {
+                            endStatus.getAndSet(true);
+                        }else
                         {
-                            endStatus=false;
+                            endStatus.getAndSet(false);
                         }
 					}else
                     {
-                        endStatus=true;
+                        endStatus.getAndSet(true);
                     }
                     if (true == (boolean) obj) {
 
-						if(endStatus)
+						if(endStatus.get())
 						{
 							AlarmTag po = new AlarmTag();
 							po.setId(ar.getId());
 							po.setTs(new Date().getTime());
 							po.setEndts(null);
 							po.setVal(1.0);
+                            po.setOval(1.0);
 							po.setTimeLong(0.0);
 
 							saveAlarmTags.add(po);
@@ -173,13 +183,14 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
 
                     } else {
 
-						if(StringUtils.notEmp(endStatus) && !endStatus)
+						if(!endStatus.get())
 						{
 							AlarmTag po = new AlarmTag();
 							po.setId(ar.getId());
 							po.setTs(new Date().getTime());
 							po.setEndts(new Date().getTime());
 							po.setVal(0.0);
+                            po.setOval(0.0);
 							po.setTimeLong(0.0);
 
 							updateAlarmTags.add(po);

+ 2 - 2
alarm-custom/src/main/resources/application-jn.yml

@@ -168,8 +168,8 @@ frequency:
   #切入切出
   cutinandout: 1
 urls:
-  alarm-service: http://10.81.3.154:6014
-#  alarm-service: http://127.0.0.1:6014
+#  alarm-service: http://10.81.3.154:6014
+  alarm-service: http://127.0.0.1:6014
 
 task-count: 3
 read-count: 2

+ 25 - 25
alarm-custom/src/main/resources/xxl-job-executor.properties

@@ -1,25 +1,25 @@
-### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
-#xxl.job.admin.addresses=http://localhost:8175/xxl-job-admin
-xxl.job.admin.addresses=http://10.81.3.152:8175/xxl-job-admin
-### xxl-job, access token
-xxl.job.accessToken=
-
-### xxl-job executor appname
-### 场站计算
-xxl.job.executor.appname=generationTarget-job
-### 区域公司计算
-#xxl.job.executor.appname=generationRG-job
-### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
-xxl.job.executor.address=
-### xxl-job executor server-info
-xxl.job.executor.ip=
-#场站端口
-xxl.job.executor.port=9201
-#区域端口
-#xxl.job.executor.port=9202
-
-### xxl-job executor log-path
-xxl.job.executor.logpath=/data/nem/computeEngine/logs
-### xxl-job executor log-retention-days
-xxl.job.executor.logretentiondays=30
-
+#### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
+##xxl.job.admin.addresses=http://localhost:8175/xxl-job-admin
+#xxl.job.admin.addresses=http://10.81.3.152:8175/xxl-job-admin
+#### xxl-job, access token
+#xxl.job.accessToken=
+#
+#### xxl-job executor appname
+#### 场站计算
+#xxl.job.executor.appname=generationTarget-job
+#### 区域公司计算
+##xxl.job.executor.appname=generationRG-job
+#### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
+#xxl.job.executor.address=
+#### xxl-job executor server-info
+#xxl.job.executor.ip=
+##场站端口
+#xxl.job.executor.port=9201
+##区域端口
+##xxl.job.executor.port=9202
+#
+#### xxl-job executor log-path
+#xxl.job.executor.logpath=/data/nem/computeEngine/logs
+#### xxl-job executor log-retention-days
+#xxl.job.executor.logretentiondays=30
+#

+ 3 - 2
alarm-service/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java

@@ -55,7 +55,8 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "components NCHAR(50),description NCHAR(500),deviceid NCHAR(50),devicename NCHAR(70)," +
             "devicetype NCHAR(50),enabled BOOL,lineid NCHAR(50),linename NCHAR(70),modelId NCHAR(50),projectid NCHAR(50)," +
             "projectname NCHAR(70),rank INT,resettable BOOL,stationid NCHAR(50),stationname NCHAR(70),subcomponents NCHAR(50)," +
-            "suffix NCHAR(50),tagid NCHAR(100),triggertype INT,uniformcode NCHAR(50),name NCHAR(100),nemCode NCHAR(50),faultCause NCHAR(500),resolvent NCHAR(500),faultType NCHAR(50),aname NCHAR(50));")
+            "suffix NCHAR(50),tagid NCHAR(100),triggertype INT,uniformcode NCHAR(50),name NCHAR(100),nemCode NCHAR(50),faultCause NCHAR(500),resolvent NCHAR(500),faultType NCHAR(50),aname NCHAR(50) " +
+            ");")
     int createAlarmSuperTable(@Param("superTableName") String superTableName);
 
 
@@ -65,7 +66,7 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "#{characteristic}, #{components},#{description}, #{deviceid}, #{devicename}," +
             "#{devicetype}, #{enabled}, #{lineid}, #{linename}, #{modelId}, #{projectid}," +
             "#{projectname}, #{rank}, #{resettable}, #{stationid}, #{stationname}, #{subcomponents}," +
-            "#{suffix},  #{tagid}, #{triggertype}, #{uniformcode},#{name}, #{nemCode}, #{faultCause}, #{resolvent, #{faultType}, #{aname}" +
+            "#{suffix},  #{tagid}, #{triggertype}, #{uniformcode},#{name}, #{nemCode}, #{faultCause}, #{resolvent},#{faultType},#{aname} " +
             " )")
     int createTable(@Param("tbName") String tbName, @Param("alarmid") String alarmid, @Param("alarmtype") String alarmtype,
                     @Param("characteristic") String characteristic, @Param("components") String components,

+ 0 - 3
alarm-service/src/main/java/com/gyee/alarm/service/AlarmCtService.java

@@ -578,9 +578,6 @@ public class AlarmCtService {
                         if(StringUtils.notEmp(tag.getTs()))
                         {
                             alarm.setTs(tag.getTs().getTime());
-                        }else
-                        {
-                            alarm.setTs(new Date().getTime());
                         }
 
                         Date begin = new Date(alarm.getEndts());

+ 6 - 6
alarm-service/src/test/java/com/gyee/AppTest.java

@@ -21,12 +21,12 @@ public class AppTest
         AlarmInService alarmInService= SpringUtils.getBean("alarmInService");
 
 
-//        alarmWtService.createSuperTable();
-//        alarmWtService.initalWtAlarm();
-//        alarmInService.initalInAlarm();
-//
-//        alarmBtService.createSuperTable();
-//        alarmBtService.initalBtAlarm();
+        alarmWtService.createSuperTable();
+        alarmWtService.initalWtAlarm();
+        alarmInService.initalInAlarm();
+
+        alarmBtService.createSuperTable();
+        alarmBtService.initalBtAlarm();
 
         alarmCtService.createSuperTable();
         alarmCtService.initalCtAlarm();

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java

@@ -129,7 +129,7 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
 //            "</script>"})
 
     @Select({"<script>",
-            "select  ts ,val ,confirmed ,endts ,timeLong,alarmid as alarmId,alarmtype as alarmType,characteristic,components,confirmed,description,deviceid as deviceId,devicename,devicetype as deviceType,enabled,lineid,linename," +
+            "select  ts ,val ,confirmed ,endts ,timeLong,tbname as id,alarmid as alarmId,alarmtype as alarmType,characteristic,components,confirmed,description,deviceid as deviceId,devicename,devicetype as deviceType,enabled,lineid,linename," +
                     "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode,nemCode ,faultCause,resolvent from #{superTableName} " ,
             "<where>" ,
             " ts &gt;= #{begin}",

+ 2 - 1
alarm-web/src/main/java/com/gyee/alarm/model/vo/AlarmVo.java

@@ -35,7 +35,7 @@ public class AlarmVo {
     private String uniformcode;
     private String superTableName;
 
-    private Timestamp ts;
+    private long ts;
     private Integer val;
     private Integer oval;
 
@@ -66,4 +66,5 @@ public class AlarmVo {
     private String code;
     private String wpId;
     private String faultType;
+    private String id;
 }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 83389 - 47972
log/ota.log


BIN
log/ota.log.2023-09-24.1.gz


BIN
log/ota.log.2023-09-25.4.gz


BIN
log/ota.log.2023-09-25.5.gz