|
@@ -23,6 +23,7 @@ import com.ufo.project.forecast.shortterm.weather.domain.DataShortTermWeatherFor
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.ChartDataPair;
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.ChartDataPair;
|
|
|
import com.ufo.project.forecast.shortterm.weather.domain.vo.PsfcChartResult;
|
|
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.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.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;
|
|
@@ -182,6 +183,7 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
{
|
|
|
RhsfcChartResult forecast = dataShortTermWeatherForecastRawService.getRhsfcChart(stationId, startTime, endTime);
|
|
RhsfcChartResult forecast = dataShortTermWeatherForecastRawService.getRhsfcChart(stationId, startTime, endTime);
|
|
|
RhsfcChartResult local = dataWeatherLocalService.getRhsfcChart(stationId, startTime, endTime);
|
|
RhsfcChartResult local = dataWeatherLocalService.getRhsfcChart(stationId, startTime, endTime);
|
|
|
|
|
+ alignRhsfcStats(forecast, local);
|
|
|
return success(new ChartDataPair<RhsfcChartResult>(forecast, local));
|
|
return success(new ChartDataPair<RhsfcChartResult>(forecast, local));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -196,16 +198,16 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
{
|
|
{
|
|
|
RhsfcChartResult forecast = dataShortTermWeatherForecastRawService.getRhsfcChart(stationId, startTime, endTime);
|
|
RhsfcChartResult forecast = dataShortTermWeatherForecastRawService.getRhsfcChart(stationId, startTime, endTime);
|
|
|
RhsfcChartResult local = dataWeatherLocalService.getRhsfcChart(stationId, startTime, endTime);
|
|
RhsfcChartResult local = dataWeatherLocalService.getRhsfcChart(stationId, startTime, endTime);
|
|
|
- List<RhsfcChartStat> stats = new ArrayList<RhsfcChartStat>();
|
|
|
|
|
- if (forecast.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(forecast.getStats());
|
|
|
|
|
|
|
+ stats.add(new RhsfcChartExportStat(forecastStats.get(i).getTime(),
|
|
|
|
|
+ forecastStats.get(i).getRhsfc(), localStats.get(i).getRhsfc()));
|
|
|
}
|
|
}
|
|
|
- if (local.getStats() != null)
|
|
|
|
|
- {
|
|
|
|
|
- stats.addAll(local.getStats());
|
|
|
|
|
- }
|
|
|
|
|
- ExcelUtil<RhsfcChartStat> util = new ExcelUtil<RhsfcChartStat>(RhsfcChartStat.class);
|
|
|
|
|
|
|
+ ExcelUtil<RhsfcChartExportStat> util = new ExcelUtil<RhsfcChartExportStat>(RhsfcChartExportStat.class);
|
|
|
util.exportExcel(response, stats, "湿度曲线数据");
|
|
util.exportExcel(response, stats, "湿度曲线数据");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -428,6 +430,52 @@ public class DataShortTermWeatherForecastRawController extends BaseController
|
|
|
return map;
|
|
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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 导出短期气象原始数据列表
|
|
* 导出短期气象原始数据列表
|
|
|
*/
|
|
*/
|