瀏覽代碼

测光法a1,a2调整为场站级别配置

taosj 6 小時之前
父節點
當前提交
34ed7afd32

+ 10 - 0
doc/数据库脚本/update/20261113-20261126/taosj_patch_3.sql

@@ -0,0 +1,10 @@
+-- 测光法改为场站级别配置
+INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark)
+select
+    nextval(pg_get_serial_sequence('sys_dict_data', 'dict_code')), 
+    1, 
+    '测光法配置', '{"a1": 0.0, "a2": 0.0}', 
+    'algorithm_config', '', '', 'N', '0', 'admin', now(), '测光法 P=n*(a1*G+a2*T);a1/a2 初始为 0 占位,需运维替换为真实系数'
+where not exists (select 1 from sys_dict_data where dict_type = 'algorithm_config');
+
+update sys_dict_data set dict_value = '{"JMJD01":{"a1": 0.15598743, "a2": 0.26587976},"ZHONGXIN":{"a1": 0.19545898, "a2": -0.00031972},"YUWEI":{"a1": 1.27035672, "a2": 0.89066745}}' where dict_type = 'algorithm_config';

+ 1 - 1
forecast-backend-server/src/main/java/com/ufo/project/theoretical/calc/TheoreticalPowerCalc.java

@@ -157,7 +157,7 @@ public class TheoreticalPowerCalc
         }
         if (den == null || den == 0)
         {
-            return 0;
+            return 100;
         }
         return num / den * 100;
     }

+ 32 - 22
forecast-backend-server/src/main/java/com/ufo/project/theoretical/service/impl/TheoreticalPowerServiceImpl.java

@@ -103,8 +103,8 @@ public class TheoreticalPowerServiceImpl implements ITheoreticalPowerService
         int freq = requireFrequency(query.getSamplingFrequency());
         List<DataElectricityLocal> power = loadSingleDayPower(station, day);
         List<DataWeatherLocal> weather = loadSingleDayWeather(station, day);
-        double a1 = getPhotometricA1();
-        double a2 = getPhotometricA2();
+        double a1 = getPhotometricA1(station.getStationCode());
+        double a2 = getPhotometricA2(station.getStationCode());
         Integer n = station.getInverterQuantity();
 
         List<double[]> actual = rawDataElectricityLocalPoints(power, DataElectricityLocal::getActualPower);
@@ -151,8 +151,8 @@ public class TheoreticalPowerServiceImpl implements ITheoreticalPowerService
             return Collections.emptyList();
         }
         List<DataWeatherLocal> weather = loadSingleDayWeather(station, day);
-        double a1 = getPhotometricA1();
-        double a2 = getPhotometricA2();
+        double a1 = getPhotometricA1(station.getStationCode());
+        double a2 = getPhotometricA2(station.getStationCode());
         Integer n = station.getInverterQuantity();
 
         long dayEnd = dayStartEpoch(day) + 86400L;
@@ -220,8 +220,8 @@ public class TheoreticalPowerServiceImpl implements ITheoreticalPowerService
         String day = DateUtils.parseDateToStr("yyyy-MM-dd", last.getTm());
         List<DataWeatherLocal> weather = loadSingleDayWeather(station, day);
 
-        double a1 = getPhotometricA1();
-        double a2 = getPhotometricA2();
+        double a1 = getPhotometricA1(station.getStationCode());
+        double a2 = getPhotometricA2(station.getStationCode());
         Integer n = station.getInverterQuantity();
         double actualPower = last.getActualPower() == null ? 0 : last.getActualPower();
         double availability = last.getAvailability() == null || last.getAvailability() == 0 ? 100
@@ -257,8 +257,8 @@ public class TheoreticalPowerServiceImpl implements ITheoreticalPowerService
             return Collections.emptyList();
         }
         List<DataWeatherLocal> weather = loadSingleDayWeather(station, day);
-        double a1 = getPhotometricA1();
-        double a2 = getPhotometricA2();
+        double a1 = getPhotometricA1(station.getStationCode());
+        double a2 = getPhotometricA2(station.getStationCode());
         Integer n = station.getInverterQuantity();
 
         long dayEnd = dayStartEpoch(day) + 86400L;
@@ -315,8 +315,8 @@ public class TheoreticalPowerServiceImpl implements ITheoreticalPowerService
         String day = requireDay(query.getDay());
         List<DataElectricityLocal> power = loadSingleDayPower(station, day);
         List<DataWeatherLocal> weather = loadSingleDayWeather(station, day);
-        double a1 = getPhotometricA1();
-        double a2 = getPhotometricA2();
+        double a1 = getPhotometricA1(station.getStationCode());
+        double a2 = getPhotometricA2(station.getStationCode());
         Integer n = station.getInverterQuantity();
         JSONObject config = loadPowerConfig();
         double installed = station.getInstalledCapacity() == null ? 0D : station.getInstalledCapacity().doubleValue();
@@ -369,8 +369,8 @@ public class TheoreticalPowerServiceImpl implements ITheoreticalPowerService
         String day = requireDay(query.getDay());
         List<DataElectricityLocal> power = loadSingleDayPower(station, day);
         List<DataWeatherLocal> weather = loadSingleDayWeather(station, day);
-        double a1 = getPhotometricA1();
-        double a2 = getPhotometricA2();
+        double a1 = getPhotometricA1(station.getStationCode());
+        double a2 = getPhotometricA2(station.getStationCode());
         Integer n = station.getInverterQuantity();
         JSONObject config = loadPowerConfig();
 
@@ -418,8 +418,8 @@ public class TheoreticalPowerServiceImpl implements ITheoreticalPowerService
         String day = requireDay(query.getDay());
         List<DataElectricityLocal> power = loadSingleDayPower(station, day);
         List<DataWeatherLocal> weather = loadSingleDayWeather(station, day);
-        double a1 = getPhotometricA1();
-        double a2 = getPhotometricA2();
+        double a1 = getPhotometricA1(station.getStationCode());
+        double a2 = getPhotometricA2(station.getStationCode());
         Integer n = station.getInverterQuantity();
         JSONObject config = loadPowerConfig();
 
@@ -624,29 +624,39 @@ public class TheoreticalPowerServiceImpl implements ITheoreticalPowerService
     /**
      * 读取测光法系数 a1(字典 algorithm_config/测光法配置,缺失按 0)
      */
-    private double getPhotometricA1()
+    private double getPhotometricA1(String stationCode)
     {
         String json = DictUtils.getDictValue(DICT_ALGORITHM_CONFIG, DICT_LABEL_PHOTOMETRIC);
         if (StringUtils.isEmpty(json))
         {
-            return 0;
+            throw new ServiceException("测光法配置项algorithm_config不存在");
         }
         JSONObject obj = JSON.parseObject(json);
-        return obj.getDoubleValue("a1");
+        JSONObject stationObj = obj.getJSONObject(stationCode);
+        if (stationObj == null)
+        {
+            throw new ServiceException("测光法配置项a1不存在场站:" + stationCode);
+        }
+        return stationObj.getDoubleValue("a1");
     }
 
     /**
      * 读取测光法系数 a2(字典 algorithm_config/测光法配置,缺失按 0)
      */
-    private double getPhotometricA2()
+    private double getPhotometricA2(String stationCode)
     {
         String json = DictUtils.getDictValue(DICT_ALGORITHM_CONFIG, DICT_LABEL_PHOTOMETRIC);
         if (StringUtils.isEmpty(json))
         {
-            return 0;
+            throw new ServiceException("测光法配置项algorithm_config不存在");
         }
         JSONObject obj = JSON.parseObject(json);
-        return obj.getDoubleValue("a2");
+        JSONObject stationObj = obj.getJSONObject(stationCode);
+        if (stationObj == null)
+        {
+            throw new ServiceException("测光法配置项a2不存在场站:" + stationCode);
+        }
+        return stationObj.getDoubleValue("a2");
     }
 
     /**
@@ -936,8 +946,8 @@ public class TheoreticalPowerServiceImpl implements ITheoreticalPowerService
         String endIsoExcl = days.get(days.size() - 1).plusDays(1).toString() + "T00:00:00+08:00";
         List<DataElectricityLocal> power = loadElectricityPaged(station.getId(), startIso, endIsoExcl);
         List<DataWeatherLocal> weather = loadWeatherPaged(station.getId(), startIso, endIsoExcl);
-        double a1 = getPhotometricA1();
-        double a2 = getPhotometricA2();
+        double a1 = getPhotometricA1(station.getStationCode());
+        double a2 = getPhotometricA2(station.getStationCode());
         Integer n = station.getInverterQuantity();
 
         int dayCount = days.size();