|
|
@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import com.ufo.base.common.utils.TimeUtils;
|
|
|
import com.ufo.base.framework.aspectj.lang.annotation.Log;
|
|
|
import com.ufo.base.framework.aspectj.lang.enums.BusinessType;
|
|
|
+import com.ufo.project.forecast.domain.ForecastCorrectChartExcel;
|
|
|
import com.ufo.project.forecast.mediumterm.power.domain.DataMediumTermPowerForecastCorrect;
|
|
|
import com.ufo.project.forecast.mediumterm.power.domain.DataMediumTermPowerForecastReport;
|
|
|
import com.ufo.project.forecast.mediumterm.power.mapper.DataMediumTermPowerForecastCorrectMapper;
|
|
|
@@ -78,62 +79,17 @@ public class DataMediumTermPowerForecastCorrectController extends BaseController
|
|
|
@RequestParam("forecastStartTime") Long forecastStartTime,
|
|
|
@RequestParam("forecastEndTime") Long forecastEndTime)
|
|
|
{
|
|
|
- String entityId = String.valueOf(stationId);
|
|
|
-
|
|
|
- List<DataMediumTermPowerForecastReport> reportList = dataMediumTermPowerForecastReportMapper.selectLatestByWindow(entityId, forecastStartTime, forecastEndTime);
|
|
|
- Map<Long, Double> reportPowerMap = new HashMap<>();
|
|
|
- if (reportList != null)
|
|
|
- {
|
|
|
- for (DataMediumTermPowerForecastReport item : reportList)
|
|
|
- {
|
|
|
- if (item.getForecastTime() != null)
|
|
|
- {
|
|
|
- reportPowerMap.put(item.getForecastTime(), parsePower(item.getPower()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- List<DataMediumTermPowerForecastCorrect> correctList = dataMediumTermPowerForecastCorrectMapper.selectLatestByWindow(entityId, forecastStartTime, forecastEndTime);
|
|
|
- Map<Long, Double> correctPowerMap = new HashMap<>();
|
|
|
- if (correctList != null)
|
|
|
- {
|
|
|
- for (DataMediumTermPowerForecastCorrect item : correctList)
|
|
|
- {
|
|
|
- if (item.getForecastTime() != null)
|
|
|
- {
|
|
|
- correctPowerMap.put(item.getForecastTime(), parsePower(item.getPower()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Map<Long, Double> monitorPowerMap = new HashMap<>();
|
|
|
- List<DataElectricityLocal> localList = dataElectricityLocalService.selectActualPowerList(
|
|
|
- stationId, TimeUtils.utcToGmt8Format(forecastStartTime), TimeUtils.utcToGmt8Format(forecastEndTime));
|
|
|
- if (localList != null)
|
|
|
- {
|
|
|
- for (DataElectricityLocal item : localList)
|
|
|
- {
|
|
|
- if (item.getTm() != null)
|
|
|
- {
|
|
|
- monitorPowerMap.put(item.getTm().getTime() / 1000, item.getActualPower() == null ? 0.0 : item.getActualPower());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- TreeSet<Long> times = new TreeSet<>();
|
|
|
- times.addAll(reportPowerMap.keySet());
|
|
|
- times.addAll(correctPowerMap.keySet());
|
|
|
- times.addAll(monitorPowerMap.keySet());
|
|
|
+ ChartSeriesData seriesData = loadChartSeries(stationId, forecastStartTime, forecastEndTime);
|
|
|
|
|
|
Map<String, Object> body = new LinkedHashMap<>();
|
|
|
- body.put("report", buildSeries(times, reportPowerMap));
|
|
|
- body.put("correct", buildSeries(times, correctPowerMap));
|
|
|
- body.put("monitor", buildSeries(times, monitorPowerMap));
|
|
|
+ body.put("report", buildSeries(seriesData.getTimes(), seriesData.getReport()));
|
|
|
+ body.put("correct", buildSeries(seriesData.getTimes(), seriesData.getCorrect()));
|
|
|
+ body.put("monitor", buildSeries(seriesData.getTimes(), seriesData.getMonitor()));
|
|
|
return AjaxResult.success(body);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 导出中期功率修正数据列表
|
|
|
+ * 导出中期功率修正数据(与chart接口同结构: 时间/上报功率/修正功率/观测功率, 缺失补0)
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('mediumterm:powerForecastCorrect:export')")
|
|
|
@Log(title = "中期功率修正数据", businessType = BusinessType.EXPORT)
|
|
|
@@ -142,10 +98,19 @@ public class DataMediumTermPowerForecastCorrectController extends BaseController
|
|
|
@RequestParam("forecastStartTime") Long forecastStartTime,
|
|
|
@RequestParam("forecastEndTime") Long forecastEndTime)
|
|
|
{
|
|
|
- List<DataMediumTermPowerForecastCorrect> list = dataMediumTermPowerForecastCorrectMapper.selectLatestByWindow(
|
|
|
- String.valueOf(stationId), forecastStartTime, forecastEndTime);
|
|
|
- ExcelUtil<DataMediumTermPowerForecastCorrect> util = new ExcelUtil<DataMediumTermPowerForecastCorrect>(DataMediumTermPowerForecastCorrect.class);
|
|
|
- util.exportExcel(response, list, "中期功率修正数据数据");
|
|
|
+ ChartSeriesData seriesData = loadChartSeries(stationId, forecastStartTime, forecastEndTime);
|
|
|
+ List<ForecastCorrectChartExcel> list = new ArrayList<>();
|
|
|
+ for (Long time : seriesData.getTimes())
|
|
|
+ {
|
|
|
+ ForecastCorrectChartExcel row = new ForecastCorrectChartExcel();
|
|
|
+ row.setTime(TimeUtils.utcToGmt8Format(time));
|
|
|
+ row.setReportPower(seriesData.getReport().getOrDefault(time, 0.0));
|
|
|
+ row.setCorrectPower(seriesData.getCorrect().getOrDefault(time, 0.0));
|
|
|
+ row.setMonitorPower(seriesData.getMonitor().getOrDefault(time, 0.0));
|
|
|
+ list.add(row);
|
|
|
+ }
|
|
|
+ ExcelUtil<ForecastCorrectChartExcel> util = new ExcelUtil<ForecastCorrectChartExcel>(ForecastCorrectChartExcel.class);
|
|
|
+ util.exportExcel(response, list, "中期功率修正数据");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -295,6 +260,91 @@ public class DataMediumTermPowerForecastCorrectController extends BaseController
|
|
|
return series;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 加载窗口内上报/修正/观测三条曲线的功率数据(时间点取三者并集)
|
|
|
+ */
|
|
|
+ private ChartSeriesData loadChartSeries(Long stationId, Long forecastStartTime, Long forecastEndTime)
|
|
|
+ {
|
|
|
+ String entityId = String.valueOf(stationId);
|
|
|
+ ChartSeriesData seriesData = new ChartSeriesData();
|
|
|
+
|
|
|
+ List<DataMediumTermPowerForecastReport> reportList = dataMediumTermPowerForecastReportMapper.selectLatestByWindow(entityId, forecastStartTime, forecastEndTime);
|
|
|
+ if (reportList != null)
|
|
|
+ {
|
|
|
+ for (DataMediumTermPowerForecastReport item : reportList)
|
|
|
+ {
|
|
|
+ if (item.getForecastTime() != null)
|
|
|
+ {
|
|
|
+ seriesData.getReport().put(item.getForecastTime(), parsePower(item.getPower()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DataMediumTermPowerForecastCorrect> correctList = dataMediumTermPowerForecastCorrectMapper.selectLatestByWindow(entityId, forecastStartTime, forecastEndTime);
|
|
|
+ if (correctList != null)
|
|
|
+ {
|
|
|
+ for (DataMediumTermPowerForecastCorrect item : correctList)
|
|
|
+ {
|
|
|
+ if (item.getForecastTime() != null)
|
|
|
+ {
|
|
|
+ seriesData.getCorrect().put(item.getForecastTime(), parsePower(item.getPower()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DataElectricityLocal> localList = dataElectricityLocalService.selectActualPowerList(
|
|
|
+ stationId, TimeUtils.utcToGmt8Format(forecastStartTime), TimeUtils.utcToGmt8Format(forecastEndTime));
|
|
|
+ if (localList != null)
|
|
|
+ {
|
|
|
+ for (DataElectricityLocal item : localList)
|
|
|
+ {
|
|
|
+ if (item.getTm() != null)
|
|
|
+ {
|
|
|
+ seriesData.getMonitor().put(item.getTm().getTime() / 1000, item.getActualPower() == null ? 0.0 : item.getActualPower());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ seriesData.getTimes().addAll(seriesData.getReport().keySet());
|
|
|
+ seriesData.getTimes().addAll(seriesData.getCorrect().keySet());
|
|
|
+ seriesData.getTimes().addAll(seriesData.getMonitor().keySet());
|
|
|
+ return seriesData;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 图表序列数据(上报/修正/观测功率映射及时间点并集)
|
|
|
+ */
|
|
|
+ private static class ChartSeriesData
|
|
|
+ {
|
|
|
+ private final TreeSet<Long> times = new TreeSet<>();
|
|
|
+
|
|
|
+ private final Map<Long, Double> report = new HashMap<>();
|
|
|
+
|
|
|
+ private final Map<Long, Double> correct = new HashMap<>();
|
|
|
+
|
|
|
+ private final Map<Long, Double> monitor = new HashMap<>();
|
|
|
+
|
|
|
+ public TreeSet<Long> getTimes()
|
|
|
+ {
|
|
|
+ return times;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<Long, Double> getReport()
|
|
|
+ {
|
|
|
+ return report;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<Long, Double> getCorrect()
|
|
|
+ {
|
|
|
+ return correct;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<Long, Double> getMonitor()
|
|
|
+ {
|
|
|
+ return monitor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取中期功率修正数据详细信息
|
|
|
*/
|