Browse Source

报警统计功能

shilin 1 year ago
parent
commit
095ee0e9ca

+ 78 - 11
alarm-web/src/main/java/com/gyee/alarm/controller/AlarmHistoryController.java

@@ -46,7 +46,7 @@ public class AlarmHistoryController {
             @ApiImplicitParam(name = "begin", value = "开始时间", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "end", value = "结束时间", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "alarmType", value = "报警类型 booststation:升压站报警,windturbine:设备报警,custom:自定义报警", required = true, dataType = "string", paramType = "query"),
-            @ApiImplicitParam(name = "stationid", value = "场站编号", required = false, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "stationid", value = "场站编号", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "deviceid", value = "设备编号", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "description", value = "描述", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "modelId", value = "型号", required = false, dataType = "string", paramType = "query"),
@@ -58,7 +58,7 @@ public class AlarmHistoryController {
             @RequestParam(value = "begin", required = true) String begin,
             @RequestParam(value = "end", required = true) String end,
             @RequestParam(value = "alarmType", required = true) String alarmType,
-            @RequestParam(value = "stationid", required = false) String stationid,
+            @RequestParam(value = "stationid", required = true) String stationid,
             @RequestParam(value = "deviceid", required = false) String deviceid,
             @RequestParam(value = "description", required = false) String description,
             @RequestParam(value = "modelId", required = false) String modelId,
@@ -69,7 +69,7 @@ public class AlarmHistoryController {
 
     ) throws Exception {
 
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date beginDate = df.parse(begin);
         Date endDate = df.parse(end);
         Map<String,Object> map = alarmHistoryService.findAlarmlist(modelId,beginDate.getTime(), endDate.getTime(), alarmType, stationid,deviceid, description,deviceType,components, pageNum, pageSize);
@@ -79,37 +79,42 @@ public class AlarmHistoryController {
 
     @GetMapping(value = "/history/findAlarmByTypelist")
     @ApiOperation(value = "获取升压站、设备、自定义报警报警信息查询", notes = "报警信息查询")
-   public AjaxResult findAlarmByTypelist() throws Exception {
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "type", value = "报警类型 booststation:升压站报警,windturbine:设备报警,custom:自定义报警", required = true, dataType = "string", paramType = "query")
+    })
+   public AjaxResult findAlarmByTypelist(String type) throws Exception {
 
 
-        Map<String,Object> map = alarmHistoryService.findAlarmByTypelist();
-        return AjaxResult.successData(AjaxStatus.success.code, map);
+        List<AlarmVo> ls = alarmHistoryService.findAlarmByTypelist(type);
+        return AjaxResult.successData(AjaxStatus.success.code, ls);
 
     }
 
 
-    @GetMapping(value = "/history/findFeatureStat")
-    @ApiOperation(value = "查询报警类型、报警时长、报警次数", notes = "查询报警类型、报警时长、报警次数")
+    @GetMapping(value = "/history/findWtFeatureStat")
+    @ApiOperation(value = "查询原始报警类型、报警时长、报警次数", notes = "查询报警类型、报警时长、报警次数")
     @ApiImplicitParams({
 
             @ApiImplicitParam(name = "begin", value = "开始时间", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "end", value = "结束时间", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "stationid", value = "场站编号", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "modelId", value = "型号编号", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "components", value = "部件编号", required = true, dataType = "string", paramType = "query")
            })
-    public List<Map.Entry<String, List<AlarmStatVo>>> findFeatureStat(
+    public List<Map.Entry<String, List<AlarmStatVo>>> findWtFeatureStat(
 
             @RequestParam(value = "begin", required = true) String begin,
             @RequestParam(value = "end", required = true) String end,
             @RequestParam(value = "stationid", required = true) String stId,
+            @RequestParam(value = "modelId", required = true) String modelId,
             @RequestParam(value = "components", required = true) String components
     ) throws ParseException {
 
 
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date dtStart = sdf.parse(begin);
         Date dtEnd = sdf.parse(end);
-        List<AlarmStatVo> pressureList = alarmHistoryService.findByCondition(stId, dtStart, dtEnd,components);
+        List<AlarmStatVo> pressureList = alarmHistoryService.findWtFeatureStat(stId,modelId, dtStart, dtEnd,components);
 
 //
 //        Map<String, List<AlarmStatVo>> map=new TreeMap<>();
@@ -147,6 +152,68 @@ public class AlarmHistoryController {
 
     }
 
+
+    @GetMapping(value = "/history/findCtFeatureStat")
+    @ApiOperation(value = "查询自定义报警类型、报警时长、报警次数", notes = "查询报警类型、报警时长、报警次数")
+    @ApiImplicitParams({
+
+            @ApiImplicitParam(name = "begin", value = "开始时间", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "end", value = "结束时间", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "stationid", value = "场站编号", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "modelId", value = "型号编号", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "description", value = "规则描述", required = true, dataType = "string", paramType = "query")
+    })
+    public List<Map.Entry<String, List<AlarmStatVo>>> findCtFeatureStat(
+
+            @RequestParam(value = "begin", required = true) String begin,
+            @RequestParam(value = "end", required = true) String end,
+            @RequestParam(value = "stationid", required = true) String stId,
+            @RequestParam(value = "modelId", required = true) String modelId,
+            @RequestParam(value = "description", required = true) String description
+    ) throws ParseException {
+
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date dtStart = sdf.parse(begin);
+        Date dtEnd = sdf.parse(end);
+        List<AlarmStatVo> pressureList = alarmHistoryService.findCtFeatureStat(stId,modelId, dtStart, dtEnd,description);
+
+//
+//        Map<String, List<AlarmStatVo>> map=new TreeMap<>();
+//
+//        for(AlarmStatVo vo:pressureList)
+//        {
+//            if(map.containsKey(vo.getRelateParts()))
+//            {
+//                List<AlarmStatVo>
+//            }
+//        }
+        //根据风机编号分组
+        Map<String, List<AlarmStatVo>> alarmStatMapGroupbyWindturbineId = pressureList.stream().collect(Collectors.groupingBy(AlarmStatVo::getWindturbineId));
+
+        Map<String, List<AlarmStatVo>> resultMap = new TreeMap<>();
+
+        for (Map.Entry<String, List<AlarmStatVo>> entry : alarmStatMapGroupbyWindturbineId.entrySet()) {
+            String windturbineId = entry.getKey();
+            resultMap.put(windturbineId, entry.getValue());
+        }
+
+        //根据风机编号进行排序
+        List<Map.Entry<String, List<AlarmStatVo>>> list = new ArrayList<>(resultMap.entrySet());
+        Collections.sort(list, new Comparator<Map.Entry<String, List<AlarmStatVo>>>() {
+            @Override
+            public int compare(Map.Entry<String, List<AlarmStatVo>> o1, Map.Entry<String, List<AlarmStatVo>> o2) {
+                String key1=o1.getKey();
+                String key2=o1.getKey();
+                return key1.compareTo(key2);
+            }
+        });
+
+        return list;
+
+
+    }
+
 }
 
 

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

@@ -403,17 +403,17 @@ public class AlertRuleController {
 
         List<ProEconAlarmRule> list = Arrays.asList(
                 ProEconAlarmRule.builder().id("").name("单机变桨电池柜温度1温度传感器异常值").description("温度等于850度或者温度小于零下40度")
-                        .expression("AI242 == 850 || AI242 <-40").tag("").rank(4).modelId("TZ-2000")
+                        .expression("AI242 == 850 || AI242 <-40").tag("").rank(4).modelId("UP2000")
                         .category("windturbine").range("parts")
-                        .stationId("SXJ_KGDL_HSM_FDC_STA").projectId("SXJ_KGDL_HSMF01_EG").lineId("SXJ_KGDL_HSMF01_LN").deviceId("SXJ_KGDL_HSM_F_WT_0001_EQ")
+                        .stationId("SXJ_KGDL_GJY_FDC_STA").projectId("SXJ_KGDL_GJYF01_EG").lineId("SXJ_KGDL_GJYF01_LN").deviceId("SXJ_KGDL_GJY_F_WT_0001_EQ")
                         .electricalId("").relatedParts("BJXT").createTime(DateUtils.truncate(previousDay))
                         .enable(true).uniformCode("AI091")
                         .build(),
 
-                ProEconAlarmRule.builder().id("").name("单机变桨电池柜温度2超限报警").description("温度等于850度或者温度小于零下40度")
-                        .expression("(AI243>=65 || AI243<-10)").tag("").rank(4).modelId("TZ-2000")
+                ProEconAlarmRule.builder().id("").name("单机变桨电池柜温度1温度传感器异常值").description("温度等于850度或者温度小于零下40度")
+                        .expression("AI242 == 850 || AI242 <-40").tag("").rank(4).modelId("UP2000")
                         .category("windturbine").range("parts")
-                        .stationId("SXJ_KGDL_HSM_FDC_STA").projectId("SXJ_KGDL_HSMF01_EG").lineId("SXJ_KGDL_HSMF01_LN").deviceId("SXJ_KGDL_HSM_F_WT_0002_EQ")
+                        .stationId("SXJ_KGDL_GJY_FDC_STA").projectId("SXJ_KGDL_GJYF01_EG").lineId("SXJ_KGDL_GJYF01_LN").deviceId("SXJ_KGDL_GJY_F_WT_0001_EQ")
                         .electricalId("").relatedParts("BJXT").createTime(DateUtils.truncate(previousDay))
                         .enable(true).uniformCode("AI091")
                         .build()

+ 0 - 20
alarm-web/src/main/java/com/gyee/alarm/controller/ProBasicFeatureStatController.java

@@ -1,20 +0,0 @@
-package com.gyee.alarm.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 设备功能统计 前端控制器
- * </p>
- *
- * @author shilin
- * @since 2023-08-14
- */
-@RestController
-@RequestMapping("//pro-basic-feature-stat")
-public class ProBasicFeatureStatController {
-
-}

+ 0 - 20
alarm-web/src/main/java/com/gyee/alarm/controller/ProEconRuleUpdateInfoController.java

@@ -1,20 +0,0 @@
-package com.gyee.alarm.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 规则修改记录内容 前端控制器
- * </p>
- *
- * @author shilin
- * @since 2023-08-15
- */
-@RestController
-@RequestMapping("//pro-econ-rule-update-info")
-public class ProEconRuleUpdateInfoController {
-
-}

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

@@ -617,7 +617,7 @@ public class CacheContext implements CommandLineRunner {
             customls=customls.stream().filter(i ->null !=i.getEnable() &&  i.getEnable()).collect(Collectors.toList());
         }
         List<ProEconAlarmRule> wtCustomls=new ArrayList<>();
-        List<ProEconAlarmRule> wpCustomls=new ArrayList<>();
+        List<ProEconAlarmRule> btCustomls=new ArrayList<>();
 //        List<ProEconAlarmRule> btCustomls=new ArrayList<>();
         if(!customls.isEmpty())
         {
@@ -628,15 +628,15 @@ public class CacheContext implements CommandLineRunner {
                     if(vo.getCategory().equals(AlarmCustomType.WT.getCode()))
                     {
                         wtCustomls.add(vo);
-                    }else  if(vo.getCategory().equals(AlarmCustomType.WP.getCode()))
+                    }else  if(vo.getCategory().equals(AlarmCustomType.BT.getCode()))
                     {
-                        wpCustomls.add(vo);
+                        btCustomls.add(vo);
                     }
                 }
             }
         }
         alarmRulesMap.put(AlarmCustomType.WT.getCode(),wtCustomls);
-        alarmRulesMap.put(AlarmCustomType.WP.getCode(),wpCustomls);
+        alarmRulesMap.put(AlarmCustomType.BT.getCode(),btCustomls);
 
 
         List<ProEconAlarmConfiguration> templs = proEconAlarmConfigurationService.list().stream().filter(i -> i.getEnable()).collect(Collectors.toList());

+ 33 - 6
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java

@@ -93,9 +93,11 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
 //            "#{whereSql}  order by ts desc limit #{limit} offset #{offset} ")
 
     @Select({"<script>",
-            "select ts,val,alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
+            "select  last_row(ts) as lastts,ts,val,alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
                     "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{superTableName} " ,
             "<where>" ,
+            "  ts &gt;= #{begin} ",
+            " and ts &lt;= #{end} ",
             "<if test='modelId != null'>",
             "and modelId= #{modelId}",
             "</if>",
@@ -111,10 +113,16 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "<if test='components != null'>",
             "and components = #{components}",
             "</if>",
+            "<if test='stationid != null'>",
             "and stationid = #{stationid}",
-            "and ts &gt;= #{begin}",
-            "and ts &lt;= #{end}",
+            "</if>",
+
+
+            " and stationid in ('SXJ_KGDL_GJY_FDC_STA','SXJ_KGDL_DJY_FDC_STA')",
+            " and  confirmed = false ",
+            " and  enabled = true ",
             "</where>",
+            " group by tbname,alarmid,alarmtype,characteristic,components,description,deviceid,devicename,devicetype,enabled,lineid,linename,modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode ",
             " 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("components")String components,@Param("limit")int limit, @Param("offset") int offset);
@@ -149,9 +157,11 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
     @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}",
+
+            " ts &gt;= #{begin}",
             "and ts &lt;= #{end}",
+            "and stationid = #{stationid}",
+            "and modelId = #{modelId}",
             "<if test='components != null'>",
             "and components= #{components}",
             "</if>",
@@ -159,8 +169,25 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             " 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);
+    List<ProBasicFeatureStat> findWtFeatureStat( @Param("begin")long begin, @Param("end") long end, @Param("stationid") String stationid, @Param("modelId")String modelId, @Param("components") String components);
 
 
+    @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 alarmCt " ,
+            "<where>" ,
+
+            " ts &gt;= #{begin}",
+            "and ts &lt;= #{end}",
+            "and stationid = #{stationid}",
+            "and modelId = #{modelId}",
+            "<if test='description != null'>",
+            "and description= #{description}",
+            "</if>",
+            "</where>",
+            " group by deviceid,components,stationid,alarmid,description ",
+            " order by deviceid  ",
+            "</script>"})
+    List<ProBasicFeatureStat> findCtFeatureStat( @Param("begin")long begin, @Param("end") long end, @Param("stationid") String stationid, @Param("modelId")String modelId, @Param("description") String description);
+
 
 }

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/model/vo/AlarmCustomType.java

@@ -3,7 +3,7 @@ package com.gyee.alarm.model.vo;
 public enum AlarmCustomType {
 
     WT("windturbine", "设备自定义报警"),
-    Bt("booststation", "升压站报警"),
+    BT("booststation", "升压站报警"),
     WP("station", "场站自定义报警");
 
     private String code;

+ 176 - 15
alarm-web/src/main/java/com/gyee/alarm/service/AlarmHistoryService.java

@@ -124,32 +124,43 @@ public class AlarmHistoryService   {
 
 
 
-    public Map<String,Object> findAlarmByTypelist() {
+    public List<AlarmVo> findAlarmByTypelist(String type) {
 
-        Map<String,Object> map=new HashMap<>();
 
+        List<AlarmVo> vos=new ArrayList<>();
 
 
+        if(StringUtils.notEmp(type) )
+        {
             Date endDate = new Date();
-            Date beginDate = DateUtils.truncate(endDate);
+            Date beginDate = DateUtils.addHours(endDate,-1);
+
+            if(type.equals(AlarmTypeValue.BT.getCode()))
+            {
+               vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.BT.getCode(), AlarmTypeValue.BT.getCode(), null, null, null,null,null, 0, home_pagep_size);
 
+            }else if(type.equals(AlarmTypeValue.WT.getCode()))
+            {
+                vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.WT.getCode(), AlarmTypeValue.WT.getCode(), null, 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);
+            }else if(type.equals(AlarmTypeValue.CT.getCode()))
+            {
+                vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.CT.getCode(), AlarmTypeValue.CT.getCode(), null, 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, null,0, home_pagep_size);
-        map.put("ctls",ctls);
-        return map;
+        }
+
+        return vos;
     }
 
 
-    public List<AlarmStatVo> findByCondition(String stationId, Date startTime, Date endTime,String components) {
+    public List<AlarmStatVo> findWtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components) {
         List<AlarmStatVo> resultList = new ArrayList<>();
 
-        List<ProBasicFeatureStat> fsls = alarmTsMapper.findFeatureStatList(startTime.getTime(), endTime.getTime(),stationId,components);
+
+
+        List<ProBasicFeatureStat> fsls = alarmTsMapper.findWtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,components);
 
 
         Map<String, ProBasicFeatureStat> map = new HashMap<>();
@@ -180,9 +191,15 @@ public class AlarmHistoryService   {
                 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()))
+                        if(StringUtils.notEmp(components) )
                         {
-                            setValues(statDate, map, vos, wt, at);
+                            if( components.equals(at.getComponents()))
+                            {
+                                setWtValues(statDate, map, vos, wt, at);
+                            }
+                        }else
+                        {
+                            setWtValues(statDate, map, vos, wt, at);
                         }
 
                     }
@@ -251,7 +268,7 @@ public class AlarmHistoryService   {
 
         return resultList;
     }
-    private  static void setValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration at) {
+    private  static void setWtValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration at) {
 
         ProBasicFeatureStat fs = new ProBasicFeatureStat();
 
@@ -282,5 +299,149 @@ public class AlarmHistoryService   {
         vos.add(fs);
     }
 
+    public List<AlarmStatVo> findCtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String description) {
+        List<AlarmStatVo> resultList = new ArrayList<>();
+
+
+
+        List<ProBasicFeatureStat> fsls = alarmTsMapper.findCtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,description);
+
+
+        Map<String, ProBasicFeatureStat> map = new HashMap<>();
+        Date statDate=DateUtils.truncate(new Date());
+
+        if (!fsls.isEmpty()) {
+            for (ProBasicFeatureStat fs : fsls) {
+                if (StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode())) {
+                    ProEconAlarmType at = CacheContext.alarmTypeMap.get(fs.getTypeCode());
+                    fs.setTypeName(at.getName());
+                }
+                fs.setStatDate(new Timestamp(statDate.getTime()));
+                fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                StringBuilder sb = new StringBuilder();
+                sb.append(fs.getWtId()).append("_").append(fs.getAlarmid());
+                map.put(String.valueOf(sb), fs);
+            }
+        }
+        List<ProBasicFeatureStat> vos = new ArrayList<>();
+
+        if(CacheContext.wpwtmap.containsKey(stationId))
+        {
+            List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(stationId);
+            for (ProBasicEquipment wt : wtls) {
+
+                StringBuilder sb=new StringBuilder();
+                sb.append(wt.getWindpowerstationId()).append(wt.getModelId());
+                if(CacheContext.wtAlarmMap.containsKey(String.valueOf(sb))) {
+                    List<ProEconAlarmRule> wtCustomls=CacheContext.alarmRulesMap.get(AlarmCustomType.WT.getCode());
+
+                    for (ProEconAlarmRule at : wtCustomls) {
+                        if(StringUtils.notEmp(description) && description.equals(at.getDescription()))
+                        {
+                            if(description.equals(at.getDescription()))
+                            {
+                                setCtValues(statDate, map, vos, wt, at);
+                            }
+
+                        }else
+                        {
+                            setCtValues(statDate, map, vos, wt, at);
+                        }
 
+                    }
+                }
+            }
+        }
+
+
+        Map<String,List<AlarmStatVo>> vomap=new HashMap<>();
+        for(ProBasicFeatureStat fs:vos)
+        {
+            AlarmStatVo d = new AlarmStatVo();
+            d.setRelateParts(fs.getTypeCode());
+            d.setRelatePartsText(fs.getTypeName());
+            d.setAlertText(fs.getDescription());
+            d.setCount(fs.getTotal());
+            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 setCtValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmRule at) {
+
+        ProBasicFeatureStat fs = new ProBasicFeatureStat();
+
+        StringBuilder sb = new StringBuilder();
+        sb.append(fs.getWtId()).append("_").append(at.getId());
+        if (map.containsKey(String.valueOf(sb))) {
+            ProBasicFeatureStat old = map.get(String.valueOf(sb));
+            BeanUtil.copyProperties(old, fs);
+        } else {
+            fs.setStatDate(new Timestamp(statDate.getTime()));
+            fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+            fs.setWtId(wt.getId());
+            fs.setStationId(wt.getWindpowerstationId());
+            fs.setTypeCode(at.getCategory());
+            if(CacheContext.alarmTypeMap.containsKey(at.getCategory()))
+            {
+                fs.setTypeName(CacheContext.alarmTypeMap.get(at.getCategory()).getName());
+            }
+            fs.setAlarmid(at.getId());
+            fs.setDescription(at.getDescription());
+            fs.setTotal(0l);
+            fs.setAvgSeconds(0.0);
+            fs.setMaxSeconds(0.0);
+            fs.setMinSeconds(0.0);
+            fs.setTotalSeconds(0.0);
+
+        }
+        vos.add(fs);
+    }
 }

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

@@ -140,7 +140,7 @@ db:
 
 #参与计算的场站
 #runWindpowerstation: SXJ_KGDL_GJY_FDC_STA
-runWindpowerstation: SXJ_KGDL_NJL_FDC_STA,SXJ_KGDL_YF_FDC_STA,SXJ_KGDL_YLZ_FDC_STA,SXJ_KGDL_XWT_FDC_STA,SXJ_KGDL_PTZ_FDC_STA,SXJ_KGDL_GJY_FDC_STA,SXJ_KGDL_BHB_FDC_STA,SXJ_KGDL_HSM_FDC_STA,SXJ_KGDL_YTY_FDC_STA,SXJ_KGDL_BHB3_FDC_STA,SXJ_KGDL_SY_GDC_STA,SXJ_KGDL_PDL_FDC_STA,SXJ_KGDL_ZK_FDC_STA,SXJ_KGDL_JR_GDC_STA,SXJ_KGDL_FS_GDC_STA,SXJ_KGDL_HR_GDC_STA,SXJ_KGDL_YY_GDC_STA,SXJ_KGDL_PL_GDC_STA,SXJ_KGDL_TL_GDC_STA
+runWindpowerstation: SXJ_KGDL_DJY_FDC_STA,SXJ_KGDL_NJL_FDC_STA,SXJ_KGDL_YF_FDC_STA,SXJ_KGDL_YLZ_FDC_STA,SXJ_KGDL_XWT_FDC_STA,SXJ_KGDL_PTZ_FDC_STA,SXJ_KGDL_GJY_FDC_STA,SXJ_KGDL_BHB_FDC_STA,SXJ_KGDL_HSM_FDC_STA,SXJ_KGDL_YTY_FDC_STA,SXJ_KGDL_BHB3_FDC_STA,SXJ_KGDL_SY_GDC_STA,SXJ_KGDL_PDL_FDC_STA,SXJ_KGDL_ZK_FDC_STA,SXJ_KGDL_JR_GDC_STA,SXJ_KGDL_FS_GDC_STA,SXJ_KGDL_HR_GDC_STA,SXJ_KGDL_YY_GDC_STA,SXJ_KGDL_PL_GDC_STA,SXJ_KGDL_TL_GDC_STA
 #计算状态用ai或者di
 clauStatus:
   ai: GJY03_GC,YLZ01_GC,PTZ02_GC   #配置期次

File diff suppressed because it is too large
+ 1702 - 5382
log/ota.log


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