Prechádzať zdrojové kódy

feat: 增加光伏电场累计日报、月报、年报接口

- 新增 PvPlantCumulativeReport 查询及导出接口
- 支持日报(daily)/月报(monthly)/年报(yearly)三种粒度
- 计算辐照度、发电量、有效利用小时数、日照小时数等指标
- 新增气象字段查询方法 selectWeatherFieldsByTimeRange
- 新增 data_local_frequency 数据采集频率字典配置
taosj 2 mesiacov pred
rodič
commit
de3ad7655d

+ 31 - 0
forecast-backend-server/src/main/java/com/ufo/project/data/controller/DataController.java

@@ -23,10 +23,13 @@ import com.ufo.base.framework.web.page.TableDataInfo;
 import com.ufo.base.common.utils.poi.ExcelUtil;
 import com.ufo.project.data.domain.IrradiancePowerComparisonQuery;
 import com.ufo.project.data.domain.vo.IrradiancePowerComparisonVO;
+import com.ufo.project.data.domain.vo.PvPlantCumulativeReportQuery;
+import com.ufo.project.data.domain.vo.PvPlantCumulativeReportVO;
 import com.ufo.project.data.domain.vo.ShortTermPowerForecastReportQuery;
 import com.ufo.project.data.domain.vo.ShortTermPowerForecastReportVO;
 import com.ufo.project.data.domain.vo.UltraShortTermPowerForecastReportQuery;
 import com.ufo.project.data.domain.vo.UltraShortTermPowerForecastReportVO;
+import com.ufo.project.data.service.IPvPlantCumulativeReportService;
 import com.ufo.project.data.service.IShortTermPowerForecastReportService;
 import com.ufo.project.data.service.IUltraShortTermPowerForecastReportService;
 import com.ufo.project.forecast.shortterm.power.domain.DataShortTermPowerForecastIssued;
@@ -68,6 +71,9 @@ public class DataController extends BaseController
     @Autowired
     private IUltraShortTermPowerForecastReportService ultraShortTermPowerForecastReportService;
 
+    @Autowired
+    private IPvPlantCumulativeReportService pvPlantCumulativeReportService;
+
     /**
      * 辐照度功率对比
      */
@@ -144,6 +150,31 @@ public class DataController extends BaseController
         util.exportExcel(response, list, "超短期预测报表");
     }
 
+    /**
+     * 光伏电场累计报表(日报、月报、年报)
+     */
+    @PreAuthorize("@ss.hasPermi('data:pvPlantCumulativeReport:list')")
+    @PostMapping("/pvPlantCumulativeReport")
+    public TableDataInfo pvPlantCumulativeReport(@RequestBody PvPlantCumulativeReportQuery query)
+    {
+        List<PvPlantCumulativeReportVO> list = pvPlantCumulativeReportService.selectReportList(query);
+        return getDataTable(list);
+    }
+
+    /**
+     * 光伏电场累计报表导出
+     */
+    @PreAuthorize("@ss.hasPermi('data:pvPlantCumulativeReport:export')")
+    @Log(title = "光伏电场累计报表", businessType = BusinessType.EXPORT)
+    @PostMapping("/pvPlantCumulativeReport/export")
+    public void pvPlantCumulativeReportExport(HttpServletResponse response,
+            @RequestBody PvPlantCumulativeReportQuery query)
+    {
+        List<PvPlantCumulativeReportVO> list = pvPlantCumulativeReportService.selectReportList(query);
+        ExcelUtil<PvPlantCumulativeReportVO> util = new ExcelUtil<>(PvPlantCumulativeReportVO.class);
+        util.exportExcel(response, list, "光伏电场累计报表");
+    }
+
     /**
      * 构建对比数据列表
      */

+ 68 - 0
forecast-backend-server/src/main/java/com/ufo/project/data/domain/vo/PvPlantCumulativeReportQuery.java

@@ -0,0 +1,68 @@
+package com.ufo.project.data.domain.vo;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * 光伏电场累计报表查询参数
+ *
+ * @author ufo
+ * @date 2026-09-08
+ */
+public class PvPlantCumulativeReportQuery
+{
+    /** 报表类型:daily-日报, monthly-月报, yearly-年报 */
+    @NotBlank(message = "报表类型不能为空")
+    private String type;
+
+    /** 站点/场站 id */
+    @NotBlank(message = "站点id不能为空")
+    private String entityId;
+
+    /** 开始时间 yyyy-MM-dd */
+    @NotBlank(message = "开始时间不能为空")
+    private String startTime;
+
+    /** 结束时间 yyyy-MM-dd */
+    @NotBlank(message = "结束时间不能为空")
+    private String endTime;
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType(String type)
+    {
+        this.type = type;
+    }
+
+    public String getEntityId()
+    {
+        return entityId;
+    }
+
+    public void setEntityId(String entityId)
+    {
+        this.entityId = entityId;
+    }
+
+    public String getStartTime()
+    {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime)
+    {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime()
+    {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime)
+    {
+        this.endTime = endTime;
+    }
+}

+ 198 - 0
forecast-backend-server/src/main/java/com/ufo/project/data/domain/vo/PvPlantCumulativeReportVO.java

@@ -0,0 +1,198 @@
+package com.ufo.project.data.domain.vo;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import com.ufo.base.framework.aspectj.lang.annotation.Excel;
+
+/**
+ * 光伏电场累计报表视图对象
+ *
+ * @author ufo
+ * @date 2026-09-08
+ */
+public class PvPlantCumulativeReportVO implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 时间(日报: yyyy-MM-dd, 月报: yyyy-MM, 年报: yyyy) */
+    @Excel(name = "时间")
+    private String time;
+
+    /** 平均辐照度 W/m² */
+    @Excel(name = "平均辐照度(W/m²)")
+    private BigDecimal avgIrradiance;
+
+    /** 最大辐照度 W/m² */
+    @Excel(name = "最大辐照度(W/m²)")
+    private BigDecimal maxIrradiance;
+
+    /** 累计辐照量 MJ/㎡ */
+    @Excel(name = "累计辐照量(MJ/㎡)")
+    private BigDecimal totalIrradiation;
+
+    /** 并网功率最大对应时间 */
+    @Excel(name = "并网功率最大对应时间")
+    private String gridMaxPowerTime;
+
+    /** 并网功率最大值 MW */
+    @Excel(name = "并网功率最大值(MW)")
+    private BigDecimal gridMaxPowder;
+
+    /** 实际发电量 万千瓦时 */
+    @Excel(name = "实际发电量(万千瓦时)")
+    private BigDecimal actualPower;
+
+    /** 理论发电量 万千瓦时 */
+    @Excel(name = "理论发电量(万千瓦时)")
+    private BigDecimal theoreticalPower;
+
+    /** 有效利用小时数 */
+    @Excel(name = "有效利用小时数")
+    private BigDecimal validHours;
+
+    /** 累计日照小时数 */
+    @Excel(name = "累计日照小时数")
+    private BigDecimal totalHours;
+
+    /** 平均风速 m/s */
+    @Excel(name = "平均风速(m/s)")
+    private BigDecimal avgWindSpeed;
+
+    /** 平均温度 ℃ */
+    @Excel(name = "平均温度(℃)")
+    private BigDecimal avgTemperature;
+
+    /** 组件平均温度 ℃ */
+    @Excel(name = "组件平均温度(℃)")
+    private BigDecimal avgBoardTemperature;
+
+    public String getTime()
+    {
+        return time;
+    }
+
+    public void setTime(String time)
+    {
+        this.time = time;
+    }
+
+    public BigDecimal getAvgIrradiance()
+    {
+        return avgIrradiance;
+    }
+
+    public void setAvgIrradiance(BigDecimal avgIrradiance)
+    {
+        this.avgIrradiance = avgIrradiance;
+    }
+
+    public BigDecimal getMaxIrradiance()
+    {
+        return maxIrradiance;
+    }
+
+    public void setMaxIrradiance(BigDecimal maxIrradiance)
+    {
+        this.maxIrradiance = maxIrradiance;
+    }
+
+    public BigDecimal getTotalIrradiation()
+    {
+        return totalIrradiation;
+    }
+
+    public void setTotalIrradiation(BigDecimal totalIrradiation)
+    {
+        this.totalIrradiation = totalIrradiation;
+    }
+
+    public String getGridMaxPowerTime()
+    {
+        return gridMaxPowerTime;
+    }
+
+    public void setGridMaxPowerTime(String gridMaxPowerTime)
+    {
+        this.gridMaxPowerTime = gridMaxPowerTime;
+    }
+
+    public BigDecimal getGridMaxPowder()
+    {
+        return gridMaxPowder;
+    }
+
+    public void setGridMaxPowder(BigDecimal gridMaxPowder)
+    {
+        this.gridMaxPowder = gridMaxPowder;
+    }
+
+    public BigDecimal getActualPower()
+    {
+        return actualPower;
+    }
+
+    public void setActualPower(BigDecimal actualPower)
+    {
+        this.actualPower = actualPower;
+    }
+
+    public BigDecimal getTheoreticalPower()
+    {
+        return theoreticalPower;
+    }
+
+    public void setTheoreticalPower(BigDecimal theoreticalPower)
+    {
+        this.theoreticalPower = theoreticalPower;
+    }
+
+    public BigDecimal getValidHours()
+    {
+        return validHours;
+    }
+
+    public void setValidHours(BigDecimal validHours)
+    {
+        this.validHours = validHours;
+    }
+
+    public BigDecimal getTotalHours()
+    {
+        return totalHours;
+    }
+
+    public void setTotalHours(BigDecimal totalHours)
+    {
+        this.totalHours = totalHours;
+    }
+
+    public BigDecimal getAvgWindSpeed()
+    {
+        return avgWindSpeed;
+    }
+
+    public void setAvgWindSpeed(BigDecimal avgWindSpeed)
+    {
+        this.avgWindSpeed = avgWindSpeed;
+    }
+
+    public BigDecimal getAvgTemperature()
+    {
+        return avgTemperature;
+    }
+
+    public void setAvgTemperature(BigDecimal avgTemperature)
+    {
+        this.avgTemperature = avgTemperature;
+    }
+
+    public BigDecimal getAvgBoardTemperature()
+    {
+        return avgBoardTemperature;
+    }
+
+    public void setAvgBoardTemperature(BigDecimal avgBoardTemperature)
+    {
+        this.avgBoardTemperature = avgBoardTemperature;
+    }
+}

+ 22 - 0
forecast-backend-server/src/main/java/com/ufo/project/data/service/IPvPlantCumulativeReportService.java

@@ -0,0 +1,22 @@
+package com.ufo.project.data.service;
+
+import java.util.List;
+import com.ufo.project.data.domain.vo.PvPlantCumulativeReportQuery;
+import com.ufo.project.data.domain.vo.PvPlantCumulativeReportVO;
+
+/**
+ * 光伏电场累计报表Service接口
+ *
+ * @author ufo
+ * @date 2026-09-08
+ */
+public interface IPvPlantCumulativeReportService
+{
+    /**
+     * 查询光伏电场累计报表数据
+     *
+     * @param query 查询参数
+     * @return 报表数据列表
+     */
+    List<PvPlantCumulativeReportVO> selectReportList(PvPlantCumulativeReportQuery query);
+}

+ 508 - 0
forecast-backend-server/src/main/java/com/ufo/project/data/service/impl/PvPlantCumulativeReportServiceImpl.java

@@ -0,0 +1,508 @@
+package com.ufo.project.data.service.impl;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+
+import com.ufo.module.system.domain.SysDictData;
+import com.ufo.module.system.service.ISysDictTypeService;
+import com.ufo.project.config.domain.ConfigStation;
+import com.ufo.project.config.service.IConfigStationService;
+import com.ufo.project.data.domain.vo.PvPlantCumulativeReportQuery;
+import com.ufo.project.data.domain.vo.PvPlantCumulativeReportVO;
+import com.ufo.project.data.service.IPvPlantCumulativeReportService;
+import com.ufo.project.model.domain.DataElectricityLocal;
+import com.ufo.project.model.service.IDataElectricityLocalService;
+import com.ufo.project.weather.domain.DataWeatherLocal;
+import com.ufo.project.weather.service.IDataWeatherLocalService;
+
+/**
+ * 光伏电场累计报表Service业务层处理
+ *
+ * @author ufo
+ * @date 2026-09-08
+ */
+@Service
+public class PvPlantCumulativeReportServiceImpl implements IPvPlantCumulativeReportService
+{
+    /** 数据采集频率字典类型 */
+    private static final String DICT_TYPE_DATA_LOCAL_FREQUENCY = "data_local_frequency";
+
+    /** 北京时间偏移 */
+    private static final ZoneOffset ZONE_OFFSET = ZoneOffset.ofHours(8);
+
+    /** 组件有效辐照时段(北京时间) */
+    private static final int BOARD_TEMP_START_HOUR = 7;
+    private static final int BOARD_TEMP_START_MINUTE = 30;
+    private static final int BOARD_TEMP_END_HOUR = 18;
+    private static final int BOARD_TEMP_END_MINUTE = 30;
+
+    /** 辐照度阈值(W/m²),用于累计日照小时数计算 */
+    private static final double IRRADIANCE_THRESHOLD = 120.0;
+
+    @Resource
+    private IDataWeatherLocalService weatherLocalService;
+
+    @Resource
+    private IDataElectricityLocalService electricityLocalService;
+
+    @Resource
+    private IConfigStationService configStationService;
+
+    @Resource
+    private ISysDictTypeService dictTypeService;
+
+    /**
+     * 查询光伏电场累计报表数据
+     */
+    @Override
+    public List<PvPlantCumulativeReportVO> selectReportList(PvPlantCumulativeReportQuery query)
+    {
+        // 1. 获取站点配置
+        Long stationId = parseLong(query.getEntityId());
+        ConfigStation station = configStationService.selectConfigStationById(stationId);
+        if (station == null || station.getInstalledCapacity() == null || station.getInstalledCapacity() == 0)
+        {
+            return new ArrayList<>();
+        }
+        BigDecimal installedCapacity = new BigDecimal(station.getInstalledCapacity());
+
+        // 2. 获取数据采集频率(单位:秒)
+        Long frequency = getCollectionFrequency();
+
+        // 3. 构建时间参数(ISO 8601 格式)
+        String startStr = formatOffsetDateTime(query.getStartTime());
+        String endStr = formatOffsetDateTime(query.getEndTime());
+
+        // 4. 获取气象数据和电力数据
+        List<DataWeatherLocal> weatherList = weatherLocalService.selectWeatherFieldsByTimeRange(
+                stationId, startStr, endStr);
+        List<DataElectricityLocal> electricityList = electricityLocalService.selectActualPowerList(
+                stationId, startStr, endStr);
+
+        // 5. 按时间戳合并
+        Map<Long, PointData> mergeMap = mergeData(weatherList, electricityList);
+
+        // 6. 按时间分组
+        Map<String, List<PointData>> groupedMap = groupByTime(mergeMap.values(), query.getType());
+
+        // 7. 逐组计算
+        List<PvPlantCumulativeReportVO> result = new ArrayList<>();
+        for (Map.Entry<String, List<PointData>> entry : groupedMap.entrySet())
+        {
+            String timeKey = entry.getKey();
+            List<PointData> points = entry.getValue();
+            PvPlantCumulativeReportVO vo = computeGroup(timeKey, points, query.getType(), frequency, installedCapacity);
+            result.add(vo);
+        }
+
+        return result;
+    }
+
+    /**
+     * 获取数据采集频率(秒)
+     */
+    private Long getCollectionFrequency()
+    {
+        List<SysDictData> dictList = dictTypeService.selectDictDataByType(DICT_TYPE_DATA_LOCAL_FREQUENCY);
+        if (dictList != null && !dictList.isEmpty())
+        {
+            try
+            {
+                return Long.parseLong(dictList.get(0).getDictValue());
+            }
+            catch (NumberFormatException e)
+            {
+                return 900L; // 默认15分钟
+            }
+        }
+        return 900L; // 默认15分钟
+    }
+
+    /**
+     * 将 yyyy-MM-dd 转换为 ISO 8601 格式(北京时间)
+     */
+    private String formatOffsetDateTime(String dateStr)
+    {
+        try
+        {
+            // 解析为北京时间的当天 00:00:00
+            DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            LocalDateTime ldt = LocalDateTime.parse(dateStr, fmt);
+            LocalDateTime beijing = ldt.atZone(ZoneId.of("Asia/Shanghai")).withZoneSameInstant(ZONE_OFFSET).toLocalDateTime();
+            return beijing.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
+        }
+        catch (Exception e)
+        {
+            return dateStr;
+        }
+    }
+
+    /**
+     * 合并气象数据和电力数据,按时间戳去重
+     */
+    private Map<Long, PointData> mergeData(List<DataWeatherLocal> weatherList, List<DataElectricityLocal> electricityList)
+    {
+        Map<Long, PointData> map = new LinkedHashMap<>();
+
+        for (DataWeatherLocal w : weatherList)
+        {
+            if (w.getTm() == null) continue;
+            Long ts = w.getTm().getTime();
+            map.computeIfAbsent(ts, k -> new PointData()).setWeather(w);
+        }
+
+        for (DataElectricityLocal e : electricityList)
+        {
+            if (e.getTm() == null) continue;
+            Long ts = e.getTm().getTime();
+            PointData pd = map.computeIfAbsent(ts, k -> new PointData());
+            pd.setElectricity(e);
+        }
+
+        return map;
+    }
+
+    /**
+     * 按时间类型分组
+     */
+    private Map<String, List<PointData>> groupByTime(Iterable<PointData> points, String type)
+    {
+        Map<String, List<PointData>> map = new LinkedHashMap<>();
+        for (PointData pd : points)
+        {
+            if (pd.getTm() == null) continue;
+            String key = toTimeKey(pd.getTm(), type);
+            map.computeIfAbsent(key, k -> new ArrayList<>()).add(pd);
+        }
+        return map;
+    }
+
+    /**
+     * 将时间戳转换为时间分组键
+     */
+    private String toTimeKey(java.util.Date tm, String type)
+    {
+        long ts = tm.getTime();
+        LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(ts), ZONE_OFFSET);
+
+        switch (type)
+        {
+            case "daily":
+                return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            case "monthly":
+                return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM"));
+            case "yearly":
+                return ldt.format(DateTimeFormatter.ofPattern("yyyy"));
+            default:
+                return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        }
+    }
+
+    /**
+     * 计算一组数据的报表行
+     */
+    private PvPlantCumulativeReportVO computeGroup(String timeKey, List<PointData> points, String type,
+            Long frequency, BigDecimal installedCapacity)
+    {
+        PvPlantCumulativeReportVO vo = new PvPlantCumulativeReportVO();
+        vo.setTime(timeKey);
+
+        // 过滤空数据点
+        List<PointData> validPoints = new ArrayList<>();
+        for (PointData pd : points)
+        {
+            if (pd.getTm() != null)
+            {
+                validPoints.add(pd);
+            }
+        }
+        if (validPoints.isEmpty()) return vo;
+
+        // --- 气象字段聚合 ---
+        double sumIrradiance = 0.0;
+        double maxIrradiance = 0.0;
+        double sumWindSpeed = 0.0;
+        double sumTemperature = 0.0;
+        double sumBoardTemperature = 0.0;
+        int weatherCount = 0;
+        int boardTempCount = 0;
+        double totalIrradiation = 0.0;
+
+        for (PointData pd : validPoints)
+        {
+            if (pd.weather != null)
+            {
+                Double irradiance = pd.weather.getIrradiance();
+                if (irradiance != null)
+                {
+                    sumIrradiance += irradiance;
+                    maxIrradiance = Math.max(maxIrradiance, irradiance);
+                }
+                Double windSpeed = pd.weather.getWindSpeed();
+                if (windSpeed != null) sumWindSpeed += windSpeed;
+                Double temperature = pd.weather.getTemperature();
+                if (temperature != null) sumTemperature += temperature;
+                Double boardTemperature = pd.weather.getBoardTemperature();
+                if (boardTemperature != null && isWithinBoardTempWindow(pd.getTm()))
+                {
+                    sumBoardTemperature += boardTemperature;
+                    boardTempCount++;
+                }
+                weatherCount++;
+            }
+        }
+
+        // avgIrradiance
+        if (weatherCount > 0)
+        {
+            vo.setAvgIrradiance(round2(new BigDecimal(sumIrradiance).divide(new BigDecimal(weatherCount), 4, RoundingMode.HALF_UP)));
+        }
+
+        // maxIrradiance
+        if (maxIrradiance > 0)
+        {
+            vo.setMaxIrradiance(round2(BigDecimal.valueOf(maxIrradiance)));
+        }
+
+        // totalIrradiation = SUM(irradiance) * frequency / 1000000 (MJ/m²)
+        if (sumIrradiance > 0)
+        {
+            totalIrradiation = sumIrradiance * frequency.doubleValue() / 1000000.0;
+            vo.setTotalIrradiation(round2(BigDecimal.valueOf(totalIrradiation)));
+        }
+
+        // avgWindSpeed
+        if (weatherCount > 0)
+        {
+            vo.setAvgWindSpeed(round2(new BigDecimal(sumWindSpeed).divide(new BigDecimal(weatherCount), 4, RoundingMode.HALF_UP)));
+        }
+
+        // avgTemperature
+        if (weatherCount > 0)
+        {
+            vo.setAvgTemperature(round2(new BigDecimal(sumTemperature).divide(new BigDecimal(weatherCount), 4, RoundingMode.HALF_UP)));
+        }
+
+        // avgBoardTemperature
+        if (boardTempCount > 0)
+        {
+            vo.setAvgBoardTemperature(round2(new BigDecimal(sumBoardTemperature).divide(new BigDecimal(boardTempCount), 4, RoundingMode.HALF_UP)));
+        }
+
+        // --- 电力字段聚合 ---
+        double sumActualPower = 0.0;
+        double sumTheoreticalPower = 0.0;
+        double maxActualPower = 0.0;
+        Long maxPowerTimestamp = null;
+        int electricityCount = 0;
+
+        for (PointData pd : validPoints)
+        {
+            if (pd.electricity != null && pd.electricity.getGridStatus() != null && pd.electricity.getGridStatus() == 1)
+            {
+                Double actualPower = pd.electricity.getActualPower();
+                if (actualPower != null)
+                {
+                    sumActualPower += actualPower;
+                    if (actualPower > maxActualPower)
+                    {
+                        maxActualPower = actualPower;
+                        maxPowerTimestamp = pd.getTm().getTime();
+                    }
+                }
+                Double theoreticalPower = pd.electricity.getTheoreticalPower();
+                if (theoreticalPower != null)
+                {
+                    sumTheoreticalPower += theoreticalPower;
+                }
+                electricityCount++;
+            }
+            else if (pd.electricity != null)
+            {
+                Double actualPower = pd.electricity.getActualPower();
+                if (actualPower != null)
+                {
+                    sumActualPower += actualPower;
+                }
+                Double theoreticalPower = pd.electricity.getTheoreticalPower();
+                if (theoreticalPower != null)
+                {
+                    sumTheoreticalPower += theoreticalPower;
+                }
+                electricityCount++;
+            }
+        }
+
+        // gridMaxPowerTime
+        if (maxPowerTimestamp != null)
+        {
+            vo.setGridMaxPowerTime(formatTimeByType(maxPowerTimestamp, type));
+        }
+
+        // gridMaxPowder = MAX(actual_power) / 1000 (MW)
+        if (maxActualPower > 0)
+        {
+            vo.setGridMaxPowder(round2(BigDecimal.valueOf(maxActualPower).divide(BigDecimal.valueOf(1000), 4, RoundingMode.HALF_UP)));
+        }
+
+        // actualPower = SUM(actual_power) * frequency / 3600 / 10000 (万千瓦时)
+        if (sumActualPower > 0)
+        {
+            BigDecimal energy = BigDecimal.valueOf(sumActualPower)
+                    .multiply(BigDecimal.valueOf(frequency))
+                    .divide(BigDecimal.valueOf(3600))
+                    .divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_UP);
+            vo.setActualPower(energy);
+        }
+
+        // theoreticalPower = SUM(theoretical_power) * frequency / 3600 / 10000 (万千瓦时)
+        if (sumTheoreticalPower > 0)
+        {
+            BigDecimal energy = BigDecimal.valueOf(sumTheoreticalPower)
+                    .multiply(BigDecimal.valueOf(frequency))
+                    .divide(BigDecimal.valueOf(3600))
+                    .divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_UP);
+            vo.setTheoreticalPower(energy);
+        }
+
+        // validHours = SUM(actual_power) * frequency / 3600 / installedCapacity (h)
+        if (sumActualPower > 0 && installedCapacity.compareTo(BigDecimal.ZERO) > 0)
+        {
+            BigDecimal hours = BigDecimal.valueOf(sumActualPower)
+                    .multiply(BigDecimal.valueOf(frequency))
+                    .divide(BigDecimal.valueOf(3600))
+                    .divide(installedCapacity, 4, RoundingMode.HALF_UP);
+            vo.setValidHours(hours);
+        }
+
+        // totalHours = 累计日照小时数(辐照度 > 120 W/m² 的小时数)
+        int totalHours = countValidHours(validPoints);
+        vo.setTotalHours(BigDecimal.valueOf(totalHours));
+
+        return vo;
+    }
+
+    /**
+     * 判断时间点是否处于组件有效辐照时段(北京时间 07:30 ~ 18:30)
+     */
+    private boolean isWithinBoardTempWindow(java.util.Date tm)
+    {
+        LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(tm.getTime()), ZONE_OFFSET);
+        return (ldt.getHour() > BOARD_TEMP_START_HOUR
+                || (ldt.getHour() == BOARD_TEMP_START_HOUR && ldt.getMinute() >= BOARD_TEMP_START_MINUTE))
+                && (ldt.getHour() < BOARD_TEMP_END_HOUR
+                || (ldt.getHour() == BOARD_TEMP_END_HOUR && ldt.getMinute() <= BOARD_TEMP_END_MINUTE));
+    }
+
+    /**
+     * 按小时聚合辐照度,统计 avg(irradiance) > 120 W/m² 的小时数
+     */
+    private int countValidHours(List<PointData> points)
+    {
+        // 按小时分组:key = 小时时间戳(去掉分钟和秒)
+        Map<Long, List<Double>> hourlyIrradiance = new LinkedHashMap<>();
+        for (PointData pd : points)
+        {
+            if (pd.weather == null || pd.weather.getIrradiance() == null) continue;
+            long ts = pd.getTm().getTime();
+            LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(ts), ZONE_OFFSET);
+            LocalDateTime hourStart = ldt.withMinute(0).withSecond(0).withNano(0);
+            long hourTs = hourStart.atZone(ZONE_OFFSET).toInstant().toEpochMilli();
+            hourlyIrradiance.computeIfAbsent(hourTs, k -> new ArrayList<>()).add(pd.weather.getIrradiance());
+        }
+
+        int count = 0;
+        for (List<Double> values : hourlyIrradiance.values())
+        {
+            if (values.isEmpty()) continue;
+            double sum = 0.0;
+            for (Double v : values) sum += v;
+            double avg = sum / values.size();
+            if (avg > IRRADIANCE_THRESHOLD) count++;
+        }
+        return count;
+    }
+
+    /**
+     * 将时间戳格式化为时间字符串,按报表类型
+     */
+    private String formatTimeByType(long timestamp, String type)
+    {
+        LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZONE_OFFSET);
+        switch (type)
+        {
+            case "daily":
+                return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            case "monthly":
+                return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            case "yearly":
+                return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            default:
+                return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        }
+    }
+
+    /**
+     * 保留两位小数(四舍五入)
+     */
+    private BigDecimal round2(BigDecimal value)
+    {
+        if (value == null) return null;
+        return value.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    /**
+     * 安全解析String为Long
+     */
+    private Long parseLong(String value)
+    {
+        if (value == null || value.isEmpty()) return null;
+        try
+        {
+            return Long.parseLong(value.trim());
+        }
+        catch (NumberFormatException e)
+        {
+            return null;
+        }
+    }
+
+    /**
+     * 合并数据点
+     */
+    private static class PointData
+    {
+        DataWeatherLocal weather;
+        DataElectricityLocal electricity;
+
+        java.util.Date getTm()
+        {
+            if (weather != null && weather.getTm() != null) return weather.getTm();
+            if (electricity != null && electricity.getTm() != null) return electricity.getTm();
+            return null;
+        }
+
+        void setWeather(DataWeatherLocal weather)
+        {
+            this.weather = weather;
+        }
+
+        void setElectricity(DataElectricityLocal electricity)
+        {
+            this.electricity = electricity;
+        }
+    }
+}

+ 12 - 1
forecast-backend-server/src/main/java/com/ufo/project/weather/mapper/DataWeatherLocalMapper.java

@@ -70,9 +70,20 @@ public interface DataWeatherLocalMapper
 
     /**
      * 批量删除本地气象采样数据
-     * 
+     *
      * @param tms 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteDataWeatherLocalByTms(Date[] tms);
+
+    /**
+     * 按时间范围查询天气字段(ISO 8601 格式字符串参数)
+     *
+     * @param configStationId 场站ID
+     * @param startTime 起始时间(ISO 8601 字符串)
+     * @param endTime 结束时间(ISO 8601 字符串)
+     * @return 本地气象采样数据集合
+     */
+    public List<DataWeatherLocal> selectWeatherFieldsByTimeRange(@Param("configStationId") Long configStationId,
+            @Param("startTime") String startTime, @Param("endTime") String endTime);
 }

+ 11 - 1
forecast-backend-server/src/main/java/com/ufo/project/weather/service/IDataWeatherLocalService.java

@@ -94,9 +94,19 @@ public interface IDataWeatherLocalService
      */
     public List<DataWeatherLocal> selectIrradianceByTimeRange(Long stationId, Long startTime, Long endTime);
 
+    /**
+     * 按时间范围查询天气字段(ISO 8601 格式字符串参数)
+     *
+     * @param configStationId 场站ID
+     * @param startTime 起始时间(ISO 8601 字符串)
+     * @param endTime 结束时间(ISO 8601 字符串)
+     * @return 气象采样数据集合
+     */
+    public List<DataWeatherLocal> selectWeatherFieldsByTimeRange(Long configStationId, String startTime, String endTime);
+
     /**
      * 新增本地气象采样数据
-     * 
+     *
      * @param dataWeatherLocal 本地气象采样数据
      * @return 结果
      */

+ 15 - 1
forecast-backend-server/src/main/java/com/ufo/project/weather/service/impl/DataWeatherLocalServiceImpl.java

@@ -261,9 +261,23 @@ public class DataWeatherLocalServiceImpl implements IDataWeatherLocalService
         return BigDecimal.valueOf(value).setScale(2, RoundingMode.HALF_UP).doubleValue();
     }
 
+    /**
+     * 按时间范围查询天气字段(ISO 8601 格式字符串参数)
+     *
+     * @param configStationId 场站ID
+     * @param startTime 起始时间(ISO 8601 字符串)
+     * @param endTime 结束时间(ISO 8601 字符串)
+     * @return 气象采样数据集合
+     */
+    @Override
+    public List<DataWeatherLocal> selectWeatherFieldsByTimeRange(Long configStationId, String startTime, String endTime)
+    {
+        return dataWeatherLocalMapper.selectWeatherFieldsByTimeRange(configStationId, startTime, endTime);
+    }
+
     /**
      * 新增本地气象采样数据
-     * 
+     *
      * @param dataWeatherLocal 本地气象采样数据
      * @return 结果
      */

+ 20 - 1
forecast-backend-server/src/main/resources/mybatis/weather/DataWeatherLocalMapper.xml

@@ -14,10 +14,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="humidity"    column="humidity"    />
         <result property="windSpeed"    column="wind_speed"    />
         <result property="windDirection"    column="wind_direction"    />
+        <result property="boardTemperature"    column="board_temperature"    />
+        <result property="dailyIrradiance"    column="daily_irradiance"    />
     </resultMap>
 
     <sql id="selectDataWeatherLocalVo">
-        select tm, config_station_id, horizontal_irradiance, irradiance, temperature, pressure, humidity, wind_speed, wind_direction from data_weather_local
+        select tm, config_station_id, horizontal_irradiance, irradiance, temperature, pressure, humidity, wind_speed, wind_direction, board_temperature, daily_irradiance from data_weather_local
     </sql>
 
     <select id="selectDataWeatherLocalList" parameterType="DataWeatherLocal" resultMap="DataWeatherLocalResult">
@@ -32,6 +34,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="humidity != null "> and humidity = #{humidity}</if>
             <if test="windSpeed != null "> and wind_speed = #{windSpeed}</if>
             <if test="windDirection != null "> and wind_direction = #{windDirection}</if>
+            <if test="boardTemperature != null "> and board_temperature = #{boardTemperature}</if>
+            <if test="dailyIrradiance != null "> and daily_irradiance = #{dailyIrradiance}</if>
         </where>
     </select>
 
@@ -49,6 +53,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by tm asc
     </select>
 
+    <!-- 按时间范围查询天气字段(ISO 8601 格式字符串参数) -->
+    <select id="selectWeatherFieldsByTimeRange" resultMap="DataWeatherLocalResult">
+        select tm, config_station_id, irradiance, wind_speed, temperature, board_temperature
+        from data_weather_local
+        where config_station_id = #{configStationId}
+          and tm &gt;= #{startTime} and tm &lt;= #{endTime}
+        order by tm asc
+    </select>
+
     <select id="selectDataWeatherLocalByTm" parameterType="Date" resultMap="DataWeatherLocalResult">
         <include refid="selectDataWeatherLocalVo"/>
         where tm = #{tm}
@@ -66,6 +79,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="humidity != null">humidity,</if>
             <if test="windSpeed != null">wind_speed,</if>
             <if test="windDirection != null">wind_direction,</if>
+            <if test="boardTemperature != null">board_temperature,</if>
+            <if test="dailyIrradiance != null">daily_irradiance,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="tm != null">#{tm},</if>
@@ -77,6 +92,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="humidity != null">#{humidity},</if>
             <if test="windSpeed != null">#{windSpeed},</if>
             <if test="windDirection != null">#{windDirection},</if>
+            <if test="boardTemperature != null">#{boardTemperature},</if>
+            <if test="dailyIrradiance != null">#{dailyIrradiance},</if>
          </trim>
     </insert>
 
@@ -91,6 +108,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="humidity != null">humidity = #{humidity},</if>
             <if test="windSpeed != null">wind_speed = #{windSpeed},</if>
             <if test="windDirection != null">wind_direction = #{windDirection},</if>
+            <if test="boardTemperature != null">board_temperature = #{boardTemperature},</if>
+            <if test="dailyIrradiance != null">daily_irradiance = #{dailyIrradiance},</if>
         </trim>
         where tm = #{tm}
     </update>

+ 14 - 1
release_note/2026.09.03/20260903_dp.sql

@@ -130,4 +130,17 @@ COMMENT ON COLUMN "public"."data_ultra_short_term_power_forecasting"."power180"
 COMMENT ON COLUMN "public"."data_ultra_short_term_power_forecasting"."power195" IS 't+195min预测功率';
 COMMENT ON COLUMN "public"."data_ultra_short_term_power_forecasting"."power210" IS 't+210min预测功率';
 COMMENT ON COLUMN "public"."data_ultra_short_term_power_forecasting"."power225" IS 't+225min预测功率';
-COMMENT ON COLUMN "public"."data_ultra_short_term_power_forecasting"."power240" IS 't+240min预测功率';
+COMMENT ON COLUMN "public"."data_ultra_short_term_power_forecasting"."power240" IS 't+240min预测功率';
+
+-- 光伏电场累计报表数据采集频率配置(单位:秒)
+INSERT INTO "public"."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
+    NULL, COALESCE((SELECT MAX(dict_sort) + 1 FROM sys_dict_data WHERE dict_type = 'data_local_frequency'), 1),
+    '15分钟', '900', 'data_local_frequency', '', 'default', 'N', '0', 'admin', NOW(),
+    '数据采集频率(秒)'
+WHERE NOT EXISTS (
+    SELECT 1 FROM sys_dict_data WHERE dict_type = 'data_local_frequency' AND dict_value = '900'
+);