|
@@ -1,7 +1,10 @@
|
|
|
package com.ufo.project.forecast.shortterm.weather.controller;
|
|
package com.ufo.project.forecast.shortterm.weather.controller;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.TreeSet;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -24,6 +27,7 @@ import com.ufo.project.forecast.shortterm.weather.domain.vo.RhsfcChartResult;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.RhsfcChartStat;
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.RhsfcChartStat;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.RoseChartDirectionStat;
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.RoseChartDirectionStat;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.RoseChartResult;
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.RoseChartResult;
|
|
|
|
|
+import com.ufo.project.forecast.shortterm.weather.domain.vo.TirrChartExportStat;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.TirrChartResult;
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.TirrChartResult;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.TirrChartStat;
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.TirrChartStat;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.TsfcChartResult;
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.TsfcChartResult;
|
|
@@ -239,7 +243,7 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 统计辐照曲线数据(短期预报 + 本地实测)
|
|
|
|
|
|
|
+ * 统计辐照曲线数据(短期预报 + 本地实测,两侧 stats 对齐到同一时间点并集,缺数填0)
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('weather:weatherRaw:tirrchart')")
|
|
@PreAuthorize("@ss.hasPermi('weather:weatherRaw:tirrchart')")
|
|
|
@GetMapping("/tirrchart")
|
|
@GetMapping("/tirrchart")
|
|
@@ -248,11 +252,12 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
{
|
|
|
TirrChartResult forecast = dataShortTermWeatherForecastRawService.getTirrChart(stationId, startTime, endTime);
|
|
TirrChartResult forecast = dataShortTermWeatherForecastRawService.getTirrChart(stationId, startTime, endTime);
|
|
|
TirrChartResult local = dataWeatherLocalService.getTirrChart(stationId, startTime, endTime);
|
|
TirrChartResult local = dataWeatherLocalService.getTirrChart(stationId, startTime, endTime);
|
|
|
|
|
+ alignTirrStats(forecast, local);
|
|
|
return success(new ChartDataPair<TirrChartResult>(forecast, local));
|
|
return success(new ChartDataPair<TirrChartResult>(forecast, local));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 导出辐照曲线数据(短期预报 + 本地实测,合并导出)
|
|
|
|
|
|
|
+ * 导出辐照曲线数据(短期预报 + 本地实测,按时间点并集对齐导出 时间/预测辐照/观测辐照)
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('weather:weatherRaw:tirrchart')")
|
|
@PreAuthorize("@ss.hasPermi('weather:weatherRaw:tirrchart')")
|
|
|
@Log(title = "辐照曲线", businessType = BusinessType.EXPORT)
|
|
@Log(title = "辐照曲线", businessType = BusinessType.EXPORT)
|
|
@@ -262,17 +267,65 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
{
|
|
|
TirrChartResult forecast = dataShortTermWeatherForecastRawService.getTirrChart(stationId, startTime, endTime);
|
|
TirrChartResult forecast = dataShortTermWeatherForecastRawService.getTirrChart(stationId, startTime, endTime);
|
|
|
TirrChartResult local = dataWeatherLocalService.getTirrChart(stationId, startTime, endTime);
|
|
TirrChartResult local = dataWeatherLocalService.getTirrChart(stationId, startTime, endTime);
|
|
|
- List<TirrChartStat> stats = new ArrayList<TirrChartStat>();
|
|
|
|
|
- if (forecast.getStats() != null)
|
|
|
|
|
|
|
+ alignTirrStats(forecast, local);
|
|
|
|
|
+ List<TirrChartStat> forecastStats = forecast.getStats();
|
|
|
|
|
+ List<TirrChartStat> localStats = local.getStats();
|
|
|
|
|
+ List<TirrChartExportStat> stats = new ArrayList<TirrChartExportStat>();
|
|
|
|
|
+ for (int i = 0; i < forecastStats.size(); i++)
|
|
|
{
|
|
{
|
|
|
- stats.addAll(forecast.getStats());
|
|
|
|
|
|
|
+ stats.add(new TirrChartExportStat(forecastStats.get(i).getTime(),
|
|
|
|
|
+ forecastStats.get(i).getTirr(), localStats.get(i).getTirr()));
|
|
|
}
|
|
}
|
|
|
- if (local.getStats() != null)
|
|
|
|
|
|
|
+ ExcelUtil<TirrChartExportStat> util = new ExcelUtil<TirrChartExportStat>(TirrChartExportStat.class);
|
|
|
|
|
+ util.exportExcel(response, stats, "辐照曲线数据");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 将辐照曲线的短期预报与本地实测对齐到同一时间点并集(时间从小到大)。
|
|
|
|
|
+ * 某侧缺失的时间点 tirr 填 0;预测源同一时间点可能含多份重叠报告,保留列表中首个(最新报告)。
|
|
|
|
|
+ * 合并后两侧 stats 等长、下标一一对应。
|
|
|
|
|
+ */
|
|
|
|
|
+ private void alignTirrStats(TirrChartResult forecast, TirrChartResult local)
|
|
|
|
|
+ {
|
|
|
|
|
+ Map<String, Double> forecastMap = buildTirrTimeMap(forecast.getStats());
|
|
|
|
|
+ Map<String, Double> localMap = buildTirrTimeMap(local.getStats());
|
|
|
|
|
+ TreeSet<String> times = new TreeSet<String>();
|
|
|
|
|
+ times.addAll(forecastMap.keySet());
|
|
|
|
|
+ times.addAll(localMap.keySet());
|
|
|
|
|
+ List<TirrChartStat> forecastStats = new ArrayList<TirrChartStat>();
|
|
|
|
|
+ List<TirrChartStat> localStats = new ArrayList<TirrChartStat>();
|
|
|
|
|
+ for (String time : times)
|
|
|
{
|
|
{
|
|
|
- stats.addAll(local.getStats());
|
|
|
|
|
|
|
+ TirrChartStat forecastStat = new TirrChartStat(time, forecastMap.getOrDefault(time, 0d));
|
|
|
|
|
+ forecastStat.setSource("预测");
|
|
|
|
|
+ forecastStats.add(forecastStat);
|
|
|
|
|
+ TirrChartStat localStat = new TirrChartStat(time, localMap.getOrDefault(time, 0d));
|
|
|
|
|
+ localStat.setSource("本地实测");
|
|
|
|
|
+ localStats.add(localStat);
|
|
|
}
|
|
}
|
|
|
- ExcelUtil<TirrChartStat> util = new ExcelUtil<TirrChartStat>(TirrChartStat.class);
|
|
|
|
|
- util.exportExcel(response, stats, "辐照曲线数据");
|
|
|
|
|
|
|
+ forecast.setStats(forecastStats);
|
|
|
|
|
+ local.setStats(localStats);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按时间建立 时间->辐照 映射(LinkedHashMap 保留列表序,putIfAbsent 去重取首个)
|
|
|
|
|
+ */
|
|
|
|
|
+ private Map<String, Double> buildTirrTimeMap(List<TirrChartStat> stats)
|
|
|
|
|
+ {
|
|
|
|
|
+ Map<String, Double> map = new LinkedHashMap<String, Double>();
|
|
|
|
|
+ if (stats == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (TirrChartStat stat : stats)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (stat == null || stat.getTime() == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ map.putIfAbsent(stat.getTime(), stat.getTirr() == null ? 0d : stat.getTirr());
|
|
|
|
|
+ }
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|