diff --git a/src/main/java/ru/ulstu/controller/TimeSeriesController.java b/src/main/java/ru/ulstu/controller/TimeSeriesController.java index eef1580..1248005 100644 --- a/src/main/java/ru/ulstu/controller/TimeSeriesController.java +++ b/src/main/java/ru/ulstu/controller/TimeSeriesController.java @@ -88,8 +88,7 @@ public class TimeSeriesController { @PostMapping("getGroupedTendencies") @Operation(description = "Получить список сгруппированных тенденций") - public ResponseEntity getGroupedTendencies(@RequestBody TimeSeries timeSeries) throws ModelingException, ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { - return new ResponseEntity<>(timeSeriesService.getGroupedTendencies(timeSeries), HttpStatus.OK); + public ResponseEntity> getGroupedTendencies(@RequestBody List timeSeriesList) { + return new ResponseEntity<>(timeSeriesService.getGroupedTendencies(timeSeriesList), HttpStatus.OK); } - } diff --git a/src/main/java/ru/ulstu/service/TimeSeriesService.java b/src/main/java/ru/ulstu/service/TimeSeriesService.java index 10c7eea..e9bf4b0 100644 --- a/src/main/java/ru/ulstu/service/TimeSeriesService.java +++ b/src/main/java/ru/ulstu/service/TimeSeriesService.java @@ -10,6 +10,7 @@ import ru.ulstu.method.Method; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; @Service @@ -43,8 +44,16 @@ public class TimeSeriesService { return methodParamBruteForce.getAvailableMethods(); } - public TimeSeries getGroupedTendencies(TimeSeries timeSeries) throws ModelingException, ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { - timeSeries = smoothTimeSeries(timeSeries, "FTransform").getTimeSeries(); + public List getGroupedTendencies(List timeSeriesList) { + return timeSeriesList.stream().map(this::getGroupedTendencies).collect(Collectors.toList()); + } + + public TimeSeries getGroupedTendencies(TimeSeries timeSeries) { + try { + timeSeries = smoothTimeSeries(timeSeries, "FTransform").getTimeSeries(); + } catch (Exception e) { + e.printStackTrace(); + } int i = 2; double prevDiff = timeSeries.getNumericValue(1) - timeSeries.getNumericValue(0);