Browse Source

修改功率曲线拟合功能

shilin 1 year ago
parent
commit
78ffe37b9f
19 changed files with 344 additions and 672 deletions
  1. 12 0
      realtime/healthmodel-server/pom.xml
  2. 179 36
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/init/CacheContext.java
  3. 3 3
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/init/InitialRedis.java
  4. 2 1
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlarmTsMapper.java
  5. 3 3
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconAlarmRuleFailureMapper.java
  6. 3 23
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmConfiguration.java
  7. 1 3
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmRuleFailure.java
  8. 1 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmVo.java
  9. 2 2
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmHistoryService.java
  10. 4 7
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmInService.java
  11. 0 3
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmWtService.java
  12. 55 444
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/HealthJudgeService.java
  13. 33 59
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/HealthReportService.java
  14. 1 31
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/RecommenmainsService.java
  15. 5 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmRuleFailureService.java
  16. 16 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmRuleFailureServiceImpl.java
  17. 0 46
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/task/SaticScheduleTask.java
  18. 8 4
      realtime/healthmodel-server/src/main/resources/application-jn.yml
  19. 16 7
      realtime/healthmodel-server/src/test/java/HealthTest.java

+ 12 - 0
realtime/healthmodel-server/pom.xml

@@ -26,6 +26,7 @@
 
     </properties>
     <dependencies>
+
         <dependency>
             <groupId>redis.clients</groupId>
             <artifactId>jedis</artifactId>
@@ -165,6 +166,17 @@
             <scope>system</scope>
             <systemPath>${basedir}/lib/xxl-job-core-2.3.1-SNAPSHOT.jar</systemPath>
         </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>

+ 179 - 36
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/init/CacheContext.java

@@ -1,9 +1,18 @@
 package com.gyee.healthmodel.init;
 
 
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.model.StringUtils;
 import com.gyee.healthmodel.model.auto.*;
+import com.gyee.healthmodel.model.vo.AlarmCustomType;
+import com.gyee.healthmodel.model.vo.AlarmVo;
+import com.gyee.healthmodel.service.AlarmCtService;
+import com.gyee.healthmodel.service.AlarmInService;
+import com.gyee.healthmodel.service.AlarmWtService;
 import com.gyee.healthmodel.service.auto.*;
+import com.gyee.healthmodel.util.redis.RedisService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,8 +54,27 @@ public class CacheContext implements CommandLineRunner {
     private IProBasicPowerstationPointService  proBasicPowerstationPointService;
 
     @Resource
-    private IAlertrule2Service alertrule2Service;
+    private AlarmWtService alarmWtService;
+    @Resource
+    private AlarmInService alarmInService;
+
+    @Resource
+    private AlarmCtService alarmCtService;
+
+    @Resource
+    private IProBasicSubStationService proBasicSubStationService;
+    @Resource
+    private IProEconAlarmRuleService proEconAlarmRuleService;
+
+    @Resource
+    private RedisService redisService;
+    public static List<ProBasicSubStation> subwpls = new ArrayList<>();
 
+    public static Map<String, ProBasicSubStation> subwpmap = new HashMap<>();
+
+    public static Map<String, Map<String, ProBasicPowerstationPoint>> subwppointmap = new HashMap<>();
+
+    public static Map<String, List<ProBasicEquipment>> subWtsMap = new HashMap<>();
     public static Map<String, ProBasicEquipment> wtmap = new HashMap<String, ProBasicEquipment>(); // 风电机MAP
 
 
@@ -70,13 +98,34 @@ public class CacheContext implements CommandLineRunner {
     public static List<ProEconEquipmentmodel> mlls = new ArrayList<ProEconEquipmentmodel>();// 风电机模型LIST集合
     public static Map<String, ProEconEquipmentmodel> mlmap = new HashMap<String, ProEconEquipmentmodel>();// 风电机模型
     public static Map<String, List<ProBasicEquipment>> wtlinemap = new HashMap<String, List<ProBasicEquipment>>(); // 
-    public static List<Alertrule2> alarmrulels = new ArrayList<>();
+
 
     public static List<ProBasicPowerstationPoint> powerpointls = new ArrayList<>();
     public static Map<String, Map<String, ProBasicPowerstationPoint>> pointwpmap = new HashMap<>();
 
     public static Map<String, Map<String, ProBasicPowerstationPoint>> lnPointmap = new HashMap<>();//线路测点
     public static Map<String, Map<String, ProBasicPowerstationPoint>> pjPointmap = new HashMap<>(); //期次测点
+
+    public static Map<String,List<ProEconAlarmConfiguration>> wtAlarmMap=new HashMap<>();
+
+    public static Map<String, List<ProEconAlarmRule>> alarmRulesMap = new HashMap<>();
+
+    public static Map<String, List<ProEconAlarmRule>> alarmRulesModelMap = new HashMap<>();
+    public static Map<String,List<AlarmVo>> alarmWpMap=new HashMap<>();
+    public static List<AlarmVo> alarmWtList=new ArrayList<>();
+    public static Map<String,AlarmVo> alarmWtMap=new HashMap<>();
+
+    public static List<AlarmVo> alarmInList=new ArrayList<>();
+    public static Map<String,AlarmVo> alarmInMap=new HashMap<>();
+
+    public static List<AlarmVo> alarmCtList=new ArrayList<>();
+    public static Map<String,AlarmVo> alarmCtMap=new HashMap<>();
+
+    public static Map<String, ProEconAlarmType> alarmTypeMap = new HashMap<>();
+
+    public static Map<String, List<ProEconAlarmRule>> ctAlarmlsMap = new HashMap<>();
+
+    public static Map<String, List<ProBasicEquipment>> wpwtmap = new HashMap<>();
     @Override
     public void run(String... args) throws Exception {
 
@@ -168,6 +217,15 @@ public class CacheContext implements CommandLineRunner {
                     wts.add(wt);
                     wtlinemap.put(wt.getLineId(), wts);
                 }
+
+
+                if (wpwtmap.containsKey(wt.getWindpowerstationId())) {
+                    wpwtmap.get(wt.getWindpowerstationId()).add(wt);
+                } else {
+                    List<ProBasicEquipment> wps = new ArrayList<>();
+                    wps.add(wt);
+                    wpwtmap.put(wt.getWindpowerstationId(), wps);
+                }
             }
         }
 
@@ -243,40 +301,125 @@ public class CacheContext implements CommandLineRunner {
             }
         }
 
+        QueryWrapper<ProBasicSubStation> querySubWrapper = new QueryWrapper<>();
+        querySubWrapper.orderByAsc("order_num");
+        subwpls = proBasicSubStationService.list(querySubWrapper).stream().filter(i ->  i.getIsAble() == 1).collect(Collectors.toList());
+        subwpls.stream().forEach(sub -> {
+
+            subwpmap.put(sub.getId(), sub);
+            String subString = redisService.get(sub.getId());
+            Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(subString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
+            });
+            subwppointmap.put(sub.getId(), stringWindpowerstationpointnewMap);
+
+            List<ProBasicEquipment> collect = wtls.stream().filter(wt -> wt.getSubstationId().equals(sub.getId())).collect(Collectors.toList());
+            subWtsMap.put(sub.getId(), collect);
+
+        });
+
+        List<ProEconAlarmRule> customls =proEconAlarmRuleService.list().stream().filter(i -> i.getEnable()).collect(Collectors.toList());
+
+        List<ProEconAlarmRule> wtCustomls=new ArrayList<>();
+        List<ProEconAlarmRule> inCustomls=new ArrayList<>();
+        List<ProEconAlarmRule> btCustomls=new ArrayList<>();
+        if(!customls.isEmpty())
+        {
+            for(ProEconAlarmRule vo: customls)
+            {
+                if(vo.getCategory().equals(AlarmCustomType.WT.getCode()))
+                {
+                    wtCustomls.add(vo);
+                }else  if(vo.getCategory().equals(AlarmCustomType.IN.getCode()))
+                {
+                    inCustomls.add(vo);
+                }else  if(vo.getCategory().equals(AlarmCustomType.BT.getCode()))
+                {
+                    btCustomls.add(vo);
+                }
+                StringBuilder sb=new StringBuilder();
+                sb.append(vo.getStationId()).append("_").append(vo.getModelId());
+
+                if(alarmRulesModelMap.containsKey(String.valueOf(sb)))
+                {
+                    List<ProEconAlarmRule> customtempls=alarmRulesModelMap.get(String.valueOf(sb));
+                    customtempls.add(vo);
+                }else
+                {
+                    List<ProEconAlarmRule> customtempls=new ArrayList<>();
+                    customtempls.add(vo);
+                    alarmRulesModelMap.put(String.valueOf(sb),customtempls);
+                }
+
+                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);
+                        }
+                    }
+                    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);
+                        }
+                   }
+                }
+            }
+        }
+        alarmRulesMap.put(AlarmCustomType.BT.getCode(),btCustomls);
+        alarmRulesMap.put(AlarmCustomType.WT.getCode(),wtCustomls);
+        alarmRulesMap.put(AlarmCustomType.IN.getCode(),inCustomls);
+
+
+        //风机报警初始化标签
+        alarmWtList=alarmWtService.initalAlarmVo();
+        if(!alarmWtList.isEmpty())
+        {
+            for(AlarmVo vo: alarmWtList)
+            {
+                if(alarmWpMap.containsKey(vo.getStationid()))
+                {
+                    List<AlarmVo> ls=alarmWpMap.get(vo.getStationid());
+                    ls.add(vo);
+                }else {
+                    List<AlarmVo> ls=new ArrayList<>();
+                    ls.add(vo);
+                    alarmWpMap.put(vo.getStationid(),ls);
+                }
+                alarmWtMap.put(vo.getTbName(),vo);
+            }
+        }
+        //逆变器报警初始化标签
+        alarmInList=alarmInService.initalAlarmVo();
+        if(!alarmInList.isEmpty())
+        {
+            for(AlarmVo vo: alarmInList)
+            {
+                alarmInMap.put(vo.getTbName(),vo);
+            }
+        }
+
+        //自定义报警初始化标签
+        alarmCtList=alarmCtService.initalAlarmVo();
+        if(!alarmCtList.isEmpty())
+        {
+            for(AlarmVo vo: alarmCtList)
+            {
+                alarmCtMap.put(vo.getTbName(),vo);
+            }
+        }
+
         log.info("-------------------------------缓存结束--------------------------------------");
     }
-//  取redis
-//    private Logger logger = LoggerFactory.getLogger(CacheContext.class);
-//    @Resource
-//    private IWindturbinetestingpointService windturbinetestingpointService;
-//    @Resource
-//    private RedisService redisService;
-//
-//    public static Map<String, Map<String, Windturbinetestingpoint>> wtpAimap = new HashMap<>();// 风电机测点表
-//
-//    @Override
-//    public void run(String... args) {
-//        logger.info("--------------------------------缓存开始--------------------------------");
-//        if (redisService.hasKey("WT")){
-//            String wt = redisService.get("WT");
-//            wtpAimap = (Map<String, Map<String, Windturbinetestingpoint>>) JSONUtils.parse(wt);
-//        }else {
-//            List<Windturbinetestingpoint> windturbinetestingpointList = windturbinetestingpointService.list();
-//            Map<String, Windturbinetestingpoint> map = null;
-//
-//            if(windturbinetestingpointList != null && !windturbinetestingpointList.isEmpty()){
-//                for(Windturbinetestingpoint mp : windturbinetestingpointList){
-//                    if(wtpAimap.containsKey(mp.getWindturbineId())){
-//                        map = wtpAimap.get(mp.getWindturbineId());
-//                        map.put(mp.getUniformCode(), mp);
-//                    }else{
-//                        map = new HashMap<String, Windturbinetestingpoint>();
-//                        map.put(mp.getUniformCode(), mp);
-//                        wtpAimap.put(mp.getWindturbineId(), map);
-//                    }
-//                }
-//            }
-//        }
-//        logger.info("--------------------------------缓存结束--------------------------------");
-//    }
+
 }

+ 3 - 3
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/init/InitialRedis.java

@@ -38,9 +38,9 @@ public  class InitialRedis {
     public  void initialRedisAll() throws Exception {
 
         System.out.println("初始化开始!");
-        intialWpScatter();
-        intialPjScatter();
-        intialLnScatter();
+//        intialWpScatter();
+//        intialPjScatter();
+//        intialLnScatter();
         intialWtScatter();
         System.out.println("初始化完成!");
 

+ 2 - 1
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlarmTsMapper.java

@@ -251,6 +251,7 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "and ts &lt;= #{end}",
             "and stationid = #{stationid}",
             "and modelId = #{modelId}",
+            "and deviceid = #{wtId}",
             "<if test='alarmid != null'>",
             "and alarmid in(${alarmid}) ",
             "</if>",
@@ -265,7 +266,7 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             " group by deviceid,components,stationid,alarmid,description ",
             " order by deviceid, total desc ",
             "</script>"})
-    List<ProBasicFeatureStat> findCtFeatureStat( @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("deviceType")String deviceType);
+    List<ProBasicFeatureStat> findCtFeatureStat( @Param("wtId") String wtId,  @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("deviceType")String deviceType);
 
     @Select("${sql}")
     List<AlarmSimpleVo> selectLastRowByTbname(@Param("sql") String sql);

+ 3 - 3
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconAlarmRuleFailureMapper.java

@@ -19,7 +19,7 @@ import java.util.List;
 public interface ProEconAlarmRuleFailureMapper extends BaseMapper<ProEconAlarmRuleFailure> {
 
     @Select({"<script>",
-            "select * from pro_econ_alarm_configuration ",
+            "select * from pro_econ_alarm_rule_failure ",
             "<where>",
             " 1=1 ",
 
@@ -27,7 +27,7 @@ public interface ProEconAlarmRuleFailureMapper extends BaseMapper<ProEconAlarmRu
             "and station_id  = #{wpId} ",
             "</if>",
             "<if test='name !=null  '>",
-            "and description = #{description} ",
+            "and name = #{name} ",
             "</if>",
             "<if test='modelId !=null  '>",
             "and model_id = #{modelId} ",
@@ -35,7 +35,7 @@ public interface ProEconAlarmRuleFailureMapper extends BaseMapper<ProEconAlarmRu
             "</where>",
 
             "</script>"})
-    List<ProEconAlarmRuleFailure> queryObject(@Param("description") String description,
+    List<ProEconAlarmRuleFailure> queryObject(@Param("name") String name,
                                                 @Param("wpId") String wpId,
                                                 @Param("modelId") String modelId);
 }

+ 3 - 23
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmConfiguration.java

@@ -1,6 +1,6 @@
 package com.gyee.healthmodel.model.auto;
 
-import com.alibaba.excel.annotation.ExcelProperty;
+
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -29,128 +29,108 @@ public class ProEconAlarmConfiguration extends Model {
     /**
      * 编号
      */
-    @ExcelProperty("编号")
+
     @TableId(value = "ID",type = IdType.INPUT)
     private String id;
 
     /**
      * 测点(如果根据uniformcode配置此字段可为空)
      */
-    @ExcelProperty("测点")
     private String tagId;
 
     /**
      * 触发条件,0触发,1触发,-1变化触发,4ai点触发
      */
-    @ExcelProperty("触发条件")
     private Integer triggerType;
 
     /**
      * 设备ID
      */
-    @ExcelProperty("设备ID")
     private String deviceId;
 
     /**
      * 后缀
      */
-    @ExcelProperty("后缀")
     private String suffix;
 
     /**
      * 报警级别
      */
-    @ExcelProperty("报警级别")
     private Integer rank;
 
     /**
      * 统一识别码(如果通过uniformCode配置,则设备类型,场站,机型不能为空)
      */
-    @ExcelProperty("统一识别码")
     private String uniformCode;
 
     /**
      * 场站ID
      */
-    @ExcelProperty("场站ID")
     private String stationId;
 
     /**
      * 机型
      */
-    @ExcelProperty("机型")
     private String modelId;
 
     /**
      * 报警类型 /自定义报警 custom,风机 windturbine,场站 station,升压站 booststation
      */
-    @ExcelProperty("报警类型")
     private String alarmType;
 
     /**
      * 设备类型,场站 station,风机 windturbine,升压站 booststation
      */
-    @ExcelProperty("设备类型")
     private String deviceType;
 
     /**
      * 设备部件
      */
-    @ExcelProperty("设备部件")
     private String components;
 
     /**
      * 设备子部件
      */
-    @ExcelProperty("设备子部件")
     private String subcomponents;
 
     /**
      * 报警描述
      */
-    @ExcelProperty("报警描述")
     private String description;
 
     /**
      * 特性
      */
-    @ExcelProperty("特性")
     private String characteristic;
 
     /**
      * 是否可复位
      */
-    @ExcelProperty("是否可复位")
     private Boolean resetTable;
 
     /**
      * 是否启用
      */
-    @ExcelProperty("是否启用")
     private Boolean enable;
 
     /**
      * 故障名称
      */
-    @ExcelProperty("故障名称")
-    private String name;
+      private String name;
 
     /**
      *故障码
      */
-    @ExcelProperty("故障码")
     private String nemCode;
 
     /**
      * 故障原因
      */
-    @ExcelProperty("故障原因")
     private String faultCause;
 
     /**
      * 排查方法
      */
-    @ExcelProperty("排查方法")
     private String resolvent;
 
 

+ 1 - 3
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmRuleFailure.java

@@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
-import java.math.BigDecimal;
-
 /**
  * <p>
  * 故障规则
@@ -73,7 +71,7 @@ public class ProEconAlarmRuleFailure extends Model {
     /**
      * 故障时长
      */
-    private BigDecimal faultTimes;
+    private Double faultTimes;
 
     /**
      * 关联部件

+ 1 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmVo.java

@@ -65,4 +65,5 @@ public class AlarmVo {
     private String wpId;
     private String faultType;
     private String id;
+    private String aname;
 }

+ 2 - 2
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmHistoryService.java

@@ -379,7 +379,7 @@ public class AlarmHistoryService {
         vos.add(fs);
     }
 
-    public List<AlarmStatVo> findCtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components,String deviceType,String alarmIds,String timeType) {
+    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<>();
 
 
@@ -419,7 +419,7 @@ public class AlarmHistoryService {
         {
             component=String.valueOf(componentsList.substring(0,componentsList.length()-1));
         }
-        List<ProBasicFeatureStat> fsls = alarmTsMapper.findCtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId,deviceType);
+        List<ProBasicFeatureStat> fsls = alarmTsMapper.findCtFeatureStat(wtId,startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId,deviceType);
 
 
         Map<String, ProBasicFeatureStat> map = new HashMap<>();

+ 4 - 7
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmInService.java

@@ -8,7 +8,6 @@ import com.gyee.healthmodel.model.vo.AlarmSuperTalbeType;
 import com.gyee.healthmodel.model.vo.AlarmTypeValue;
 import com.gyee.healthmodel.model.vo.AlarmVo;
 import com.gyee.healthmodel.service.auto.IAlarmTsService;
-import com.gyee.healthmodel.util.realtimesource.IEdosUtil;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -27,8 +26,6 @@ public class AlarmInService {
     private String initialcode;
 
 
-    @Resource
-    private IEdosUtil edosUtil;
 
 
     public List<AlarmVo> initalAlarmVo() throws Exception {
@@ -65,15 +62,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()))

+ 0 - 3
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmWtService.java

@@ -8,7 +8,6 @@ import com.gyee.healthmodel.model.vo.AlarmTypeValue;
 import com.gyee.healthmodel.model.vo.AlarmVo;
 import com.gyee.healthmodel.service.auto.IAlarmTsService;
 import com.gyee.healthmodel.util.StringUtils;
-import com.gyee.healthmodel.util.realtimesource.IEdosUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
@@ -28,8 +27,6 @@ public class AlarmWtService {
     private String initialcode;
 
 
-    @Resource
-    private IEdosUtil edosUtil;
 
     private static Logger logger = LoggerFactory.getLogger(AlarmWtService.class);
 

+ 55 - 444
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/HealthJudgeService.java

@@ -5,15 +5,15 @@ import com.gyee.common.contant.ContantXk;
 import com.gyee.common.model.PointData;
 import com.gyee.healthmodel.init.CacheContext;
 import com.gyee.healthmodel.model.auto.*;
+import com.gyee.healthmodel.model.vo.AlarmCustomType;
+import com.gyee.healthmodel.model.vo.AlarmStatVo;
 import com.gyee.healthmodel.model.vo.StatusDetailValue;
 import com.gyee.healthmodel.service.auto.*;
 import com.gyee.healthmodel.util.*;
-import com.gyee.healthmodel.vo.healthsystem.DataVo;
 import com.gyee.healthmodel.vo.healthsystem.HealthExpression;
 import com.gyee.healthmodel.vo.healthsystem.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -21,7 +21,6 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
 import java.util.Map.Entry;
-import java.util.concurrent.CountDownLatch;
 
 
 @Service
@@ -32,8 +31,7 @@ public class HealthJudgeService {
     private IProEconHealthSystemService proEconHealthSystemService;
     @Resource
     private IProEconHealthSystemSubService proEconHealthSystemSubService;
-    @Resource
-    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
+
     @Resource
     private IProEconStateJudgmentDayService proEconStateJudgmentDayService;
     @Resource
@@ -43,32 +41,14 @@ public class HealthJudgeService {
     @Resource
     private HealthFactoryService healthFactoryService;
 
-    @Resource
-    private AlarmcountsService alarmcountsService;
-    @Resource
-    private AlarmsnapsService alarmsnapsService;
-    @Resource
-    private Alertrule2sService alertrule2sService;
-
-    @Resource
-    private IProEconWindturbineWarnCountService proEconWindturbineWarnCountService;
-    @Resource
-    private IProEconPartWarnCountService proEconPartWarnCountService;
-    @Resource
-    private IProEconPartWarnCountSubService proEconPartWarnCountSubService;
-
-    @Resource
-    private AlertrulefailuresubsService alertrulefailuresubsService;
-    @Resource
-    private IProEconEarlyWarningMainService proEconEarlyWarningMainService;
     private final double judgescore = 80;
     @Resource
     private IProBasicEquipmentPointService proBasicEquipmentPointsService;
-    @Resource
-    private IProEconCurveFittingSubService proEconCurveFittingSubService;
-    @Resource
-    private IProEconEquipmentInfoDayTopService proEconEquipmentInfoDayTopService;
+
+
     IRealTimeDataBaseUtil realApiUtil = RealTimeDataBaseFactory.createRealTimeDataBase();
+    @Resource
+    private  AlarmHistoryService  alarmHistoryService;
 
     public void changeHealthModelValue() throws Exception {
 
@@ -152,18 +132,17 @@ public class HealthJudgeService {
 
                 if(clxzt==4 || fdjzt==4 || bjzt==4 || zkzt==4)
                 {
-                    score =  score=setScoreValue(score);
+                    score=setScoreValue(score);
                     statejudgment.append("1-");
                 }else if(clxzt==3 || fdjzt==3 || bjzt==3 || zkzt==3)
                 {
-                    score =  score=setScoreValue(score);
+                   score=setScoreValue(score);
                     statejudgment.append("1-");
                 }else {
                     statejudgment.append("0-");
                 }
 
 
-//                Map<String, Double> xnmap = proEconEquipmentInfoDayTopService.findXnfx(Calendar.getInstance().getTime());
                 Map<String, Double> xnmap=HealthInitialService.djpgchagemap;
                 if (xnmap.containsKey(wt.getId())) {
                     double djpgscore = xnmap.get(wt.getId());
@@ -177,15 +156,7 @@ public class HealthJudgeService {
                     statejudgment.append("0-");
                 }
 
-//                Map<String, List<ProEconCurveFittingSub>> cfmap = null;
-//                Calendar c = Calendar.getInstance();
-//                c.add(Calendar.DAY_OF_MONTH, -1);
-//
-//
-////                cfmap = proEconCurveFittingSubService.findCurvefittingmapByDate(c.getTime(), wt.getId(), 3.0, 5.0);
-//
-//                double qxpc1 = proEconCurveFittingSubService.getNuberValue(cfmap, wt);
-//                double xfqrqc = Math.abs(qxpc1);
+
                 Map<String, Double> xfpdmap=HealthInitialService.xfpdchagemap;
                 if(xfpdmap.containsKey(wt.getId()))
                 {
@@ -201,9 +172,6 @@ public class HealthJudgeService {
                     statejudgment.append("0-");
                 }
 
-//                cfmap = proEconCurveFittingSubService.findCurvefittingmapByDate(c.getTime(), wt.getId(), 5.0, 11.0);
-//                double qxpc2 = proEconCurveFittingSubService.getNuberValue(cfmap, wt);
-//                double zcclqc = Math.abs(qxpc2);
 
                 Map<String, Double> clpdmap=HealthInitialService.clpdchagemap;
                 if(clpdmap.containsKey(wt.getId()))
@@ -219,10 +187,7 @@ public class HealthJudgeService {
                 }else {
                     statejudgment.append("0-");
                 }
-//
-//                cfmap = proEconCurveFittingSubService.findCurvefittingmapByDate(c.getTime(), wt.getId(), 11.0, 25.0);
-//                double qxpc3 = proEconCurveFittingSubService.getNuberValue(cfmap, wt);
-//                double dfqrqc = Math.abs(qxpc3);
+
 
                 Map<String, Double> dfpdmap=HealthInitialService.dfpdchagemap;
                 if(dfpdmap.containsKey(wt.getId()))
@@ -239,13 +204,12 @@ public class HealthJudgeService {
                     statejudgment.append("0-");
                 }
 
-
-
                 po.setStateJudgment(String.valueOf(statejudgment.substring(0, statejudgment.length() - 1)));
 
                 pols.add(po);
 
                 fjjkzfpoint.setPointValueInDouble(score);
+
                 realApiUtil.updatePoint(fjjkzfpoint);
 
             }
@@ -511,14 +475,14 @@ public class HealthJudgeService {
         Date beginDate = c.getTime();
         Map<String, ResultVo> map = new HashMap<String, ResultVo>();
         List<String> resultList = new ArrayList<String>();
-        List<Alertrule2> voList = findArsubs(wt.getWindpowerstationId(), wt.getModelId());
-        for (Alertrule2 arv : voList) {
-            Long snapid = findAlarmsnap(wt, arv.getEdnavalue());
-            String cc = findAlarmcount(snapid, beginDate, endDate);
-            String[] temp = cc.split(",");
-            Double countsum = Double.parseDouble(temp[0]);
+        List<ProEconAlarmRule> voList = findArsubs(wt.getWindpowerstationId(), wt.getModelId());
+        for (ProEconAlarmRule arv : voList) {
+
+            String temp = findAlarmcount(wt.getId(),arv.getStationId(),arv.getModelId(),arv.getId(), beginDate, endDate);
+            Double countsum = Double.parseDouble(temp);
             Double benchmark = countsum / 3;
-            Double yestodayCount = findyearstodayAlarmcount(snapid, date, date);
+            String yestodayTemp =findAlarmcount(wt.getId(),arv.getStationId(),arv.getModelId(),arv.getId(), date, date);
+            Double yestodayCount =Double.valueOf(yestodayTemp);
             Double deviation = 0.0;
             if (benchmark != 0) {
                 deviation = (double) (Math.abs((yestodayCount - benchmark)) / benchmark);
@@ -656,53 +620,46 @@ public class HealthJudgeService {
     /**
      * 查询指定时间区间内的规则报警次数
      *
-     * @param snapid
+     * @param stationId
+     * @param modelId
+     * @param alarmIds
      * @param beginDate
      * @param endDate
      * @return
      */
-    private String findAlarmcount(Long snapid, Date beginDate, Date endDate) {
-
-        if (snapid != 0) {
+    private String findAlarmcount(String wtId,String stationId, String modelId,String alarmIds, Date beginDate, Date endDate) {
 
-            String result = alarmcountsService.findAlarmcount(snapid, beginDate, endDate);
-
-            return result;
-        }
-        return "0.0,0.0";
+        String result =  "0.0";
+        if(StringUtils.notEmp(stationId) && StringUtils.notEmp(modelId) && StringUtils.notEmp(modelId))
+        {
+            List<AlarmStatVo> pressureList =new ArrayList<>();
 
-    }
+            if(StringUtils.notEmp(stationId) && stationId.contains("FDC"))
+            {    String deviceType= AlarmCustomType.WT.getCode();
+                pressureList = alarmHistoryService.findCtFeatureStat(wtId,stationId,modelId, beginDate, endDate,null,deviceType,alarmIds,"m");
 
-    private Double findyearstodayAlarmcount(Long snapid, Date beginDate, Date endDate) {
+            }else   if(StringUtils.notEmp(stationId) && stationId.contains("GDC"))
+            {    String deviceType= AlarmCustomType.IN.getCode();
+                pressureList = alarmHistoryService.findCtFeatureStat(wtId,stationId,modelId, beginDate, endDate,null,deviceType,alarmIds,"m");
 
-        if (snapid != 0) {
-            Double result = alarmcountsService.findyearstodayAlarmcount(snapid, beginDate, endDate);
+            }
 
-            return result;
+            if(!pressureList.isEmpty())
+            {
+                AlarmStatVo vo=pressureList.get(0);
+                StringBuilder sb=new StringBuilder();
+                sb.append(vo.getCount());
+                result =  String.valueOf(sb);
+            }
         }
-        return 0.0;
-
-    }
 
-    /**
-     * 查询风机单个规则在alermsnap表里id snapid:此id可以关联到alarmcount表查询次数
-     *
-     * @param wt
-     * @param ednavalue
-     * @return
-     */
-
-    private Long findAlarmsnap(ProBasicEquipment wt, Long ednavalue) {
+        return result;
 
-        if (StringUtils.notEmp(wt) && StringUtils.notEmp(ednavalue)) {
-            Long result = alarmsnapsService.getAlarmsnapid(wt.getId(), ednavalue);
-            return result;
-        }
 
-        return 0l;
     }
 
 
+
     /**
      * 查询单个风场型号的特征规则
      *
@@ -710,10 +667,20 @@ public class HealthJudgeService {
      * @param staionid
      * @return
      */
-    private List<Alertrule2> findArsubs(String staionid, String modelid) {
+    private List<ProEconAlarmRule> findArsubs(String staionid, String modelid) {
+
+        List<ProEconAlarmRule> voList =new ArrayList<>();
 
         if (StringUtils.notEmp(modelid) && StringUtils.notEmp(staionid)) {
-            List<Alertrule2> voList = alertrule2sService.findAlertRuleList(staionid, modelid);
+
+            StringBuilder sb=new StringBuilder();
+            sb.append(staionid).append("_").append(modelid);
+
+            if(CacheContext.alarmRulesModelMap.containsKey(String.valueOf(sb)))
+            {
+               voList=CacheContext.alarmRulesModelMap.get(String.valueOf(sb));
+            }
+
 
             return voList;
         }
@@ -775,364 +742,8 @@ public class HealthJudgeService {
         }
     }
 
-    private List<ProEconWindturbineWarnCount> queryWindturbinebjCountByLineAndAlertrule(Alertrule2 ar, String lnid) {
-
-        if (StringUtils.notEmp(ar) && StringUtils.notEmp(lnid)) {
-            List<ProEconWindturbineWarnCount> list = proEconWindturbineWarnCountService.queryWindturbinebjCountByLineAndAlertrule(ar.getId(), lnid);
-            return list;
-        }
-        return new ArrayList<>();
-    }
-
-    private Boolean isExceedingStandard(ProEconWindturbineWarnCount wb) {
-        if (wb.getTotal() == 0 || wb.getTotal() <= wb.getAverageQuantity()) {
-            return false;
-        }
-        if (("" + wb.getAverageQuantity()).length() == 1) {
-            if (wb.getAverageQuantity() == 0 && wb.getTotal() >= 8) {
-                return true;
-            } else if (wb.getAverageQuantity() == 1 && wb.getTotal() >= 20) {
-                return true;
-            } else if (wb.getAverageQuantity() == 2 && wb.getTotal() >= 30) {
-                return true;
-            } else if (wb.getAverageQuantity() == 3 && wb.getTotal() >= 30) {
-                return true;
-            } else if (wb.getAverageQuantity() == 4 && wb.getTotal() >= 30) {
-                return true;
-            } else if (wb.getAverageQuantity() == 5 && wb.getTotal() >= 30) {
-                return true;
-            } else if (wb.getAverageQuantity() == 6 && wb.getTotal() >= 30) {
-                return true;
-            } else if (wb.getAverageQuantity() == 7 && wb.getTotal() >= 30) {
-                return true;
-            } else if (wb.getAverageQuantity() == 8 && wb.getTotal() >= 30) {
-                return true;
-            } else if (wb.getAverageQuantity() == 9 && wb.getTotal() >= 30) {
-                return true;
-            } else {
-                return false;
-            }
-        } else if (("" + wb.getAverageQuantity()).length() == 2) {
-            if (getFirstDigit(wb.getAverageQuantity().intValue()) == 1 && wb.getTotal() >= (wb.getAverageQuantity() * 3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 2 && wb.getTotal() >= (wb.getAverageQuantity() * 2)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 3 && wb.getTotal() >= (wb.getAverageQuantity() * 1.5)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 4 && wb.getTotal() >= (wb.getAverageQuantity() * 1.4)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 5 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 6 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 7 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 8 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 9 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else {
-                return false;
-            }
-        } else if (("" + wb.getAverageQuantity()).length() == 3) {
-            if (getFirstDigit(wb.getAverageQuantity().intValue()) == 1 && wb.getTotal() >= (wb.getAverageQuantity() * 2)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 2 && wb.getTotal() >= (wb.getAverageQuantity() * 1.5)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 3 && wb.getTotal() >= (wb.getAverageQuantity() * 1.4)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 4 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 5 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 6 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 7 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 8 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 9 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            if (getFirstDigit(wb.getAverageQuantity().intValue()) == 1 && wb.getTotal() >= (wb.getAverageQuantity() * 1.9)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 2 && wb.getTotal() >= (wb.getAverageQuantity() * 1.5)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 3 && wb.getTotal() >= (wb.getAverageQuantity() * 1.4)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 4 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 5 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 6 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 7 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 8 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
-                return true;
-            } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 9 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
-                return true;
-            } else {
-                return false;
-            }
-        }
-
-    }
-
-    private List<String> queryWindturbinebjCountLine(Alertrule2 ar) {
-
-        if (StringUtils.notEmp(ar)) {
-            List<String> lnids = proEconWindturbineWarnCountService.queryWindturbinebjCountLine(ar.getId());
-            return lnids;
-        }
-        return new ArrayList<>();
-    }
-
-    public void savePartbjcount() {
-
-
-        Calendar c = Calendar.getInstance();
-        c.set(Calendar.HOUR_OF_DAY, 0);
-        c.set(Calendar.MINUTE, 0);
-        c.set(Calendar.SECOND, 0);
-        c.add(Calendar.DAY_OF_MONTH, -1);
-        Date date = c.getTime();
 
-        proEconPartWarnCountService.deletePartbjcount(date);
-
-        List<Alertrule2> ars = CacheContext.alarmrulels;
-        for (Alertrule2 ar : ars) {
-            List<String> lnids = queryWindturbinebjCountLine(ar);
-            for (String lnid : lnids) {
-                int count = 0;
-                String part = null;
-                List<ProEconWindturbineWarnCount> wclist = queryWindturbinebjCountByLineAndAlertrule(ar, lnid);
-                for (ProEconWindturbineWarnCount wc : wclist) {
-                    boolean temp = isExceedingStandard(wc);
-                    part = wc.getPart();
-                    if (temp == true) {
-
-                        count++;
-                    }
-                }
-                if (count >= (wclist.size() * 0.9)) {
-                    String uuid = UUID.randomUUID().toString().replaceAll("-", "");
-
-                    ProEconPartWarnCount po = new ProEconPartWarnCount();
-                    po.setId(uuid);
-                    po.setLnId(lnid);
-                    po.setAlertruleId(ar.getId());
-                    po.setPart(part);
-                    po.setRecordDate(DateUtils.truncate(date));
-                    proEconPartWarnCountService.insertPartbjcount(po);
-
-                    for (ProEconWindturbineWarnCount wbc : wclist) {
-                        if (isExceedingStandard(wbc) == true) {
-                            String id = UUID.randomUUID().toString().replaceAll("-", "");
-                            ProEconPartWarnCountSub posub = new ProEconPartWarnCountSub();
-                            posub.setId(id);
-                            posub.setWtId(wbc.getWtId());
-                            posub.setTotal(wbc.getTotal());
-                            posub.setAverageQuantity(wbc.getAverageQuantity());
-                            posub.setPid(uuid);
-                            proEconPartWarnCountSubService.insertPartbjcountsub(posub);
-                        }
-                    }
 
-                }
-            }
-        }
-
-    }
-
-
-    /**
-     * 保存
-     *
-     * @return
-     */
-    public void saveWindturbineBjCount() {
-        Calendar c = Calendar.getInstance();
-        c.set(Calendar.HOUR_OF_DAY, 0);
-        c.set(Calendar.MINUTE, 0);
-        c.set(Calendar.SECOND, 0);
-        c.add(Calendar.DAY_OF_MONTH, -2);
-        Date endDate = c.getTime();
-        c.add(Calendar.DAY_OF_MONTH, -6);
-        Date beginDate = c.getTime();
-        c.add(Calendar.DAY_OF_MONTH, 7);
-        Date date = c.getTime();
-        List<ProEconWindturbineWarnCount> melist = new ArrayList<ProEconWindturbineWarnCount>();
-
-        proEconWindturbineWarnCountService.deleteWindturbinebjcount(date);
-
-        for (ProBasicLine line : CacheContext.lines) {
-            List<ProBasicEquipment> wtls = CacheContext.wtlinemap.get(line.getId());
-            List<DataVo> arlist = findAlertRuleList(line);
-            if (arlist != null && arlist.size() > 0) {
-
-                for (DataVo ar : arlist) {
-
-                    for (ProBasicEquipment w : wtls) {
-//						if (wobugeqsService
-//								.isQueryThreeDayWobugeqs(w.getId()) == false) {
-                        Long snapid = getAlarmsnapid(w.getId(), ar.getEdnavalue());
-                        String cc = findAlarmcount(snapid, beginDate, endDate);
-                        String[] s = cc.split(",");
-                        Double avg = 0.0;
-                        if (Double.parseDouble(s[1]) != 0) {
-                            avg = (Double.parseDouble(s[0]) / Double.parseDouble(s[1]));
-                        }
-
-                        Double sjcount = findyearstodayAlarmcount(snapid, date, date);
-                        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
-                        String part = getPartByAlertruleid(ar.getId());
-                        ProEconWindturbineWarnCount wbc = new ProEconWindturbineWarnCount();
-                        wbc.setId(uuid);
-                        wbc.setWtId(w.getId());
-                        wbc.setLnId(w.getLineId());
-                        wbc.setWpId(w.getWindpowerstationId());
-                        wbc.setAlertruleId(ar.getId());
-                        wbc.setAlertruleName(ar.getName());
-                        wbc.setPart(part);
-                        wbc.setTotal(sjcount.intValue());
-                        wbc.setAverageQuantity(avg);
-                        wbc.setRecordDate(date);
-                        melist.add(wbc);
-//						}
-
-                    }
-
-
-                }
-            }
-        }
-        insertWindturbineBjCount(melist);
-
-    }
-
-    /**
-     * 向WindturbineBjCount表插入数据
-     *
-     * @param melist
-     */
-    private void insertWindturbineBjCount(List<ProEconWindturbineWarnCount> melist) {
-
-        for (ProEconWindturbineWarnCount wb : melist) {
-            proEconWindturbineWarnCountService.insertWindturbineBjCount(wb);
-        }
-    }
-
-    /**
-     * 根据alertrule2id查询所属分组
-     *
-     * @param id
-     * @return
-     */
-
-    private String getPartByAlertruleid(String id) {
-
-        if (StringUtils.notEmp(id)) {
-            List<String> list = alertrulefailuresubsService.getPartByAlertruleid(id);
-            if (!list.isEmpty()) {
-                return list.get(0);
-            }
-        }
-
-        return "";
-
-    }
-
-    private Long getAlarmsnapid(String wtid, Long ednavalue) {
-
-        if (StringUtils.notEmp(wtid) && StringUtils.notEmp(ednavalue)) {
-            Long snapid = alarmsnapsService.getAlarmsnapid(wtid, ednavalue);
-            return snapid;
-        }
-
-
-        return 0l;
-    }
-
-    private List<DataVo> findAlertRuleList(ProBasicLine line) {
-        List<ProBasicEquipment> wt1 = CacheContext.wtlinemap.get(line.getId());
-        ProBasicEquipment wt = wt1.get(0);
-        List<DataVo> dos = new ArrayList<>();
-        if (StringUtils.notEmp(line)) {
-            List<Alertrule2> ls = alertrule2sService.findAlertRuleList(wt.getWindpowerstationId(), wt.getModelId());
-            if (!ls.isEmpty()) {
-                for (Alertrule2 ar : ls) {
-                    DataVo vo = new DataVo();
-                    vo.setId(ar.getId());
-                    vo.setEdnavalue(ar.getEdnavalue());
-                    vo.setName(ar.getName());
-                    dos.add(vo);
-                }
-            }
-        }
-
-        return dos;
-    }
-
-    public void test1() {
-        final CountDownLatch countDownLatch = new CountDownLatch(6);
-        for (int i = 0; i < 3; i++) {
-
-            threadPoolTaskExecutor.execute(new Runnable() {
-                // 解决多线程操作同一集合
-                @Override
-                public void run() {
-                    // logger.debug("启动:" + wt.getId() + "---" + ar.getId()
-                    // + "--特征分析子线程--");
-
-                    //synchronized (this) {
-                    try {
-
-                        for (int j = 0; j < 2; j++) {
-
-                            System.out.println("======" + j);
-
-                            // if(i==funList.size()-1)
-                            // {
-                            // if (obj instanceof Boolean) {
-                            // if (true == (boolean) obj) {
-                            // // atomic.getAndIncrement();
-                            // time++;
-                            // break;
-                            // }
-                            // }
-                            // }
-
-                            Thread.sleep(10000);
-
-                            // logger.debug("剩余线程数:"+countDownLatch.getTotal());
-                            // logger.debug("完成:" + wt.getId() + "---" +
-                            // ar.getId() + "--特征分析子线程--");
-                            //
-
-                        }
-
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                        countDownLatch.countDown();// 工人完成工作,计数器减一
-                    }
-
-                }
-            });
-
-        }
-        // threadPoolTaskExecutor.shutdown();
-        try {
-            countDownLatch.await();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        // logger.debug("特征提取完成!");
-    }
 
 
 }

+ 33 - 59
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/HealthReportService.java

@@ -33,10 +33,10 @@ public class HealthReportService {
     private ThreadPoolTaskExecutor threadPoolTaskExecutor;
 
     @Resource
-    private IAlarmcountService alarmcountService;
+    private AlarmHistoryService alarmHistoryService;
 
     @Resource
-    private IAlertrulefailureService alertrulefailureService;
+    private IProEconAlarmRuleFailureService proEconAlarmRuleFailureService;
 
     @Resource
     private IProBasicEquipmentPointService proBasicEquipmentPointService;
@@ -293,19 +293,18 @@ public class HealthReportService {
                                     String gz2=gzarr[1];
                                     String gz3=gzarr[2];
 
-                                    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);
+                                        ProEconAlarmRuleFailure af=afls.get(0);
                                         vo.setTop1(gz1);
                                         vo.setTop2(gz2);
                                         vo.setTop3(gz3);
-                                        vo.setGzpc(af.getGzpc());
-                                        vo.setGzcl(af.getGzyy());
-                                        vo.setGqj(af.getGqj());
+                                        vo.setGzpc(af.getFaultCause());
+                                        vo.setGzcl(af.getResolvent());
                                         vo.setRecordDate(sj.getRecordDate());
-                                        vo.setXqsc(af.getXqsc());
+                                        vo.setXqsc(af.getFaultTimes());
                                         vo.setWtId(wt.getId());
                                         vo.setWtName(wt.getName());
                                     }
@@ -746,57 +745,32 @@ public class HealthReportService {
         return vo;
     }
 
-    /**
-     * 获得报警部件次数统计
-     *
-     * @param recordDate
-     * @param wtId
-     * @return
-     */
-    public List<AlarmcountResultVo> getAlarmcountVoList(Date recordDate, String wtId) {
-
-        List<AlarmcountResultVo> vos = new ArrayList<>();
-        if (StringUtils.notEmp(recordDate) && StringUtils.notEmp(wtId)) {
-            Calendar c = Calendar.getInstance();
-            c.setTime(DateUtils.truncate(recordDate));
-
-            Date end = c.getTime();
-            c.set(Calendar.DAY_OF_MONTH, 1);
-            Date begin = c.getTime();
-
-            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);
-                }
-            }
-
-            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;
-    }
+//    /**
+//     * 获得报警部件次数统计
+//     *
+//     * @param recordDate
+//     * @param wtId
+//     * @return
+//     */
+//    public List<AlarmStatVo> getAlarmcountVoList(Date recordDate, String wtId) {
+//
+//        List<AlarmStatVo> vos = new ArrayList<>();
+//        if (StringUtils.notEmp(recordDate) && StringUtils.notEmp(wtId)) {
+//            Calendar c = Calendar.getInstance();
+//            c.setTime(DateUtils.truncate(recordDate));
+//
+//            Date end = c.getTime();
+//            c.set(Calendar.DAY_OF_MONTH, 1);
+//            Date begin = c.getTime();
+//
+//            ProBasicEquipment wt = CacheContext.wtmap.get(wtId);
+//
+//           vos = alarmHistoryService.findWtFeatureStat( stationId, String modelId, Date startTime, Date endTime, null, null, String alarmType, String timeType);
+//
+//
+//        }
+//        return vos;
+//    }
 
     /**
      * 获得曲线偏差率列表

+ 1 - 31
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/RecommenmainsService.java

@@ -23,8 +23,7 @@ public class RecommenmainsService {
     private final int DIGIT=2;
     @Resource
     private IProEconRecommenMainService   proEconRecommenMainService;
-    @Resource
-    private Alertrule2sService alertrule2sService;
+
     @Resource
     private IProEconStateJudgmentDayService  proEconStateJudgmentDayService;
 
@@ -56,27 +55,6 @@ public class RecommenmainsService {
         return proEconRecommenMainService.insertRecommenmain(recommenmain);
     }
 
-    public List<ProEconRecommenMain> findRecommenmainList(Date recodeDate)
-    {
-        if(StringUtils.notEmp(recodeDate))
-        {
-            Calendar c = Calendar.getInstance();
-            c.setTime(recodeDate);
-            c.set(Calendar.HOUR_OF_DAY, 0);
-            c.set(Calendar.MINUTE, 0);
-            c.set(Calendar.SECOND, 0);
-
-            Date endDate = c.getTime();
-            c.add(Calendar.DAY_OF_MONTH, -3);
-            Date beginDate = c.getTime();
-            return proEconRecommenMainService.findRecommenmainList(beginDate, endDate);
-        }else
-        {
-            return new ArrayList<>();
-        }
-
-    }
-
 
 
     public void recommenMainWt() {
@@ -141,14 +119,6 @@ public class RecommenmainsService {
 
 
 
-    private String getAlertRuleIDByName(ProBasicEquipment wt, String partName) {
-
-        if (StringUtils.notEmp(wt) && StringUtils.notEmp(partName)) {
-           return alertrule2sService.getAlertRuleIdByName(wt.getWindpowerstationId(),wt.getModelId(),partName);
-        }
-        return null;
-
-    }
 
     private void setJudgeWeatherAndSpeed( ProBasicEquipment wt, ProEconRecommenMain rm) {
 

+ 5 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmRuleFailureService.java

@@ -4,6 +4,8 @@ package com.gyee.healthmodel.service.auto;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.healthmodel.model.auto.ProEconAlarmRuleFailure;
 
+import java.util.List;
+
 /**
  * <p>
  * 故障规则 服务类
@@ -14,4 +16,7 @@ import com.gyee.healthmodel.model.auto.ProEconAlarmRuleFailure;
  */
 public interface IProEconAlarmRuleFailureService extends IService<ProEconAlarmRuleFailure> {
 
+   public List<ProEconAlarmRuleFailure> queryObject(String name,
+                                              String wpId,
+                                              String modelId);
 }

+ 16 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmRuleFailureServiceImpl.java

@@ -2,11 +2,16 @@ package com.gyee.healthmodel.service.auto.impl;
 
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.common.model.StringUtils;
 import com.gyee.healthmodel.mapper.auto.ProEconAlarmRuleFailureMapper;
 import com.gyee.healthmodel.model.auto.ProEconAlarmRuleFailure;
 import com.gyee.healthmodel.service.auto.IProEconAlarmRuleFailureService;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
  * 故障规则 服务实现类
@@ -18,4 +23,15 @@ import org.springframework.stereotype.Service;
 @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;
+    }
 }

+ 0 - 46
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/task/SaticScheduleTask.java

@@ -146,51 +146,5 @@ public class SaticScheduleTask {
 
 
 
-    /**
-     * 风机报警统计
-     */
-    //@Scheduled(cron = "0 0 2 * * ?")
-    //或直接指定时间间隔,例如:5秒
-    //@Scheduled(fixedRate=5000)
-    @XxlJob("healthmodel-wtAlarmStatistics")
-    public void configureTasks6()  {
-
-
-        XxlJobHelper.log("风机报警统计调度程序执行开始!........");
-
-        try {
-
-            healthJudgeService.saveWindturbineBjCount();
-        } catch (Exception e) {
-
-            e.printStackTrace();
-        }
-
-        XxlJobHelper.log("风机报警统计调度任务处理完成!........");
-    }
-
 
-
-    /**
-     * 部件报警统计
-     */
-    //@Scheduled(cron = "0 0 3 * * ?")
-    //或直接指定时间间隔,例如:5秒
-    //@Scheduled(fixedRate=5000)
-    @XxlJob("healthmodel-partAlarmStatistics")
-    public void configureTasks7()  {
-
-
-        XxlJobHelper.log("部件报警统计调度程序执行开始!........");
-
-        try {
-
-            healthJudgeService.savePartbjcount();
-        } catch (Exception e) {
-
-            e.printStackTrace();
-        }
-
-        XxlJobHelper.log("部件报警统计调度任务处理完成!........");
-    }
 }

+ 8 - 4
realtime/healthmodel-server/src/main/resources/application-jn.yml

@@ -69,10 +69,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
     druid:
       max-active: 20
       initial-size: 1
@@ -101,3 +101,7 @@ logging:
 
 edos:
   baseURL: http://10.0.118.73:8011/ts
+
+initialcode: INITIAL
+#首页展示数据数量
+home_pagep_size: 50

+ 16 - 7
realtime/healthmodel-server/src/test/java/HealthTest.java

@@ -1,7 +1,13 @@
 import com.gyee.healthmodel.HealthmodelMain;
+import com.gyee.healthmodel.service.HealthReportService;
+import com.gyee.healthmodel.service.RecommenmainsService;
+import com.gyee.healthmodel.util.DateUtils;
+import com.gyee.healthmodel.util.SpringUtils;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
 
+import java.util.Calendar;
+
 public class HealthTest {
 
     @SneakyThrows
@@ -11,22 +17,25 @@ public class HealthTest {
 
         System.out.println("调度程序执行开始!........");
 
+
 //        HealthJudgeService healthJudgeService= SpringUtils.getBean("healthJudgeService");
 //        healthJudgeService.healthJudge();
 //        healthJudgeService.changeHealthModelValue();
-//       RecommenmainsService recommenmainsService= SpringUtils.getBean("recommenmainsService");
-//        Calendar cal = Calendar.getInstance();
-//        recommenmainsService.deleteList(cal.getTime());
-////        recommenmainsService.recommenMainWt();
+       RecommenmainsService recommenmainsService= SpringUtils.getBean("recommenmainsService");
+        Calendar c = Calendar.getInstance();
+        c.add(Calendar.DAY_OF_MONTH,-1);
+        recommenmainsService.deleteList(c.getTime());
+        recommenmainsService.recommenMainWt();
 //        healthJudgeService.saveWindturbineBjCount();
 // healthJudgeService.savePartbjcount();
 //
-//        HealthReportService healthReportService= SpringUtils.getBean("healthReportService");
-//        healthReportService.createHealthReport(new Date());
+        HealthReportService healthReportService= SpringUtils.getBean("healthReportService");
+
+        healthReportService.createHealthReport(DateUtils.truncate(c.getTime()));
 
 
 //        InitialRedis initialRedis= SpringUtils.getBean("initialRedis");
-////        initialRedis.initialRedisAll();
+//        initialRedis.initialRedisAll();
 //
 //        initialRedis.intialWindturbinepowercurvefitting();
          System.out.println("调度任务处理完成!........");