|
|
@@ -1,6 +1,10 @@
|
|
|
package com.ufo.project.forecast.shortterm.power.controller;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.TreeMap;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -18,7 +22,6 @@ import com.ufo.project.forecast.shortterm.power.domain.DataShortTermPowerForecas
|
|
|
import com.ufo.project.forecast.shortterm.power.service.IDataShortTermPowerForecastCorrectService;
|
|
|
import com.ufo.base.framework.web.controller.BaseController;
|
|
|
import com.ufo.base.framework.web.domain.AjaxResult;
|
|
|
-import com.ufo.base.common.utils.TimeUtils;
|
|
|
import com.ufo.base.common.utils.poi.ExcelUtil;
|
|
|
import com.ufo.base.framework.web.page.TableDataInfo;
|
|
|
|
|
|
@@ -51,7 +54,7 @@ public class DataShortTermPowerForecastCorrectController extends BaseController
|
|
|
@GetMapping("/chart")
|
|
|
public TableDataInfo chart(DataShortTermPowerForecastCorrect dataShortTermPowerForecastCorrect)
|
|
|
{
|
|
|
- List<DataShortTermPowerForecastCorrect> list = dataShortTermPowerForecastCorrectService.selectDataShortTermPowerForecastCorrectList(dataShortTermPowerForecastCorrect);
|
|
|
+ List<DataShortTermPowerForecastCorrect> list = this.queryList(dataShortTermPowerForecastCorrect);
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
@@ -63,11 +66,36 @@ public class DataShortTermPowerForecastCorrectController extends BaseController
|
|
|
@PostMapping("/export/excel")
|
|
|
public void export(HttpServletResponse response, DataShortTermPowerForecastCorrect dataShortTermPowerForecastCorrect)
|
|
|
{
|
|
|
- List<DataShortTermPowerForecastCorrect> list = dataShortTermPowerForecastCorrectService.selectDataShortTermPowerForecastCorrectList(dataShortTermPowerForecastCorrect);
|
|
|
+ List<DataShortTermPowerForecastCorrect> list = this.queryList(dataShortTermPowerForecastCorrect);
|
|
|
ExcelUtil<DataShortTermPowerForecastCorrect> util = new ExcelUtil<DataShortTermPowerForecastCorrect>(DataShortTermPowerForecastCorrect.class);
|
|
|
util.exportExcel(response, list, "短期功率修正数据数据");
|
|
|
}
|
|
|
|
|
|
+ private List<DataShortTermPowerForecastCorrect> queryList(DataShortTermPowerForecastCorrect dataShortTermPowerForecastCorrect)
|
|
|
+ {
|
|
|
+ List<DataShortTermPowerForecastCorrect> list = dataShortTermPowerForecastCorrectService.selectDataShortTermPowerForecastCorrectList(dataShortTermPowerForecastCorrect);
|
|
|
+ if (list == null || list.isEmpty())
|
|
|
+ {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 按 forecast_time 分组,每组按 start_time desc, id desc 取第一条(即同一时间点最新起报的数据)
|
|
|
+ Comparator<DataShortTermPowerForecastCorrect> latestFirst = Comparator
|
|
|
+ .comparing(DataShortTermPowerForecastCorrect::getStartTime, Comparator.nullsFirst(Comparator.<Long>naturalOrder()))
|
|
|
+ .thenComparing(DataShortTermPowerForecastCorrect::getId, Comparator.nullsFirst(Comparator.<Long>naturalOrder()));
|
|
|
+ Map<Long, DataShortTermPowerForecastCorrect> latestByForecastTime = new TreeMap<>();
|
|
|
+ for (DataShortTermPowerForecastCorrect item : list)
|
|
|
+ {
|
|
|
+ if (item.getForecastTime() == null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ latestByForecastTime.merge(item.getForecastTime(), item,
|
|
|
+ (existing, candidate) -> latestFirst.compare(candidate, existing) > 0 ? candidate : existing);
|
|
|
+ }
|
|
|
+ return new ArrayList<>(latestByForecastTime.values());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取短期功率修正数据详细信息
|
|
|
*/
|