|
|
@@ -21,8 +21,10 @@ import com.ufo.base.framework.aspectj.lang.annotation.Log;
|
|
|
import com.ufo.base.framework.aspectj.lang.enums.BusinessType;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.DataShortTermWeatherForecastRaw;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.ChartDataPair;
|
|
|
+import com.ufo.project.forecast.shortterm.weather.domain.vo.PsfcChartExportStat;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.PsfcChartResult;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.PsfcChartStat;
|
|
|
+import com.ufo.project.forecast.shortterm.weather.domain.vo.RhsfcChartExportStat;
|
|
|
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.RoseChartDirectionStat;
|
|
|
@@ -30,8 +32,10 @@ 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.WsChartExportStat;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.WsChartResult;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.WsChartStat;
|
|
|
import com.ufo.project.forecast.shortterm.weather.service.IDataShortTermWeatherForecastRawService;
|
|
|
@@ -95,7 +99,7 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 统计风速曲线数据(短期预报 + 本地实测)
|
|
|
+ * 统计风速曲线数据(短期预报 + 本地实测,两侧 stats 对齐到同一时间点并集,缺数填0)
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('weather:weatherRaw:wschart')")
|
|
|
@GetMapping("/wschart")
|
|
|
@@ -104,11 +108,12 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
|
WsChartResult forecast = dataShortTermWeatherForecastRawService.getWsChart(stationId, startTime, endTime);
|
|
|
WsChartResult local = dataWeatherLocalService.getWsChart(stationId, startTime, endTime);
|
|
|
+ alignWsStats(forecast, local);
|
|
|
return success(new ChartDataPair<WsChartResult>(forecast, local));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 导出风速曲线数据(短期预报 + 本地实测,合并导出)
|
|
|
+ * 导出风速曲线数据(短期预报 + 本地实测,按时间点并集对齐导出 时间/预测风速/观测风速)
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('weather:weatherRaw:wschart')")
|
|
|
@Log(title = "风速曲线", businessType = BusinessType.EXPORT)
|
|
|
@@ -118,21 +123,21 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
|
WsChartResult forecast = dataShortTermWeatherForecastRawService.getWsChart(stationId, startTime, endTime);
|
|
|
WsChartResult local = dataWeatherLocalService.getWsChart(stationId, startTime, endTime);
|
|
|
- List<WsChartStat> stats = new ArrayList<WsChartStat>();
|
|
|
- if (forecast.getStats() != null)
|
|
|
- {
|
|
|
- stats.addAll(forecast.getStats());
|
|
|
- }
|
|
|
- if (local.getStats() != null)
|
|
|
+ alignWsStats(forecast, local);
|
|
|
+ List<WsChartStat> forecastStats = forecast.getStats();
|
|
|
+ List<WsChartStat> localStats = local.getStats();
|
|
|
+ List<WsChartExportStat> stats = new ArrayList<WsChartExportStat>();
|
|
|
+ for (int i = 0; i < forecastStats.size(); i++)
|
|
|
{
|
|
|
- stats.addAll(local.getStats());
|
|
|
+ stats.add(new WsChartExportStat(forecastStats.get(i).getTime(),
|
|
|
+ forecastStats.get(i).getWs(), localStats.get(i).getWs()));
|
|
|
}
|
|
|
- ExcelUtil<WsChartStat> util = new ExcelUtil<WsChartStat>(WsChartStat.class);
|
|
|
+ ExcelUtil<WsChartExportStat> util = new ExcelUtil<WsChartExportStat>(WsChartExportStat.class);
|
|
|
util.exportExcel(response, stats, "风速曲线数据");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 统计温度曲线数据(短期预报 + 本地实测)
|
|
|
+ * 统计温度曲线数据(短期预报 + 本地实测,两侧 stats 对齐到同一时间点并集,缺数填0)
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('weather:weatherRaw:tsfcchart')")
|
|
|
@GetMapping("/tsfcchart")
|
|
|
@@ -141,11 +146,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 +161,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)
|
|
|
- {
|
|
|
- stats.addAll(forecast.getStats());
|
|
|
- }
|
|
|
- if (local.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(local.getStats());
|
|
|
+ stats.add(new TsfcChartExportStat(forecastStats.get(i).getTime(),
|
|
|
+ forecastStats.get(i).getTsfc(), localStats.get(i).getTsfc()));
|
|
|
}
|
|
|
- ExcelUtil<TsfcChartStat> util = new ExcelUtil<TsfcChartStat>(TsfcChartStat.class);
|
|
|
+ ExcelUtil<TsfcChartExportStat> util = new ExcelUtil<TsfcChartExportStat>(TsfcChartExportStat.class);
|
|
|
util.exportExcel(response, stats, "温度曲线数据");
|
|
|
}
|
|
|
|
|
|
@@ -178,6 +184,7 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
|
RhsfcChartResult forecast = dataShortTermWeatherForecastRawService.getRhsfcChart(stationId, startTime, endTime);
|
|
|
RhsfcChartResult local = dataWeatherLocalService.getRhsfcChart(stationId, startTime, endTime);
|
|
|
+ alignRhsfcStats(forecast, local);
|
|
|
return success(new ChartDataPair<RhsfcChartResult>(forecast, local));
|
|
|
}
|
|
|
|
|
|
@@ -192,16 +199,16 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
|
RhsfcChartResult forecast = dataShortTermWeatherForecastRawService.getRhsfcChart(stationId, startTime, endTime);
|
|
|
RhsfcChartResult local = dataWeatherLocalService.getRhsfcChart(stationId, startTime, endTime);
|
|
|
- List<RhsfcChartStat> stats = new ArrayList<RhsfcChartStat>();
|
|
|
- if (forecast.getStats() != null)
|
|
|
- {
|
|
|
- stats.addAll(forecast.getStats());
|
|
|
- }
|
|
|
- if (local.getStats() != null)
|
|
|
+ alignRhsfcStats(forecast, local);
|
|
|
+ List<RhsfcChartStat> forecastStats = forecast.getStats();
|
|
|
+ List<RhsfcChartStat> localStats = local.getStats();
|
|
|
+ List<RhsfcChartExportStat> stats = new ArrayList<RhsfcChartExportStat>();
|
|
|
+ for (int i = 0; i < forecastStats.size(); i++)
|
|
|
{
|
|
|
- stats.addAll(local.getStats());
|
|
|
+ stats.add(new RhsfcChartExportStat(forecastStats.get(i).getTime(),
|
|
|
+ forecastStats.get(i).getRhsfc(), localStats.get(i).getRhsfc()));
|
|
|
}
|
|
|
- ExcelUtil<RhsfcChartStat> util = new ExcelUtil<RhsfcChartStat>(RhsfcChartStat.class);
|
|
|
+ ExcelUtil<RhsfcChartExportStat> util = new ExcelUtil<RhsfcChartExportStat>(RhsfcChartExportStat.class);
|
|
|
util.exportExcel(response, stats, "湿度曲线数据");
|
|
|
}
|
|
|
|
|
|
@@ -215,6 +222,7 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
|
PsfcChartResult forecast = dataShortTermWeatherForecastRawService.getPsfcChart(stationId, startTime, endTime);
|
|
|
PsfcChartResult local = dataWeatherLocalService.getPsfcChart(stationId, startTime, endTime);
|
|
|
+ alignPsfcStats(forecast, local);
|
|
|
return success(new ChartDataPair<PsfcChartResult>(forecast, local));
|
|
|
}
|
|
|
|
|
|
@@ -229,16 +237,16 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
|
PsfcChartResult forecast = dataShortTermWeatherForecastRawService.getPsfcChart(stationId, startTime, endTime);
|
|
|
PsfcChartResult local = dataWeatherLocalService.getPsfcChart(stationId, startTime, endTime);
|
|
|
- List<PsfcChartStat> stats = new ArrayList<PsfcChartStat>();
|
|
|
- if (forecast.getStats() != null)
|
|
|
- {
|
|
|
- stats.addAll(forecast.getStats());
|
|
|
- }
|
|
|
- if (local.getStats() != null)
|
|
|
+ alignPsfcStats(forecast, local);
|
|
|
+ List<PsfcChartStat> forecastStats = forecast.getStats();
|
|
|
+ List<PsfcChartStat> localStats = local.getStats();
|
|
|
+ List<PsfcChartExportStat> stats = new ArrayList<PsfcChartExportStat>();
|
|
|
+ for (int i = 0; i < forecastStats.size(); i++)
|
|
|
{
|
|
|
- stats.addAll(local.getStats());
|
|
|
+ stats.add(new PsfcChartExportStat(forecastStats.get(i).getTime(),
|
|
|
+ forecastStats.get(i).getPsfc(), localStats.get(i).getPsfc()));
|
|
|
}
|
|
|
- ExcelUtil<PsfcChartStat> util = new ExcelUtil<PsfcChartStat>(PsfcChartStat.class);
|
|
|
+ ExcelUtil<PsfcChartExportStat> util = new ExcelUtil<PsfcChartExportStat>(PsfcChartExportStat.class);
|
|
|
util.exportExcel(response, stats, "气压曲线数据");
|
|
|
}
|
|
|
|
|
|
@@ -328,6 +336,194 @@ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将风速曲线的短期预报与本地实测对齐到同一时间点并集(时间从小到大)。
|
|
|
+ * 某侧缺失的时间点 ws 填 0;预测源同一时间点可能含多份重叠报告,保留列表中首个(最新报告)。
|
|
|
+ * 合并后两侧 stats 等长、下标一一对应。
|
|
|
+ */
|
|
|
+ private void alignWsStats(WsChartResult forecast, WsChartResult local)
|
|
|
+ {
|
|
|
+ Map<String, Double> forecastMap = buildWsTimeMap(forecast.getStats());
|
|
|
+ Map<String, Double> localMap = buildWsTimeMap(local.getStats());
|
|
|
+ TreeSet<String> times = new TreeSet<String>();
|
|
|
+ times.addAll(forecastMap.keySet());
|
|
|
+ times.addAll(localMap.keySet());
|
|
|
+ List<WsChartStat> forecastStats = new ArrayList<WsChartStat>();
|
|
|
+ List<WsChartStat> localStats = new ArrayList<WsChartStat>();
|
|
|
+ for (String time : times)
|
|
|
+ {
|
|
|
+ WsChartStat forecastStat = new WsChartStat(time, forecastMap.getOrDefault(time, 0d));
|
|
|
+ forecastStat.setSource("预测");
|
|
|
+ forecastStats.add(forecastStat);
|
|
|
+ WsChartStat localStat = new WsChartStat(time, localMap.getOrDefault(time, 0d));
|
|
|
+ localStat.setSource("本地实测");
|
|
|
+ localStats.add(localStat);
|
|
|
+ }
|
|
|
+ forecast.setStats(forecastStats);
|
|
|
+ local.setStats(localStats);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按时间建立 时间->风速 映射(LinkedHashMap 保留列表序,putIfAbsent 去重取首个)
|
|
|
+ */
|
|
|
+ private Map<String, Double> buildWsTimeMap(List<WsChartStat> stats)
|
|
|
+ {
|
|
|
+ Map<String, Double> map = new LinkedHashMap<String, Double>();
|
|
|
+ if (stats == null)
|
|
|
+ {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ for (WsChartStat stat : stats)
|
|
|
+ {
|
|
|
+ if (stat == null || stat.getTime() == null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ map.putIfAbsent(stat.getTime(), stat.getWs() == null ? 0d : stat.getWs());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将预测/本地实测湿度统计对齐到同一时间点并集(升序,缺数填0,等长下标一一对应)
|
|
|
+ */
|
|
|
+ private void alignRhsfcStats(RhsfcChartResult forecast, RhsfcChartResult local)
|
|
|
+ {
|
|
|
+ Map<String, Double> forecastMap = buildRhsfcTimeMap(forecast.getStats());
|
|
|
+ Map<String, Double> localMap = buildRhsfcTimeMap(local.getStats());
|
|
|
+ TreeSet<String> times = new TreeSet<String>();
|
|
|
+ times.addAll(forecastMap.keySet());
|
|
|
+ times.addAll(localMap.keySet());
|
|
|
+ List<RhsfcChartStat> forecastStats = new ArrayList<RhsfcChartStat>();
|
|
|
+ List<RhsfcChartStat> localStats = new ArrayList<RhsfcChartStat>();
|
|
|
+ for (String time : times)
|
|
|
+ {
|
|
|
+ RhsfcChartStat forecastStat = new RhsfcChartStat(time, forecastMap.getOrDefault(time, 0d));
|
|
|
+ forecastStat.setSource("预测");
|
|
|
+ forecastStats.add(forecastStat);
|
|
|
+ RhsfcChartStat localStat = new RhsfcChartStat(time, localMap.getOrDefault(time, 0d));
|
|
|
+ localStat.setSource("本地实测");
|
|
|
+ localStats.add(localStat);
|
|
|
+ }
|
|
|
+ forecast.setStats(forecastStats);
|
|
|
+ local.setStats(localStats);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按时间建立 时间->湿度 映射(LinkedHashMap 保留列表序,putIfAbsent 去重取首个)
|
|
|
+ */
|
|
|
+ private Map<String, Double> buildRhsfcTimeMap(List<RhsfcChartStat> stats)
|
|
|
+ {
|
|
|
+ Map<String, Double> map = new LinkedHashMap<String, Double>();
|
|
|
+ if (stats == null)
|
|
|
+ {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ for (RhsfcChartStat stat : stats)
|
|
|
+ {
|
|
|
+ if (stat == null || stat.getTime() == null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ map.putIfAbsent(stat.getTime(), stat.getRhsfc() == null ? 0d : stat.getRhsfc());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将预测/本地实测气压统计对齐到同一时间点并集(升序,缺数填0,等长下标一一对应)
|
|
|
+ */
|
|
|
+ private void alignPsfcStats(PsfcChartResult forecast, PsfcChartResult local)
|
|
|
+ {
|
|
|
+ Map<String, Double> forecastMap = buildPsfcTimeMap(forecast.getStats());
|
|
|
+ Map<String, Double> localMap = buildPsfcTimeMap(local.getStats());
|
|
|
+ TreeSet<String> times = new TreeSet<String>();
|
|
|
+ times.addAll(forecastMap.keySet());
|
|
|
+ times.addAll(localMap.keySet());
|
|
|
+ List<PsfcChartStat> forecastStats = new ArrayList<PsfcChartStat>();
|
|
|
+ List<PsfcChartStat> localStats = new ArrayList<PsfcChartStat>();
|
|
|
+ for (String time : times)
|
|
|
+ {
|
|
|
+ PsfcChartStat forecastStat = new PsfcChartStat(time, forecastMap.getOrDefault(time, 0d));
|
|
|
+ forecastStat.setSource("预测");
|
|
|
+ forecastStats.add(forecastStat);
|
|
|
+ PsfcChartStat localStat = new PsfcChartStat(time, localMap.getOrDefault(time, 0d));
|
|
|
+ localStat.setSource("本地实测");
|
|
|
+ localStats.add(localStat);
|
|
|
+ }
|
|
|
+ forecast.setStats(forecastStats);
|
|
|
+ local.setStats(localStats);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按时间建立 时间->气压 映射(LinkedHashMap 保留列表序,putIfAbsent 去重取首个)
|
|
|
+ */
|
|
|
+ private Map<String, Double> buildPsfcTimeMap(List<PsfcChartStat> stats)
|
|
|
+ {
|
|
|
+ Map<String, Double> map = new LinkedHashMap<String, Double>();
|
|
|
+ if (stats == null)
|
|
|
+ {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ for (PsfcChartStat stat : stats)
|
|
|
+ {
|
|
|
+ if (stat == null || stat.getTime() == null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ map.putIfAbsent(stat.getTime(), stat.getPsfc() == null ? 0d : stat.getPsfc());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导出短期气象原始数据列表
|
|
|
*/
|