#3 -- add smoothing by specific method

This commit is contained in:
Anton Romanov 2022-07-25 09:22:45 +04:00
parent 8201842801
commit aa4f389bf0
2 changed files with 46 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import ru.ulstu.HttpUtils;
import ru.ulstu.configuration.ApiConfiguration; import ru.ulstu.configuration.ApiConfiguration;
import ru.ulstu.datamodel.ForecastParams; import ru.ulstu.datamodel.ForecastParams;
import ru.ulstu.datamodel.ModelingResult; import ru.ulstu.datamodel.ModelingResult;
import ru.ulstu.datamodel.SmoothingParams;
import ru.ulstu.datamodel.exception.ModelingException; import ru.ulstu.datamodel.exception.ModelingException;
import ru.ulstu.datamodel.ts.TimeSeries; import ru.ulstu.datamodel.ts.TimeSeries;
import ru.ulstu.method.Method; import ru.ulstu.method.Method;
@ -57,6 +58,16 @@ public class TimeSeriesController {
return result; return result;
} }
@PostMapping("getSpecificMethodSmoothed")
@Operation(description = "Получить сглаженный временной ряд выбранным методом")
public ResponseEntity<ModelingResult> getSpecificMethodSmoothedTimeSeries(@RequestBody @Valid SmoothingParams smoothingParams, HttpServletRequest request) throws ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, ModelingException {
LOGGER.info("User ip: " + HttpUtils.getUserIp(request));
LOGGER.info("Time series for smoothing: " + smoothingParams.getOriginalTimeSeries());
ResponseEntity<ModelingResult> result = new ResponseEntity<>(timeSeriesService.smoothTimeSeries(smoothingParams.getOriginalTimeSeries(), smoothingParams.getMethodClassName()), HttpStatus.OK);
LOGGER.info("Smoothing complete");
return result;
}
@PostMapping("getSpecificMethodForecast") @PostMapping("getSpecificMethodForecast")
@Operation(description = "Получить прогноз временного ряда указанным методом") @Operation(description = "Получить прогноз временного ряда указанным методом")
public ResponseEntity<ModelingResult> getForecastTimeSeriesSpecificMethod(@RequestBody @Valid ForecastParams forecastParams, HttpServletRequest request) throws ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, ModelingException { public ResponseEntity<ModelingResult> getForecastTimeSeriesSpecificMethod(@RequestBody @Valid ForecastParams forecastParams, HttpServletRequest request) throws ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, ModelingException {

View File

@ -0,0 +1,35 @@
package ru.ulstu.datamodel;
import ru.ulstu.datamodel.ts.TimeSeries;
import javax.validation.constraints.NotNull;
public class SmoothingParams {
@NotNull
private TimeSeries originalTimeSeries;
private String methodClassName;
public TimeSeries getOriginalTimeSeries() {
return originalTimeSeries;
}
public void setOriginalTimeSeries(TimeSeries originalTimeSeries) {
this.originalTimeSeries = originalTimeSeries;
}
public String getMethodClassName() {
return methodClassName;
}
public void setMethodClassName(String methodClassName) {
this.methodClassName = methodClassName;
}
@Override
public String toString() {
return "ForecastParams{" +
"originalTimeSeries=" + originalTimeSeries +
", methodClassName=" + methodClassName +
'}';
}
}