Bladeren bron

change 指令下发改为异步进行

18339543638 4 jaren geleden
bovenliggende
commit
f9fd0e9f78

+ 4 - 6
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/DeviceDirectiveController.java

@@ -65,7 +65,7 @@ public class DeviceDirectiveController implements
     @CreateAction
     @Operation(summary = "批量重新发送指令到设备")
     public Mono<Void> resendDirectives(@RequestBody Mono<List<String>> idList){
-        return  idList.flatMapMany(directivesService::findById)
+        return  Mono.fromRunnable(()->idList.flatMapMany(directivesService::findById)
             .parallel(Runtime.getRuntime().availableProcessors()*2)
             .runOn(Schedulers.parallel())
             .flatMap(directive->
@@ -81,16 +81,14 @@ public class DeviceDirectiveController implements
                                 .then();
                         }
                     )
-            )
-            .then()
-            .doOnError(e->Mono.error(new BusinessException("参数错误")));
+            ).subscribe());
     }
 
     @PostMapping("/send")
     @CreateAction
     @Operation(summary = "批量重新发送指令到设备")
     public Mono<Void> sendDirective(@RequestBody DirectiveParam directiveParam){
-        return Mono.zip(this.parseParamMsg(directiveParam),this.parseDeviceIds(directiveParam))
+        return Mono.fromRunnable(()->Mono.zip(this.parseParamMsg(directiveParam),this.parseDeviceIds(directiveParam))
             .flatMap(tp2->{
                 List<DeviceOperator> t2 = tp2.getT2();
                 DeviceMessage message = tp2.getT1();
@@ -106,7 +104,7 @@ public class DeviceDirectiveController implements
                         }
                     )
                     .then();
-            });
+            }).subscribe());
     }