Просмотр исходного кода

修改功率曲线拟合功能

shilin 1 год назад
Родитель
Сommit
9e593c7253
42 измененных файлов с 2765 добавлено и 56 удалено
  1. 10 1
      web/health/pom.xml
  2. 2 1
      web/health/src/main/java/com/gyee/health/controller/health/HealthReportController.java
  3. 117 0
      web/health/src/main/java/com/gyee/health/init/CacheContext.java
  4. 288 0
      web/health/src/main/java/com/gyee/health/mapper/auto/AlarmTsMapper.java
  5. 68 0
      web/health/src/main/java/com/gyee/health/mapper/auto/ProEconAlarmConfigurationMapper.java
  6. 41 0
      web/health/src/main/java/com/gyee/health/mapper/auto/ProEconAlarmRuleFailureMapper.java
  7. 149 0
      web/health/src/main/java/com/gyee/health/mapper/auto/ProEconAlarmRuleMapper.java
  8. 18 0
      web/health/src/main/java/com/gyee/health/mapper/auto/ProEconAlarmTypeMapper.java
  9. 17 0
      web/health/src/main/java/com/gyee/health/model/auto/AlarmTs.java
  10. 93 0
      web/health/src/main/java/com/gyee/health/model/auto/ProBasicFeatureStat.java
  11. 137 0
      web/health/src/main/java/com/gyee/health/model/auto/ProEconAlarmConfiguration.java
  12. 135 0
      web/health/src/main/java/com/gyee/health/model/auto/ProEconAlarmRule.java
  13. 83 0
      web/health/src/main/java/com/gyee/health/model/auto/ProEconAlarmRuleFailure.java
  14. 52 0
      web/health/src/main/java/com/gyee/health/model/auto/ProEconAlarmType.java
  15. 21 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmConfigurationVo.java
  16. 52 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmCustomTag.java
  17. 53 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmCustomType.java
  18. 24 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmRuleVo.java
  19. 19 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmSimpleVo.java
  20. 31 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmStatVo.java
  21. 54 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmSuperTalbeType.java
  22. 119 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmTag.java
  23. 54 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmTime.java
  24. 17 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmTsVo.java
  25. 54 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmType.java
  26. 56 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmTypeValue.java
  27. 69 0
      web/health/src/main/java/com/gyee/health/model/vo/AlarmVo.java
  28. 1 2
      web/health/src/main/java/com/gyee/health/model/vo/StateJudgmentVo.java
  29. 60 0
      web/health/src/main/java/com/gyee/health/service/auto/IAlarmTsService.java
  30. 25 0
      web/health/src/main/java/com/gyee/health/service/auto/IProEconAlarmConfigurationService.java
  31. 22 0
      web/health/src/main/java/com/gyee/health/service/auto/IProEconAlarmRuleFailureService.java
  32. 17 0
      web/health/src/main/java/com/gyee/health/service/auto/IProEconAlarmRuleService.java
  33. 17 0
      web/health/src/main/java/com/gyee/health/service/auto/IProEconAlarmTypeService.java
  34. 172 0
      web/health/src/main/java/com/gyee/health/service/auto/impl/AlarmTsServiceImpl.java
  35. 42 0
      web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconAlarmConfigurationServiceImpl.java
  36. 37 0
      web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconAlarmRuleFailureServiceImpl.java
  37. 21 0
      web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconAlarmRuleServiceImpl.java
  38. 21 0
      web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconAlarmTypeServiceImpl.java
  39. 304 0
      web/health/src/main/java/com/gyee/health/service/health/AlarmHistoryService.java
  40. 24 46
      web/health/src/main/java/com/gyee/health/service/health/HealthReportService.java
  41. 161 0
      web/health/src/main/java/com/gyee/health/util/SnowflakeGenerator.java
  42. 8 6
      web/health/src/main/resources/application-jn.yml

+ 10 - 1
web/health/pom.xml

@@ -140,7 +140,16 @@
             <artifactId>swagger-models</artifactId>
             <version>1.5.21</version>
         </dependency>
-
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.taosdata.jdbc</groupId>
+            <artifactId>taos-jdbcdriver</artifactId>
+            <version>3.2.2</version>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 2 - 1
web/health/src/main/java/com/gyee/health/controller/health/HealthReportController.java

@@ -2,6 +2,7 @@ package com.gyee.health.controller.health;
 
 import com.gyee.health.dto.AjaxResult;
 import com.gyee.health.dto.AjaxStatus;
+import com.gyee.health.model.auto.ProBasicFeatureStat;
 import com.gyee.health.model.auto.ProEconHealthReportMain;
 import com.gyee.health.model.auto.ProEconHealthReportTarget;
 import com.gyee.health.model.vo.*;
@@ -181,7 +182,7 @@ public class HealthReportController {
     public AjaxResult getAlarmcountVoList(String recordDate, String wtId) throws Exception {
 
 
-        List<AlarmcountResultVo> vos = new ArrayList<>();
+        List<ProBasicFeatureStat> vos = new ArrayList<>();
 
         if (StringUtils.notEmp(recordDate) && StringUtils.notEmp(wtId)) {
             vos = healthReportService.getAlarmcountVoList(DateUtils.parseDate(recordDate), wtId);

+ 117 - 0
web/health/src/main/java/com/gyee/health/init/CacheContext.java

@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.gyee.common.model.StringUtils;
 import com.gyee.health.model.auto.*;
+import com.gyee.health.model.vo.AlarmCustomType;
+import com.gyee.health.model.vo.AlarmTypeValue;
 import com.gyee.health.service.auto.*;
 import com.gyee.health.util.redis.RedisService;
 import org.slf4j.Logger;
@@ -72,6 +74,15 @@ public class CacheContext implements CommandLineRunner {
     @Resource
     private IProBasicEquipmentPointService proBasicEquipmentPointService;
 
+    @Resource
+    private IProEconAlarmTypeService proEconAlarmTypeService;
+
+    @Resource
+    private IProEconAlarmRuleService proEconAlarmRuleService;
+
+    @Resource
+    private IProEconAlarmConfigurationService proEconAlarmConfigurationService;
+
     public static List<ProBasicEquipment> wtls = new ArrayList<>();
     public static List<ProBasicProject> pjls = new ArrayList<>();
     public static List<ProBasicLine>  lnls = new ArrayList<>();
@@ -152,9 +163,20 @@ public class CacheContext implements CommandLineRunner {
     public static Map<String, Map<Double, ProEconWtPowerCurveFitting>> wpcmap = new HashMap<String, Map<Double, ProEconWtPowerCurveFitting>>();
 
 
+    public static Map<String, ProEconAlarmType> alarmTypeMap = new HashMap<>();
+    public static List<ProEconAlarmType> alarmTypeList = new ArrayList<>();
 
+    public static List<ProEconAlarmConfiguration> inalarmls = new ArrayList<>();
+    public static List<ProEconAlarmConfiguration> wtalarmls = new ArrayList<>();
+    public static List<ProEconAlarmConfiguration> btalarmls = new ArrayList<>();
+    public static Map<String, List<ProEconAlarmConfiguration>> wtAlarmMap = new HashMap<>();
+    public static Map<String, List<ProEconAlarmConfiguration>> inAlarmMap = new HashMap<>();
+    public static Map<String, ProEconAlarmConfiguration> alarmMap = new HashMap<>();
 
+    public static Map<String, List<ProEconAlarmRule>> ctAlarmlsMap = new HashMap<>();
 
+    public static Map<String, ProEconAlarmRule> ctAlarmMap = new HashMap<>();
+    public static Map<String, List<ProEconAlarmRule>> alarmRulesMap = new HashMap<>();
     @Override
     public void run(String... args) throws Exception {
         logger.info("缓存开始------------------------------------------------------------");
@@ -694,6 +716,101 @@ public class CacheContext implements CommandLineRunner {
             }
         }
 
+        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()) {
+            for (ProEconAlarmConfiguration alarm : templs) {
+
+                alarmMap.put(alarm.getId(), alarm);
+                if (alarm.getAlarmType().equals(AlarmTypeValue.WT.getCode())) {
+                    wtalarmls.add(alarm);
+                    alarmMap.put(alarm.getId(), alarm);
+                    StringBuilder sb = new StringBuilder();
+                    sb.append(alarm.getStationId()).append(alarm.getModelId());
+
+                    if (wtAlarmMap.containsKey(String.valueOf(sb))) {
+                        List<ProEconAlarmConfiguration> ls = wtAlarmMap.get(String.valueOf(sb));
+                        ls.add(alarm);
+                    } else {
+                        List<ProEconAlarmConfiguration> ls = new ArrayList<>();
+                        ls.add(alarm);
+                        wtAlarmMap.put(String.valueOf(sb), ls);
+                    }
+                }else if (alarm.getAlarmType().equals(AlarmTypeValue.IN.getCode())) {
+                    inalarmls.add(alarm);
+
+                    StringBuilder sb = new StringBuilder();
+                    sb.append(alarm.getStationId()).append(alarm.getModelId());
+
+                    if (inAlarmMap.containsKey(String.valueOf(sb))) {
+                        List<ProEconAlarmConfiguration> ls = inAlarmMap.get(String.valueOf(sb));
+                        ls.add(alarm);
+                    } else {
+                        List<ProEconAlarmConfiguration> ls = new ArrayList<>();
+                        ls.add(alarm);
+                        inAlarmMap.put(String.valueOf(sb), ls);
+                    }
+                } else if (alarm.getAlarmType().equals(AlarmTypeValue.BT.getCode())) {
+                    btalarmls.add(alarm);
+
+                }
+            }
+        }
+
+        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> btCustomls = new ArrayList<>();
+//        List<ProEconAlarmRule> btCustomls=new ArrayList<>();
+        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);
+                        } 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);
+                    }
+                }
+            }
+        }
+        alarmRulesMap.put(AlarmCustomType.WT.getCode(), wtCustomls);
+        alarmRulesMap.put(AlarmCustomType.BT.getCode(), btCustomls);
 
         logger.info("缓存结束------------------------------------------------------------");
     }

Разница между файлами не показана из-за своего большого размера
+ 288 - 0
web/health/src/main/java/com/gyee/health/mapper/auto/AlarmTsMapper.java


+ 68 - 0
web/health/src/main/java/com/gyee/health/mapper/auto/ProEconAlarmConfigurationMapper.java

@@ -0,0 +1,68 @@
+package com.gyee.health.mapper.auto;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.health.model.auto.ProEconAlarmConfiguration;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 报警配置表 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-06-19
+ */
+public interface ProEconAlarmConfigurationMapper extends BaseMapper<ProEconAlarmConfiguration> {
+
+
+    @Select({"<script>",
+            "select * from pro_econ_alarm_configuration ",
+            "<where>",
+            " 1=1 ",
+            "<if test='wpId !=null  '>",
+            "and station_id = #{wpId} ",
+            "</if>",
+            "<if test='description !=null  '>",
+            "and description like #{description} ",
+            "</if>",
+            "<if test='modelId !=null  '>",
+            "and model_id = #{modelId} ",
+            "</if>",
+            "<if test='alarmType !=null  '>",
+            "and alarm_type = #{alarmType} ",
+            "</if>",
+            "</where>",
+            " order by id ",
+            "</script>"})
+    IPage<ProEconAlarmConfiguration> pageQueryAll(Page page,
+                                         @Param("description") String description,
+                                         @Param("wpId") String wpId,
+                                         @Param("modelId") String modelId,@Param("alarmType")String alarmType);
+
+
+    @Select({"<script>",
+            "select * from pro_econ_alarm_configuration ",
+            "<where>",
+            " 1=1 ",
+
+            "<if test='wpId !=null  '>",
+            "and station_id  = #{wpId} ",
+            "</if>",
+            "<if test='description !=null  '>",
+            "and description = #{description} ",
+            "</if>",
+            "<if test='modelId !=null  '>",
+            "and model_id = #{modelId} ",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmConfiguration> queryObject(@Param("description") String description,
+                                       @Param("wpId") String wpId,
+                                       @Param("modelId") String modelId);
+}

+ 41 - 0
web/health/src/main/java/com/gyee/health/mapper/auto/ProEconAlarmRuleFailureMapper.java

@@ -0,0 +1,41 @@
+package com.gyee.health.mapper.auto;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.health.model.auto.ProEconAlarmRuleFailure;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 故障规则 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-10-04
+ */
+public interface ProEconAlarmRuleFailureMapper extends BaseMapper<ProEconAlarmRuleFailure> {
+
+    @Select({"<script>",
+            "select * from pro_econ_alarm_rule_failure ",
+            "<where>",
+            " 1=1 ",
+
+            "<if test='wpId !=null  '>",
+            "and station_id  = #{wpId} ",
+            "</if>",
+            "<if test='name !=null  '>",
+            "and name = #{name} ",
+            "</if>",
+            "<if test='modelId !=null  '>",
+            "and model_id = #{modelId} ",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmRuleFailure> queryObject(@Param("name") String name,
+                                                @Param("wpId") String wpId,
+                                                @Param("modelId") String modelId);
+}

+ 149 - 0
web/health/src/main/java/com/gyee/health/mapper/auto/ProEconAlarmRuleMapper.java

@@ -0,0 +1,149 @@
+package com.gyee.health.mapper.auto;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.health.model.auto.ProEconAlarmRule;
+import com.gyee.health.model.vo.AlarmRuleVo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 自定义报警配置 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+public interface ProEconAlarmRuleMapper extends BaseMapper<ProEconAlarmRule> {
+
+
+    @Update({"<script>",
+            "update pro_econ_alarm_rule ",
+            "<set>",
+            "name = #{name},",
+            "description = #{description},",
+            "expression = #{expression},",
+            "tag = #{tag}," ,
+            "rank = #{rank},",
+            "enable = #{enable},",
+            "model_id = #{modelId},",
+            "category = #{category}," ,
+            "range =#{range}," ,
+            "station_id =#{stationId}," ,
+            "device_id = #{deviceId}," ,
+            "line_id = #{lineId}," ,
+            "project_id = #{projectId}," ,
+            "electrical_id = #{electricalId}," ,
+            "related_parts = #{relatedParts}," ,
+            "create_time = #{createTime}," ,
+            "uniform_code = #{uniformCode}" ,
+            "</set>",
+            "where id = #{id}",
+
+            "</script>"})
+    Integer updateByAlertruleId(ProEconAlarmRule alertrule);
+
+    @Select({"<script>",
+            "select a.* from pro_econ_alarm_rule a",
+            "<where>",
+            " 1=1 ",
+
+            "<if test='wpId !=null  '>",
+            "and a.station_id  = #{wpId} ",
+            "</if>",
+            "<if test='name !=null  '>",
+            "and a.name like #{name} ",
+            "</if>",
+            "<if test='modelId !=null  '>",
+            "and a.model_id = #{modelId} ",
+            "</if>",
+            "<if test='rank !=null  '>",
+            "and a.rank = #{rank} ",
+            "</if>",
+            "<if test='category !=null  '>",
+            "and a.category = #{category} ",
+            "</if>",
+            "<if test='enable !=null  '>",
+            "and a.enable = #{enable} ",
+            "</if>",
+            "<if test='relatedparts !=null  '>",
+            "and a.related_parts = #{relatedparts} ",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    IPage<ProEconAlarmRule> pageQueryAll(Page page,
+                                         @Param("name") String name,
+                                         @Param("wpId") String wpId,
+                                         @Param("modelId") String modelId,
+                                         @Param("rank") Integer rank,
+                                         @Param("category") String category,
+                                         @Param("enable") Boolean enable,
+                                         @Param("relatedparts") String relatedparts);
+
+    @Select("select distinct a.related_parts as relatedParts,a.name as alarmName,d.name  as typeName from pro_econ_alarm_rule a " +
+            "left join pro_econ_alarm_type d on d.nem_code = a.related_parts " +
+            "where related_parts is not null")
+    List<AlarmRuleVo> queryTree();
+
+
+    @Select({"<script>",
+            "select a.* from pro_econ_alarm_rule a",
+            "<where>",
+            " 1=1 ",
+
+            "<if test='wpId !=null  '>",
+            "and a.station_id  = #{wpId} ",
+            "</if>",
+            "<if test='name !=null  '>",
+            "and a.name =  #{name} ",
+            "</if>",
+            "<if test='modelId !=null  '>",
+            "and a.model_id = #{modelId} ",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmRule> queryObject( @Param("name") String name,
+                                 @Param("wpId") String wpId,
+                                 @Param("modelId") String modelId);
+    @Select(" select a.name from  pro_econ_alarm_rule a where a.related_parts = #{relatedParts}   group by a.name ")
+    List<ProEconAlarmRule> quertByrelatedParts(@Param("relatedParts") String relatedParts);
+
+    @Select({"<script>",
+            "select a.* from pro_econ_alarm_rule a",
+            "<where>",
+            "a.station like '%#{station}%'",
+            "<if test='modelId !=null '>",
+            "and a.model_id like '%#{modelId}%'",
+            "</if>",
+
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmRule> getAllByStationIdAndModelId(@Param("station") String station,
+                                                       @Param("modelId") String modelId
+    );
+
+
+    @Select({"<script>",
+            "select a.* from pro_econ_alarm_rule a",
+            "<where>",
+            "a.station like '%#{station}%'",
+
+            "<if test='name !=null  '>",
+            "and a.name like '%#{name}%'",
+            "</if>",
+            "<if test='modelid !=null  '>",
+            "and a.model_id like '%#{modelid}%'",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmRule> getUniformCodeByNameAndStation(@Param("name") String name, @Param("station") String station, @Param("modelid") String modelid);
+}

+ 18 - 0
web/health/src/main/java/com/gyee/health/mapper/auto/ProEconAlarmTypeMapper.java

@@ -0,0 +1,18 @@
+package com.gyee.health.mapper.auto;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.health.model.auto.ProEconAlarmType;
+
+
+/**
+ * <p>
+ * 自定义类型 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+public interface ProEconAlarmTypeMapper extends BaseMapper<ProEconAlarmType> {
+
+}

+ 17 - 0
web/health/src/main/java/com/gyee/health/model/auto/AlarmTs.java

@@ -0,0 +1,17 @@
+package com.gyee.health.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 String tbName;
+}

+ 93 - 0
web/health/src/main/java/com/gyee/health/model/auto/ProBasicFeatureStat.java

@@ -0,0 +1,93 @@
+package com.gyee.health.model.auto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.sql.Timestamp;
+
+/**
+ * <p>
+ * 设备功能统计
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-14
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProBasicFeatureStat extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    @TableId(value = "ID",type = IdType.INPUT)
+    private String id;
+
+    /**
+     * 设备编号
+     */
+    private String wtId;
+
+    /**
+     * 场站编号
+     */
+    private String stationId;
+
+    /**
+     * 统计时间
+     */
+    private Timestamp statDate;
+
+    /**
+     * 总次数
+     */
+    private Long total;
+
+    /**
+     * 总时间
+     */
+    private Double totalSeconds;
+
+    /**
+     * 平均时长
+     */
+    private Double avgSeconds;
+
+    /**
+     * 最大时长
+     */
+    private Double maxSeconds;
+
+    /**
+     * 最小时长
+     */
+    private Double minSeconds;
+
+    /**
+     * 类型编码
+     */
+    private String typeCode;
+
+    /**
+     * 类型名称
+     */
+    private String typeName;
+    /**
+     * 报警编号
+     */
+    private String alarmid;
+
+    /**
+     * 描述
+     */
+    private String description;
+
+    @TableField(exist = false)
+    private String code;
+}

+ 137 - 0
web/health/src/main/java/com/gyee/health/model/auto/ProEconAlarmConfiguration.java

@@ -0,0 +1,137 @@
+package com.gyee.health.model.auto;
+
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 报警配置表
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-06-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString
+@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
+public class ProEconAlarmConfiguration extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+
+    @TableId(value = "ID",type = IdType.INPUT)
+    private String id;
+
+    /**
+     * 测点(如果根据uniformcode配置此字段可为空)
+     */
+    private String tagId;
+
+    /**
+     * 触发条件,0触发,1触发,-1变化触发,4ai点触发
+     */
+    private Integer triggerType;
+
+    /**
+     * 设备ID
+     */
+    private String deviceId;
+
+    /**
+     * 后缀
+     */
+    private String suffix;
+
+    /**
+     * 报警级别
+     */
+    private Integer rank;
+
+    /**
+     * 统一识别码(如果通过uniformCode配置,则设备类型,场站,机型不能为空)
+     */
+    private String uniformCode;
+
+    /**
+     * 场站ID
+     */
+    private String stationId;
+
+    /**
+     * 机型
+     */
+    private String modelId;
+
+    /**
+     * 报警类型 /自定义报警 custom,风机 windturbine,场站 station,升压站 booststation
+     */
+    private String alarmType;
+
+    /**
+     * 设备类型,场站 station,风机 windturbine,升压站 booststation
+     */
+    private String deviceType;
+
+    /**
+     * 设备部件
+     */
+    private String components;
+
+    /**
+     * 设备子部件
+     */
+    private String subcomponents;
+
+    /**
+     * 报警描述
+     */
+    private String description;
+
+    /**
+     * 特性
+     */
+    private String characteristic;
+
+    /**
+     * 是否可复位
+     */
+    private Boolean resetTable;
+
+    /**
+     * 是否启用
+     */
+    private Boolean enable;
+
+    /**
+     * 故障名称
+     */
+      private String name;
+
+    /**
+     *故障码
+     */
+    private String nemCode;
+
+    /**
+     * 故障原因
+     */
+    private String faultCause;
+
+    /**
+     * 排查方法
+     */
+    private String resolvent;
+
+
+}

+ 135 - 0
web/health/src/main/java/com/gyee/health/model/auto/ProEconAlarmRule.java

@@ -0,0 +1,135 @@
+package com.gyee.health.model.auto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * <p>
+ * 自定义报警配置
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString
+@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
+public class ProEconAlarmRule extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+
+    @TableId(value = "ID",type = IdType.INPUT)
+    private String id;
+
+    /**
+     * 自定义报警名称
+     */
+
+    private String name;
+
+    /**
+     * 报警描述
+     */
+    private String description;
+
+    /**
+     * 公式
+     */
+    private String expression;
+
+    /**
+     * 标签
+     */
+    private String tag;
+
+    /**
+     * 报警级别
+     */
+    private Integer rank;
+
+    /**
+     * 机型
+     */
+    private String modelId;
+
+    /**
+     * 报警类别
+     */
+    private String category;
+
+    /**
+     * 范围
+     */
+    private String range;
+
+    /**
+     * 场站ID
+     */
+
+    private String stationId;
+
+    /**
+     * 项目ID
+     */
+
+    private String projectId;
+
+    /**
+     * 线路ID
+     */
+
+    private String lineId;
+
+    /**
+     * 设备ID
+     */
+
+    private String deviceId;
+
+    /**
+     * 电气ID
+     */
+
+    private String electricalId;
+
+    /**
+     * 关联部件
+     */
+
+    private String relatedParts;
+
+    /**
+     * 创建时间
+     */
+
+    private Date createTime;
+
+    /**
+     * 是否启用
+     */
+
+    private Boolean enable;
+    /**
+     * 统一识别码(如果通过uniformCode配置,则设备类型,场站,机型不能为空)
+     */
+    private String uniformCode;
+
+    @TableField(exist = false)
+    private String stationName;
+    @TableField(exist = false)
+    private String relatedPartsName;
+}

+ 83 - 0
web/health/src/main/java/com/gyee/health/model/auto/ProEconAlarmRuleFailure.java

@@ -0,0 +1,83 @@
+package com.gyee.health.model.auto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 故障规则
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-10-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconAlarmRuleFailure extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private String id;
+
+    /**
+     * 故障码
+     */
+    private String nemCode;
+
+    /**
+     * 故障英文描述
+     */
+    private String describe;
+
+    /**
+     * 故障名称
+     */
+    private String name;
+
+    /**
+     * 故障原因
+     */
+    private String faultCause;
+
+    /**
+     * 排查方法
+     */
+    private String resolvent;
+
+    /**
+     * 故障类型
+     */
+    private String types;
+
+    /**
+     * 关联报警
+     */
+    private String alarmId;
+
+    /**
+     * 型号
+     */
+    private String modelId;
+
+    /**
+     * 场站编号
+     */
+    private String stationId;
+
+    /**
+     * 故障时长
+     */
+    private Double faultTimes;
+
+    /**
+     * 关联部件
+     */
+    private String relatedParts;
+
+
+}

+ 52 - 0
web/health/src/main/java/com/gyee/health/model/auto/ProEconAlarmType.java

@@ -0,0 +1,52 @@
+package com.gyee.health.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 自定义类型
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconAlarmType extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private String id;
+
+    /**
+     * 报警类别
+     */
+    private String category;
+
+    /**
+     * 编码
+     */
+    private String nemCode;
+
+    /**
+     * 类型名称
+     */
+    private String name;
+
+    /**
+     * 范围
+     */
+    private Integer orderNumber;
+
+    /**
+     * 是否启用
+     */
+    private Integer enable;
+
+
+}

+ 21 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmConfigurationVo.java

@@ -0,0 +1,21 @@
+package com.gyee.health.model.vo;
+
+import lombok.Data;
+
+@Data
+public class AlarmConfigurationVo {
+
+    /**
+     * 报警标号
+     */
+    private String alarmId;
+
+    /**
+     * 报警描述
+     */
+    private String description;
+
+
+
+
+}

+ 52 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmCustomTag.java

@@ -0,0 +1,52 @@
+package com.gyee.health.model.vo;
+
+import lombok.Data;
+
+@Data
+public class AlarmCustomTag {
+
+    /**
+     * 表名
+     */
+    private String id;
+
+    /**
+     * 时间戳
+     */
+    private Long ts;
+
+    /**
+     * 当前值
+     */
+    private Double val;
+
+    /**
+     * 公式
+     */
+    private String tagId;
+
+    /**
+     * 公式解析
+     */
+    private String description;
+    /**
+     * 设备编号
+     */
+    private String deviceid;
+    /**
+     * 设备类型
+     */
+    private String devicetype;
+    /**
+     * 型号编号
+     */
+    private String modelId;
+    /**
+     * 报警类型
+     */
+    private String alarmtype;
+    /**
+     * 场站编号
+     */
+    private String stationid;
+}

+ 53 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmCustomType.java

@@ -0,0 +1,53 @@
+package com.gyee.health.model.vo;
+
+public enum AlarmCustomType {
+
+    WT("windturbine", "设备自定义报警"),
+    BT("booststation", "升压站报警"),
+    IN("inverter", "逆变器报警");
+
+    private String code;
+    private String name;
+
+    AlarmCustomType(String code) {
+        this.code = code;
+    }
+
+    AlarmCustomType(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmCustomType ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 24 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmRuleVo.java

@@ -0,0 +1,24 @@
+package com.gyee.health.model.vo;
+
+import lombok.Data;
+
+@Data
+public class AlarmRuleVo {
+
+    /**
+     * 关联部件编码
+     */
+    private String relatedParts;
+
+    /**
+     * 报警名称
+     */
+    private String alarmName;
+
+    /**
+     * 部件名称
+     */
+    private String typeName;
+
+
+}

+ 19 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmSimpleVo.java

@@ -0,0 +1,19 @@
+package com.gyee.health.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;
+
+}

+ 31 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmStatVo.java

@@ -0,0 +1,31 @@
+package com.gyee.health.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class AlarmStatVo implements Serializable{
+
+    private Long snapId;
+
+    private String stationId;
+
+    private String windturbineId;
+
+    private String alertText;
+
+    private long count;
+    private String alarmid;
+    private double time;
+    //关联部件编号
+    private String relateParts;
+    //关联部件名称
+    private String relatePartsText;
+
+    private String code;
+
+    private String windturbineCode;
+
+
+}

+ 54 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmSuperTalbeType.java

@@ -0,0 +1,54 @@
+package com.gyee.health.model.vo;
+
+public enum AlarmSuperTalbeType {
+
+    WT("alarmWt", "设备报警超级表"),
+
+    BT("alarmBt", "升压站报警超级表"),
+    CT("alarmCt", "自定义报警超级表");
+
+    private String code;
+    private String name;
+
+    AlarmSuperTalbeType(String code) {
+        this.code = code;
+    }
+
+    AlarmSuperTalbeType(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmSuperTalbeType ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 119 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmTag.java

@@ -0,0 +1,119 @@
+package com.gyee.health.model.vo;
+
+import com.gyee.common.model.PointData;
+import lombok.Data;
+
+@Data
+public class AlarmTag {
+
+    /**
+     * 表名
+     */
+    private String id;
+
+    /**
+     * 时间戳
+     */
+    private Long ts;
+
+    /**
+     * 当前值
+     */
+    private Double val;
+
+    /**
+     * 报警类别,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;
+
+    /**
+     * 报警类型 /自定义报警 custom,风机 windturbine,场站 station,升压站 booststation
+     */
+    private String alarmType;
+
+    /**
+     * 设备类型,场站 station,风机 windturbine,升压站 booststation
+     */
+    private String deviceType;
+
+    /**
+     * 更新并检测是否触发报警
+     */
+    public Boolean updateAndCheck(PointData pointData) {
+
+        if (pointData.getPointValueInDouble() == oval) {
+            return false;
+        }
+        ts = pointData.getPointTime();
+        oval = pointData.getPointValueInDouble();
+
+        endts= pointData.getPointTime();
+        val=0.0;
+        if(triggerType==-1)
+        {
+            val=1.0;
+        }else  if(triggerType==0)
+        {
+            if (oval == 0)
+            {
+                val=1.0;
+            }else
+            {
+                val=0.0;
+                return false;
+            }
+        }else  if(triggerType==1)
+        {
+            if (oval == 1)
+            {
+                val=1.0;
+            }else
+            {
+                val=0.0;
+                return false;
+            }
+        }else {
+            if (oval.intValue() == triggerType) {
+                val=1.0;
+            } else if (oval == 0) {
+                val=0.0;
+                return false;
+            }
+        }
+
+        return true;
+    }
+}

+ 54 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmTime.java

@@ -0,0 +1,54 @@
+package com.gyee.health.model.vo;
+
+
+public enum AlarmTime {
+
+    H("h", "时"),
+    M("m", "分"),
+    S("s", "秒");
+
+    private String code;
+    private String name;
+
+    AlarmTime(String code) {
+        this.code = code;
+    }
+
+    AlarmTime(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmTime ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 17 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmTsVo.java

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

+ 54 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmType.java

@@ -0,0 +1,54 @@
+package com.gyee.health.model.vo;
+
+public enum AlarmType {
+
+    FJBJ("alertrule_category", "风机部件"),
+    GFBJ("alertrule_category_GF", "光伏部件"),
+    YJ("early_category", "预警"),
+    SD("userset", "用户设定");
+
+    private String code;
+    private String name;
+
+    AlarmType(String code) {
+        this.code = code;
+    }
+
+    AlarmType(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmType ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 56 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmTypeValue.java

@@ -0,0 +1,56 @@
+package com.gyee.health.model.vo;
+
+public enum AlarmTypeValue {
+
+    BT("booststation", "升压站报警"),
+
+    BTE("booststationevent", "升压站报警事件"),
+    IN("inverter", "逆变器报警"),
+    WT("windturbine", "设备报警"),
+    CT("custom", "自定义报警");
+
+    private String code;
+    private String name;
+
+    AlarmTypeValue(String code) {
+        this.code = code;
+    }
+
+    AlarmTypeValue(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmTypeValue ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 69 - 0
web/health/src/main/java/com/gyee/health/model/vo/AlarmVo.java

@@ -0,0 +1,69 @@
+package com.gyee.health.model.vo;
+
+
+import lombok.Data;
+
+@Data
+public class AlarmVo {
+
+    private  String tbName;
+    private String alarmId;
+    private String alarmType;
+    private String characteristic;
+    private String components;
+    private Boolean confirmed;
+    private String description;
+    private String deviceId;
+    private String devicename;
+    private String deviceType;
+    private Boolean enabled;
+    private String lineid;
+    private String linename;
+    private String modelId;
+    private String projectid;
+    private String projectname;
+    private Integer rank;
+    private Boolean resettable;
+    private String stationid;
+    private String stationname;
+    private String subcomponents;
+    private String suffix;
+    private String tagid;
+    private Integer triggertype;
+    private String uniformcode;
+    private String superTableName;
+
+    private long ts;
+    private Integer val;
+    private Integer oval;
+
+    private long endts;
+
+    private Double timelong;
+
+    /**
+     * 故障名称
+     */
+    private String name;
+
+    /**
+     *故障码
+     */
+    private String nemCode;
+
+    /**
+     * 故障原因
+     */
+    private String faultCause;
+
+    /**
+     * 排查方法
+     */
+    private String resolvent;
+    private String wpName;
+    private String code;
+    private String wpId;
+    private String faultType;
+    private String id;
+    private String aname;
+}

+ 1 - 2
web/health/src/main/java/com/gyee/health/model/vo/StateJudgmentVo.java

@@ -22,7 +22,6 @@ public class StateJudgmentVo {
     public String gqj;
     public Double xqsc;
     public Date recordDate;
-
-
+    public String code;
 
 }

+ 60 - 0
web/health/src/main/java/com/gyee/health/service/auto/IAlarmTsService.java

@@ -0,0 +1,60 @@
+package com.gyee.health.service.auto;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.health.model.auto.AlarmTs;
+import com.gyee.health.model.vo.AlarmSimpleVo;
+import com.gyee.health.model.vo.AlarmTag;
+import com.gyee.health.model.vo.AlarmTsVo;
+import com.gyee.health.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
+
+    );
+
+
+
+    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> selectByWpGroup(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);
+}
+

+ 25 - 0
web/health/src/main/java/com/gyee/health/service/auto/IProEconAlarmConfigurationService.java

@@ -0,0 +1,25 @@
+package com.gyee.health.service.auto;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.health.model.auto.ProEconAlarmConfiguration;
+
+
+/**
+ * <p>
+ * 报警配置表 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-06-19
+ */
+public interface IProEconAlarmConfigurationService extends IService<ProEconAlarmConfiguration> {
+
+
+    public IPage<ProEconAlarmConfiguration> pageQueryAll(Page page,
+                                                         String description,
+                                                         String wpId,
+                                                         String modelId, String alarmType);
+}

+ 22 - 0
web/health/src/main/java/com/gyee/health/service/auto/IProEconAlarmRuleFailureService.java

@@ -0,0 +1,22 @@
+package com.gyee.health.service.auto;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.health.model.auto.ProEconAlarmRuleFailure;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 故障规则 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-10-04
+ */
+public interface IProEconAlarmRuleFailureService extends IService<ProEconAlarmRuleFailure> {
+
+   public List<ProEconAlarmRuleFailure> queryObject(String name,
+                                              String wpId,
+                                              String modelId);
+}

+ 17 - 0
web/health/src/main/java/com/gyee/health/service/auto/IProEconAlarmRuleService.java

@@ -0,0 +1,17 @@
+package com.gyee.health.service.auto;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.health.model.auto.ProEconAlarmRule;
+
+/**
+ * <p>
+ * 自定义报警配置 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+public interface IProEconAlarmRuleService extends IService<ProEconAlarmRule> {
+
+}

+ 17 - 0
web/health/src/main/java/com/gyee/health/service/auto/IProEconAlarmTypeService.java

@@ -0,0 +1,17 @@
+package com.gyee.health.service.auto;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.health.model.auto.ProEconAlarmType;
+
+/**
+ * <p>
+ * 自定义类型 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+public interface IProEconAlarmTypeService extends IService<ProEconAlarmType> {
+
+}

+ 172 - 0
web/health/src/main/java/com/gyee/health/service/auto/impl/AlarmTsServiceImpl.java

@@ -0,0 +1,172 @@
+package com.gyee.health.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.health.mapper.auto.AlarmTsMapper;
+import com.gyee.health.model.auto.AlarmTs;
+import com.gyee.health.model.vo.AlarmSimpleVo;
+import com.gyee.health.model.vo.AlarmTag;
+import com.gyee.health.model.vo.AlarmTsVo;
+import com.gyee.health.model.vo.AlarmVo;
+import com.gyee.health.service.auto.IAlarmTsService;
+import com.gyee.health.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
+
+    ) {
+        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);
+    }
+
+
+    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;
+    }
+
+    @Override
+    public List<AlarmTsVo> selectByWpGroup(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.selectByWpGroup(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( ").append(tbnames).append(" ) group by tbname");
+
+            ls= alarmTsMapper.selectLastRowByTbname(String.valueOf(sb));
+        }
+
+        return ls;
+    }
+}

+ 42 - 0
web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconAlarmConfigurationServiceImpl.java

@@ -0,0 +1,42 @@
+package com.gyee.health.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.health.mapper.auto.ProEconAlarmConfigurationMapper;
+import com.gyee.health.model.auto.ProEconAlarmConfiguration;
+import com.gyee.health.service.auto.IProEconAlarmConfigurationService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * <p>
+ * 报警配置表 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-06-19
+ */
+@Service
+public class ProEconAlarmConfigurationServiceImpl extends ServiceImpl<ProEconAlarmConfigurationMapper, ProEconAlarmConfiguration> implements IProEconAlarmConfigurationService {
+
+    @Resource
+    private  ProEconAlarmConfigurationMapper proEconAlarmConfigurationMapper;
+
+    public IPage<ProEconAlarmConfiguration> pageQueryAll(Page page,
+                                                         String description,
+                                                         String wpId,
+                                                         String modelId, String alarmType)
+    {
+        IPage<ProEconAlarmConfiguration> pages=  proEconAlarmConfigurationMapper.pageQueryAll(page,
+                description,
+                 wpId,
+                 modelId, alarmType);
+
+        return pages;
+    }
+
+
+}

+ 37 - 0
web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconAlarmRuleFailureServiceImpl.java

@@ -0,0 +1,37 @@
+package com.gyee.health.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.common.model.StringUtils;
+import com.gyee.health.mapper.auto.ProEconAlarmRuleFailureMapper;
+import com.gyee.health.model.auto.ProEconAlarmRuleFailure;
+import com.gyee.health.service.auto.IProEconAlarmRuleFailureService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 故障规则 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-10-04
+ */
+@Service
+public class ProEconAlarmRuleFailureServiceImpl extends ServiceImpl<ProEconAlarmRuleFailureMapper, ProEconAlarmRuleFailure> implements IProEconAlarmRuleFailureService {
+
+    @Resource
+    private ProEconAlarmRuleFailureMapper proEconAlarmRuleFailureMapper;
+
+    public List<ProEconAlarmRuleFailure> queryObject(String name, String wpId,String modelId) {
+        List<ProEconAlarmRuleFailure> ls = new ArrayList<>();
+
+        if (StringUtils.notEmp(name) && StringUtils.notEmp(modelId) && StringUtils.notEmp(wpId)) {
+            ls = proEconAlarmRuleFailureMapper.queryObject(name,wpId,modelId);
+        }
+        return ls;
+    }
+}

+ 21 - 0
web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconAlarmRuleServiceImpl.java

@@ -0,0 +1,21 @@
+package com.gyee.health.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.health.mapper.auto.ProEconAlarmRuleMapper;
+import com.gyee.health.model.auto.ProEconAlarmRule;
+import com.gyee.health.service.auto.IProEconAlarmRuleService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 自定义报警配置 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Service
+public class ProEconAlarmRuleServiceImpl extends ServiceImpl<ProEconAlarmRuleMapper, ProEconAlarmRule> implements IProEconAlarmRuleService {
+
+}

+ 21 - 0
web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconAlarmTypeServiceImpl.java

@@ -0,0 +1,21 @@
+package com.gyee.health.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.health.mapper.auto.ProEconAlarmTypeMapper;
+import com.gyee.health.model.auto.ProEconAlarmType;
+import com.gyee.health.service.auto.IProEconAlarmTypeService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 自定义类型 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Service
+public class ProEconAlarmTypeServiceImpl extends ServiceImpl<ProEconAlarmTypeMapper, ProEconAlarmType> implements IProEconAlarmTypeService {
+
+}

+ 304 - 0
web/health/src/main/java/com/gyee/health/service/health/AlarmHistoryService.java

@@ -0,0 +1,304 @@
+package com.gyee.health.service.health;
+
+
+import cn.hutool.core.bean.BeanUtil;
+import com.gyee.health.init.CacheContext;
+import com.gyee.health.mapper.auto.AlarmTsMapper;
+import com.gyee.health.model.auto.*;
+import com.gyee.health.model.vo.AlarmStatVo;
+import com.gyee.health.model.vo.AlarmSuperTalbeType;
+import com.gyee.health.model.vo.AlarmTime;
+import com.gyee.health.model.vo.AlarmTypeValue;
+import com.gyee.health.util.DateUtils;
+import com.gyee.health.util.SnowflakeGenerator;
+import com.gyee.health.util.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.sql.Timestamp;
+import java.util.*;
+
+
+@Service
+
+public class AlarmHistoryService {
+
+    @Resource
+    private AlarmTsMapper alarmTsMapper;
+
+    @Value("${home_pagep_size}")
+    private int home_pagep_size;
+
+
+    public List<ProBasicFeatureStat> findWtFeatureStat(Date startTime, Date endTime, String deviceid, String alarmType, String timeType) {
+
+
+
+
+
+        List<ProBasicFeatureStat> fsls = new ArrayList<>();
+        if(alarmType.equals(AlarmTypeValue.BT.getCode()))
+        {
+            fsls = alarmTsMapper.findWtFeatureStatWt(AlarmSuperTalbeType.BT.getCode(), startTime.getTime(), endTime.getTime(),deviceid);
+
+        }else if(alarmType.equals(AlarmTypeValue.WT.getCode()))
+        {
+            fsls = alarmTsMapper.findWtFeatureStatWt(AlarmSuperTalbeType.WT.getCode(),startTime.getTime(), endTime.getTime(),deviceid);
+        }else if(alarmType.equals(AlarmTypeValue.IN.getCode()))
+        {
+            fsls = alarmTsMapper.findWtFeatureStatWt(AlarmSuperTalbeType.WT.getCode(),startTime.getTime(), endTime.getTime(),deviceid);
+        }
+
+
+        if (!fsls.isEmpty()) {
+            for (ProBasicFeatureStat fs : fsls) {
+                if (StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode())) {
+                    ProEconAlarmType at = CacheContext.alarmTypeMap.get(fs.getTypeCode());
+                    fs.setTypeName(at.getName());
+                }
+                double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                fs.setTotalSeconds(times);
+                times= new BigDecimal(fs.getMaxSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                fs.setMaxSeconds(times);
+                times= new BigDecimal(fs.getMinSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                fs.setMinSeconds(times);
+                times= new BigDecimal(fs.getAvgSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                fs.setAvgSeconds(times);
+                if(CacheContext.wtmap.containsKey(fs.getWtId()))
+                {
+                    fs.setCode(CacheContext.wtmap.get(fs.getWtId()).getNemCode());
+                }
+            }
+        }
+
+
+
+
+
+
+
+        return fsls;
+    }
+    private  static void setWtValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration at) {
+
+        ProBasicFeatureStat fs = new ProBasicFeatureStat();
+
+        StringBuilder sb = new StringBuilder();
+        sb.append(wt.getId()).append("_").append(at.getId());
+        if (map.containsKey(String.valueOf(sb))) {
+            ProBasicFeatureStat old = map.get(String.valueOf(sb));
+            BeanUtil.copyProperties(old, fs);
+        } else {
+            fs.setStatDate(new Timestamp(statDate.getTime()));
+            fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+            fs.setWtId(wt.getId());
+            fs.setStationId(wt.getWindpowerstationId());
+            fs.setTypeCode(at.getComponents());
+            if(CacheContext.alarmTypeMap.containsKey(at.getComponents()))
+            {
+                fs.setTypeName(CacheContext.alarmTypeMap.get(at.getComponents()).getName());
+            }
+            fs.setAlarmid(at.getId());
+            fs.setDescription(at.getDescription());
+            fs.setTotal(0l);
+            fs.setAvgSeconds(0.0);
+            fs.setMaxSeconds(0.0);
+            fs.setMinSeconds(0.0);
+            fs.setTotalSeconds(0.0);
+
+        }
+        vos.add(fs);
+    }
+
+    public List<AlarmStatVo> findCtFeatureStat(String wtId,String stationId,String modelId, Date startTime, Date endTime,String components,String deviceType,String alarmIds,String timeType) {
+        List<AlarmStatVo> resultList = new ArrayList<>();
+
+
+        StringBuilder alarmIdList=new StringBuilder();
+        StringBuilder componentsList=new StringBuilder();
+
+        Map<String,String> alarmIdMap=new HashMap<>();
+        Map<String,String> componentsMap=new HashMap();
+
+        if(StringUtils.notEmp(components))
+        {
+            String [] componentsStr=components.split(",");
+            for(String c:componentsStr)
+            {
+                componentsList.append("'").append(c).append("',");
+                componentsMap.put(c,c);
+            }
+
+        }
+        if(StringUtils.notEmp(alarmIds))
+        {
+            String [] alarmIdStr=alarmIds.split(",");
+            for(String c:alarmIdStr)
+            {
+                alarmIdList.append("'").append(c).append("',");
+                alarmIdMap.put(c,c);
+            }
+
+        }
+        String alarmId=null;
+        String component=null;
+        if(alarmIdList.length()>0)
+        {
+            alarmId=String.valueOf(alarmIdList.substring(0,alarmIdList.length()-1));
+        }
+        if(componentsList.length()>0)
+        {
+            component=String.valueOf(componentsList.substring(0,componentsList.length()-1));
+        }
+        List<ProBasicFeatureStat> fsls = alarmTsMapper.findCtFeatureStat(wtId,startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId,deviceType);
+
+
+        Map<String, ProBasicFeatureStat> map = new HashMap<>();
+        Date statDate=DateUtils.truncate(new Date());
+
+        if (!fsls.isEmpty()) {
+            for (ProBasicFeatureStat fs : fsls) {
+                if (StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode())) {
+                    ProEconAlarmType at = CacheContext.alarmTypeMap.get(fs.getTypeCode());
+                    fs.setTypeName(at.getName());
+                }
+                fs.setStatDate(new Timestamp(statDate.getTime()));
+                fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                StringBuilder sb = new StringBuilder();
+                sb.append(fs.getWtId()).append("_").append(fs.getAlarmid());
+                map.put(String.valueOf(sb), fs);
+            }
+        }
+        List<ProBasicFeatureStat> vos = new ArrayList<>();
+
+        if(CacheContext.wpwtmap.containsKey(stationId))
+        {
+            List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(stationId);
+            for (ProBasicEquipment wt : wtls) {
+
+                StringBuilder sb=new StringBuilder();
+                sb.append(wt.getWindpowerstationId()).append(wt.getModelId());
+
+                if(CacheContext.ctAlarmlsMap.containsKey(String.valueOf(sb))) {
+
+                    List<ProEconAlarmRule> wtCustomls=CacheContext.ctAlarmlsMap.get(String.valueOf(sb));
+
+                    for (ProEconAlarmRule at : wtCustomls) {
+
+                        if(StringUtils.notEmp(components) )
+                        {
+                            if(componentsMap.containsKey(at.getRelatedParts()) )
+                            {
+                                if(StringUtils.notEmp(alarmIdMap) && !alarmIdMap.isEmpty())
+                                {
+                                    if( alarmIdMap.containsKey(at.getId()))
+                                    {
+                                        setCtValues(statDate, map, vos, wt, at);
+                                    }
+
+                                }else
+                                {
+                                    setCtValues(statDate, map, vos, wt, at);
+                                }
+                            }
+                        }else
+                        {
+                            setCtValues(statDate, map, vos, wt, at);
+                        }
+
+                    }
+
+                }
+            }
+        }
+
+
+        Map<String,List<AlarmStatVo>> vomap=new HashMap<>();
+        for(ProBasicFeatureStat fs:vos)
+        {
+            AlarmStatVo d = new AlarmStatVo();
+            d.setRelateParts(fs.getTypeCode());
+            d.setRelatePartsText(fs.getTypeName());
+            d.setAlertText(fs.getDescription());
+            d.setCount(fs.getTotal());
+            if(StringUtils.notEmp(timeType))
+            {
+                if(AlarmTime.H.getCode().equals(timeType))
+                {
+                    double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(360), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    d.setTime(times);
+                }else if(AlarmTime.M.getCode().equals(timeType))
+                {
+                    double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    d.setTime(times);
+                }else
+                {
+                    d.setTime(fs.getTotalSeconds());
+                }
+            }else
+            {
+                double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                d.setTime(times);
+            }
+            d.setStationId(fs.getStationId());
+            d.setSnapId(SnowflakeGenerator.generateId());
+            d.setWindturbineId(fs.getWtId());
+            if(CacheContext.wtmap.containsKey(fs.getWtId()))
+            {
+                ProBasicEquipment wt= CacheContext.wtmap.get(fs.getWtId());
+                d.setWindturbineCode(wt.getNemCode());
+            }
+
+            StringBuilder sb=new StringBuilder();
+            sb.append(fs.getWtId()).append("_").append(fs.getTypeCode()).append("_").append(fs.getAlarmid());
+
+            if(map.containsKey(String.valueOf(sb)))
+            {
+                List<AlarmStatVo> ls=vomap.get(String.valueOf(sb));
+                ls.add(d);
+            }else
+            {
+                List<AlarmStatVo> ls=new ArrayList<>();
+                ls.add(d);
+                vomap.put(String.valueOf(sb),ls);
+            }
+            resultList.add(d);
+        }
+
+
+        return resultList;
+    }
+    private  static void setCtValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmRule at) {
+
+        ProBasicFeatureStat fs = new ProBasicFeatureStat();
+
+        StringBuilder sb = new StringBuilder();
+        sb.append(fs.getWtId()).append("_").append(at.getId());
+        if (map.containsKey(String.valueOf(sb))) {
+            ProBasicFeatureStat old = map.get(String.valueOf(sb));
+            BeanUtil.copyProperties(old, fs);
+        } else {
+            fs.setStatDate(new Timestamp(statDate.getTime()));
+            fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+            fs.setWtId(wt.getId());
+            fs.setStationId(wt.getWindpowerstationId());
+            fs.setTypeCode(at.getCategory());
+            if(CacheContext.alarmTypeMap.containsKey(at.getCategory()))
+            {
+                fs.setTypeName(CacheContext.alarmTypeMap.get(at.getCategory()).getName());
+            }
+            fs.setAlarmid(at.getId());
+            fs.setDescription(at.getDescription());
+            fs.setTotal(0l);
+            fs.setAvgSeconds(0.0);
+            fs.setMaxSeconds(0.0);
+            fs.setMinSeconds(0.0);
+            fs.setTotalSeconds(0.0);
+
+        }
+        vos.add(fs);
+    }
+}

+ 24 - 46
web/health/src/main/java/com/gyee/health/service/health/HealthReportService.java

@@ -25,11 +25,9 @@ public class HealthReportService {
 
     private static Logger logger = LoggerFactory.getLogger(HealthReportService.class);
 
-    @Resource
-    private IAlarmcountService alarmcountService;
 
-    @Resource
-    private IAlertrulefailureService alertrulefailureService;
+
+
 
     @Resource
     private IProBasicEquipmentPointService proBasicEquipmentPointService;
@@ -51,7 +49,11 @@ public class HealthReportService {
     private IProEconRecommenMainService proEconRecommenMainService;
 
     IRealTimeDataBaseUtil realApiUtil = RealTimeDataBaseFactory.createRealTimeDataBase();
+    @Resource
+    private IProEconAlarmRuleFailureService proEconAlarmRuleFailureService;
 
+    @Resource
+    private AlarmHistoryService alarmHistoryService;
 
     /**
      * 获得健康报告指标信息
@@ -234,22 +236,24 @@ public class HealthReportService {
                                     String gz2=gzarr[1];
                                     String gz3=gzarr[2];
 
-                                    vo.setTop1(gz1);
-                                    vo.setTop2(gz2);
-                                    vo.setTop3(gz3);
-
-                                    vo.setRecordDate(sj.getRecordDate());
 
-                                    vo.setWtId(wt.getId());
-                                    vo.setWtName(wt.getName());
-                                    List<Alertrulefailure> afls=alertrulefailureService.getPartByAlertrule(gz1,wt.getModelId());
+                                    List<ProEconAlarmRuleFailure> afls=proEconAlarmRuleFailureService.queryObject(gz1,wt.getWindpowerstationId(),wt.getModelId());
                                     if(!afls.isEmpty())
                                     {
-                                        Alertrulefailure af=afls.get(0);
-                                        vo.setGzpc(af.getGzpc());
-                                        vo.setGzcl(af.getGzyy());
-                                        vo.setGqj(af.getGqj());
-                                        vo.setXqsc(af.getXqsc());
+
+                                        ProEconAlarmRuleFailure af=afls.get(0);
+
+
+                                        vo.setTop1(gz1);
+                                        vo.setTop2(gz2);
+                                        vo.setTop3(gz3);
+                                        vo.setGzpc(af.getFaultCause());
+                                        vo.setGzcl(af.getResolvent());
+                                        vo.setRecordDate(sj.getRecordDate());
+                                        vo.setXqsc(af.getFaultTimes());
+                                        vo.setWtId(wt.getId());
+                                        vo.setWtName(wt.getName());
+                                        vo.setCode(wt.getNemCode());
                                     }
                                 }
                             }
@@ -699,9 +703,9 @@ public class HealthReportService {
      * @param wtId
      * @return
      */
-    public List<AlarmcountResultVo> getAlarmcountVoList(Date recordDate, String wtId) {
+    public List<ProBasicFeatureStat> getAlarmcountVoList(Date recordDate, String wtId) {
 
-        List<AlarmcountResultVo> vos = new ArrayList<>();
+        List<ProBasicFeatureStat> vos = new ArrayList<>();
         if (StringUtils.notEmp(recordDate) && StringUtils.notEmp(wtId)) {
             Calendar c = Calendar.getInstance();
             c.setTime(DateUtils.truncate(recordDate));
@@ -712,34 +716,8 @@ public class HealthReportService {
 
             ProBasicEquipment wt = CacheContext.wtmap.get(wtId);
 
-            Map<String, AlarmcountVo> map = new HashMap<>();
-            List<AlarmcountVo> vomodells = alarmcountService.findAlarmCountByModelId(wt.getModelId(), begin, end);
-            if (!vomodells.isEmpty()) {
-                for (AlarmcountVo vo : vomodells) {
-                    map.put(vo.getName() + vo.getAlertText(), vo);
-                }
-            }
+            vos = alarmHistoryService.findWtFeatureStat(begin, end, wt.getId(), AlarmTypeValue.WT.getCode(), "m");
 
-            List<AlarmcountVo> vols = alarmcountService.findAlarmCountByWt(wtId, begin, end);
-
-            if (!vols.isEmpty()) {
-                for (AlarmcountVo vo : vols) {
-                    AlarmcountResultVo po = new AlarmcountResultVo();
-                    if (map.containsKey(vo.getName() + vo.getAlertText())) {
-                        AlarmcountVo avgvo = map.get(vo.getName() + vo.getAlertText());
-                        po.setAvgtimes(avgvo.getTimes());
-                        po.setAvgcounts(avgvo.getCounts());
-                    }
-
-                    po.setName(vo.getName());
-                    po.setAlertText(vo.getAlertText());
-                    po.setModelId(wt.getModelId());
-                    po.setWtId(wt.getId());
-                    po.setTimes(vo.getTimes());
-                    po.setCounts(vo.getCounts());
-
-                }
-            }
         }
         return vos;
     }

+ 161 - 0
web/health/src/main/java/com/gyee/health/util/SnowflakeGenerator.java

@@ -0,0 +1,161 @@
+package com.gyee.health.util;
+
+/**
+ * Twitter_Snowflake<br>
+ * SnowFlake的结构如下(每部分用-分开):<br>
+ * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
+ * 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br>
+ * 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截)
+ * 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
+ * 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br>
+ * 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br>
+ * 加起来刚好64位,为一个Long型。<br>
+ * SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。
+ */
+public class SnowflakeGenerator {
+
+    // ==============================Fields===========================================
+    /** 开始时间截 (2015-01-01) */
+    private final long twepoch = 1420041600000L;
+
+    /** 机器id所占的位数 */
+    private final long workerIdBits = 5L;
+
+    /** 数据标识id所占的位数 */
+    private final long datacenterIdBits = 5L;
+
+    /** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
+    private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
+
+    /** 支持的最大数据标识id,结果是31 */
+    private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
+
+    /** 序列在id中占的位数 */
+    private final long sequenceBits = 12L;
+
+    /** 机器ID向左移12位 */
+    private final long workerIdShift = sequenceBits;
+
+    /** 数据标识id向左移17位(12+5) */
+    private final long datacenterIdShift = sequenceBits + workerIdBits;
+
+    /** 时间截向左移22位(5+5+12) */
+    private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
+
+    /** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
+    private final long sequenceMask = -1L ^ (-1L << sequenceBits);
+
+    /** 工作机器ID(0~31) */
+    private long workerId;
+
+    /** 数据中心ID(0~31) */
+    private long datacenterId;
+
+    /** 毫秒内序列(0~4095) */
+    private long sequence = 0L;
+
+    /** 上次生成ID的时间截 */
+    private long lastTimestamp = -1L;
+
+    //==============================Constructors=====================================
+    /**
+     * 构造函数
+     * @param workerId 工作ID (0~31)
+     * @param datacenterId 数据中心ID (0~31)
+     */
+    public SnowflakeGenerator(long workerId, long datacenterId) {
+        if (workerId > maxWorkerId || workerId < 0) {
+            throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
+        }
+        if (datacenterId > maxDatacenterId || datacenterId < 0) {
+            throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
+        }
+        this.workerId = workerId;
+        this.datacenterId = datacenterId;
+    }
+
+    // ==============================Methods==========================================
+    /**
+     * 获得下一个ID (该方法是线程安全的)
+     * @return SnowflakeId
+     */
+    public synchronized long nextId() {
+        long timestamp = timeGen();
+
+        //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
+        if (timestamp < lastTimestamp) {
+            throw new RuntimeException(
+                    String.format("Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
+        }
+
+        //如果是同一时间生成的,则进行毫秒内序列
+        if (lastTimestamp == timestamp) {
+            sequence = (sequence + 1) & sequenceMask;
+            //毫秒内序列溢出
+            if (sequence == 0) {
+                //阻塞到下一个毫秒,获得新的时间戳
+                timestamp = tilNextMillis(lastTimestamp);
+            }
+        }
+        //时间戳改变,毫秒内序列重置
+        else {
+            sequence = 0L;
+        }
+
+        //上次生成ID的时间截
+        lastTimestamp = timestamp;
+
+        //移位并通过或运算拼到一起组成64位的ID
+        return ((timestamp - twepoch) << timestampLeftShift) //
+                | (datacenterId << datacenterIdShift) //
+                | (workerId << workerIdShift) //
+                | sequence;
+    }
+
+    /**
+     * 阻塞到下一个毫秒,直到获得新的时间戳
+     * @param lastTimestamp 上次生成ID的时间截
+     * @return 当前时间戳
+     */
+    protected long tilNextMillis(long lastTimestamp) {
+        long timestamp = timeGen();
+        while (timestamp <= lastTimestamp) {
+            timestamp = timeGen();
+        }
+        return timestamp;
+    }
+
+    /**
+     * 返回以毫秒为单位的当前时间
+     * @return 当前时间(毫秒)
+     */
+    protected long timeGen() {
+        return System.currentTimeMillis();
+    }
+
+
+    private static SnowflakeGenerator idWorker = null;
+
+    public synchronized static SnowflakeGenerator getIdWorker() {
+
+        if (idWorker == null)
+            idWorker = new SnowflakeGenerator(2, 3);
+
+        return idWorker;
+    }
+
+    public static long generateId() {
+        //if (idWorker == null)
+            //idWorker = new SnowflakeGenerator(0, 0);
+
+        //return idWorker.nextId();
+        SnowflakeGenerator snowflakeGenerator = getIdWorker();
+
+        return snowflakeGenerator.nextId();
+//        for (int i = 0; i < 1000; i++) {
+//            long id = idWorker.nextId();
+//            System.out.println(Long.toBinaryString(id));
+//            System.out.println(id);
+//        }
+    }
+}

+ 8 - 6
web/health/src/main/resources/application-jn.yml

@@ -96,10 +96,10 @@ spring:
           password: postgres
           driver-class-name: org.postgresql.Driver
         slave:
-          url: jdbc:postgresql://10.81.3.151:5432/wisdom
-          username: postgres
-          password: gd123
-          driver-class-name: org.postgresql.Driver
+          driver-class-name: com.taosdata.jdbc.TSDBDriver
+          url: jdbc:TAOS://10.81.3.154:6030/nemjn?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8
+          username: root
+          password: taosdata
         #配置初始化连接数大小
       initial-size: 10
       # 最大连接数
@@ -170,5 +170,7 @@ logging:
     com.example: debug
 initialcode: INITIAL
 db:
-  baseURL: http://10.81.3.152:8098/ts
-  baseURL1: http://10.81.3.152:8099/ts
+  baseURL: http://10.81.3.162:8011/ts
+  baseURL1: http://10.81.3.162:8012/ts
+#首页展示数据数量
+home_pagep_size: 50