只注册已启用设备

This commit is contained in:
shikong 2024-01-12 14:58:57 +08:00
parent f452e3af3b
commit 5a68c819cb

View File

@ -50,10 +50,10 @@ public class RegisterService {
public DeferredResult<JsonResponse<Boolean>> register() { public DeferredResult<JsonResponse<Boolean>> register() {
DeferredResult<JsonResponse<Boolean>> result = new DeferredResult<>(TimeUnit.SECONDS.toMillis(TIMEOUT)); DeferredResult<JsonResponse<Boolean>> result = new DeferredResult<>(TimeUnit.SECONDS.toMillis(TIMEOUT));
List<MockingDevice> allDevice = deviceService.getAllDevice(); List<MockingDevice> enabledDevice = deviceService.getAllEnabledDevice();
List<CompletableFuture<JsonResponse<Void>>[]> completableFutures = ListUtil.split(allDevice, 10).stream().map(items -> { List<CompletableFuture<JsonResponse<Void>>[]> completableFutures = ListUtil.split(enabledDevice, 10).stream().map(items -> {
CompletableFuture<JsonResponse<Void>>[] array = allDevice.stream().map(this::register).toArray(CompletableFuture[]::new); CompletableFuture<JsonResponse<Void>>[] array = enabledDevice.stream().map(this::register).toArray(CompletableFuture[]::new);
CompletableFuture.allOf(array); CompletableFuture.allOf(array);
return array; return array;
}).toList(); }).toList();