group list of time series tendencies

This commit is contained in:
Anton Romanov 2023-02-27 22:36:08 +04:00
parent b3ab0496f8
commit d4080e69c1
2 changed files with 13 additions and 5 deletions

View File

@ -88,8 +88,7 @@ public class TimeSeriesController {
@PostMapping("getGroupedTendencies")
@Operation(description = "Получить список сгруппированных тенденций")
public ResponseEntity<TimeSeries> getGroupedTendencies(@RequestBody TimeSeries timeSeries) throws ModelingException, ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
return new ResponseEntity<>(timeSeriesService.getGroupedTendencies(timeSeries), HttpStatus.OK);
public ResponseEntity<List<TimeSeries>> getGroupedTendencies(@RequestBody List<TimeSeries> timeSeriesList) {
return new ResponseEntity<>(timeSeriesService.getGroupedTendencies(timeSeriesList), HttpStatus.OK);
}
}

View File

@ -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 {
public List<TimeSeries> getGroupedTendencies(List<TimeSeries> 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);