|
|
@@ -30,6 +30,7 @@ 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.TirrChartStat;
|
|
|
+import com.ufo.project.forecast.shortterm.weather.domain.vo.TsfcChartExportStat;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.TsfcChartResult;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.TsfcChartStat;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.WsChartResult;
|
|
|
@@ -132,7 +133,7 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 统计温度曲线数据(短期预报 + 本地实测)
|
|
|
+ * 统计温度曲线数据(短期预报 + 本地实测,两侧 stats 对齐到同一时间点并集,缺数填0)
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('weather:weatherRaw:tsfcchart')")
|
|
|
@GetMapping("/tsfcchart")
|
|
|
@@ -141,11 +142,12 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
|
TsfcChartResult forecast = dataShortTermWeatherForecastRawService.getTsfcChart(stationId, startTime, endTime);
|
|
|
TsfcChartResult local = dataWeatherLocalService.getTsfcChart(stationId, startTime, endTime);
|
|
|
+ alignTsfcStats(forecast, local);
|
|
|
return success(new ChartDataPair<TsfcChartResult>(forecast, local));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 导出温度曲线数据(短期预报 + 本地实测,合并导出)
|
|
|
+ * 导出温度曲线数据(短期预报 + 本地实测,按时间点并集对齐导出 时间/预测温度/观测温度)
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('weather:weatherRaw:tsfcchart')")
|
|
|
@Log(title = "温度曲线", businessType = BusinessType.EXPORT)
|
|
|
@@ -155,16 +157,16 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
|
TsfcChartResult forecast = dataShortTermWeatherForecastRawService.getTsfcChart(stationId, startTime, endTime);
|
|
|
TsfcChartResult local = dataWeatherLocalService.getTsfcChart(stationId, startTime, endTime);
|
|
|
- List<TsfcChartStat> stats = new ArrayList<TsfcChartStat>();
|
|
|
- if (forecast.getStats() != null)
|
|
|
+ alignTsfcStats(forecast, local);
|
|
|
+ List<TsfcChartStat> forecastStats = forecast.getStats();
|
|
|
+ List<TsfcChartStat> localStats = local.getStats();
|
|
|
+ List<TsfcChartExportStat> stats = new ArrayList<TsfcChartExportStat>();
|
|
|
+ for (int i = 0; i < forecastStats.size(); i++)
|
|
|
{
|
|
|
- stats.addAll(forecast.getStats());
|
|
|
+ stats.add(new TsfcChartExportStat(forecastStats.get(i).getTime(),
|
|
|
+ forecastStats.get(i).getTsfc(), localStats.get(i).getTsfc()));
|
|
|
}
|
|
|
- if (local.getStats() != null)
|
|
|
- {
|
|
|
- stats.addAll(local.getStats());
|
|
|
- }
|
|
|
- ExcelUtil<TsfcChartStat> util = new ExcelUtil<TsfcChartStat>(TsfcChartStat.class);
|
|
|
+ ExcelUtil<TsfcChartExportStat> util = new ExcelUtil<TsfcChartExportStat>(TsfcChartExportStat.class);
|
|
|
util.exportExcel(response, stats, "温度曲线数据");
|
|
|
}
|
|
|
|
|
|
@@ -328,6 +330,54 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 将温度曲线的短期预报与本地实测对齐到同一时间点并集(时间从小到大)。
|
|
|
+ * 某侧缺失的时间点 tsfc 填 0;预测源同一时间点可能含多份重叠报告,保留列表中首个(最新报告)。
|
|
|
+ * 合并后两侧 stats 等长、下标一一对应。
|
|
|
+ */
|
|
|
+ private void alignTsfcStats(TsfcChartResult forecast, TsfcChartResult local)
|
|
|
+ {
|
|
|
+ Map<String, Double> forecastMap = buildTsfcTimeMap(forecast.getStats());
|
|
|
+ Map<String, Double> localMap = buildTsfcTimeMap(local.getStats());
|
|
|
+ TreeSet<String> times = new TreeSet<String>();
|
|
|
+ times.addAll(forecastMap.keySet());
|
|
|
+ times.addAll(localMap.keySet());
|
|
|
+ List<TsfcChartStat> forecastStats = new ArrayList<TsfcChartStat>();
|
|
|
+ List<TsfcChartStat> localStats = new ArrayList<TsfcChartStat>();
|
|
|
+ for (String time : times)
|
|
|
+ {
|
|
|
+ TsfcChartStat forecastStat = new TsfcChartStat(time, forecastMap.getOrDefault(time, 0d));
|
|
|
+ forecastStat.setSource("预测");
|
|
|
+ forecastStats.add(forecastStat);
|
|
|
+ TsfcChartStat localStat = new TsfcChartStat(time, localMap.getOrDefault(time, 0d));
|
|
|
+ localStat.setSource("本地实测");
|
|
|
+ localStats.add(localStat);
|
|
|
+ }
|
|
|
+ forecast.setStats(forecastStats);
|
|
|
+ local.setStats(localStats);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按时间建立 时间->温度 映射(LinkedHashMap 保留列表序,putIfAbsent 去重取首个)
|
|
|
+ */
|
|
|
+ private Map<String, Double> buildTsfcTimeMap(List<TsfcChartStat> stats)
|
|
|
+ {
|
|
|
+ Map<String, Double> map = new LinkedHashMap<String, Double>();
|
|
|
+ if (stats == null)
|
|
|
+ {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ for (TsfcChartStat stat : stats)
|
|
|
+ {
|
|
|
+ if (stat == null || stat.getTime() == null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ map.putIfAbsent(stat.getTime(), stat.getTsfc() == null ? 0d : stat.getTsfc());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导出短期气象原始数据列表
|
|
|
*/
|