ソースを参照

删除弃用的API

zhou-hao 5 年 前
コミット
588ca7d08e

+ 0 - 77
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/service/LocalDeviceInstanceService.java

@@ -101,50 +101,6 @@ public class LocalDeviceInstanceService extends GenericReactiveCrudService<Devic
             .as(super::save);
     }
 
-    /**
-     * 获取设备所有信息
-     *
-     * @param id 设备ID
-     * @return 设备详情信息
-     */
-    @Deprecated
-    public Mono<DeviceAllInfoResponse> getDeviceAllInfo(String id) {
-
-        return findById(id)//设备信息
-            .zipWhen(instance -> deviceProductService.findById(instance.getProductId()), DeviceInfo::of) //产品型号信息
-            .switchIfEmpty(Mono.error(NotFoundException::new))
-            .zipWhen(deviceInfo -> getDeviceRunRealInfo(id), DeviceAllInfoResponse::of) //设备运行状态
-            .zipWhen(info -> getDeviceLatestProperties(id).collectList(), DeviceAllInfoResponse::ofProperties) //设备属性
-            .zipWhen(info -> {
-                    DeviceMetadata deviceMetadata = new JetLinksDeviceMetadata(JSON.parseObject(info.getDeviceInfo().getDeriveMetadata()));
-                    return getEventCounts(deviceMetadata.getEvents(), id, info.getDeviceInfo().getProductId()); //事件数量统计
-                },
-                DeviceAllInfoResponse::ofEventCounts)
-            ;
-    }
-
-    /**
-     * 获取设备事件上报次数
-     *
-     * @param events    设备事件元数据
-     * @param deviceId  设备Id
-     * @param productId 型号id
-     * @return
-     */
-    private Mono<Map<String, Integer>> getEventCounts(List<EventMetadata> events, String deviceId, String productId) {
-        return Flux.merge(
-            events
-                .stream()
-                .map(Metadata::getId)
-                .map(eventId -> Query.of()
-                    .where("deviceId", deviceId)
-                    .execute(timeSeriesManager.getService(DeviceTimeSeriesMetric.deviceEventMetric(productId, eventId))::count)
-                    .map(count -> Tuples.of(eventId, count)))
-                .collect(Collectors.toList())
-        ).collect(Collectors.toMap(Tuple2::getT1, Tuple2::getT2));
-    }
-
-
     /**
      * 发布设备到设备注册中心
      *
@@ -272,39 +228,6 @@ public class LocalDeviceInstanceService extends GenericReactiveCrudService<Devic
             .defaultIfEmpty(DeviceState.notActive);
     }
 
-    @Deprecated
-    public Mono<DeviceRunInfo> getDeviceRunInfo(String deviceId) {
-        return getDeviceRunRealInfo(deviceId);
-    }
-
-    @Deprecated
-    private Mono<DeviceRunInfo> getDeviceRunRealInfo(String deviceId) {
-        return registry.getDevice(deviceId)
-            .flatMap(deviceOperator -> Mono.zip(
-                deviceOperator.getOnlineTime().switchIfEmpty(Mono.just(0L)),// 1
-                deviceOperator.getOfflineTime().switchIfEmpty(Mono.just(0L)),// 2
-                deviceOperator.checkState()
-                    .switchIfEmpty(deviceOperator.getState())
-                    .map(DeviceState::of)
-                    .defaultIfEmpty(DeviceState.notActive),// 3
-                deviceOperator.getConfig(DeviceConfigKey.metadata).switchIfEmpty(Mono.just("")),//4
-                deviceOperator.getConfig(DeviceConfigKey.productId).switchIfEmpty(Mono.just(""))//5
-                ).map(tuple4 -> DeviceRunInfo.of(
-                tuple4.getT1(), //1. 上线时间
-                tuple4.getT2(), //2. 离线时间
-                tuple4.getT3(), //3. 状态
-                tuple4.getT4(),  //4. 设备模型元数据
-                tuple4.getT5() //5. 设备类型ID
-                )
-                ).flatMap(deviceRunInfo -> createUpdate()
-                    .set(DeviceInstanceEntity::getState, deviceRunInfo.getState())
-                    .where(DeviceInstanceEntity::getId, deviceId)
-                    .execute()
-                    .thenReturn(deviceRunInfo))
-            );
-    }
-
-
     public Mono<PagerResult<DevicePropertiesEntity>> queryDeviceProperties(String deviceId, QueryParamEntity entity) {
         return registry.getDevice(deviceId)
             .flatMap(operator -> operator.getSelfConfig(DeviceConfigKey.productId))

+ 1 - 1
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/service/LocalDeviceProductService.java

@@ -29,7 +29,7 @@ public class LocalDeviceProductService extends GenericReactiveCrudService<Device
 
     public Mono<Integer> deploy(String id) {
         return findById(Mono.just(id))
-            .flatMap(product -> registry.registry(
+            .flatMap(product -> registry.register(
                 ProductInfo.builder()
                     .id(id)
                     .protocol(product.getMessageProtocol())

+ 4 - 38
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/DeviceInstanceController.java

@@ -69,8 +69,6 @@ public class DeviceInstanceController implements
     @Getter
     private final LocalDeviceInstanceService service;
 
-    private final TimeSeriesManager timeSeriesManager;
-
     private final DeviceRegistry registry;
 
     private final LocalDeviceProductService productService;
@@ -81,13 +79,11 @@ public class DeviceInstanceController implements
 
     @SuppressWarnings("all")
     public DeviceInstanceController(LocalDeviceInstanceService service,
-                                    TimeSeriesManager timeSeriesManager,
                                     DeviceRegistry registry,
                                     LocalDeviceProductService productService,
                                     ImportExportService importExportService,
                                     ReactiveRepository<DeviceTagEntity, String> tagRepository) {
         this.service = service;
-        this.timeSeriesManager = timeSeriesManager;
         this.registry = registry;
         this.productService = productService;
         this.importExportService = importExportService;
@@ -109,36 +105,15 @@ public class DeviceInstanceController implements
         return service.getDeviceState(id);
     }
 
-    //已弃用 下一个版本删除
-    @GetMapping("/info/{id:.+}")
-    @QueryAction
-    @Deprecated
-    public Mono<DeviceInfo> getDeviceInfoById(@PathVariable String id) {
-        return service.getDeviceInfoById(id);
-    }
-
-    //已弃用 下一个版本删除
-    @GetMapping("/run-info/{id:.+}")
-    @QueryAction
-    @Deprecated
-    public Mono<DeviceRunInfo> getRunDeviceInfoById(@PathVariable String id) {
-        return service.getDeviceRunInfo(id);
-    }
-
-
-    @PostMapping({
-        "/deploy/{deviceId:.+}",//todo 已弃用 下一个版本删除
-        "/{deviceId:.+}/deploy"
-    })
+    //激活
+    @PostMapping("/{deviceId:.+}/deploy")
     @SaveAction
     public Mono<DeviceDeployResult> deviceDeploy(@PathVariable String deviceId) {
         return service.deploy(deviceId);
     }
 
-    @PostMapping({
-        "/cancelDeploy/{deviceId:.+}", //todo 已弃用 下一个版本删除
-        "/{deviceId:.+}/undeploy"
-    })
+    //注销
+    @PostMapping( "/{deviceId:.+}/undeploy")
     @SaveAction
     public Mono<Integer> cancelDeploy(@PathVariable String deviceId) {
         return service.cancelDeploy(deviceId);
@@ -189,15 +164,6 @@ public class DeviceInstanceController implements
             .defaultIfEmpty(0);
     }
 
-    //已废弃
-    @GetMapping("/{productId:.+}/{deviceId:.+}/properties")
-    @Deprecated
-    @QueryAction
-    public Flux<DevicePropertiesEntity> getDeviceLatestProperties(@PathVariable String productId,
-                                                                  @PathVariable String deviceId) {
-        return service.getDeviceLatestProperties(deviceId);
-    }
-
     //获取最新的设备属性
     @GetMapping("/{deviceId:.+}/properties/latest")
     @QueryAction