Explorar o código

添加报警缓存同步功能

shilin hai 2 días
pai
achega
738927ec16

+ 16 - 1
alarm-custom/pom.xml

@@ -32,13 +32,28 @@
         <pgsql.version>42.2.5</pgsql.version>
         <groovy.version>3.0.8</groovy.version>
         <springframework.boot.version>2.2.2.RELEASE</springframework.boot.version>
-
+        <tomcat.version>9.0.83</tomcat.version>
     </properties>
 
 
     <dependencies>
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-core</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-websocket</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
 
         <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-el</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+        <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
             <version>23.0</version>

+ 17 - 1
alarm-scanner/pom.xml

@@ -33,12 +33,28 @@
         <pgsql.version>42.2.5</pgsql.version>
         <groovy.version>3.0.8</groovy.version>
         <springframework.boot.version>2.2.2.RELEASE</springframework.boot.version>
-
+        <tomcat.version>9.0.83</tomcat.version>
     </properties>
 
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-core</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-websocket</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-el</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+        <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
             <version>23.0</version>

+ 1 - 11
alarm-scanner/src/main/java/com/gyee/alarm/model/vo/AlarmTag.java

@@ -126,17 +126,7 @@ public class AlarmTag {
             return false;
         }
 
-//        if (StringUtils.empty(pointData.getPointTime())) {
-//            return false;
-//        }
-//
-//        if (pointData.getPointTime().intValue()==0) {
-//            return false;
-//        }
-//        if(StringUtils.notEmp(wpId) && wpId.contains("_SBS"))
-//        {
-//            log.info("判定相等报警tagId_"+tagId+"_wpId_"+wpId+"_ts_"+ts+"_val_"+oval.doubleValue());
-//        }
+
         ts = pointData.getPointTime();
         oval = pointData.getPointValueInDouble();
         endts= pointData.getPointTime();

+ 8 - 8
alarm-service/src/main/java/com/gyee/alarm/service/auto/impl/AlarmTsServiceImpl.java

@@ -61,20 +61,20 @@ public class AlarmTsServiceImpl extends ServiceImpl<AlarmTsMapper, AlarmTs> impl
         deviceid = deviceid != null ? deviceid : "";
         devicename = devicename != null ? devicename : "";
         devicetype = devicetype != null ? devicetype : "";
-        enabled = enabled;
+        enabled = enabled != null ? enabled : false;
         lineid = lineid != null ? lineid : "";
         linename = linename != null ? linename : "";
         modelId = modelId != null ? modelId : "";
         projectid = projectid != null ? projectid : "";
         projectname = projectname != null ? projectname : "";
-        rank = rank;
-        resettable = resettable;
+        rank = rank  != null ? rank : 0;
+        resettable = resettable  != null ? resettable : false;
         stationid = stationid != null ? stationid : "";
         stationname = stationname != null ? stationname : "";
         subcomponents = subcomponents != null ? subcomponents : "";
         suffix = suffix != null ? suffix : "";
         tagid = tagid != null ? tagid : "";
-        triggertype = triggertype;
+        triggertype = triggertype  != null ? triggertype : 1;
         uniformcode = uniformcode != null ? uniformcode : "";
         superTableName = superTableName != null ? superTableName : "";
         name = name != null ? name : "";
@@ -124,20 +124,20 @@ public class AlarmTsServiceImpl extends ServiceImpl<AlarmTsMapper, AlarmTs> impl
         deviceid = deviceid != null ? deviceid : "";
         devicename = devicename != null ? devicename : "";
         devicetype = devicetype != null ? devicetype : "";
-        enabled = enabled;
+        enabled = enabled != null ? enabled : false;
         lineid = lineid != null ? lineid : "";
         linename = linename != null ? linename : "";
         modelId = modelId != null ? modelId : "";
         projectid = projectid != null ? projectid : "";
         projectname = projectname != null ? projectname : "";
-        rank = rank;
-        resettable = resettable;
+        rank = rank  != null ? rank : 0;
+        resettable = resettable  != null ? resettable : false;
         stationid = stationid != null ? stationid : "";
         stationname = stationname != null ? stationname : "";
         subcomponents = subcomponents != null ? subcomponents : "";
         suffix = suffix != null ? suffix : "";
         tagid = tagid != null ? tagid : "";
-        triggertype = triggertype;
+        triggertype = triggertype  != null ? triggertype : 1;
         uniformcode = uniformcode != null ? uniformcode : "";
         superTableName = superTableName != null ? superTableName : "";
         name = name != null ? name : "";

+ 16 - 1
alarm-web/pom.xml

@@ -29,14 +29,29 @@
         <pgsql.version>42.2.5</pgsql.version>
         <groovy.version>3.0.8</groovy.version>
         <springframework.boot.version>2.2.2.RELEASE</springframework.boot.version>
-
+        <tomcat.version>9.0.83</tomcat.version>
     </properties>
 
 
     <dependencies>
 
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-core</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-websocket</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
 
         <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-el</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+        <dependency>
             <groupId>com.opencsv</groupId>
             <artifactId>opencsv</artifactId>
             <version>4.4</version>

+ 5 - 2
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconShutdownEvent2Mapper.java

@@ -43,7 +43,7 @@ public interface ProEconShutdownEvent2Mapper extends BaseMapper<ProEconShutdownE
             "</if>",
             "and s.stop_time &gt;= #{begin}",
             "and s.stop_time &lt;= #{end}",
-
+            "and s.stop_hours &gt;= 0.0083",
             "</where>",
 
             "</script>"})
@@ -62,7 +62,7 @@ public interface ProEconShutdownEvent2Mapper extends BaseMapper<ProEconShutdownE
             "</if>",
             "and s.stop_time &gt;= #{begin}",
             "and s.stop_time &lt;= #{end}",
-
+            "and s.stop_hours &gt;= 0.0083",
             "</where>",
             " GROUP BY t.name ",
             "</script>"})
@@ -123,6 +123,7 @@ public interface ProEconShutdownEvent2Mapper extends BaseMapper<ProEconShutdownE
             "</if>",
             "and s.stop_time &gt;= #{begin}",
             "and s.stop_time &lt;= #{end}",
+            "and s.stop_hours &gt;= 0.0083",
             "and (t.nem_code='YP' or t.nem_code='LG' or t.nem_code='PHXT' or t.nem_code='BJXT' )",
             "</where>",
 
@@ -142,6 +143,7 @@ public interface ProEconShutdownEvent2Mapper extends BaseMapper<ProEconShutdownE
             "</if>",
             "and s.stop_time &gt;= #{begin}",
             "and s.stop_time &lt;= #{end}",
+            "and s.stop_hours &gt;= 0.0083",
             "and (t.nem_code='FDJ' or t.nem_code='BPQ' or t.nem_code='KZXT'  )",
             "</where>",
 
@@ -162,6 +164,7 @@ public interface ProEconShutdownEvent2Mapper extends BaseMapper<ProEconShutdownE
             "</if>",
             "and s.stop_time &gt;= #{begin}",
             "and s.stop_time &lt;= #{end}",
+            "and s.stop_hours &gt;= 0.0083",
             "and (t.nem_code!='FDJ' and t.nem_code!='BPQ' and t.nem_code!='KZXT' and t.nem_code!='YP' and t.nem_code!='LG' and t.nem_code!='PHXT' and t.nem_code!='BJXT' )",
             "</where>",
 

+ 64 - 16
alarm-web/src/main/java/com/gyee/alarm/service/AlarmInitalService.java

@@ -3,11 +3,14 @@ package com.gyee.alarm.service;
 import com.gyee.alarm.init.CacheContext;
 import com.gyee.alarm.model.auto.ProEconAlarmConfiguration;
 import com.gyee.alarm.model.auto.ProEconAlarmRule;
+import com.gyee.alarm.model.auto.ProEconAlarmType;
 import com.gyee.alarm.model.vo.AlarmCustomType;
 import com.gyee.alarm.model.vo.AlarmTypeValue;
 import com.gyee.alarm.model.vo.AlarmVo;
 import com.gyee.alarm.service.auto.IProEconAlarmConfigurationService;
 import com.gyee.alarm.service.auto.IProEconAlarmRuleService;
+import com.gyee.alarm.service.auto.IProEconAlarmTypeService;
+import com.gyee.alarm.util.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -31,7 +34,8 @@ public class AlarmInitalService {
 
     @Resource
     private AlarmCtService alarmCtService;
-
+    @Resource
+    private IProEconAlarmTypeService proEconAlarmTypeService;
 
     public void initialAlarm() throws Exception {
 
@@ -56,6 +60,20 @@ public class AlarmInitalService {
         Map<String, List<ProEconAlarmConfiguration>> inAlarmMap = new HashMap<>();
         Map<String, AlarmVo> alarmWtMap = new HashMap<>();
 
+        Map<String, List<ProEconAlarmRule>> ctAlarmlsMap = new HashMap<>();
+        Map<String, ProEconAlarmType> alarmTypeMap = new HashMap<>();
+        List<ProEconAlarmType> alarmTypeList = new ArrayList<>();
+        Map<String, ProEconAlarmRule> ctAlarmMap = new HashMap<>();
+
+           alarmTypeList = proEconAlarmTypeService.list();
+
+            if (!alarmTypeList.isEmpty()) {
+                for (ProEconAlarmType at : alarmTypeList) {
+                    alarmTypeMap.put(at.getNemCode(), at);
+                }
+            }
+
+
 
         List<ProEconAlarmConfiguration> templs = proEconAlarmConfigurationService.list().stream().filter(i -> i.getEnable()).collect(Collectors.toList());
         if (!templs.isEmpty()) {
@@ -138,28 +156,51 @@ public class AlarmInitalService {
         }
 
         //从pg数据库获取自定义报警配置信息
-        List<ProEconAlarmRule> customls =proEconAlarmRuleService.list().stream().filter(i -> i.getEnable()).collect(Collectors.toList());
+        List<ProEconAlarmRule> customls = proEconAlarmRuleService.list();
 
+        if (!customls.isEmpty()) {
+            customls = customls.stream().filter(i -> null != i.getEnable() && i.getEnable()).collect(Collectors.toList());
+        }
         List<ProEconAlarmRule> wtCustomls=new ArrayList<>();
         List<ProEconAlarmRule> inCustomls=new ArrayList<>();
         List<ProEconAlarmRule> btCustomls=new ArrayList<>();
 
         //对自定义报警进行分类
-        if(!customls.isEmpty())
-        {
-            for(ProEconAlarmRule vo: customls)
-            {
-                if(vo.getCategory().equals(AlarmCustomType.WT.getCode()))
-                {
-                    wtCustomls.add(vo);
-                }else  if(vo.getCategory().equals(AlarmCustomType.IN.getCode()))
-                {
-                    inCustomls.add(vo);
-                }else  if(vo.getCategory().equals(AlarmCustomType.BT.getCode()))
-                {
-                    btCustomls.add(vo);
+        if (!customls.isEmpty()) {
+            for (ProEconAlarmRule vo : customls) {
+
+                ctAlarmMap.put(vo.getId(),vo);
+                StringBuilder sb = new StringBuilder();
+                sb.append(vo.getStationId()).append(vo.getModelId());
+                if (StringUtils.notEmp(vo.getCategory())) {
+
+
+                    if (vo.getCategory().equals(AlarmCustomType.WT.getCode())) {
+                        if (ctAlarmlsMap.containsKey(String.valueOf(sb))) {
+                            List<ProEconAlarmRule> ls = ctAlarmlsMap.get(String.valueOf(sb));
+                            ls.add(vo);
+                            ctAlarmlsMap.put(String.valueOf(sb), ls);
+                        } else {
+                            List<ProEconAlarmRule> ls = new ArrayList<>();
+                            ls.add(vo);
+                            ctAlarmlsMap.put(String.valueOf(sb), ls);
+                        }
+                        wtCustomls.add(vo);
+                    }
+                    if (vo.getCategory().equals(AlarmCustomType.IN.getCode())) {
+                        if (ctAlarmlsMap.containsKey(String.valueOf(sb))) {
+                            List<ProEconAlarmRule> ls = ctAlarmlsMap.get(String.valueOf(sb));
+                            ls.add(vo);
+                        } else {
+                            List<ProEconAlarmRule> ls = new ArrayList<>();
+                            ls.add(vo);
+                            ctAlarmlsMap.put(String.valueOf(sb), ls);
+                        }
+                        wtCustomls.add(vo);
+                    } else if (vo.getCategory().equals(AlarmCustomType.BT.getCode())) {
+                        btCustomls.add(vo);
+                    }
                 }
-
             }
         }
 
@@ -197,5 +238,12 @@ public class AlarmInitalService {
         CacheContext.alarmWpMap=alarmWpMap;
         CacheContext.inAlarmMap = inAlarmMap;
         CacheContext.alarmWtMap = alarmWtMap;
+
+
+
+        CacheContext.ctAlarmlsMap = ctAlarmlsMap;
+        CacheContext.alarmTypeMap = alarmTypeMap;
+        CacheContext.alarmTypeList = alarmTypeList;
+        CacheContext.ctAlarmMap = ctAlarmMap;
     }
 }