소스 검색

首页报警统计查询bug修改

‘xugp 2 년 전
부모
커밋
7cab8d92df

+ 1 - 1
warning-web/src/main/java/com/gyee/wisdom/Bootstrap.java

@@ -12,11 +12,11 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @ServletComponentScan
 @EnableScheduling
 public class Bootstrap {
-
     public static void main(String[] args) {
         SpringApplication.run(Bootstrap.class, args);
     }
 
+
 }
 
 

+ 2 - 0
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/entity/AlarmPartsCount.java

@@ -20,6 +20,8 @@ public class AlarmPartsCount implements Serializable{
     private int count;
     @TableField("WINDTURBINEID")
     private String windturbineId;
+    @TableField("WINDPOWERSTATIONID")
+    private String windpowerstationId;
 
 
 }

+ 2 - 0
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/entity/AlarmRuleCount.java

@@ -22,6 +22,8 @@ public class AlarmRuleCount implements Serializable{
     private int count;
     @TableField("WINDTURBINEID")
     private String windturbineId;
+    @TableField("WINDPOWERSTATIONID")
+    private String windpowerstationId;
 
 
 }

+ 14 - 11
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/schedule/AlarmCountPartsScheduled.java

@@ -3,10 +3,7 @@ package com.gyee.wisdom.alarm.sharding.schedule;
 import com.gyee.wisdom.alarm.sharding.entity.*;
 import com.gyee.wisdom.alarm.sharding.mapper.AlarmPartsCountMapper;
 import com.gyee.wisdom.alarm.sharding.mapper.AlarmRuleCountMapper;
-import com.gyee.wisdom.alarm.sharding.service.AlarmHistoryService;
-import com.gyee.wisdom.alarm.sharding.service.AlarmSnapService;
-import com.gyee.wisdom.alarm.sharding.service.TableNameService;
-import com.gyee.wisdom.alarm.sharding.service.Warning2Service;
+import com.gyee.wisdom.alarm.sharding.service.*;
 import com.gyee.wisdom.alarm.sharding.util.SnowflakeGenerator;
 import com.gyee.wisdom.common.utils.DateUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -14,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
-import org.w3c.dom.ls.LSInput;
 
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -23,7 +19,7 @@ import java.util.stream.Collectors;
 /**
  * @author :xugp
  * @date :Created in 2022/9/8 10:15
- * @description:报警信息统计根据部件、规则统计发生报警次数
+ * @description:风机报警统计根据部件、规则发生报警次数
  * @modified By:
  * @version: $
  */
@@ -47,10 +43,13 @@ public class AlarmCountPartsScheduled {
     @Autowired
     private Warning2Service warning2Service;
 
+    @Autowired
+    private WindturbineService windturbineService;
+
 
     @Autowired
     private AlarmHistoryService alarmHistoryService;
-    @Scheduled(cron = "* 46 17 ? * 5")
+    @Scheduled(cron = "* 41 10 ? * 3")
     public boolean doTask() {
 
         try {
@@ -67,7 +66,7 @@ public class AlarmCountPartsScheduled {
                 //根据windturbineid分组
                 Map<String,List<AlarmSnap>> maps = snapList.stream().collect(Collectors.groupingBy(AlarmSnap::getWindturbineId));
                 for (Map.Entry<String,List<AlarmSnap>> listEntry : maps.entrySet()) {
-                    List<AlarmSnap> alarmSnap = alarmSnapService.getAlarmSnap(listEntry.getKey());
+                    List<AlarmSnap> alarmSnap = listEntry.getValue();
                     List<AlarmHistory> alarmHistories = new ArrayList<>();
                     for(AlarmSnap snap : alarmSnap){
                         String tbName = tableNameService.getAlarmHistoryTableName(snap.getStationId(), dtStart);
@@ -76,7 +75,7 @@ public class AlarmCountPartsScheduled {
                     }
                     map.put(listEntry.getKey(),alarmHistories);
                 }
-                //遍历map(key:windturbined,value:history)
+                //遍历map(key:windturbined,value:history),得到部件
                 for (Map.Entry<String,List<AlarmHistory>> entry : map.entrySet()){
                     Map<String,String> map1 = new HashMap<>();
                     List<AlarmHistory> value = entry.getValue();
@@ -111,6 +110,7 @@ public class AlarmCountPartsScheduled {
                             alarmRuleCount.setRulesId(entryString.getKey());
                             alarmRuleCount.setCount(entryString.getValue());
                             alarmRuleCount.setWindturbineId(entry.getKey());
+                            alarmRuleCount.setWindpowerstationId(windturbineService.selectWindturbineByWindturbineid(entry.getKey()).getWindpowerstationid());
                             alarmRuleCounts.add(alarmRuleCount);
                         }
                         if (count > 0) {
@@ -121,14 +121,17 @@ public class AlarmCountPartsScheduled {
                             alarmPartsCount.setParts(entry1.getKey());
                             alarmPartsCount.setCount(count);
                             alarmPartsCount.setWindturbineId(entry.getKey());
+                            alarmPartsCount.setWindpowerstationId(windturbineService.selectWindturbineByWindturbineid(entry.getKey()).getWindpowerstationid());
                             acList.add(alarmPartsCount);
                         }
                     }
                 }
-                if (alarmRuleCounts.size() > 0)
+                if (alarmRuleCounts.size() > 0) {
                     alarmRuleCountMapper.batchInsert(alarmRuleCounts);
-                if (acList.size() > 0)
+                }
+                if (acList.size() > 0) {
                     alarmPartsCountMapper.batchInsert(acList);
+                }
                 dtStart = dtEnd;
                 dtEnd = DateUtil.addDays(dtStart, 1);
             }

+ 2 - 2
warning-web/src/main/resources/mappers-oracle/AlarmPartsCountMapper.xml

@@ -3,10 +3,10 @@
 <mapper namespace="com.gyee.wisdom.alarm.sharding.mapper.AlarmPartsCountMapper">
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="false">
-        insert into alarmpartscount ( ID, alarmdate, parts,count,windturbineid )
+        insert into alarmpartscount ( ID, alarmdate, parts,count,windturbineid,windpowerstationid)
         <foreach collection="list" item="item" index="index" separator="union all" >
             ( select
-            #{item.id}, #{item.alarmDate},#{item.parts},#{item.count},#{item.windturbineId}
+            #{item.id}, #{item.alarmDate},#{item.parts},#{item.count},#{item.windturbineId},#{item.windpowerstationId}
             from dual )
         </foreach>
     </insert>

+ 2 - 2
warning-web/src/main/resources/mappers-oracle/AlarmRuleCountMapper.xml

@@ -3,10 +3,10 @@
 <mapper namespace="com.gyee.wisdom.alarm.sharding.mapper.AlarmRuleCountMapper">
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="false">
-        insert into alarmrulecount ( ID, alarmdate, parts,rulesid,count,windturbineid)
+        insert into alarmrulecount ( ID, alarmdate, parts,rulesid,count,windturbineid,windpowerstationid)
         <foreach collection="list" item="item" index="index" separator="union all" >
             ( select
-            #{item.id}, #{item.alarmDate},#{item.parts},#{item.rulesId},#{item.count},#{item.windturbineId}
+            #{item.id}, #{item.alarmDate},#{item.parts},#{item.rulesId},#{item.count},#{item.windturbineId},#{item.windpowerstationId}
             from dual )
         </foreach>
     </insert>