浏览代码

准确性计算

wangb@gyee-china.com 1 年之前
父节点
当前提交
ea93744fcd

+ 25 - 19
realtime/generationXK-service/src/main/java/com/gyee/generation/service/StationPower/StationPowerService.java

@@ -3,7 +3,6 @@ package com.gyee.generation.service.StationPower;
 import com.gyee.common.contant.ContantXk;
 import com.gyee.common.model.PointData;
 import com.gyee.common.model.StringUtils;
-import com.gyee.common.util.DateUtils;
 import com.gyee.common.util.SortUtils;
 import com.gyee.generation.init.CacheContext;
 import com.gyee.generation.model.auto.ProBasicPowerstation;
@@ -11,6 +10,7 @@ import com.gyee.generation.model.auto.ProBasicPowerstationPoint;
 import com.gyee.generation.model.auto.ProBasicProject;
 import com.gyee.generation.model.auto.ProEconStationPower;
 import com.gyee.generation.service.auto.impl.ProEconStationPowerServiceImpl;
+import com.gyee.generation.util.math.PowerCalculator;
 import com.gyee.generation.util.math.PowerIntegration;
 import com.gyee.generation.util.math.ShortTermPowerPredictionAccuracyCalculator;
 import com.gyee.generation.util.realtimesource.IEdosUtil;
@@ -32,7 +32,8 @@ public class StationPowerService {
 
     @Resource
     private PowerIntegration powerIntegration;
-
+    @Resource
+    private PowerCalculator powerCalculator;
     @Resource
     private ProEconStationPowerServiceImpl powerService;
 
@@ -57,7 +58,7 @@ public class StationPowerService {
         calendar.set(Calendar.MILLISECOND, 0);
 
         // 设置 beginDate 为前一天的0点
-        calendar.add(Calendar.DAY_OF_MONTH, -2);
+        calendar.add(Calendar.DAY_OF_MONTH, -1);
         Date beginDate = calendar.getTime();
 
         // 设置 endDate 为当天的0点
@@ -66,7 +67,7 @@ public class StationPowerService {
 
         String wpId = null;
 
-        for (int g = 0; g <= 14; g++) {
+//        for (int g = 0; g <= 56; g++) {
 
             List<ProBasicProject> pjls = CacheContext.pjls;
 
@@ -113,11 +114,11 @@ public class StationPowerService {
 
                         if (wpId.endsWith("FDC_STA") && type.equals("F")) {
                             ycgl = propointMap.get(ContantXk.GLYC);
-                            sjgl = propointMap.get(ContantXk.PJGL15);
+                            sjgl = propointMap.get(ContantXk.SSZGL);
                         }
                         if (wpId.endsWith("GDC_STA") && type.equals("G")) {
                             ycgl = propointMap.get(ContantXk.GLYC);
-                            sjgl = propointMap.get(ContantXk.PJGL15);
+                            sjgl = propointMap.get(ContantXk.SSZGL);
                         }
 
                         if (ycgl != null && sjgl != null) {
@@ -492,11 +493,11 @@ public class StationPowerService {
 
                         if (wpId.endsWith("FDC_STA") && type.equals("F")) {
                             ycgl1 = proBasicWppointMap.get( ContantXk.GLYC);
-                            sjgl1 = proBasicWppointMap.get(ContantXk.PJGL15);
+                            sjgl1 = proBasicWppointMap.get(ContantXk.SSZGL);
                         }
                         if (wpId.endsWith("GDC_STA") && type.equals("G")) {
                             ycgl1 = proBasicWppointMap.get(ContantXk.GLYC);
-                            sjgl1 = proBasicWppointMap.get(ContantXk.PJGL15);
+                            sjgl1 = proBasicWppointMap.get(ContantXk.SSZGL);
                         }
                         if (ycgl1 != null && sjgl1 != null) {
 
@@ -540,7 +541,7 @@ public class StationPowerService {
             }
 
             List<ProEconStationPower> stringList = new ArrayList<>();
-//        Date currenttime = new Date();
+
             for (Map.Entry<String, Object> entry : map.entrySet()) {
                 String key = entry.getKey();
 
@@ -549,7 +550,8 @@ public class StationPowerService {
                     if (key.equals(p1.getId())) {
                         ArrayList<ForecastVo> forecastVos = (ArrayList<ForecastVo>) entry.getValue();
 
-                        Map<Integer,Double> gl = new TreeMap<>();
+//                        Map<Integer,Double> gl = new TreeMap<>();
+                        List<Double> gl = new ArrayList<>();
                         double[] sjglarr=new double[forecastVos.size()];
                         double[] ycglarr=new double[forecastVos.size()];
                         double dlycTotal = 0.0; // 累加的总值
@@ -558,31 +560,35 @@ public class StationPowerService {
                             sjglarr[i]=forecastVo.getSjgl();
                             ycglarr[i]=forecastVo.getYcgl();
 
-                            gl.put(i,forecastVo.getYcgl());
+                            gl.add(i,forecastVo.getYcgl());
                             double dlyc = 24.0 * forecastVo.getYcgl() / forecastVos.size(); // 每次循环的值
                             dlycTotal += dlyc; // 累加每次循环的值
                         }
-                        double energy = powerIntegration.calculateEnergy(gl, 0.25);
-
                         double Capacity = p1.getJrwindCapacity();
+                        double Capacity1 = p1.getJrwindCapacity() /1000;
+                        double maxgl = Capacity * 1.5 / 1000;
+//                        double energy = powerIntegration.calculateEnergy(gl, 0.25);
+                        double energy = powerCalculator.updateTheoryGeneration(gl, 24,maxgl);
+
+
 
 
-                        double accuracy = shortTermPowerPredictionAccuracyCalculator.calculateAccuracy(ycglarr,sjglarr, Capacity);
+                        double accuracy = shortTermPowerPredictionAccuracyCalculator.calculateAccuracy(ycglarr,sjglarr, Capacity1);
 
                         ProEconStationPower power = new ProEconStationPower();
                         power.setId(StringUtils.getUUID());
                         power.setPowerAccuracy(BigDecimal.valueOf(accuracy));
                         power.setWindpowerstationId(p1.getId());
                         power.setRecordDate(beginDate);
-                        power.setDayPowerForecast(BigDecimal.valueOf(energy));
+                        power.setDayPowerForecast(BigDecimal.valueOf(energy * 1000));
                         stringList.add(power);
                         powerService.batchAdd(stringList);
                     }
                 }
             }
-            beginDate = DateUtils.addDays(beginDate, -1);
-            calendar.add(Calendar.DAY_OF_MONTH, -1);
-            endDate = calendar.getTime();
-        }
+//            beginDate = DateUtils.addDays(beginDate, -1);
+//            calendar.add(Calendar.DAY_OF_MONTH, -1);
+//            endDate = calendar.getTime();
+//        }
     }
 }

+ 31 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/util/math/PowerCalculator.java

@@ -0,0 +1,31 @@
+package com.gyee.generation.util.math;
+
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+@Service
+public class PowerCalculator {
+    /**
+     * 用功率计算电量
+     *
+     * @param powerDataList 实际功率
+     * @param hours         总的小时数
+     * @param maxPower      最大功率
+     * @return 电量
+     */
+    public double updateTheoryGeneration(List<Double> powerDataList, double hours, double maxPower) {
+        double result = 0;
+        double T = hours;
+        int f = powerDataList.size();
+
+        if (f != 0) {
+            for (int i = 0; i < f; i++) {
+                double P = powerDataList.get(i);
+                if (P >= 0 && P <= maxPower) {
+                    result += (T / f) * P;
+                }
+            }
+        }
+        return result;
+    }
+}