shilin 1 год назад
Родитель
Сommit
c9b556bf2d
41 измененных файлов с 13465 добавлено и 69625 удалено
  1. 15 15
      alarm-custom/src/main/java/com/gyee/alarm/ApplicationReadyEventListener.java
  2. 3 3
      alarm-custom/src/main/java/com/gyee/alarm/init/CacheContext.java
  3. 126 0
      alarm-custom/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java
  4. 18 0
      alarm-custom/src/main/java/com/gyee/alarm/model/auto/AlarmTs.java
  5. 19 0
      alarm-custom/src/main/java/com/gyee/alarm/model/vo/AlarmSimpleVo.java
  6. 65 2
      alarm-custom/src/main/java/com/gyee/alarm/model/vo/AlarmTag.java
  7. 123 0
      alarm-custom/src/main/java/com/gyee/alarm/model/vo/AlarmTsMapper.java
  8. 16 0
      alarm-custom/src/main/java/com/gyee/alarm/model/vo/AlarmTsVo.java
  9. 11 7
      alarm-custom/src/main/java/com/gyee/alarm/service/AlarmCustomService.java
  10. 65 0
      alarm-custom/src/main/java/com/gyee/alarm/service/auto/IAlarmTsService.java
  11. 179 0
      alarm-custom/src/main/java/com/gyee/alarm/service/auto/impl/AlarmTsServiceImpl.java
  12. 6 2
      alarm-custom/src/main/java/com/gyee/alarm/task/thread/AlarmThread.java
  13. 114 87
      alarm-custom/src/main/java/com/gyee/alarm/task/thread/AlarmThreadPool.java
  14. 1 1
      alarm-custom/src/main/resources/application-jn.yml
  15. 16 16
      alarm-scanner/src/main/java/com/gyee/alarm/ApplicationReadyEventListener.java
  16. 2 2
      alarm-scanner/src/main/java/com/gyee/alarm/model/vo/AlarmTag.java
  17. 3 2
      alarm-scanner/src/main/java/com/gyee/alarm/service/AlarmScannerService.java
  18. 2 2
      alarm-scanner/src/main/resources/application-bt.yml
  19. 1 0
      alarm-service/src/main/java/com/gyee/alarm/service/AlarmCtService.java
  20. 159 152
      alarm-service/src/main/java/com/gyee/alarm/service/PushDataSevice.java
  21. 15 15
      alarm-service/src/main/java/com/gyee/alarm/task/thread/SaticScheduleTask.java
  22. 2 1
      alarm-service/src/main/java/com/gyee/alarm/websocket/WebSocketBt.java
  23. 6 6
      alarm-service/src/test/java/com/gyee/AppTest.java
  24. 4 4
      alarm-web/src/main/java/com/gyee/alarm/controller/AlarmConfigurationController.java
  25. 7 1
      alarm-web/src/main/java/com/gyee/alarm/controller/AlarmHistoryController.java
  26. 15 5
      alarm-web/src/main/java/com/gyee/alarm/controller/AlertRuleController.java
  27. 2 2
      alarm-web/src/main/java/com/gyee/alarm/controller/ProBasicDeviceController.java
  28. 7 3
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java
  29. 7 4
      alarm-web/src/main/java/com/gyee/alarm/model/vo/AlarmVo.java
  30. 4 4
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmBtService.java
  31. 16 16
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmCtService.java
  32. 37 6
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmHistoryService.java
  33. 4 4
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmInService.java
  34. 4 4
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmWtService.java
  35. 12391 69259
      log/ota.log
  36. BIN
      log/ota.log.2023-09-13.0.gz
  37. BIN
      log/ota.log.2023-09-14.0.gz
  38. BIN
      log/ota.log.2023-09-15.0.gz
  39. BIN
      log/ota.log.2023-09-20.110.gz
  40. BIN
      log/ota.log.2023-09-20.16.gz
  41. BIN
      log/ota.log.2023-09-20.913.gz

+ 15 - 15
alarm-custom/src/main/java/com/gyee/alarm/ApplicationReadyEventListener.java

@@ -23,20 +23,20 @@ public class ApplicationReadyEventListener implements
         calculateServer.start();
     }
 
-    /**
-     * 统计内报故障损失电量
-     */
-    @Scheduled(cron = "0 0/16 * * * ?")
-    //或直接指定时间间隔,例如:5秒
-    //@Scheduled(fixedRate=5000)
-    private void saveFaultrecord() {
-
-        try {
-            calculateServer.stop();
-            calculateServer.start();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
+//    /**
+//     * 统计内报故障损失电量
+//     */
+//    @Scheduled(cron = "0 0/16 * * * ?")
+//    //或直接指定时间间隔,例如:5秒
+//    //@Scheduled(fixedRate=5000)
+//    private void saveFaultrecord() {
+//
+//        try {
+//            calculateServer.stop();
+//            calculateServer.start();
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//    }
 
 }

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

@@ -560,9 +560,9 @@ public class CacheContext implements CommandLineRunner {
         });
 
 
-        String llglString = redisService.get("ZLLGL");
-        theoreticalPowerMap = JSONObject.parseObject(llglString, new TypeReference<Map<String, Map<Double,ProBasicModelPowerRd>>>() {
-        });
+//        String llglString = redisService.get("ZLLGL");
+//        theoreticalPowerMap = JSONObject.parseObject(llglString, new TypeReference<Map<String, Map<Double,ProBasicModelPowerRd>>>() {
+//        });
 
         String sszzt = redisService.get("SSZZT");
         statusMap = JSONObject.parseObject(sszzt, new TypeReference<Map<String,List<ProBasicStatusPoint>>>() {

+ 126 - 0
alarm-custom/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java

@@ -0,0 +1,126 @@
+package com.gyee.alarm.mapper.auto;
+
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.alarm.model.auto.AlarmTs;
+import com.gyee.alarm.model.vo.AlarmSimpleVo;
+import com.gyee.alarm.model.vo.AlarmTsVo;
+import com.gyee.alarm.model.vo.AlarmVo;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.List;
+
+
+@DS("slave")
+public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
+
+//STABLE 超级表
+// ts TIMESTAMP, 时间戳
+//val INT,触发报警值
+//confirmed BOOL,是否确认
+//endts TIMESTAMP, 报警结束时间戳
+//timeLong DOUBLE 报警时长
+
+//TAGS 标签
+//alarmid NCHAR(100), 报警id
+//alarmtype NCHAR(50), 报警类型
+//characteristic NCHAR(50),停机特性
+//components NCHAR(50),部件
+//description NCHAR(500),报警描述
+//deviceid NCHAR(50),设备id
+//devicename NCHAR(70),设备名称
+//devicetype NCHAR(50),设备类型
+//enabled BOOL,是否启用
+//lineid NCHAR(50),线路id
+//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)统一编码
+
+    @Update("CREATE STABLE if not exists ${superTableName} (ts TIMESTAMP,val INT,confirmed BOOL,endts TIMESTAMP,timeLong DOUBLE) " +
+            "TAGS (alarmid NCHAR(100),alarmtype NCHAR(50),characteristic NCHAR(50)," +
+            "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(1000),resolvent NCHAR(1000));")
+    int createAlarmSuperTable(@Param("superTableName") String superTableName);
+
+
+
+    @Update("create table if not exists ${tbName} using ${superTableName} TAGS( " +
+            "#{alarmid}, #{alarmtype}," +
+            "#{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}" +
+            " )")
+    int createTable(@Param("tbName") String tbName, @Param("alarmid") String alarmid, @Param("alarmtype") String alarmtype,
+                    @Param("characteristic") String characteristic, @Param("components") String components,
+                    @Param("description") String description,
+                    @Param("deviceid") String deviceid, @Param("devicename") String devicename,
+                    @Param("devicetype") String devicetype, @Param("enabled") Boolean enabled,
+                    @Param("lineid") String lineid, @Param("linename") String linename,
+                    @Param("modelId") String modelId, @Param("projectid") String projectid,
+                    @Param("projectname") String projectname, @Param("rank") Integer rank,
+                    @Param("resettable") Boolean resettable, @Param("stationid") String stationid,
+                    @Param("stationname") String stationname, @Param("subcomponents") String subcomponents,
+                    @Param("suffix") String suffix, @Param("tagid") String tagid,
+                    @Param("triggertype") Integer triggertype, @Param("uniformcode") String uniformcode, @Param("superTableName") String superTableName,
+                    @Param("name") String name, @Param("nemCode") String nemCode, @Param("faultCause") String faultCause, @Param("resolvent") String resolvent
+
+                    );
+
+
+
+    @Update("create table  if not exists ${tbName} using ${superTableName} tags( #{alarmid}, #{alarmtype}," +
+            "#{characteristic}, #{components}, #{description}, #{deviceid}, #{devicename}," +
+            "#{devicetype}, #{enabled}, #{lineid}, #{linename}, #{modelId}, #{projectid}," +
+            "#{projectname}, #{rank}, #{resettable}, #{stationid}, #{stationname}, #{subcomponents}," +
+            "#{suffix},  #{tagid}, #{triggertype}, #{uniformcode}" +
+            ")")
+    int createTable(AlarmVo vo);
+
+    @Update("drop table if exists ${superTableName}")
+    void dropSuperTable(@Param("superTableName")String superTableName);
+
+    @Insert("insert into ${tbName} (ts, val,oval,confirmed) values(#{ts}, #{val}, #{oval}, #{confirmed})")
+    int insertOne(AlarmTs one);
+
+
+
+    @Insert("${sql}")
+    int insertList(@Param("sql") String sql);
+
+    @Select("select last_row(*),alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
+            "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{stbaleName} group by tbname")
+    List<AlarmVo> findTags(@Param("stbaleName") String stbaleName);
+
+
+    @Select("select deviceid,description,count(*) as val,sum(timeLong) as timeLong from #{superTableName} where ts>=#{begin} and ts<=#{end}  stationid=#{stationid}  group by description,deviceid  ")
+    List<AlarmTsVo> selectByGroup(@Param("superTableName") String superTableName, @Param("stationid") String stationid, @Param("begin")long begin, @Param("end") long end);
+
+
+    @Select("select ts,val,confirmed,endts,timeLong,alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
+            "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{tbName}   limit #{limit} offset #{offset} ")
+    List<AlarmVo> selectByTbName(@Param("tbName") String tbName,@Param("limit") long limit,@Param("offset") long offset);
+
+
+//    @Select("select last_row(*),tbname from #{superTableName} where tbname in( #{tbnames} ) group by tbname")
+//List<AlarmSimpleVo> selectLastRowByTbname(@Param("superTableName") String superTableName, @Param("tbnames") String tbnames);
+    @Select("${sql}")
+    List<AlarmSimpleVo> selectLastRowByTbname(@Param("sql") String sql);
+
+}

+ 18 - 0
alarm-custom/src/main/java/com/gyee/alarm/model/auto/AlarmTs.java

@@ -0,0 +1,18 @@
+package com.gyee.alarm.model.auto;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.sql.Timestamp;
+
+@Data
+@ToString
+public class AlarmTs {
+
+    private Timestamp ts;
+    private Integer val;
+    private Integer oval;
+    private Boolean confirmed;
+    private Timestamp endts;
+    private String tbName;
+}

+ 19 - 0
alarm-custom/src/main/java/com/gyee/alarm/model/vo/AlarmSimpleVo.java

@@ -0,0 +1,19 @@
+package com.gyee.alarm.model.vo;
+
+
+import lombok.Data;
+
+import java.sql.Timestamp;
+
+@Data
+public class AlarmSimpleVo {
+
+    private  String tbName;
+    private Timestamp ts;
+    private Integer val;
+    private Integer oval;
+    private  Boolean confirmed;
+    private Timestamp endts;
+    private Double timelong;
+
+}

+ 65 - 2
alarm-custom/src/main/java/com/gyee/alarm/model/vo/AlarmTag.java

@@ -3,10 +3,11 @@ package com.gyee.alarm.model.vo;
 import com.gyee.common.model.PointData;
 import lombok.Data;
 
+import java.sql.Timestamp;
+
 @Data
 public class AlarmTag {
 
-
     /**
      * 表名
      */
@@ -21,14 +22,76 @@ public class AlarmTag {
      * 当前值
      */
     private Double val;
+
+    private String code;
+    /**
+     * 报警类别,0触发,1触发,-1变化触发,大于等于3ai点触发
+     */
+    private Integer triggerType=0;
+
+    /**
+     * 测点
+     */
+    private String tagId;
+
+    /**
+     * 过去值
+     */
+    private Double oval=0.0;
+
+    /**
+     * 报警级别
+     */
+    private Integer rank;
+
     /**
      * 结束时间戳
      */
     private Long endts;
-
     /**
      * 报警时长
      */
     private Double timeLong;
+    /**
+     * 报警描述
+     */
+    private String description;
+
+
+    private  Boolean confirmed;
+
+    private String superTalbe;
+
+    /**
+     * 故障原因
+     */
+    private String faultCause;
+    /**
+     * 类型
+     */
+    private String characteristic;
+    private String alarmId;
+    private String deviceId;
+    /**
+     * 解决方法
+     */
+    private String resolvent;
+
+    /**
+     * 报警类型 /自定义报警 custom,风机 windturbine,场站 station,升压站 booststation
+     */
+    private String alarmType;
+
+    /**
+     * 设备类型,场站 station,风机 windturbine,升压站 booststation
+     */
+    private String deviceType;
+
+    private Boolean isClose;
+
+    private String wpName;
+
+    private String wpId;
+
 
 }

+ 123 - 0
alarm-custom/src/main/java/com/gyee/alarm/model/vo/AlarmTsMapper.java

@@ -0,0 +1,123 @@
+package com.gyee.alarm.model.vo;
+
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.alarm.model.auto.AlarmTs;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.List;
+
+
+@DS("slave")
+public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
+
+//STABLE 超级表
+// ts TIMESTAMP, 时间戳
+//val INT,触发报警值
+//confirmed BOOL,是否确认
+//endts TIMESTAMP, 报警结束时间戳
+//timeLong DOUBLE 报警时长
+
+//TAGS 标签
+//alarmid NCHAR(100), 报警id
+//alarmtype NCHAR(50), 报警类型
+//characteristic NCHAR(50),停机特性
+//components NCHAR(50),部件
+//description NCHAR(500),报警描述
+//deviceid NCHAR(50),设备id
+//devicename NCHAR(70),设备名称
+//devicetype NCHAR(50),设备类型
+//enabled BOOL,是否启用
+//lineid NCHAR(50),线路id
+//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)统一编码
+
+    @Update("CREATE STABLE if not exists ${superTableName} (ts TIMESTAMP,val INT,confirmed BOOL,endts TIMESTAMP,timeLong DOUBLE) " +
+            "TAGS (alarmid NCHAR(100),alarmtype NCHAR(50),characteristic NCHAR(50)," +
+            "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(1000),resolvent NCHAR(1000));")
+    int createAlarmSuperTable(@Param("superTableName") String superTableName);
+
+
+
+    @Update("create table if not exists ${tbName} using ${superTableName} TAGS( " +
+            "#{alarmid}, #{alarmtype}," +
+            "#{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}" +
+            " )")
+    int createTable(@Param("tbName") String tbName, @Param("alarmid") String alarmid, @Param("alarmtype") String alarmtype,
+                    @Param("characteristic") String characteristic, @Param("components") String components,
+                    @Param("description") String description,
+                    @Param("deviceid") String deviceid, @Param("devicename") String devicename,
+                    @Param("devicetype") String devicetype, @Param("enabled") Boolean enabled,
+                    @Param("lineid") String lineid, @Param("linename") String linename,
+                    @Param("modelId") String modelId, @Param("projectid") String projectid,
+                    @Param("projectname") String projectname, @Param("rank") Integer rank,
+                    @Param("resettable") Boolean resettable, @Param("stationid") String stationid,
+                    @Param("stationname") String stationname, @Param("subcomponents") String subcomponents,
+                    @Param("suffix") String suffix, @Param("tagid") String tagid,
+                    @Param("triggertype") Integer triggertype, @Param("uniformcode") String uniformcode, @Param("superTableName") String superTableName,
+                    @Param("name") String name, @Param("nemCode") String nemCode, @Param("faultCause") String faultCause, @Param("resolvent") String resolvent
+
+                    );
+
+
+
+    @Update("create table  if not exists ${tbName} using ${superTableName} tags( #{alarmid}, #{alarmtype}," +
+            "#{characteristic}, #{components}, #{description}, #{deviceid}, #{devicename}," +
+            "#{devicetype}, #{enabled}, #{lineid}, #{linename}, #{modelId}, #{projectid}," +
+            "#{projectname}, #{rank}, #{resettable}, #{stationid}, #{stationname}, #{subcomponents}," +
+            "#{suffix},  #{tagid}, #{triggertype}, #{uniformcode}" +
+            ")")
+    int createTable(AlarmVo vo);
+
+    @Update("drop table if exists ${superTableName}")
+    void dropSuperTable(@Param("superTableName")String superTableName);
+
+    @Insert("insert into ${tbName} (ts, val,oval,confirmed) values(#{ts}, #{val}, #{oval}, #{confirmed})")
+    int insertOne(AlarmTs one);
+
+
+
+    @Insert("${sql}")
+    int insertList(@Param("sql") String sql);
+
+    @Select("select last_row(*),alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
+            "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{stbaleName} group by tbname")
+    List<AlarmVo> findTags(@Param("stbaleName") String stbaleName);
+
+
+    @Select("select deviceid,description,count(*) as val,sum(timeLong) as timeLong from #{superTableName} where ts>=#{begin} and ts<=#{end}  stationid=#{stationid}  group by description,deviceid  ")
+    List<AlarmTsVo> selectByGroup(@Param("superTableName") String superTableName, @Param("stationid") String stationid, @Param("begin")long begin, @Param("end") long end);
+
+
+    @Select("select ts,val,confirmed,endts,timeLong,alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
+            "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{tbName}   limit #{limit} offset #{offset} ")
+    List<AlarmVo> selectByTbName(@Param("tbName") String tbName,@Param("limit") long limit,@Param("offset") long offset);
+
+
+//    @Select("select last_row(*),tbname from #{superTableName} where tbname in( #{tbnames} ) group by tbname")
+//List<AlarmSimpleVo> selectLastRowByTbname(@Param("superTableName") String superTableName, @Param("tbnames") String tbnames);
+    @Select("${sql}")
+    List<AlarmSimpleVo> selectLastRowByTbname(@Param("sql") String sql);
+
+}

+ 16 - 0
alarm-custom/src/main/java/com/gyee/alarm/model/vo/AlarmTsVo.java

@@ -0,0 +1,16 @@
+package com.gyee.alarm.model.vo;
+
+
+import lombok.Data;
+
+@Data
+public class AlarmTsVo {
+
+
+    private String description;
+    private String deviceid;
+    private Integer val;
+
+    private Double timeLong;
+
+}

+ 11 - 7
alarm-custom/src/main/java/com/gyee/alarm/service/AlarmCustomService.java

@@ -8,6 +8,7 @@ import com.gyee.alarm.model.auto.ProBasicEquipmentPoint;
 import com.gyee.alarm.model.auto.ProBasicPowerstationPoint;
 import com.gyee.alarm.model.vo.AlarmCustomTag;
 import com.gyee.alarm.model.vo.AlarmTag;
+import com.gyee.alarm.service.auto.IAlarmTsService;
 import com.gyee.alarm.task.thread.*;
 import com.gyee.alarm.util.realtimesource.IEdosUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -49,10 +50,13 @@ public class AlarmCustomService {
     @Resource
     private IAlarmService alarmService;
 
-    private List<AlarmCustomTag> alarmTags = new ArrayList<>();
+    private List<AlarmCustomTag> alarmTags = new CopyOnWriteArrayList<>();
     @Resource
     private Executor executor;
 
+
+    @Resource
+    private  IAlarmTsService alarmTsService;
     /**
      * 初始化
      */
@@ -67,11 +71,11 @@ public class AlarmCustomService {
 
             readTaskJobs(runStarted);
 
-            Thread.sleep((interval * 500));
+            Thread.sleep((interval * 1000));
 
             calTaskJobs(runStarted);
 
-            Thread.sleep((interval * 500));
+            Thread.sleep((interval * 1000));
         }
     }
 
@@ -158,7 +162,7 @@ public class AlarmCustomService {
             countDownLatch.await();
             log.info("数据读取完成!");
             try {
-                Thread.sleep((interval * 500));
+                Thread.sleep((interval * 1000));
             } catch (InterruptedException e) {
                 throw new RuntimeException(e);
             }
@@ -190,7 +194,7 @@ public class AlarmCustomService {
                     time++;
                     str.setLength(0);
                     str.append("自定义分析").append(time).append("线程");
-                    new Thread(new AlarmThread(executor,  alarmService,  alarmls,interval,str,readRows,countDownLatch)).start();
+                    new Thread(new AlarmThread(executor,  alarmService,  alarmls,interval,str,readRows,countDownLatch,alarmTsService)).start();
                     alarmls = new ArrayList<>();
 
                 }
@@ -201,14 +205,14 @@ public class AlarmCustomService {
                 time++;
                 str.setLength(0);
                 str.append("自定义分析").append(time).append("线程");
-                new Thread(new AlarmThread(executor,  alarmService,  alarmls,interval,str,readRows,countDownLatch)).start();
+                new Thread(new AlarmThread(executor,  alarmService,  alarmls,interval,str,readRows,countDownLatch,alarmTsService)).start();
 
             }
 
             countDownLatch.await();
             log.info("自定义分析完成!");
             try {
-                Thread.sleep((interval * 500));
+                Thread.sleep((interval * 1000));
             } catch (InterruptedException e) {
                 throw new RuntimeException(e);
             }

+ 65 - 0
alarm-custom/src/main/java/com/gyee/alarm/service/auto/IAlarmTsService.java

@@ -0,0 +1,65 @@
+package com.gyee.alarm.service.auto;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.alarm.model.auto.AlarmTs;
+import com.gyee.alarm.model.vo.AlarmSimpleVo;
+import com.gyee.alarm.model.vo.AlarmTag;
+import com.gyee.alarm.model.vo.AlarmTsVo;
+import com.gyee.alarm.model.vo.AlarmVo;
+
+import java.util.List;
+
+
+public interface IAlarmTsService extends IService<AlarmTs> {
+
+    public void createSuperTable(String type);
+
+
+    public void dropSuperTable(String type);
+
+
+    public int createTable(AlarmVo vo) ;
+
+    public int createTable(String tbName, String alarmid, String alarmtype,
+                           String characteristic, String components,
+                           String description,
+                           String deviceid, String devicename,
+                           String devicetype, Boolean enabled,
+                           String lineid, String linename,
+                           String modelId, String projectid,
+                           String projectname, Integer rank,
+                           Boolean resettable, String stationid,
+                           String stationname, String subcomponents,
+                           String suffix, String tagid,
+                           Integer triggertype, String uniformcode,String superTableName,
+                           String name,String nemCode, String faultCause, String resolvent
+
+    );
+
+
+
+    public int insertOne(AlarmTs one);
+
+
+
+
+    public void insertList(List<AlarmTag>  alarmTags ) ;
+
+    public void createSql(List<AlarmTag>  alarmTags )  ;
+
+
+    public List<AlarmVo> findTags(String stbaleName);
+
+    public List<AlarmTsVo> selectByGroup(String superTableName, String stationid, long begin, long end);
+
+
+    public   List<AlarmVo> selectByTbName(String tbName,long limit,long offset);
+
+
+
+    public List<AlarmSimpleVo> selectLastRowByTbname(String superTableName, String tbnames);
+
+
+
+}
+

+ 179 - 0
alarm-custom/src/main/java/com/gyee/alarm/service/auto/impl/AlarmTsServiceImpl.java

@@ -0,0 +1,179 @@
+package com.gyee.alarm.service.auto.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.alarm.mapper.auto.AlarmTsMapper;
+import com.gyee.alarm.model.auto.AlarmTs;
+import com.gyee.alarm.model.vo.AlarmSimpleVo;
+import com.gyee.alarm.model.vo.AlarmTag;
+import com.gyee.alarm.model.vo.AlarmTsVo;
+import com.gyee.alarm.model.vo.AlarmVo;
+import com.gyee.alarm.service.auto.IAlarmTsService;
+import com.gyee.alarm.util.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+
+@Service
+public class AlarmTsServiceImpl extends ServiceImpl<AlarmTsMapper, AlarmTs> implements IAlarmTsService {
+
+    @Resource
+    private AlarmTsMapper alarmTsMapper;
+
+
+
+    public void createSuperTable(String type) {
+
+        alarmTsMapper.createAlarmSuperTable(type);
+
+    }
+
+
+    public void dropSuperTable(String type) {
+
+        alarmTsMapper.dropSuperTable(type);
+
+    }
+
+    public int createTable(String tbName, String alarmid, String alarmtype,
+                           String characteristic, String components,
+                           String description,
+                           String deviceid, String devicename,
+                           String devicetype, Boolean enabled,
+                           String lineid, String linename,
+                           String modelId, String projectid,
+                           String projectname, Integer rank,
+                           Boolean resettable, String stationid,
+                           String stationname, String subcomponents,
+                           String suffix, String tagid,
+                           Integer triggertype, String uniformcode, String superTableName,
+                          String name,String nemCode, String faultCause, String resolvent
+
+
+    ) {
+        return alarmTsMapper.createTable(tbName, alarmid, alarmtype,
+                characteristic, components,
+                description,
+                deviceid, devicename,
+                devicetype, enabled,
+                lineid, linename,
+                modelId, projectid,
+                projectname, rank,
+                resettable, stationid,
+                stationname, subcomponents,
+                suffix, tagid,
+                triggertype, uniformcode,superTableName,   name, nemCode,  faultCause,  resolvent);
+    }
+
+
+    public int createTable(AlarmVo vo) {
+        return alarmTsMapper.createTable(vo);
+    }
+
+
+
+    public int insertOne(AlarmTs one) {
+        return alarmTsMapper.insertOne(one);
+    }
+
+
+
+    public void insertList(List<AlarmTag>  alarmTags )  {
+
+        if(StringUtils.notEmp(alarmTags) && !alarmTags.isEmpty())
+        {
+
+            createSql(alarmTags);
+        }
+
+
+    }
+
+    public void createSql(List<AlarmTag>  alarmTags )   {
+
+        StringBuilder sb = new StringBuilder("INSERT INTO ");
+
+        int i=0;
+        for (AlarmTag tag:alarmTags) {
+
+            String tableName = tag.getId();
+            StringBuilder sub_sb = new StringBuilder(tableName);
+
+            sub_sb.append( " values ");
+            sub_sb.append(" (");
+            sub_sb.append(tag.getTs()).append(",").append(tag.getVal().intValue()).append(",").append(tag.getConfirmed()).append(",")
+                    .append(tag.getEndts()).append(",").append(tag.getTimeLong());
+            sub_sb.append(" ) ");
+            i++;
+            if (i==100) {
+                alarmTsMapper.insertList(String.valueOf(sb));
+                sb = new StringBuilder("INSERT INTO ");
+                i=0;
+            }
+            sb.append(sub_sb);
+
+        }
+
+        if(i!=0)
+        {
+            alarmTsMapper.insertList(String.valueOf(sb));
+        }
+
+    }
+
+
+
+
+
+    public List<AlarmVo> findTags(String stbaleName)
+    {
+        List<AlarmVo> ls=new ArrayList<>();
+        if(StringUtils.notEmp(stbaleName))
+        {
+           ls= alarmTsMapper.findTags(stbaleName);
+        }
+
+        return ls;
+    }
+
+    public List<AlarmTsVo> selectByGroup(String superTableName, String stationid, long begin, long end)
+    {
+        List<AlarmTsVo> ls=new ArrayList<>();
+        if(StringUtils.notEmp(superTableName) && StringUtils.notEmp(stationid) && StringUtils.notEmp(begin) && StringUtils.notEmp(end))
+        {
+            ls= alarmTsMapper.selectByGroup(superTableName, stationid, begin, end);
+        }
+
+        return ls;
+    }
+
+
+    public   List<AlarmVo> selectByTbName(String tbName,long limit,long offset)
+    {
+        List<AlarmVo> ls=new ArrayList<>();
+        if(StringUtils.notEmp(tbName) && StringUtils.notEmp(limit) && StringUtils.notEmp(offset))
+        {
+            ls= alarmTsMapper.selectByTbName(tbName, limit, offset);
+        }
+
+        return ls;
+    }
+
+    public List<AlarmSimpleVo> selectLastRowByTbname(String superTableName, String tbnames){
+        List<AlarmSimpleVo> ls=new ArrayList<>();
+        if(StringUtils.notEmp(superTableName) && StringUtils.notEmp(tbnames))
+        {
+            StringBuilder sb= new StringBuilder();
+            sb.append(" select last_row(*),tbname from ")
+            .append(superTableName).append(" where tbname in( ");
+            sb.append(tbnames)
+                    .append(" ) group by tbname");
+
+            ls= alarmTsMapper.selectLastRowByTbname(String.valueOf(sb));
+        }
+
+        return ls;
+    }
+}

+ 6 - 2
alarm-custom/src/main/java/com/gyee/alarm/task/thread/AlarmThread.java

@@ -3,6 +3,7 @@ package com.gyee.alarm.task.thread;
 import com.gyee.alarm.feigns.IAlarmService;
 import com.gyee.alarm.model.vo.AlarmCustomTag;
 import com.gyee.alarm.model.vo.AlarmVo;
+import com.gyee.alarm.service.auto.IAlarmTsService;
 import com.gyee.alarm.util.realtimesource.IEdosUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -28,8 +29,10 @@ public class AlarmThread implements Runnable {
     private Integer interval;
 
     private CountDownLatch countDownLatch;
+
+    private  IAlarmTsService alarmTsService;
     public AlarmThread(Executor executor, IAlarmService alarmService, List<AlarmCustomTag> alarmVoList, Integer interval,
-                       StringBuilder str, Integer readRows, CountDownLatch countDownLatch) {
+                       StringBuilder str, Integer readRows, CountDownLatch countDownLatch,IAlarmTsService alarmTsService) {
         this.executor = executor;
         this.alarmService = alarmService;
         this.alarmVoList = alarmVoList;
@@ -37,6 +40,7 @@ public class AlarmThread implements Runnable {
         this.str = str;
         this.readRows = readRows;
         this.countDownLatch = countDownLatch;
+        this.alarmTsService = alarmTsService;
     }
 
 
@@ -46,7 +50,7 @@ public class AlarmThread implements Runnable {
 
         String task = "task@ " + String.valueOf(str);
         logger.info("创建任务并提交到线程池中:" + task);
-        FutureTask<Integer> futureTask = new FutureTask<>(new AlarmThreadPool(alarmService,  alarmVoList,interval,str,readRows));
+        FutureTask<Integer> futureTask = new FutureTask<>(new AlarmThreadPool(alarmService,  alarmVoList,interval,str,readRows,alarmTsService));
 
         executor.execute(futureTask);
 

+ 114 - 87
alarm-custom/src/main/java/com/gyee/alarm/task/thread/AlarmThreadPool.java

@@ -1,15 +1,15 @@
 package com.gyee.alarm.task.thread;
 
 import com.gyee.alarm.feigns.IAlarmService;
-import com.gyee.alarm.model.vo.AlarmCustomTag;
-import com.gyee.alarm.model.vo.AlarmTag;
-import com.gyee.alarm.model.vo.AlarmTypeValue;
-import com.gyee.alarm.model.vo.DeviceTypeValue;
+import com.gyee.alarm.init.CacheContext;
+import com.gyee.alarm.model.vo.*;
 import com.gyee.alarm.rule.AlarmFunction;
 import com.gyee.alarm.rule.expression.AlarmExpression;
 import com.gyee.alarm.rule.expression.Analyzer;
+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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -19,68 +19,85 @@ import java.util.concurrent.Callable;
 
 public class AlarmThreadPool implements Callable<Integer>, Serializable {
 
-	private Logger logger = LoggerFactory.getLogger(this.getClass());
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
 
-	private static final long serialVersionUID = 0;
+    private static final long serialVersionUID = 0;
 
-	// 保存任务所需要的数据
+    // 保存任务所需要的数据
 
-	private Object threadPoolTaskData;
+    private Object threadPoolTaskData;
 
 
+    private IAlarmService alarmService;
 
-	private IAlarmService alarmService;
+    private List<AlarmCustomTag> alarmVoList;
+    private StringBuilder str;
 
-	private List<AlarmCustomTag> alarmVoList;
-	private StringBuilder str;
+    private Integer interval;
 
-	private Integer interval;
+    private Integer readRows;
+    private IAlarmTsService alarmTsService;
 
-	private Integer readRows;
+    public AlarmThreadPool(IAlarmService alarmService, List<AlarmCustomTag> alarmVoList,
+                           Integer interval, StringBuilder str, Integer readRows, IAlarmTsService alarmTsService
+    ) {
 
+        this.alarmService = alarmService;
+        this.alarmVoList = alarmVoList;
+        this.interval = interval;
+        this.str = str;
+        this.readRows = readRows;
+        this.alarmTsService = alarmTsService;
+    }
 
-	public AlarmThreadPool( IAlarmService alarmService, List<AlarmCustomTag> alarmVoList,
-						   Integer interval, StringBuilder str,Integer readRows
-	) {
+    public synchronized Integer call() throws Exception {
 
+        Integer result = 1;
 
-		this.alarmService = alarmService;
-		this.alarmVoList = alarmVoList;
-		this.interval = interval;
-		this.str = str;
-		this.readRows = readRows;
-
-	}
-
-	public synchronized Integer call() throws Exception {
-
-		Integer result = 1;
-
-		try {
+        try {
 
 //			while (runStarted)
 //			{
 
-				List<AlarmTag>  saveAlarmTags=new ArrayList<>();
-				List<AlarmTag>  updateAlarmTags=new ArrayList<>();
-				for(AlarmCustomTag vo:alarmVoList)
-				{
+            List<AlarmTag> saveAlarmTags = new ArrayList<>();
+            List<AlarmTag> updateAlarmTags = new ArrayList<>();
+
+            StringBuilder sb = new StringBuilder();
+            Map<String, AlarmSimpleVo> map = new HashMap<>();
+            for (AlarmCustomTag alarm : alarmVoList) {
+                sb.append("'").append(alarm.getId().toLowerCase()).append("',");
+            }
+            String ids = null;
+            if (sb.length() > 0) {
+                ids = sb.substring(0, sb.length() - 1);
+            }
+            List<AlarmSimpleVo> alarmls = new ArrayList<>();
+            if (null != ids) {
+                alarmls = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.CT.getCode(), ids);
+            }
+
+            if (!alarmls.isEmpty()) {
+                for (AlarmSimpleVo vo : alarmls) {
+                    map.put(vo.getTbName().toLowerCase(), vo);
+                }
+            }
+
 
-					checkRule(saveAlarmTags,updateAlarmTags,vo);
+            for (AlarmCustomTag vo : alarmVoList) {
 
-					logger.info(String.valueOf(threadPoolTaskData)+"新增报警数量:" + saveAlarmTags.size());
-					logger.info(String.valueOf(threadPoolTaskData)+"结束报警数量:" + updateAlarmTags.size());
-				}
+                checkRule(saveAlarmTags, updateAlarmTags, vo,map);
 
-				if(!saveAlarmTags.isEmpty())
-				{
-					alarmService.saveAlarm(saveAlarmTags);
-				}
+                logger.info(String.valueOf(threadPoolTaskData) + "新增报警数量:" + saveAlarmTags.size());
+                logger.info(String.valueOf(threadPoolTaskData) + "结束报警数量:" + updateAlarmTags.size());
+            }
 
-				if(!saveAlarmTags.isEmpty())
-				{
-					alarmService.updateAlarm(updateAlarmTags);
-				}
+            if (!saveAlarmTags.isEmpty()) {
+                alarmService.saveAlarm(saveAlarmTags);
+            }
+
+            if (!updateAlarmTags.isEmpty()) {
+                alarmService.updateAlarm(updateAlarmTags);
+            }
 
 
 //				try {
@@ -90,61 +107,69 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
 //				}
 //			}
 
-		} catch (Exception e) {
+        } catch (Exception e) {
 
-			e.printStackTrace();
-			result = 0;
-		}
-		threadPoolTaskData = null;
+            e.printStackTrace();
+            result = 0;
+        }
+        threadPoolTaskData = null;
 
-		return result;
+        return result;
 
-	}
+    }
 
-	private void checkRule(List<AlarmTag>  saveAlarmTags,List<AlarmTag>  updateAlarmTags,AlarmCustomTag ar) {
+    private synchronized void checkRule(List<AlarmTag> saveAlarmTags, List<AlarmTag> updateAlarmTags, AlarmCustomTag ar,Map<String, AlarmSimpleVo> map) {
 
 
-		try {
+        try {
 
-			AlarmExpression alarmExpression = Analyzer.getAlarmExpression(ar.getTagId());
+            AlarmExpression alarmExpression = Analyzer.getAlarmExpression(ar.getTagId());
 
-			AlarmFunction alarmFunction=null;
+            AlarmFunction alarmFunction = null;
 
-			if (ar.getDevicetype().equals(DeviceTypeValue.WT.getCode()) ) {
-				 alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.WT, ar.getDeviceid());
+            if (ar.getDevicetype().equals(DeviceTypeValue.WT.getCode())) {
+                alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.WT, ar.getDeviceid());
 
 
+            } else if (ar.getDevicetype().equals(DeviceTypeValue.BT.getCode())) {
+                alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.BT, ar.getStationid());
 
-			}
-//			else if (ar.getDevicetype().equals(DeviceTypeValue.WP.getCode()) ) {
-//				 alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.WP, ar.getStationid());
-//
-//
-//			}
-			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) {
 
-			try {
+					boolean endStatus=false;
+					if(map.containsKey(ar.getId().toLowerCase()))
+					{
+						AlarmSimpleVo vo=map.get(ar.getId().toLowerCase());
 
-                    Object obj = alarmFunction.explain();
-                    if (obj instanceof Boolean) {
+						if(StringUtils.notEmp(vo.getEndts()))
+						{
+							endStatus=true;
+						}
+					}
+                    if (true == (boolean) obj) {
 
-                        if (true == (boolean) obj) {
-
-							AlarmTag po=new AlarmTag();
+						if(endStatus)
+						{
+							AlarmTag po = new AlarmTag();
 							po.setId(ar.getId());
 							po.setTs(new Date().getTime());
-							po.setEndts(new Date().getTime());
+							po.setEndts(null);
 							po.setVal(1.0);
 							po.setTimeLong(0.0);
 
 							saveAlarmTags.add(po);
+						}
+
+                    } else {
 
-                        } else {
-							AlarmTag po=new AlarmTag();
+						if(!endStatus)
+						{
+							AlarmTag po = new AlarmTag();
 							po.setId(ar.getId());
 							po.setTs(new Date().getTime());
 							po.setEndts(new Date().getTime());
@@ -152,18 +177,20 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
 							po.setTimeLong(0.0);
 
 							updateAlarmTags.add(po);
-                        }
-                    } else {
-                       // System.out.print(obj.toString());
+						}
+
                     }
-                } catch (Exception ex) {
-                   // ex.printStackTrace();
-				logger.error("自定义报警规则执行时出错!"+alarmFunction.getThingId()+"--"+ar.getTagId()+"----" + ex.getMessage());
+                } else {
+                    // System.out.print(obj.toString());
                 }
-
-		} catch (Exception ex) {
-			logger.error("生成自定义报警规则失败!规则id:" + ar.getId());
-		}
-	}
+            } catch (Exception ex) {
+                // ex.printStackTrace();
+                logger.error("自定义报警规则执行时出错!" + alarmFunction.getThingId() + "--" + ar.getTagId() + "----" + ex.getMessage());
+            }
+
+        } catch (Exception ex) {
+            logger.error("生成自定义报警规则失败!规则id:" + ar.getId());
+        }
+    }
 
 }

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

@@ -173,7 +173,7 @@ urls:
 
 task-count: 3
 read-count: 2
-interval: 1
+interval: 3
 
 #WT("wt_alarms", "设备报警超级表"),
 #BT("bt_alarms", "升压站报警超级表"),

+ 16 - 16
alarm-scanner/src/main/java/com/gyee/alarm/ApplicationReadyEventListener.java

@@ -28,20 +28,20 @@ public class ApplicationReadyEventListener implements
 
 
 
-    /**
-     * 统计内报故障损失电量
-     */
-    @Scheduled(cron = "0 0/16 * * * ?")
-    //或直接指定时间间隔,例如:5秒
-    //@Scheduled(fixedRate=5000)
-
-    private void saveFaultrecord() {
-
-        try {
-            calculateServer.stop();
-            calculateServer.start();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
+//    /**
+//     * 重启读取报警信息
+//     */
+//    @Scheduled(cron = "0 0/16 * * * ?")
+//    //或直接指定时间间隔,例如:5秒
+//    //@Scheduled(fixedRate=5000)
+//
+//    private void saveFaultrecord() {
+//
+//        try {
+//            calculateServer.stop();
+//            calculateServer.start();
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//    }
 }

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

@@ -35,7 +35,7 @@ public class AlarmTag {
     /**
      * 过去值
      */
-    private Double oval;
+    private Double oval=null;
 
     /**
      * 报警级别
@@ -52,7 +52,7 @@ public class AlarmTag {
     /**
      * 更新并检测是否触发报警
      */
-    public Boolean updateAndCheck(PointData pointData) {
+    public synchronized Boolean updateAndCheck(PointData pointData) {
 
         if(null ==oval)
         {

+ 3 - 2
alarm-scanner/src/main/java/com/gyee/alarm/service/AlarmScannerService.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
 
@@ -38,7 +39,7 @@ public class AlarmScannerService {
     @Resource
     private IAlarmService alarmService;
 
-    private List<AlarmTag>  alarmTags=new ArrayList<>();
+    private List<AlarmTag>  alarmTags=new CopyOnWriteArrayList<>();
     @Resource
     @Qualifier(value = "taskExecutor")
     private Executor executor;
@@ -105,7 +106,7 @@ public class AlarmScannerService {
             countDownLatch.await();
             log.info("报警排查完成!");
             try {
-                Thread.sleep((interval * 500));
+                Thread.sleep((interval * 1000));
             } catch (InterruptedException e) {
                 throw new RuntimeException(e);
             }

+ 2 - 2
alarm-scanner/src/main/resources/application-bt.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
 
 #分隔10个线程
 task-count: 10

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

@@ -552,6 +552,7 @@ public class AlarmCtService {
 
                 }
                 String ids=null;
+
                 if(sb.length()>0)
                 {
                     ids=sb.substring(0,sb.length()-1);

+ 159 - 152
alarm-service/src/main/java/com/gyee/alarm/service/PushDataSevice.java

@@ -33,17 +33,17 @@ public class PushDataSevice {
 
     @Resource
     private WebSocketBt webSocketBt;
-    public  void pushWtData(AlarmTag po) throws EncodeException, IOException {
+
+    public void pushWtData(AlarmTag po) throws EncodeException, IOException {
         ConcurrentHashMap<String, WebSocket> webSocketPushMap = WebSocket.webSocketMap;
         ConcurrentHashMap<String, PushParams> webSocketPushParamsMap = WebSocket.webSocketParamsMap;
 
-        if(!webSocketPushMap.isEmpty()){
-            for(String key : webSocketPushMap.keySet()){
+        if (!webSocketPushMap.isEmpty()) {
+            for (String key : webSocketPushMap.keySet()) {
                 // 根据ws连接用户ID获取推送参数
 
 
-                synchronized(po.getId())
-                {
+                synchronized (po.getId()) {
 //                    if(webSocketPushParamsMap.contains(po.getId()))
 //                    {
 //                        PushParams pp=webSocketPushParamsMap.get(po.getId());
@@ -71,9 +71,8 @@ public class PushDataSevice {
 //
 //                    }
 
-                    if(checkWtId(key,po.getDeviceId()))
-                    {
-                        webSocket.sendMessageByUserId(key,po);
+                    if (checkWtId(key, po.getDeviceId())) {
+                        webSocket.sendMessageByUserId(key, po);
 
 
                     }
@@ -84,83 +83,95 @@ public class PushDataSevice {
 
     }
 
-    public  void pushBtData(AlarmTag po) throws EncodeException, IOException {
+    public void pushBtData(AlarmTag po) throws EncodeException, IOException {
         ConcurrentHashMap<String, WebSocket> webSocketPushMap = WebSocket.webSocketMap;
         ConcurrentHashMap<String, WebSocketBt> webSocketPushBtMap = WebSocketBt.webSocketBtMap;
         ConcurrentHashMap<String, PushParams> webSocketPushParamsMap = WebSocket.webSocketParamsMap;
 
         ConcurrentHashMap<String, List<String>> btParamsMap = WebSocketBt.btParamsMap;
 
-        if(!webSocketPushMap.isEmpty()){
-            for(String key : webSocketPushMap.keySet()){
+        if (!webSocketPushMap.isEmpty()) {
+            for (String key : webSocketPushMap.keySet()) {
                 // 根据ws连接用户ID获取推送参数
 //                PushParams pushParams = webSocketPushParamsMap.get(key);
-                synchronized(po.getId())
-                {
-                    if(checkBtId(key,po.getWpId()))
-                    {
-                        webSocket.sendMessageByUserId(key,po);
+                synchronized (po.getId()) {
+                    if (checkBtId(key, po.getWpId())) {
+                        webSocket.sendMessageByUserId(key, po);
 
                     }
                 }
             }
         }
 
-        if(!webSocketPushBtMap.isEmpty()){
-            for(String key : webSocketPushBtMap.keySet()){
-                // 根据ws连接用户ID获取推送参数
-//                PushParams pushParams = webSocketPushParamsMap.get(key);
+        if (!webSocketPushBtMap.isEmpty()) {
+
+            synchronized (po.getId()) {
+
+
+                if (po.getRank() > 3) {
+
+                    if (btParamsMap.containsKey(po.getWpId())) {
+
+                        List<String> btls = btParamsMap.get(po.getWpId());
 
+                        if (btls.contains(po.getAlarmId())) {
+                            btls.remove(po.getAlarmId());
+                        } else {
+                            btls.add(po.getAlarmId());
+                        }
+                        if (btls.isEmpty()) {
+                            for (String key : webSocketPushBtMap.keySet()) {
 
-                synchronized(po.getId())
-                {
-                    if(checkBtId(key,po.getWpId()))
-                    {
-                        if(po.getRank()>3)
-                        {
-                            if(btParamsMap.containsKey(po.getWpId()))
-                            {
-                                List<String> btls=btParamsMap.get(po.getWpId());
-
-                                if(btls.contains(po.getAlarmId()))
-                                {
-                                    btls.remove(po.getAlarmId());
-                                }else
-                                {
-                                    btls.add(po.getAlarmId());
+                                if (checkBtId(key, po.getWpId())) {
+                                    Map<String, Boolean> map = new HashMap<>();
+                                    map.put(po.getWpId(), false);
+                                    webSocketBt.sendMessageByUserId(key, map);
                                 }
-                                if(btls.isEmpty())
-                                {
-                                    Map<String,Boolean> map=new HashMap<>();
-                                    map.put(po.getWpId(),false);
-                                    webSocketBt.sendMessageByUserId(key,map);
-                                }else
-                                {
-                                    Map<String,Boolean> map=new HashMap<>();
-                                    map.put(po.getWpId(),true);
-                                    webSocketBt.sendMessageByUserId(key,map);
+                            }
+
+                        } else {
+
+                            for (String key : webSocketPushBtMap.keySet()) {
+
+                                if (checkBtId(key, po.getWpId())) {
+                                    Map<String, Boolean> map = new HashMap<>();
+                                    map.put(po.getWpId(), true);
+                                    webSocketBt.sendMessageByUserId(key, map);
                                 }
-                            }else
-                            {
-                                List<String> btls=new ArrayList<>();
-
-                                btls.add(po.getAlarmId());
-                                btParamsMap.put(po.getWpId(),btls);
-                                Map<String,Boolean> map=new HashMap<>();
-                                if(StringUtils.empty(po.getIsClose()))
-                                {
-                                    map.put(po.getWpId(),false);
-                                    webSocketBt.sendMessageByUserId(key,map);
-                                }else
-                                {
-                                    map.put(po.getWpId(),true);
-                                    webSocketBt.sendMessageByUserId(key,map);
+                            }
+                        }
+                    } else {
+                        List<String> btls = new ArrayList<>();
+
+                        btls.add(po.getAlarmId());
+
+                        btParamsMap.put(po.getWpId(), btls);
+
+                        if (StringUtils.empty(po.getIsClose())) {
+                            for (String key : webSocketPushBtMap.keySet()) {
+
+
+                                if (checkBtId(key, po.getWpId())) {
+                                    Map<String, Boolean> map = new HashMap<>();
+                                    map.put(po.getWpId(), false);
+                                    webSocketBt.sendMessageByUserId(key, map);
                                 }
+                            }
+
+                        } else {
+                            for (String key : webSocketPushBtMap.keySet()) {
 
+
+                                if (checkBtId(key, po.getWpId())) {
+                                    Map<String, Boolean> map = new HashMap<>();
+                                    map.put(po.getWpId(), true);
+                                    webSocketBt.sendMessageByUserId(key, map);
+                                }
                             }
+
                         }
-                    }
 
+                    }
                 }
 
             }
@@ -168,63 +179,61 @@ public class PushDataSevice {
 
     }
 
-    private boolean checkWtId(String userId,String wtId) {
+    private boolean checkWtId(String userId, String wtId) {
 
 
-        boolean result=false;
-        List<String> depls = sysUserService.getUserByuserId(Long.valueOf(userId));
-        if (!depls.isEmpty()) {
-            String depId = depls.get(0);
+        boolean result = false;
 
-            if (CacheContext.wpwtmap.containsKey(depId)) {
+        if (StringUtils.notEmp(userId)) {
+            String[] str = userId.split("_");
+            if (str.length == 2) {
+                List<String> depls = sysUserService.getUserByuserId(Long.valueOf(str[0]));
+                if (!depls.isEmpty()) {
+                    String depId = depls.get(0);
 
-                List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(depId);
-                for(ProBasicEquipment wt:wtls)
-                {
-                   if(wt.getId().equals(wtId))
-                   {
-                       result=true;
-                       break;
-                   }
+                    if (CacheContext.wpwtmap.containsKey(depId)) {
 
-                }
+                        List<ProBasicEquipment> wtls = CacheContext.wpwtmap.get(depId);
+                        for (ProBasicEquipment wt : wtls) {
+                            if (wt.getId().equals(wtId)) {
+                                result = true;
+                                break;
+                            }
 
-            } else if (CacheContext.cmwtlsmap.containsKey(depId)) {
+                        }
 
-                List<ProBasicEquipment> wtls=CacheContext.cmwtlsmap.get(depId);
-                for(ProBasicEquipment wt:wtls)
-                {
-                    if( wt.getId().equals(wtId))
-                    {
-                        result=true;
-                        break;
-                    }
+                    } else if (CacheContext.cmwtlsmap.containsKey(depId)) {
 
-                }
+                        List<ProBasicEquipment> wtls = CacheContext.cmwtlsmap.get(depId);
+                        for (ProBasicEquipment wt : wtls) {
+                            if (wt.getId().equals(wtId)) {
+                                result = true;
+                                break;
+                            }
 
-            } else if (CacheContext.rgwtlsmap.containsKey(depId)) {
+                        }
 
-                List<ProBasicEquipment> wtls=CacheContext.rgwtlsmap.get(depId);
-                for(ProBasicEquipment wt:wtls)
-                {
-                    if( wt.getId().equals(wtId))
-                    {
-                        result=true;
-                        break;
-                    }
+                    } else if (CacheContext.rgwtlsmap.containsKey(depId)) {
 
-                }
+                        List<ProBasicEquipment> wtls = CacheContext.rgwtlsmap.get(depId);
+                        for (ProBasicEquipment wt : wtls) {
+                            if (wt.getId().equals(wtId)) {
+                                result = true;
+                                break;
+                            }
 
-            }else  if(depId.equals("0"))
-            {
-                for(ProBasicEquipment wt:CacheContext.wtls)
-                {
-                    if( wt.getId().equals(wtId))
-                    {
-                        result=true;
-                        break;
-                    }
+                        }
 
+                    } else if (depId.equals("0")) {
+                        for (ProBasicEquipment wt : CacheContext.wtls) {
+                            if (wt.getId().equals(wtId)) {
+                                result = true;
+                                break;
+                            }
+
+                        }
+
+                    }
                 }
 
             }
@@ -234,68 +243,66 @@ public class PushDataSevice {
     }
 
 
-    private boolean checkBtId(String userId,String btId) {
+    private boolean checkBtId(String userId, String btId) {
 
 
-        boolean result=false;
-        List<String> depls = sysUserService.getUserByuserId(Long.valueOf(userId));
-        if (!depls.isEmpty()) {
-            String depId = depls.get(0);
+        boolean result = false;
 
-            if (CacheContext.wpmap.containsKey(depId)) {
+        if (StringUtils.notEmp(userId)) {
+            String[] str = userId.split("_");
+            if (str.length == 2) {
+                List<String> depls = sysUserService.getUserByuserId(Long.valueOf(str[0]));
+                if (!depls.isEmpty()) {
+                    String depId = depls.get(0);
 
-                ProBasicPowerstation wp=CacheContext.wpmap.get(depId);
+                    if (CacheContext.wpmap.containsKey(depId)) {
 
-                if(CacheContext.subwpmap.containsKey(btId))
-                {
-                    ProBasicSubStation sub= CacheContext.subwpmap.get(btId);
-                    if(sub.getWindpowerstationId().equals(wp.getId()))
-                    {
-                        result=true;
-                    }
-                }
+                        ProBasicPowerstation wp = CacheContext.wpmap.get(depId);
 
-            } else if (CacheContext.cpwpmap.containsKey(depId)) {
-
-                List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(depId);
-                for(ProBasicPowerstation wp:wpls)
-                {
-                    if(CacheContext.subwpmap.containsKey(btId))
-                    {
-                        ProBasicSubStation sub= CacheContext.subwpmap.get(btId);
-                        if(sub.getWindpowerstationId().equals(wp.getId()))
-                        {
-                            result=true;
-                            break;
+                        if (CacheContext.subwpmap.containsKey(btId)) {
+                            ProBasicSubStation sub = CacheContext.subwpmap.get(btId);
+                            if (sub.getWindpowerstationId().equals(wp.getId())) {
+                                result = true;
+                            }
                         }
-                    }
 
-                }
+                    } else if (CacheContext.cpwpmap.containsKey(depId)) {
+
+                        List<ProBasicPowerstation> wpls = CacheContext.cpwpmap.get(depId);
+                        for (ProBasicPowerstation wp : wpls) {
+                            if (CacheContext.subwpmap.containsKey(btId)) {
+                                ProBasicSubStation sub = CacheContext.subwpmap.get(btId);
+                                if (sub.getWindpowerstationId().equals(wp.getId())) {
+                                    result = true;
+                                    break;
+                                }
+                            }
 
-            } else if (CacheContext.rgwpmap.containsKey(depId)) {
-
-                List<ProBasicPowerstation> wpls=CacheContext.rgwpmap.get(depId);
-                for(ProBasicPowerstation wp:wpls)
-                {
-                    if(CacheContext.subwpmap.containsKey(btId))
-                    {
-                        ProBasicSubStation sub= CacheContext.subwpmap.get(btId);
-                        if(sub.getWindpowerstationId().equals(wp.getId()))
-                        {
-                            result=true;
-                            break;
                         }
-                    }
 
-                }
+                    } else if (CacheContext.rgwpmap.containsKey(depId)) {
 
-            }else  if(depId.equals("0"))
-            {
-                result=true;
+                        List<ProBasicPowerstation> wpls = CacheContext.rgwpmap.get(depId);
+                        for (ProBasicPowerstation wp : wpls) {
+                            if (CacheContext.subwpmap.containsKey(btId)) {
+                                ProBasicSubStation sub = CacheContext.subwpmap.get(btId);
+                                if (sub.getWindpowerstationId().equals(wp.getId())) {
+                                    result = true;
+                                    break;
+                                }
+                            }
+
+                        }
+
+                    } else if (depId.equals("0")) {
+                        result = true;
 
+                    }
+                }
             }
         }
 
+
         return result;
     }
 }

+ 15 - 15
alarm-service/src/main/java/com/gyee/alarm/task/thread/SaticScheduleTask.java

@@ -19,21 +19,21 @@ import javax.annotation.Resource;
 @EnableScheduling   // 2.开启定时任务
 public class SaticScheduleTask {
 
-    @Resource
-    private ReloadVoSevice reloadVoSevice;
-
-    /**
-     * 重新读取配置信息
-     */
-    @Scheduled(cron = "0 0/9 * * * ?")
-    private void reloadData() {
-
-        try {
-            reloadVoSevice.reload();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
+//    @Resource
+//    private ReloadVoSevice reloadVoSevice;
+//
+//    /**
+//     * 重新读取配置信息
+//     */
+//    @Scheduled(cron = "0 0/9 * * * ?")
+//    private void reloadData() {
+//
+//        try {
+//            reloadVoSevice.reload();
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//    }
 
 
 }

+ 2 - 1
alarm-service/src/main/java/com/gyee/alarm/websocket/WebSocketBt.java

@@ -88,9 +88,10 @@ public class WebSocketBt {
      * @param message 客户端发送过来的消息
      */
     @OnMessage
-    public void onMessage(String message, Session session) {
+    public void onMessage(String message, Session session) throws IOException {
         logger.info("Bt来自客户端用户:{} 消息:{}",userId, message);
 
+        sendMessageByUserId(userId,"ok");
         //群发消息
         /*for (String item : webSocketBtMap.keySet()) {
             try {

+ 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();

+ 4 - 4
alarm-web/src/main/java/com/gyee/alarm/controller/AlarmConfigurationController.java

@@ -105,16 +105,16 @@ public class AlarmConfigurationController {
     @ApiOperation(value = "分页查询", notes = "分页查询")
     @ApiImplicitParams({
 
-            @ApiImplicitParam(name = "pagenum", value = "页号", required = true, dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "pagesize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "pageNum", value = "页号", required = true, dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "pageSize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "wpId", value = "风场编号", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "modelId", value = "型号编号", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "alarmType", value = "报警类型", required = false, dataType = "string", paramType = "query")})
 
     public AjaxResult queryByPage(HttpServletRequest request,
-                                  @RequestParam(value = "pagenum") Integer pageNum,
-                                  @RequestParam(value = "pagesize") Integer pageSize,
+                                  @RequestParam(value = "pageNum") Integer pageNum,
+                                  @RequestParam(value = "pageSize") Integer pageSize,
                                   @RequestParam(value = "name", required = false) String name,
                                   @RequestParam(value = "wpId", required = false) String wpId,
                                   @RequestParam(value = "modelId", required = false) String modelId,

+ 7 - 1
alarm-web/src/main/java/com/gyee/alarm/controller/AlarmHistoryController.java

@@ -116,6 +116,7 @@ public class AlarmHistoryController {
             @ApiImplicitParam(name = "modelId", value = "型号编号", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "components", value = "部件编号", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "alarmIds", value = "报警编号集合", required = false, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "alarmType", value = "报警类型 booststation:升压站报警,windturbine:设备报警", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "timeType", value = "秒、分、时(s,m,h)", required = false, dataType = "string", paramType = "query")
            })
     public List<Map.Entry<String, List<AlarmStatVo>>> findWtFeatureStat(
@@ -126,6 +127,7 @@ public class AlarmHistoryController {
             @RequestParam(value = "modelId", required = false) String modelId,
             @RequestParam(value = "components", required = false) String components,
             @RequestParam(value = "alarmIds", required = false) String alarmIds,
+            @RequestParam(value = "alarmType", required = false) String alarmType,
             @RequestParam(value = "timeType", required = false) String timeType
     ) throws ParseException {
 
@@ -146,7 +148,11 @@ public class AlarmHistoryController {
         {
             alarmIds=null;
         }
-        List<AlarmStatVo> pressureList = alarmHistoryService.findWtFeatureStat(stId,modelId, dtStart, dtEnd,components,alarmIds,timeType);
+        if(StringUtils.empty(alarmType))
+        {
+            alarmType=null;
+        }
+        List<AlarmStatVo> pressureList = alarmHistoryService.findWtFeatureStat(stId,modelId, dtStart, dtEnd,components,alarmIds,alarmType,timeType);
 
 
         //根据风机编号分组

+ 15 - 5
alarm-web/src/main/java/com/gyee/alarm/controller/AlertRuleController.java

@@ -82,6 +82,16 @@ public class AlertRuleController {
                     modells.add(wt.getModelId());
                 }
             }
+        }else
+        {
+            List<ProEconEquipmentmodel> wtls=CacheContext.equipmentmodels;
+            for(ProEconEquipmentmodel wt:wtls)
+            {
+                if(!modells.contains(wt.getId()))
+                {
+                    modells.add(wt.getId());
+                }
+            }
         }
 
         if (StringUtils.notEmp(modells)) {
@@ -407,19 +417,19 @@ public class AlertRuleController {
     @ApiOperation(value = "分页查询", notes = "分页查询")
     @ApiImplicitParams({
 
-            @ApiImplicitParam(name = "pagenum", value = "页号", required = true, dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "pagesize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "pageNum", value = "页号", required = true, dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "pageSize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "wpId", value = "风场编号", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "modelId", value = "型号编号", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "rank", value = "级别", required = false, dataType = "string", paramType = "query"),
-            @ApiImplicitParam(name = "category", value = "类别(booststation:升压站报警,windturbine:风机报警)", required = false, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "category", value = "类别(booststation:升压站报警,windturbine:风机报警,inverter:逆变器)", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "enabled", value = "是否可用", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "relatedparts", value = "部件", required = false, dataType = "string", paramType = "query")})
 
     public AjaxResult queryByPage(HttpServletRequest request,
-                                  @RequestParam(value = "pagenum") Integer pageNum,
-                                  @RequestParam(value = "pagesize") Integer pageSize,
+                                  @RequestParam(value = "pageNum") Integer pageNum,
+                                  @RequestParam(value = "pageSize") Integer pageSize,
                                   @RequestParam(value = "name", required = false) String name,
                                   @RequestParam(value = "wpId", required = false) String wpId,
                                   @RequestParam(value = "modelId", required = false) String modelId,

+ 2 - 2
alarm-web/src/main/java/com/gyee/alarm/controller/ProBasicDeviceController.java

@@ -147,8 +147,8 @@ public class ProBasicDeviceController {
     }
     @GetMapping(value = "/metrics/page")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "pagenum", value = "当前页", required = true, dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "pagesize", value = "分页大小", required = true, dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "deviceId", value = "设备类型", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "structureCode", value = "结构码", required = true, dataType = "string", paramType = "query")})
     @ApiOperation(value = "分页查询标准测点")

+ 7 - 3
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,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
+            "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," +
                     "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode,nemCode ,faultCause,resolvent from #{superTableName} " ,
             "<where>" ,
             " ts &gt;= #{begin}",
@@ -215,7 +215,7 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
 //    @Select("select deviceid as wtId,stationid as stationId,alarmid,description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmWt where ts>=#{begin} and ts<=#{end}  and alarmtype='windturbine'  and #{begin} group by deviceid,components,stationid,alarmid,description")
 
     @Select({"<script>",
-            "select deviceid as wtId,stationid as stationId,alarmid,description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmWt " ,
+            "select deviceid as wtId,stationid as stationId,alarmid,description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from #{superTableName} " ,
             "<where>" ,
 
             " ts &gt;= #{begin}",
@@ -231,12 +231,16 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "<if test='modelId != null'>",
             "and modelId = #{modelId}",
             "</if>",
+            "<if test='alarmType != null'>",
+            "and alarmType = #{alarmType}",
+            "</if>",
+
             "</where>",
 
             " group by deviceid,components,stationid,alarmid,description ",
             " order by deviceid  ",
             "</script>"})
-    List<ProBasicFeatureStat> findWtFeatureStat( @Param("begin")long begin, @Param("end") long end, @Param("stationid") String stationid, @Param("modelId")String modelId,@Param("components") String components, @Param("alarmid") String alarmid);
+    List<ProBasicFeatureStat> findWtFeatureStat(@Param("superTableName") String superTableName, @Param("begin")long begin, @Param("end") long end, @Param("stationid") String stationid, @Param("modelId")String modelId,@Param("components") String components, @Param("alarmid") String alarmid, @Param("alarmType") String alarmType);
 
 
     @Select({"<script>",

+ 7 - 4
alarm-web/src/main/java/com/gyee/alarm/model/vo/AlarmVo.java

@@ -9,15 +9,15 @@ import java.sql.Timestamp;
 public class AlarmVo {
 
     private  String tbName;
-    private String alarmid;
-    private String alarmtype;
+    private String alarmId;
+    private String alarmType;
     private String characteristic;
     private String components;
     private Boolean confirmed;
     private String description;
-    private String deviceid;
+    private String deviceId;
     private String devicename;
-    private String devicetype;
+    private String deviceType;
     private Boolean enabled;
     private String lineid;
     private String linename;
@@ -62,5 +62,8 @@ public class AlarmVo {
      * 排查方法
      */
     private String resolvent;
+    private String wpName;
+    private String code;
+    private String wpId;
 
 }

+ 4 - 4
alarm-web/src/main/java/com/gyee/alarm/service/AlarmBtService.java

@@ -46,15 +46,15 @@ public class AlarmBtService {
                     StringBuilder tbName = new StringBuilder();
                     tbName.append(alarm.getStationId()).append("_").append(alarm.getId());
                     vo.setTbName(String.valueOf(tbName));
-                    vo.setAlarmid(alarm.getId());
+                    vo.setAlarmId(alarm.getId());
                     vo.setTagid(alarm.getTagId());
-                    vo.setAlarmtype(alarm.getAlarmType());
+                    vo.setAlarmType(alarm.getAlarmType());
                     vo.setCharacteristic(alarm.getCharacteristic());
                     vo.setComponents(alarm.getComponents());
                     vo.setDescription(alarm.getDescription());
-                    vo.setDeviceid("");
+                    vo.setDeviceId("");
                     vo.setDevicename("");
-                    vo.setDevicetype(DeviceTypeValue.BT.getCode());
+                    vo.setDeviceType(DeviceTypeValue.BT.getCode());
                     vo.setEnabled(alarm.getEnable());
                     vo.setLineid("");
                     vo.setLinename("");

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

@@ -84,15 +84,15 @@ public class AlarmCtService {
                         StringBuilder tbName = new StringBuilder();
                         tbName.append(wt.getId()).append("_").append(alarm.getId());
                         vo.setTbName(String.valueOf(tbName));
-                        vo.setAlarmid(alarm.getId());
+                        vo.setAlarmId(alarm.getId());
                         vo.setTagid(alarm.getExpression());
-                        vo.setAlarmtype(AlarmTypeValue.CT.getCode());
+                        vo.setAlarmType(AlarmTypeValue.CT.getCode());
                         vo.setCharacteristic(alarm.getName());
                         vo.setComponents(alarm.getRelatedParts());
                         vo.setDescription(alarm.getDescription());
-                        vo.setDeviceid(wt.getId());
+                        vo.setDeviceId(wt.getId());
                         vo.setDevicename(wt.getName());
-                        vo.setDevicetype(DeviceTypeValue.WT.getCode());
+                        vo.setDeviceType(DeviceTypeValue.WT.getCode());
                         vo.setEnabled(alarm.getEnable());
                         vo.setLineid(wt.getLineId());
                         if (CacheContext.lnmap.containsKey(wt.getLineId())) {
@@ -166,15 +166,15 @@ public class AlarmCtService {
                         StringBuilder tbName = new StringBuilder();
                         tbName.append(wt.getId()).append("_").append(alarm.getId());
                         vo.setTbName(String.valueOf(tbName));
-                        vo.setAlarmid(alarm.getId());
+                        vo.setAlarmId(alarm.getId());
                         vo.setTagid(alarm.getExpression());
-                        vo.setAlarmtype(AlarmTypeValue.CT.getCode());
+                        vo.setAlarmType(AlarmTypeValue.CT.getCode());
                         vo.setCharacteristic(alarm.getName());
                         vo.setComponents(alarm.getRelatedParts());
                         vo.setDescription(alarm.getDescription());
-                        vo.setDeviceid(wt.getId());
+                        vo.setDeviceId(wt.getId());
                         vo.setDevicename(wt.getName());
-                        vo.setDevicetype(DeviceTypeValue.IN.getCode());
+                        vo.setDeviceType(DeviceTypeValue.IN.getCode());
                         vo.setEnabled(alarm.getEnable());
                         vo.setLineid(wt.getLineId());
                         if (CacheContext.lnmap.containsKey(wt.getLineId())) {
@@ -226,15 +226,15 @@ public class AlarmCtService {
                     StringBuilder tbName = new StringBuilder();
                     tbName.append(wp.getId()).append("_").append(alarm.getId());
                     vo.setTbName(String.valueOf(tbName));
-                    vo.setAlarmid(alarm.getId());
+                    vo.setAlarmId(alarm.getId());
                     vo.setTagid(alarm.getExpression());
-                    vo.setAlarmtype(AlarmTypeValue.CT.getCode());
+                    vo.setAlarmType(AlarmTypeValue.CT.getCode());
                     vo.setCharacteristic(alarm.getName());
                     vo.setComponents(alarm.getRelatedParts());
                     vo.setDescription(alarm.getDescription());
-                    vo.setDeviceid("");
+                    vo.setDeviceId("");
                     vo.setDevicename("");
-                    vo.setDevicetype(DeviceTypeValue.WP.getCode());
+                    vo.setDeviceType(DeviceTypeValue.WP.getCode());
                     vo.setEnabled(alarm.getEnable());
                     vo.setLineid("");
                     vo.setLinename("");
@@ -309,15 +309,15 @@ public class AlarmCtService {
 
                     tbName.append(wp.getId()).append("_").append(alarm.getId());
                     vo.setTbName(String.valueOf(tbName));
-                    vo.setAlarmid(alarm.getId());
+                    vo.setAlarmId(alarm.getId());
                     vo.setTagid(alarm.getExpression());
-                    vo.setAlarmtype(AlarmTypeValue.CT.getCode());
+                    vo.setAlarmType(AlarmTypeValue.CT.getCode());
                     vo.setCharacteristic(alarm.getName());
                     vo.setComponents(alarm.getRelatedParts());
                     vo.setDescription(alarm.getDescription());
-                    vo.setDeviceid("");
+                    vo.setDeviceId("");
                     vo.setDevicename("");
-                    vo.setDevicetype(DeviceTypeValue.BT.getCode());
+                    vo.setDeviceType(DeviceTypeValue.BT.getCode());
                     vo.setEnabled(alarm.getEnable());
                     vo.setLineid("");
                     vo.setLinename("");

+ 37 - 6
alarm-web/src/main/java/com/gyee/alarm/service/AlarmHistoryService.java

@@ -165,14 +165,14 @@ public class AlarmHistoryService   {
                         po.setLastUpdateTime(new Date());
                         po.setTagId(alarm.getTagId());
                         po.setTriggerType(alarm.getTriggerType());
-                        po.setAlarmId(vo.getAlarmid());
-                        po.setDeviceId(vo.getDeviceid());
+                        po.setAlarmId(vo.getAlarmId());
+                        po.setDeviceId(vo.getDeviceId());
                         po.setSubcomponents(vo.getSuffix());
                         po.setRank(vo.getRank());
                         po.setConfirmed(alarm.getConfirmed());
                         po.setUniformCode(vo.getUniformcode());
-                        po.setAlarmType(vo.getAlarmtype());
-                        po.setDeviceType(vo.getDevicetype());
+                        po.setAlarmType(vo.getAlarmType());
+                        po.setDeviceType(vo.getDeviceType());
                         po.setComponents(vo.getComponents());
                         po.setSubcomponents(vo.getSubcomponents());
                         po.setDescription(vo.getDescription());
@@ -321,6 +321,27 @@ public class AlarmHistoryService   {
             isclose=null;
         }
         vos = alarmTsMapper.selectByWtLimit(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components, alarmId,isclose,pageNum*pageSize, pageSize);
+
+        for(AlarmVo vo:vos)
+        {
+
+            if(com.gyee.alarm.util.StringUtils.notEmp(vo.getDeviceId()) && CacheContext.wtmap.containsKey(vo.getDeviceId()))
+            {
+                vo.setCode(CacheContext.wtmap.get(vo.getDeviceId()).getNemCode());
+            }
+
+            if(CacheContext.wpmap.containsKey(vo.getStationid()))
+            {
+                vo.setWpName(CacheContext.wpmap.get(vo.getStationid()).getName());
+            }
+
+            if(CacheContext.subwpmap.containsKey(vo.getStationid()))
+            {
+                vo.setWpName(CacheContext.subwpmap.get(vo.getStationid()).getName());
+            }
+        }
+
+
         map.put("ls",vos);
         List<Integer> total=alarmTsMapper.selectByWtCount(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components,alarmId,isclose);
 
@@ -366,7 +387,7 @@ public class AlarmHistoryService   {
     }
 
 
-    public List<AlarmStatVo> findWtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components,String alarmIds,String timeType) {
+    public List<AlarmStatVo> findWtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components,String alarmIds,String alarmType,String timeType) {
         List<AlarmStatVo> resultList = new ArrayList<>();
 
         StringBuilder alarmIdList=new StringBuilder();
@@ -405,8 +426,18 @@ public class AlarmHistoryService   {
         {
             component=String.valueOf(componentsList.substring(0,componentsList.length()-1));
         }
-        List<ProBasicFeatureStat> fsls = alarmTsMapper.findWtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId);
+        List<ProBasicFeatureStat> fsls = new ArrayList<>();
+        if(alarmType.equals(AlarmTypeValue.BT.getCode()))
+        {
+            fsls = alarmTsMapper.findWtFeatureStat(AlarmSuperTalbeType.BT.getCode(), startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId, alarmType);
 
+        }else if(alarmType.equals(AlarmTypeValue.WT.getCode()))
+        {
+            fsls = alarmTsMapper.findWtFeatureStat(AlarmSuperTalbeType.WT.getCode(),startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId, alarmType);
+        }else if(alarmType.equals(AlarmTypeValue.IN.getCode()))
+        {
+            fsls = alarmTsMapper.findWtFeatureStat(AlarmSuperTalbeType.WT.getCode(),startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId, alarmType);
+        }
 
         Map<String, ProBasicFeatureStat> map = new HashMap<>();
         Date statDate=DateUtils.truncate(new Date());

+ 4 - 4
alarm-web/src/main/java/com/gyee/alarm/service/AlarmInService.java

@@ -67,15 +67,15 @@ public class AlarmInService {
                                     StringBuilder tbName = new StringBuilder();
                                     tbName.append(wt.getId()).append("_").append(alarm.getId());
                                     vo.setTbName(String.valueOf(tbName));
-                                    vo.setAlarmid(alarm.getId());
+                                    vo.setAlarmId(alarm.getId());
                                     vo.setTagid(equipmentPoint.getNemCode());
-                                    vo.setAlarmtype(alarm.getAlarmType());
+                                    vo.setAlarmType(alarm.getAlarmType());
                                     vo.setCharacteristic(alarm.getCharacteristic());
                                     vo.setComponents(alarm.getComponents());
                                     vo.setDescription(alarm.getDescription());
-                                    vo.setDeviceid(wt.getId());
+                                    vo.setDeviceId(wt.getId());
                                     vo.setDevicename(wt.getName());
-                                    vo.setDevicetype(alarm.getDeviceType());
+                                    vo.setDeviceType(alarm.getDeviceType());
                                     vo.setEnabled(alarm.getEnable());
                                     vo.setLineid(wt.getLineId());
                                     if(CacheContext.lnmap.containsKey(wt.getLineId()))

+ 4 - 4
alarm-web/src/main/java/com/gyee/alarm/service/AlarmWtService.java

@@ -76,15 +76,15 @@ public class AlarmWtService {
                                     StringBuilder tbName = new StringBuilder();
                                     tbName.append(wt.getId()).append("_").append(alarm.getId());
                                     vo.setTbName(String.valueOf(tbName));
-                                    vo.setAlarmid(alarm.getId());
+                                    vo.setAlarmId(alarm.getId());
                                     vo.setTagid(equipmentPoint.getNemCode());
-                                    vo.setAlarmtype(alarm.getAlarmType());
+                                    vo.setAlarmType(alarm.getAlarmType());
                                     vo.setCharacteristic(alarm.getCharacteristic());
                                     vo.setComponents(alarm.getComponents());
                                     vo.setDescription(alarm.getDescription());
-                                    vo.setDeviceid(wt.getId());
+                                    vo.setDeviceId(wt.getId());
                                     vo.setDevicename(wt.getName());
-                                    vo.setDevicetype(alarm.getDeviceType());
+                                    vo.setDeviceType(alarm.getDeviceType());
                                     vo.setEnabled(alarm.getEnable());
                                     vo.setLineid(wt.getLineId());
                                     if(CacheContext.lnmap.containsKey(wt.getLineId()))

Разница между файлами не показана из-за своего большого размера
+ 12391 - 69259
log/ota.log


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


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


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


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


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


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