diff --git a/src/main/java/ru/ulstu/controller/IndexController.java b/src/main/java/ru/ulstu/controller/IndexController.java index f034573..11a630a 100644 --- a/src/main/java/ru/ulstu/controller/IndexController.java +++ b/src/main/java/ru/ulstu/controller/IndexController.java @@ -12,6 +12,7 @@ import ru.ulstu.datamodel.ts.TimeSeries; import ru.ulstu.datamodel.ts.TimeSeriesValue; import ru.ulstu.db.DbService; import ru.ulstu.service.TimeSeriesService; +import ru.ulstu.statistic.StatisticService; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -27,11 +28,14 @@ import java.util.stream.Stream; public class IndexController { private final TimeSeriesService timeSeriesService; private final DbService dbService; + private final StatisticService statisticService; public IndexController(TimeSeriesService timeSeriesService, - DbService dbService) { + DbService dbService, + StatisticService statisticService) { this.timeSeriesService = timeSeriesService; this.dbService = dbService; + this.statisticService = statisticService; } @GetMapping("/") @@ -96,6 +100,7 @@ public class IndexController { testForecastValues.addAll(testForecast.getValues().stream().map(TimeSeriesValue::getValue).collect(Collectors.toList())); model.addAttribute("testForecast", testForecastValues.toArray()); model.addAttribute("forecastDescription", modelingResult); + model.addAttribute("statistic", statisticService.getStatistic(timeSeries)); } private List getDatesForChart(TimeSeries timeSeries, TimeSeries forecast) { diff --git a/src/main/java/ru/ulstu/statistic/StatisticService.java b/src/main/java/ru/ulstu/statistic/StatisticService.java index 8c7a9c2..aca1ea8 100644 --- a/src/main/java/ru/ulstu/statistic/StatisticService.java +++ b/src/main/java/ru/ulstu/statistic/StatisticService.java @@ -40,4 +40,11 @@ public class StatisticService { private Optional getOptionalValue(Double value) { return Optional.ofNullable(value); } + + public TimeSeriesStatistic getStatistic(TimeSeries timeSeries) { + return new TimeSeriesStatistic(getMin(timeSeries), + getMax(timeSeries), + getAverage(timeSeries), + getLength(timeSeries)); + } } diff --git a/src/main/java/ru/ulstu/statistic/TimeSeriesStatistic.java b/src/main/java/ru/ulstu/statistic/TimeSeriesStatistic.java new file mode 100644 index 0000000..7162ad2 --- /dev/null +++ b/src/main/java/ru/ulstu/statistic/TimeSeriesStatistic.java @@ -0,0 +1,36 @@ +package ru.ulstu.statistic; + +import java.util.Optional; + +public class TimeSeriesStatistic { + private Optional min; + private Optional max; + private Optional average; + private Optional length; + + public TimeSeriesStatistic(Optional min, + Optional max, + Optional average, + Optional length) { + this.min = min; + this.max = max; + this.average = average; + this.length = length; + } + + public Optional getMin() { + return min; + } + + public Optional getMax() { + return max; + } + + public Optional getAverage() { + return average; + } + + public Optional getLength() { + return length; + } +} diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 7cc8f1a..bc0323e 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -145,13 +145,20 @@ Статистические характеристики временного ряда:
-

Метод прогнозирования: - +

Длина: +


-

Оценка прогноза по - : - +

Минимальное значение: + +

+
+

Максимальное значение: + +

+
+

Среднее значение: +