|
|
@@ -21,6 +21,7 @@ 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;
|
|
|
@@ -221,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));
|
|
|
}
|
|
|
|
|
|
@@ -235,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, "气压曲线数据");
|
|
|
}
|
|
|
|
|
|
@@ -476,6 +478,52 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
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;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导出短期气象原始数据列表
|
|
|
*/
|