Compare commits

..

No commits in common. "de68ee9870096001ce528d3e2a5e603b9e74e01b" and "52561af52672e6d9204b22dfc41b65bddf989c8d" have entirely different histories.

4 changed files with 45 additions and 71 deletions

View File

@ -54,16 +54,12 @@ public class IndexController {
if (chartForm.getTimeSeriesMeta() != null
&& chartForm.getTimeSeriesMeta().getKey() != null
&& !chartForm.getTimeSeriesMeta().getKey().isEmpty()) {
addChartToModel(dbService.getTimeSeries(chartForm.getSet(), chartForm.getTimeSeriesMeta().getKey()),
null,
chartForm.isNeedForecast(),
model);
addChartToModel(dbService.getTimeSeries(chartForm.getSet(), chartForm.getTimeSeriesMeta().getKey()), null, model);
}
return "index";
}
private void addChartToModel(TimeSeries timeSeries, String method, boolean needForecast, Model model) throws ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, ModelingException {
if (needForecast) {
private void addChartToModel(TimeSeries timeSeries, String method, Model model) throws ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, ModelingException {
int countForecastPoints = timeSeries.getLength() > 20 ? 10 : timeSeries.getLength() / 3;
TimeSeries timeSeriesModel;
ModelingResult modelingResult;
@ -76,6 +72,8 @@ public class IndexController {
}
TimeSeries forecast = modelingResult.getTimeSeries();
TimeSeries testForecast = modelingResult.getTestForecast();
model.addAttribute("dates", getDatesForChart(timeSeries, forecast));
model.addAttribute("timeSeries", timeSeries.getValues().stream().map(TimeSeriesValue::getValue).toArray());
// если временной ряд был сжат моделью, то для графика нужно вставить пустые значения
TimeSeries modelWithSkips = new TimeSeries(timeSeriesModel.getKey());
int j = 0;
@ -103,11 +101,6 @@ public class IndexController {
model.addAttribute("testForecast", testForecastValues.toArray());
model.addAttribute("forecastDescription", modelingResult);
model.addAttribute("statistic", statisticService.getStatistic(timeSeries));
model.addAttribute("dates", getDatesForChart(timeSeries, forecast));
} else {
model.addAttribute("dates", getDatesForChart(timeSeries, new TimeSeries()));
}
model.addAttribute("timeSeries", timeSeries.getValues().stream().map(TimeSeriesValue::getValue).toArray());
}
private List<String> getDatesForChart(TimeSeries timeSeries, TimeSeries forecast) {
@ -139,10 +132,7 @@ public class IndexController {
&& !chartForm.getTimeSeriesMeta().getKey().isEmpty()
&& chartForm.getMethodClassName() != null
&& !chartForm.getMethodClassName().equals("")) {
addChartToModel(dbService.getTimeSeries(chartForm.getSet(), chartForm.getTimeSeriesMeta().getKey()),
chartForm.getMethodClassName(),
chartForm.isNeedForecast(),
model);
addChartToModel(dbService.getTimeSeries(chartForm.getSet(), chartForm.getTimeSeriesMeta().getKey()), chartForm.getMethodClassName(), model);
}
return "method";
}

View File

@ -8,8 +8,6 @@ public class ChartForm {
private TimeSeriesMeta timeSeriesMeta;
private String methodClassName = null;
private boolean needForecast;
public TimeSeriesSet getSet() {
return set;
}
@ -33,12 +31,4 @@ public class ChartForm {
public void setMethodClassName(String methodClassName) {
this.methodClassName = methodClassName;
}
public boolean isNeedForecast() {
return needForecast;
}
public void setNeedForecast(boolean needForecast) {
this.needForecast = needForecast;
}
}

View File

@ -123,10 +123,7 @@
$('#select-ts').val([[*{timeSeriesMeta.key}]]);
$('#select-ts').selectpicker('refresh');
</script>
<input id="need-forecast" type="hidden" th:field="*{needForecast}">
<button type="button" class="btn btn-primary" onclick="$('#need-forecast').val(true); form.submit();">
Построить прогноз
</button>
<h5 th:if="${forecastDescription != null && forecastDescription.timeSeriesMethod != null}">
Результаты моделирования:
</h5>

View File

@ -120,7 +120,7 @@
<select id="select-ts" class="selectpicker form-group" data-live-search="true"
th:field="*{timeSeriesMeta}"
data-width="90%" onchange="$('#need-forecast').val(false); form.submit();">
data-width="90%" onchange="form.submit();">
<option value="">Временной ряд</option>
<option th:each="ts : ${listTimeSeries}"
th:value="${ts.key}"
@ -135,7 +135,7 @@
<select id="select-method" class="selectpicker form-group" data-live-search="true"
th:field="*{methodClassName}"
data-width="90%" onchange="$('#need-forecast').val(false); form.submit();">
data-width="90%" onchange="form.submit();">
<option value="">Метод прогнозирования</option>
<option th:each="method : ${methods}"
th:value="${method.key}"
@ -148,10 +148,7 @@
</script>
<input id="need-forecast" type="hidden" th:field="*{needForecast}">
<button type="button" class="btn btn-primary" onclick="$('#need-forecast').val(true); form.submit();">
Построить прогноз
</button>
<div th:if="${forecastDescription != null && forecastDescription.timeSeriesMethod != null}">
<p> Метод прогнозирования: <span th:text="${forecastDescription.timeSeriesMethod}"> </span>
<p> Оценка: <span th:text="${forecastDescription.score.value}"> </span>