Browse Source

报警统计功能

shilin 1 year ago
parent
commit
7d2b6eb374

+ 1 - 1
alarm-stat/src/main/java/com/gyee/alarm/init/CacheContext.java

@@ -642,7 +642,7 @@ public class CacheContext implements CommandLineRunner {
         {
             for(ProEconAlarmType at:alarmTypeList)
             {
-                alarmTypeMap.put(at.getNemCode().toLowerCase(),at);
+                alarmTypeMap.put(at.getNemCode(),at);
             }
         }
 

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

@@ -90,7 +90,7 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
     List<AlarmSimpleVo> selectLastRowByTbname(@Param("superTableName") String superTableName, @Param("tbnames") String tbnames);
 
 
-    @Select("select deviceid as wtId,stationid as stationId,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmWt where ts>=#{begin} and ts<=#{end}  and alarmtype='windturbine' group by deviceid,components,stationid")
+    @Select("select deviceid as wtId,stationid as stationId,alarmid,description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmWt where ts>=#{begin} and ts<=#{end}  and alarmtype='windturbine' group by deviceid,components,stationid,alarmid,description")
     List<ProBasicFeatureStat> findFeatureStatList( @Param("begin")long begin, @Param("end") long end);
 
 }

+ 9 - 0
alarm-stat/src/main/java/com/gyee/alarm/model/auto/ProBasicFeatureStat.java

@@ -77,6 +77,15 @@ public class ProBasicFeatureStat extends Model {
      * 类型名称
      */
     private String typeName;
+    /**
+     * 报警编号
+     */
+    private String alarmid;
+
+    /**
+     * 描述
+     */
+    private String description;
 
 
 }

+ 2 - 2
alarm-stat/src/main/java/com/gyee/alarm/model/vo/AlarmType.java

@@ -2,8 +2,8 @@ package com.gyee.alarm.model.vo;
 
 public enum AlarmType {
 
-    FJBJ("alertrule_category", "部件"),
-    GFBJ("alertrule_category", "部件"),
+    FJBJ("alertrule_category", "风机部件"),
+    GFBJ("alertrule_category_GF", "光伏部件"),
     YJ("early_category", "预警"),
     SD("userset", "用户设定");
 

+ 39 - 26
alarm-stat/src/main/java/com/gyee/alarm/service/FeatureStatService.java

@@ -2,9 +2,7 @@ package com.gyee.alarm.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.alarm.init.CacheContext;
-import com.gyee.alarm.model.auto.ProBasicEquipment;
-import com.gyee.alarm.model.auto.ProBasicFeatureStat;
-import com.gyee.alarm.model.auto.ProEconAlarmType;
+import com.gyee.alarm.model.auto.*;
 import cn.hutool.core.bean.BeanUtil;
 import com.gyee.alarm.model.auto.ProBasicFeatureStat;
 import com.gyee.alarm.model.vo.AlarmType;
@@ -15,6 +13,7 @@ import com.gyee.alarm.util.SnowflakeGenerator;
 import com.gyee.alarm.util.StringUtils;
 
 
+import javafx.scene.chart.CategoryAxis;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -31,7 +30,7 @@ public class FeatureStatService {
     @Resource
     private IProBasicFeatureStatService proBasicFeatureStatService;
 
-    public List<ProBasicFeatureStat> findFeatureStatList(Date recordDate) {
+    public void findFeatureStatList(Date recordDate) {
 
 
         Calendar c = Calendar.getInstance();
@@ -50,7 +49,20 @@ public class FeatureStatService {
 
         if (idls.size() > 0) {
 
-            proBasicFeatureStatService.removeByIds(idls);
+            List<String> templs = new ArrayList<>();
+            for (String vo : idls) {
+                templs.add(vo);
+                if (templs.size() == 100) {
+                    proBasicFeatureStatService.removeByIds(templs);
+                    templs = new ArrayList<>();
+                }
+
+            }
+
+            if (!templs.isEmpty()) {
+                proBasicFeatureStatService.removeByIds(templs);
+            }
+
         }
 
         List<ProBasicFeatureStat> fsls = alarmTsService.findFeatureStatList(begin.getTime(), end.getTime());
@@ -60,34 +72,30 @@ public class FeatureStatService {
 
         if (!fsls.isEmpty()) {
             for (ProBasicFeatureStat fs : fsls) {
-                if (StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode().toLowerCase())) {
-                    ProEconAlarmType at = CacheContext.alarmTypeMap.get(fs.getTypeCode().toLowerCase());
+                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.getTypeCode().toLowerCase());
+                sb.append(fs.getWtId()).append("_").append(fs.getAlarmid());
                 map.put(String.valueOf(sb), fs);
             }
         }
         List<ProBasicFeatureStat> vos = new ArrayList<>();
         for (ProBasicEquipment wt : CacheContext.wtls) {
-            for (ProEconAlarmType at : CacheContext.alarmTypeList) {
-
-                if(wt.getWindpowerstationId().contains("_FDC_"))
-                {
-                    if (at.getCategory().equals(AlarmType.FJBJ.getCode())) {
-                        setValues(statDate,map, vos, wt, at);
-                    }
-                }else   if(wt.getWindpowerstationId().contains("_GDC_"))
-                {
-                    if (at.getCategory().equals(AlarmType.GFBJ.getCode())) {
-                        setValues(statDate,map, vos, wt, at);
-                    }
-                }
 
+            StringBuilder sb=new StringBuilder();
+            sb.append(wt.getWindpowerstationId()).append(wt.getModelId());
+            if(CacheContext.wtAlarmMap.containsKey(String.valueOf(sb))) {
+                List<ProEconAlarmConfiguration> ls = CacheContext.wtAlarmMap.get(String.valueOf(sb));
+                for (ProEconAlarmConfiguration at : ls) {
+
+                    setValues(statDate, map, vos, wt, at);
+                }
             }
+
         }
 
         List<ProBasicFeatureStat> templs = new ArrayList<>();
@@ -104,15 +112,15 @@ public class FeatureStatService {
             proBasicFeatureStatService.saveBatch(templs);
         }
 
-        return fsls;
+
     }
 
-    private static void setValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmType at) {
+    private  static void setValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration at) {
 
         ProBasicFeatureStat fs = new ProBasicFeatureStat();
 
         StringBuilder sb = new StringBuilder();
-        sb.append(fs.getWtId()).append("_").append(at.getNemCode().toLowerCase());
+        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);
@@ -121,8 +129,13 @@ public class FeatureStatService {
             fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
             fs.setWtId(wt.getId());
             fs.setStationId(wt.getWindpowerstationId());
-            fs.setTypeCode(at.getNemCode());
-            fs.setTypeName(at.getName());
+            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);

+ 1 - 3
alarm-stat/src/test/java/com/gyee/AppTest.java

@@ -4,14 +4,12 @@ package com.gyee;
 import com.gyee.alarm.AlarmMain;
 import com.gyee.alarm.service.FeatureStatService;
 
-import com.gyee.alarm.util.DateUtils;
 import com.gyee.alarm.util.SpringUtils;
 import org.springframework.boot.SpringApplication;
 
 import java.util.Calendar;
-import java.util.Date;
 
-public class AppTest
+public class AalarmStatTest
 {
     public static void main(String[] args) throws Exception {
         SpringApplication.run(AlarmMain.class, args);

File diff suppressed because it is too large
+ 62 - 110
alarm-web/src/main/java/com/gyee/alarm/controller/AlarmHistoryController.java


+ 14 - 2
alarm-web/src/main/java/com/gyee/alarm/init/CacheContext.java

@@ -85,7 +85,8 @@ public class CacheContext implements CommandLineRunner {
 
     @Resource
     private IProEconAlarmRuleService proEconAlarmRuleService;
-
+    @Resource
+    private IProEconAlarmTypeService proEconAlarmTypeService;
     public static Map<String,Map<String, ProBasicPowerstationPoint>> weatherwppointmap =new HashMap<>();
     public static List<ProBasicWeatherStation>  weawpls = new ArrayList<>();
     public static Map<String,Map<String,ProBasicEquipment>> cmwtmap = new HashMap<>();
@@ -183,7 +184,8 @@ public class CacheContext implements CommandLineRunner {
 
     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 List<ProEconAlarmType> alarmTypeList=new ArrayList<>();
     public static   Map<String,Set<ProEconEquipmentmodel>> wpByEmMap=new HashMap<>();
     @Override
 
@@ -694,6 +696,16 @@ public class CacheContext implements CommandLineRunner {
 
         });
 
+        alarmTypeList= proEconAlarmTypeService.list();
+
+        if(!alarmTypeList.isEmpty())
+        {
+            for(ProEconAlarmType at:alarmTypeList)
+            {
+                alarmTypeMap.put(at.getNemCode().toLowerCase(),at);
+            }
+        }
+
 //        inputOrOutPutService.initialInputOrOutputSpeed();
         logger.info("缓存结束------------------------------------------------------------");
     }

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

@@ -4,6 +4,7 @@ package com.gyee.alarm.mapper.auto;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.gyee.alarm.model.auto.AlarmTs;
+import com.gyee.alarm.model.auto.ProBasicFeatureStat;
 import com.gyee.alarm.model.vo.AlarmTsVo;
 import com.gyee.alarm.model.vo.AlarmVo;
 import org.apache.ibatis.annotations.Insert;
@@ -107,13 +108,16 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "<if test='deviceType != null'>",
             "and deviceType = #{deviceType}",
             "</if>",
+            "<if test='components != null'>",
+            "and components = #{components}",
+            "</if>",
             "and stationid = #{stationid}",
             "and ts &gt;= #{begin}",
             "and ts &lt;= #{end}",
             "</where>",
             " order by ts desc limit #{limit},#{offset} ",
             "</script>"})
-    List<AlarmVo> selectByWtLimit(@Param("begin")long begin,@Param("end")long end,@Param("modelId")String modelId,@Param("superTableName") String superTableName,@Param("alarmType")String alarmType,@Param("stationid")String stationid,@Param("deviceid")String deviceid,@Param("description")String description, @Param("deviceType")String deviceType,@Param("limit")int limit, @Param("offset") int offset);
+    List<AlarmVo> selectByWtLimit(@Param("begin")long begin,@Param("end")long end,@Param("modelId")String modelId,@Param("superTableName") String superTableName,@Param("alarmType")String alarmType,@Param("stationid")String stationid,@Param("deviceid")String deviceid,@Param("description")String description, @Param("deviceType")String deviceType, @Param("components")String components,@Param("limit")int limit, @Param("offset") int offset);
 
     @Select({"<script>",
             "select count(*) from #{superTableName} " ,
@@ -130,12 +134,33 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "<if test='deviceType != null'>",
             "and deviceType = #{deviceType}",
             "</if>",
+            "<if test='components != null'>",
+            "and components = #{components}",
+            "</if>",
             "and stationid = #{stationid}",
             "and ts &gt;= #{begin}",
             "and ts &lt;= #{end}",
             "</where>",
 
             "</script>"})
-    Integer selectByWtCount(@Param("begin")long begin,@Param("end")long end,@Param("modelId")String modelId,@Param("superTableName") String superTableName,@Param("alarmType")String alarmType,@Param("stationid")String stationid,@Param("deviceid")String deviceid,@Param("description")String description, @Param("deviceType")String deviceType);
+    Integer selectByWtCount(@Param("begin")long begin,@Param("end")long end,@Param("modelId")String modelId,@Param("superTableName") String superTableName,@Param("alarmType")String alarmType,@Param("stationid")String stationid,@Param("deviceid")String deviceid,@Param("description")String description, @Param("deviceType")String deviceType, @Param("components")String components);
+//    @Select("select deviceid as wtId,stationid as stationId,alarmid,description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmWt where ts>=#{begin} and ts<=#{end}  and alarmtype='windturbine'  and #{begin} group by deviceid,components,stationid,alarmid,description")
+
+    @Select({"<script>",
+            "select deviceid as wtId,stationid as stationId,alarmid,description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmWt " ,
+            "<where>" ,
+            "and stationid = #{stationid}",
+            "and ts &gt;= #{begin}",
+            "and ts &lt;= #{end}",
+            "<if test='components != null'>",
+            "and components= #{components}",
+            "</if>",
+            "</where>",
+            " group by deviceid,components,stationid,alarmid,description ",
+            " order by deviceid  ",
+            "</script>"})
+    List<ProBasicFeatureStat> findFeatureStatList(@Param("begin")long begin, @Param("end") long end, @Param("stationid") String stationid, @Param("components") String components);
+
+
 
 }

+ 25 - 0
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicFeatureStatMapper.java

@@ -2,6 +2,12 @@ package com.gyee.alarm.mapper.auto;
 
 import com.gyee.alarm.model.auto.ProBasicFeatureStat;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.alarm.model.vo.AlarmVo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.Date;
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +19,23 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ProBasicFeatureStatMapper extends BaseMapper<ProBasicFeatureStat> {
 
+
+    @Select({"<script>",
+            "select * from pro_basic_feature_stat " ,
+            "<where>" ,
+            "<if test='begin != null &amp;&amp; end != null '>",
+            " stat_Date &gt;= #{begin}",
+            "and stat_Date &lt;= #{end}",
+            "</if>",
+            "<if test='stationId != null'>",
+            "and station_id = #{stationId}",
+            "</if>",
+            "<if test='wtId != null'>",
+            "and wt_id = #{wtId}",
+            "</if>",
+            "</where>",
+            " order by wt_id  ",
+            "</script>"})
+    List<ProBasicFeatureStat> searchByCondition(@Param("begin") Date begin, @Param("end")Date end, @Param("stationId")String stationId, @Param("wtId")String wtId);
+
 }

+ 19 - 6
alarm-web/src/main/java/com/gyee/alarm/model/auto/ProBasicFeatureStat.java

@@ -1,10 +1,13 @@
 package com.gyee.alarm.model.auto;
 
-import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.sql.Timestamp;
+
 /**
  * <p>
  * 设备功能统计
@@ -22,6 +25,7 @@ public class ProBasicFeatureStat extends Model {
     /**
      * 编号
      */
+    @TableId(value = "ID",type = IdType.INPUT)
     private String id;
 
     /**
@@ -37,7 +41,7 @@ public class ProBasicFeatureStat extends Model {
     /**
      * 统计时间
      */
-    private String statDate;
+    private Timestamp statDate;
 
     /**
      * 总次数
@@ -47,22 +51,22 @@ public class ProBasicFeatureStat extends Model {
     /**
      * 总时间
      */
-    private BigDecimal totalSeconds;
+    private Double totalSeconds;
 
     /**
      * 平均时长
      */
-    private BigDecimal avgSeconds;
+    private Double avgSeconds;
 
     /**
      * 最大时长
      */
-    private BigDecimal maxSeconds;
+    private Double maxSeconds;
 
     /**
      * 最小时长
      */
-    private BigDecimal minSeconds;
+    private Double minSeconds;
 
     /**
      * 类型编码
@@ -73,6 +77,15 @@ public class ProBasicFeatureStat extends Model {
      * 类型名称
      */
     private String typeName;
+    /**
+     * 报警编号
+     */
+    private String alarmid;
+
+    /**
+     * 描述
+     */
+    private String description;
 
 
 }

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

@@ -0,0 +1,31 @@
+package com.gyee.alarm.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 double time;
+    //关联部件编号
+    private String relateParts;
+    //关联部件名称
+    private String relatePartsText;
+
+    private String code;
+
+    private String windturbineCode;
+
+
+}

+ 156 - 111
alarm-web/src/main/java/com/gyee/alarm/service/AlarmHistoryService.java

@@ -1,16 +1,15 @@
 package com.gyee.alarm.service;
 
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 
+import com.gyee.alarm.init.CacheContext;
 import com.gyee.alarm.mapper.auto.AlarmTsMapper;
-import com.gyee.alarm.model.auto.ProEconElectricaltestPoint;
-import com.gyee.alarm.model.vo.AlarmSuperTalbeType;
-import com.gyee.alarm.model.vo.AlarmTsVo;
-import com.gyee.alarm.model.vo.AlarmTypeValue;
-import com.gyee.alarm.model.vo.AlarmVo;
+import com.gyee.alarm.model.auto.*;
+import com.gyee.alarm.model.vo.*;
 import com.gyee.alarm.util.DateUtils;
 import com.gyee.alarm.util.SnowflakeGenerator;
 import com.gyee.common.model.StringUtils;
@@ -20,6 +19,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -32,6 +32,8 @@ public class AlarmHistoryService   {
     @Resource
     private AlarmTsMapper alarmTsMapper;
 
+
+
     @Value("${home_pagep_size}")
     private int home_pagep_size;
     /**
@@ -45,7 +47,7 @@ public class AlarmHistoryService   {
      * @param pageSize 每页多少条
      * @return
      */
-    public Map<String,Object> findAlarmlist(String modelId, long begin,long end ,String alarmType,String stationid,String deviceid,String description,String deviceType, int pageNum, int pageSize) {
+    public Map<String,Object> findAlarmlist(String modelId, long begin,long end ,String alarmType,String stationid,String deviceid,String description,String deviceType,String components, int pageNum, int pageSize) {
 
         Map<String,Object> map=new HashMap<>();
 
@@ -108,9 +110,14 @@ public class AlarmHistoryService   {
         {
             deviceType=null;
         }
-        vos = alarmTsMapper.selectByWtLimit(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType, pageNum*pageSize, (pageNum*pageSize+pageSize));
+
+        if(StringUtils.empty(components)  )
+        {
+            components=null;
+        }
+        vos = alarmTsMapper.selectByWtLimit(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components, pageNum*pageSize, (pageNum*pageSize+pageSize));
         map.put("ls",vos);
-        int total=alarmTsMapper.selectByWtCount(begin,end,modelId,superTableName, alarmType, stationid,deviceType, deviceid, description);
+        int total=alarmTsMapper.selectByWtCount(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components);
         map.put("total",total);
         return map;
     }
@@ -122,120 +129,158 @@ public class AlarmHistoryService   {
         Map<String,Object> map=new HashMap<>();
 
 
-            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+
             Date endDate = new Date();
             Date beginDate = DateUtils.truncate(endDate);
 
 
-        List<AlarmVo> btls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.BT.getCode(), AlarmTypeValue.BT.getCode(), null, null, null,null, 0, home_pagep_size);
+        List<AlarmVo> btls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.BT.getCode(), AlarmTypeValue.BT.getCode(), null, null, null,null,null, 0, home_pagep_size);
         map.put("btls",btls);
 
-        List<AlarmVo> wtls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.WT.getCode(), AlarmTypeValue.WT.getCode(), null, null, null,null, 0, home_pagep_size);
+        List<AlarmVo> wtls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.WT.getCode(), AlarmTypeValue.WT.getCode(), null, null, null,null, null,0, home_pagep_size);
         map.put("wtls",wtls);
 
-        List<AlarmVo> ctls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.CT.getCode(), AlarmTypeValue.CT.getCode(), null, null, null,null, 0, home_pagep_size);
+        List<AlarmVo> ctls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.CT.getCode(), AlarmTypeValue.CT.getCode(), null, null, null,null, null,0, home_pagep_size);
         map.put("ctls",ctls);
         return map;
     }
-//
-//
-//    public List<AlarmStat1> findByCondition(String stationId, Date startTime, Date endTime) {
-//        List<AlarmStat1> resultList = new ArrayList<>();
-//
-//        List<FeatureStat> lst = featurePressureStatMapper.searchByCondition(stationId, startTime, endTime);
-//
-//        //根据统计类型分组  YYBYX,LWYC,ZPH,YPH
-//        Map<String, List<FeatureStat>> typeGorupMap = lst.stream().collect(Collectors.groupingBy(FeatureStat::getTypeCode));
-//
-//
-//        // region  存储偏航类统计,将左偏航和右偏航进行合并
-//        Map<String, List<FeatureStat>> yawStatMap = new HashMap<>();
-//
-//        for (Map.Entry<String, List<FeatureStat>> entry : typeGorupMap.entrySet()) {
-//
-//            //如果统计信息不是左偏航和右偏航
-//            if (!entry.getKey().contains("ZPH") && !entry.getKey().contains("YPH")) {
-//                //根据风机编号分组
-//                Map<String, List<FeatureStat>> groupMap = entry.getValue().stream().collect(Collectors.groupingBy(FeatureStat::getWtId));
-//
-//                for (Map.Entry<String, List<FeatureStat>> item : groupMap.entrySet()) {
-//                    AlarmStat1 d = new AlarmStat1();
-//                    if(entry.getKey().equals("JLDZ")){
-//                        d.setRelateParts("PHXT");
-//                        d.setRelatePartsText("偏航系统");
-//                    }else{
-//                        d.setRelateParts("YYXT");
-//                        d.setRelatePartsText("液压系统");
-//                    }
-//
-//                    if (item.getValue() != null && item.getValue().size() > 0) {
-//                        FeatureStat stat = item.getValue().get(0);
-//                        d.setAlertText(stat.getTypeName());
-//                    } else {
-//                        if (entry.getKey().equals("YYBYX")) {
-//                            d.setAlertText("液压泵运行");
-//                        } else if (entry.getKey().equals("LWYC")) {
-//                            d.setAlertText("滤网压差");
-//                        }
-//                    }
-//
-//                    double time = 0;
-//                    int count = 0;
-//                    time = item.getValue().stream().mapToDouble(FeatureStat::getTotalSeconds).sum();
-//                    count = item.getValue().stream().mapToInt(FeatureStat::getTotal).sum();
-//                    d.setCount(count);
-//                    //总时长以分钟为单位,不到一分钟则记为一分钟
-//                    double finalTime = Math.ceil(time / 60.0);
-//
-//                    d.setTime(finalTime);
-//                    d.setWindturbineId(item.getKey());
-//                    d.setStationId(stationId);
-//                    d.setSnapId(SnowflakeGenerator.generateId());
-//                    resultList.add(d);
-//                }
-//            } else {
-//                if (!yawStatMap.containsKey("PH")) {
-//                    yawStatMap.put("PH", entry.getValue());
-//                } else {
-//                    List<FeatureStat> yawList = yawStatMap.get("PH");
-//                    yawList.addAll(entry.getValue());
-//                }
-//            }
-//        }
-//        //endregion
-//        //针对偏航类信息再次进行整合并将结果合并到resultList
-//
-//        for (Map.Entry<String, List<FeatureStat>> entry : yawStatMap.entrySet()) {
-//            //根据风机编号进行分组
-//            Map<String, List<FeatureStat>> groupMapByWindturbineId = entry.getValue().stream().collect(Collectors.groupingBy(FeatureStat::getWtId));
-//            for (Map.Entry<String, List<FeatureStat>> item : groupMapByWindturbineId.entrySet()) {
-//                AlarmStat1 d = new AlarmStat1();
-//                d.setRelateParts("PHXT");
-//                d.setRelatePartsText("偏航系统");
-//                if (entry.getKey().equals("PH")) {
-//                    d.setAlertText("偏航");
-//                }
-//
-//
-//                double time = 0;
-//                int count = 0;
-//                time = item.getValue().stream().mapToDouble(FeatureStat::getTotalSeconds).sum();
-//                count = item.getValue().stream().mapToInt(FeatureStat::getTotal).sum();
-//                d.setCount(count);
-//                //总时长以分钟为单位,不到一分钟则记为一分钟
-//                double finalTime = Math.ceil(time / 60.0);
-//
-//                d.setTime(finalTime);
-//                d.setWindturbineId(item.getKey());
-//                d.setStationId(stationId);
-//                d.setSnapId(SnowflakeGenerator.generateId());
-//                resultList.add(d);
-//            }
-//
-//        }
-//
-//        return resultList;
-//    }
+
+
+    public List<AlarmStatVo> findByCondition(String stationId, Date startTime, Date endTime,String components) {
+        List<AlarmStatVo> resultList = new ArrayList<>();
+
+        List<ProBasicFeatureStat> fsls = alarmTsMapper.findFeatureStatList(startTime.getTime(), endTime.getTime(),stationId,components);
+
+
+        Map<String, ProBasicFeatureStat> map = new HashMap<>();
+        Date statDate=DateUtils.truncate(new Date());
+
+        if (!fsls.isEmpty()) {
+            for (ProBasicFeatureStat fs : fsls) {
+                if (com.gyee.alarm.util.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.wtAlarmMap.containsKey(String.valueOf(sb))) {
+                    List<ProEconAlarmConfiguration> ls = CacheContext.wtAlarmMap.get(String.valueOf(sb));
+                    for (ProEconAlarmConfiguration at : ls) {
+                        if(StringUtils.notEmp(components) && components.equals(at.getComponents()))
+                        {
+                            setValues(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());
+           d.setTime(fs.getTotalSeconds());
+           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);
+       }
+
+
+        for (Map.Entry<String,List<AlarmStatVo>> entry : vomap.entrySet()) {
+
+            AlarmStatVo d = new AlarmStatVo();
+            List<AlarmStatVo> templs=entry.getValue();
+            if(!templs.isEmpty())
+            {
+                BeanUtil.copyProperties(templs.get(0),d);
+
+                double time = 0;
+                long count = 0;
+                time = templs.stream().mapToDouble(AlarmStatVo::getTime).sum();
+                count = templs.stream().mapToLong(AlarmStatVo::getCount).sum();
+                d.setCount(count);
+                //总时长以分钟为单位,不到一分钟则记为一分钟
+                double finalTime = Math.ceil(time / 60.0);
+
+                d.setTime(finalTime);
+                resultList.add(d);
+            }
+
+        }
+
+
+        return resultList;
+    }
+    private  static void setValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration 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.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);
+    }
 
 
 }

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

@@ -4,6 +4,7 @@ package com.gyee.alarm.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.alarm.mapper.auto.ProEconAlarmRuleMapper;
+import com.gyee.alarm.model.auto.ProBasicFeatureStat;
 import com.gyee.alarm.model.auto.ProEconAlarmRule;
 import com.gyee.alarm.model.vo.AlarmRuleVo;
 import com.gyee.alarm.service.auto.IProBasicFeatureStatService;
@@ -14,10 +15,7 @@ import com.gyee.alarm.util.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 @Service
@@ -28,5 +26,14 @@ public class FeatureStatService {
     private IProBasicFeatureStatService proBasicFeatureStatService;
 
 
+    public List<ProBasicFeatureStat> searchByCondition(Date begin, Date end, String stationId, String wtId)
+    {
+        List<ProBasicFeatureStat> ls=new ArrayList<>();
 
+        if(StringUtils.notEmp(begin) && StringUtils.notEmp(end) && StringUtils.notEmp(end))
+        {
+            ls=proBasicFeatureStatService.searchByCondition(begin,end,stationId,wtId);
+        }
+        return  ls;
+    }
 }

+ 6 - 0
alarm-web/src/main/java/com/gyee/alarm/service/auto/IProBasicFeatureStatService.java

@@ -2,6 +2,11 @@ package com.gyee.alarm.service.auto;
 
 import com.gyee.alarm.model.auto.ProBasicFeatureStat;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.alarm.model.vo.AlarmVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +18,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IProBasicFeatureStatService extends IService<ProBasicFeatureStat> {
 
+    public List<ProBasicFeatureStat> searchByCondition(Date begin, Date end, String stationId,String wtId);
 }

+ 21 - 0
alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProBasicFeatureStatServiceImpl.java

@@ -2,10 +2,18 @@ package com.gyee.alarm.service.auto.impl;
 
 import com.gyee.alarm.model.auto.ProBasicFeatureStat;
 import com.gyee.alarm.mapper.auto.ProBasicFeatureStatMapper;
+import com.gyee.alarm.model.vo.AlarmVo;
 import com.gyee.alarm.service.auto.IProBasicFeatureStatService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.alarm.util.StringUtils;
+import jdk.nashorn.internal.ir.annotations.Reference;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 设备功能统计 服务实现类
@@ -17,4 +25,17 @@ import org.springframework.stereotype.Service;
 @Service
 public class ProBasicFeatureStatServiceImpl extends ServiceImpl<ProBasicFeatureStatMapper, ProBasicFeatureStat> implements IProBasicFeatureStatService {
 
+    @Resource
+    private ProBasicFeatureStatMapper proBasicFeatureStatMapper;
+
+    public List<ProBasicFeatureStat> searchByCondition(Date begin, Date end, String stationId,String wtId)
+    {
+        List<ProBasicFeatureStat> ls=new ArrayList<>();
+
+        if(StringUtils.notEmp(begin) && StringUtils.notEmp(end) && StringUtils.notEmp(end))
+        {
+            ls=proBasicFeatureStatMapper.searchByCondition(begin,end,stationId,wtId);
+        }
+        return  ls;
+    }
 }

File diff suppressed because it is too large
+ 3444 - 1276
log/ota.log


BIN
log/ota.log.2023-08-07.0.gz


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