Browse Source

告警页面调整,计算准确率时将短期单点偏差存入新表,供盒须图使用

fanxiaoyu 7 months ago
parent
commit
3d82f6e452

+ 2 - 2
cpp-admin/src/main/java/com/cpp/web/controller/alarm/AbnormalAlarmController.java

@@ -58,8 +58,8 @@ public class AbnormalAlarmController {
 
 
     @GetMapping("/getCountByStatusAndStationCode")
-    public R getCountByStatus(Integer status, String stationCode) {
-        return R.ok(abnormalAlarmService.countByStatusAndStationCode(status, stationCode));
+    public R getCountByStatus(Integer status, String stationCode,Long startTime,Long endTime,AlarmEnum alarmType) {
+        return R.ok(abnormalAlarmService.countByStatusAndStationCode(status, stationCode,startTime,endTime,alarmType));
     }
 
 

+ 13 - 1
cpp-admin/src/main/java/com/cpp/web/service/accuracy/impl/CalculateForecastPowerShortTermRegulationImpl.java

@@ -2,10 +2,12 @@ package com.cpp.web.service.accuracy.impl;
 
 import com.cpp.common.utils.spring.SpringUtils;
 import com.cpp.web.domain.accuracy.AccuracyPassRate;
+import com.cpp.web.domain.accuracy.ShortTermSinglePointDeviation;
 import com.cpp.web.domain.enums.DataSourcesEnum;
 import com.cpp.web.domain.enums.ForecastTypeEnum;
 import com.cpp.web.domain.station.*;
 import com.cpp.web.service.accuracy.CalculateInterface;
+import com.cpp.web.service.accuracy.ShortTermSinglePointDeviationService;
 import com.cpp.web.service.station.ForecastPowerShortTermRegulationService;
 import com.syjy.calculate.entity.CalculateRequest;
 import com.syjy.calculate.entity.CalculateResult;
@@ -27,6 +29,8 @@ public class CalculateForecastPowerShortTermRegulationImpl implements CalculateI
 
     private final ForecastPowerShortTermRegulationService forecastPowerShortTermRegulationService;
 
+    private final ShortTermSinglePointDeviationService  shortTermSinglePointDeviationService;
+
     @Override
     public List<AccuracyPassRate> calc(Date startTime,Date endTime,List<PowerStationStatusData> powerStationStatusDataList, List<ElectricField> electricFieldList, List<String> formulaTypes, String province){
 
@@ -121,6 +125,7 @@ public class CalculateForecastPowerShortTermRegulationImpl implements CalculateI
 
                         }
                     }
+                    List<ShortTermSinglePointDeviation> shortTermSinglePointDeviationList = new ArrayList<>();
                     if (formulaTypes.contains("POINT_SHORT_ACCURACY")) {//单点偏差计算
                         List<BigDecimal> values = new ArrayList<>();
                         for (long stepTime = startTime.getTime(); stepTime <= endTime.getTime(); stepTime += 900000L) {
@@ -132,12 +137,19 @@ public class CalculateForecastPowerShortTermRegulationImpl implements CalculateI
                                     ForecastPowerShortTermRegulation forecastPowerShortTermRegulation = dateForecastListMap.get(finalTime).get(0);
                                     BigDecimal subtractAbs = powerStationStatusData.getRealValue().subtract(forecastPowerShortTermRegulation.getFpValue()).abs();
                                     BigDecimal value = subtractAbs.divide(electricField.getCapacity(), 4, BigDecimal.ROUND_DOWN);
+                                    // 单点偏差
+                                    ShortTermSinglePointDeviation shortTermSinglePointDeviation = new ShortTermSinglePointDeviation();
+                                    shortTermSinglePointDeviation.setDeviation(value.multiply(new BigDecimal(100)));
+                                    shortTermSinglePointDeviation.setStationCode(stationCode);
+                                    shortTermSinglePointDeviation.setTime(finalTime);
+                                    shortTermSinglePointDeviation.setForecastHowLongAgo(ago);
+                                    shortTermSinglePointDeviationList.add(shortTermSinglePointDeviation);
                                     values.add(value);
                                 }
                             }
 
                         }
-
+                        shortTermSinglePointDeviationService.saveBatch(shortTermSinglePointDeviationList);
                         if (values.size() > 0) {
                             Double value = values.stream().mapToDouble(v -> v.doubleValue()).average().getAsDouble();
                             accuracyPassRate.setDeviationSum(String.format("%.2f", value * 100) + "%");

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/service/alarm/AbnormalAlarmService.java

@@ -20,7 +20,7 @@ public interface AbnormalAlarmService extends IService<AbnormalAlarm> {
 
     Boolean updateStationStatus1(String stationCode);
 
-    Long countByStatusAndStationCode(Integer status, String stationCode);
+    Long countByStatusAndStationCode(Integer status, String stationCode,Long startTime,Long endTime,AlarmEnum alarmType);
 
 
     /**

+ 16 - 3
cpp-admin/src/main/java/com/cpp/web/service/alarm/impl/AbnormalAlarmServiceImpl.java

@@ -76,12 +76,25 @@ public class AbnormalAlarmServiceImpl extends ServiceImpl<AbnormalAlarmMapper, A
     }
 
     @Override
-    public Long countByStatusAndStationCode(Integer status, String stationCode) {
+    public Long countByStatusAndStationCode(Integer status, String stationCode,Long startTime,Long endTime,AlarmEnum alarmType) {
 
+        Date queryStartTime = new Date(startTime);
+        Date queryEndTime = new Date(endTime);
         QueryWrapper<AbnormalAlarm> wrapper = new QueryWrapper<>();
         wrapper.eq("status", status);
-        wrapper.eq("station_code", stationCode);
-
+        if (startTime != null && !endTime.equals("") && endTime != null && !endTime.equals("")) {
+            wrapper.and(a -> a.or(w -> w.isNull("end_time").le("start_time", queryEndTime))
+                    .or(w -> w.isNotNull("end_time").le("start_time", queryEndTime).gt("end_time", queryStartTime))
+                    .or(w -> w.isNotNull("end_time").le("start_time", queryEndTime).gt("start_time", queryStartTime))
+                    .or(w -> w.isNotNull("end_time").le("end_time", queryEndTime).gt("start_time", queryEndTime))
+                    .or(w -> w.isNotNull("end_time").le("start_time", queryStartTime).gt("end_time", queryEndTime)));
+        }
+        if (!stationCode.equals("all")){
+            wrapper.eq("station_code", stationCode);
+        }
+        if (alarmType != null && !alarmType.equals("")) {
+            wrapper.eq("alarm_type", alarmType);
+        }
         return baseMapper.selectCount(wrapper);
     }
 

+ 12 - 6
cpp-ui/src/views/abnormalAlarm/index.vue

@@ -44,14 +44,17 @@
         </el-form-item>
       </el-form>
     </div>
-    <div class="top-badge position-a" style="top: 20px;right: 2vw;">
-      <el-badge v-loading="loading" :value="this.alarmNum">
-        <img src="../../assets/images/svg/remind.svg" width="30px"/>
-      </el-badge>
-    </div>
+<!--    <div class="top-badge position-a" style="top: 20px;right: 2vw;">-->
+<!--      <el-badge v-loading="loading" :value="this.alarmNum">-->
+<!--        <img src="../../assets/images/svg/remind.svg" width="30px"/>-->
+<!--      </el-badge>-->
+<!--    </div>-->
     <div class="dark-el-button">
       <el-button type="primary" @click="acknowledgeByStationCode">全部确认
       </el-button>
+      <el-badge v-loading="loading" :value="this.alarmNum" style="margin-left: 5px; margin-top: 10px">
+        <img src="../../assets/images/svg/remind.svg" width="30px"/>
+      </el-badge>
     </div>
     <div style="padding-top: 10px">
       <vxe-table
@@ -127,7 +130,7 @@ export default {
       dateTime: [new Date(new Date().toLocaleDateString()).getTime(), new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000 - 5 * 1000 * 60],
       total: 0,
       sortOrder: 'asc',
-      pageSize: 15,
+      pageSize: 10,
       currentPage: 1,
       stationList: [],
       stationCode: [],
@@ -205,6 +208,9 @@ export default {
           params: {
             "status": 0,
             "stationCode": this.stationCode,
+            "startTime": startTime,
+            "endTime": endTime,
+            "alarmType": this.alarmType
           }
         }).then(response => {
           this.alarmNum = response.data