Browse Source

在data-trans服务模块中增加对外删除产品缓存和设备缓存的两个API接口

james 1 tháng trước cách đây
mục cha
commit
45178279f4

+ 5 - 0
data-transfer/data-transfer-api/src/main/java/com/usky/transfer/RemoteTransferService.java

@@ -20,6 +20,11 @@ public interface RemoteTransferService {
     @PostMapping("/sendDeviceData")
     ApiResult<Void> sendDeviceData(@RequestBody DeviceDataWriteVO writeVO);
 
+    @PostMapping("/deleteProductCache")
+    ApiResult<Void> deleteProductCache();
+    @PostMapping("/deleteDeviceCache")
+    ApiResult<Void> deleteDeviceCache(@RequestParam("productCode") String productCode);
+
     /**
      * 下发单个设备控制命令
      */

+ 8 - 0
data-transfer/data-transfer-api/src/main/java/com/usky/transfer/factory/RemoteTransferFallbackFactory.java

@@ -36,6 +36,14 @@ public class RemoteTransferFallbackFactory implements FallbackFactory<RemoteTran
                 throw new BusinessException(throwable.getMessage());
             }
             @Override
+            public ApiResult<Void> deleteProductCache() {
+                throw new BusinessException(throwable.getMessage());
+            }
+            @Override
+            public ApiResult<Void> deleteDeviceCache(String productCode) {
+                throw new BusinessException(throwable.getMessage());
+            }
+            @Override
             public Map<String,Object> deviceControl(String productCode, String deviceUuid, String commandStr,Integer tenantId, Long userId, String userName) {
                 throw new BusinessException(throwable.getMessage());
             }

+ 21 - 0
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/controller/api/DataTransferControllerApi.java

@@ -3,6 +3,7 @@ package com.usky.transfer.controller.api;
 import com.usky.common.core.bean.ApiResult;
 import com.usky.transfer.RemoteTransferService;
 import com.usky.transfer.domain.*;
+import com.usky.transfer.service.DmpProductService;
 import com.usky.transfer.service.QueryInfluxdbDataService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -14,6 +15,26 @@ public class DataTransferControllerApi implements RemoteTransferService {
 
     @Autowired
     private QueryInfluxdbDataService queryInfluxdbDataService;
+    @Autowired
+    private DmpProductService dmpProductService;
+
+    /**
+     * 删除产品缓存信息
+     */
+    @Override
+    public ApiResult<Void> deleteProductCache(){
+        dmpProductService.deleteProductCache();
+        return ApiResult.success();
+    }
+
+    /**
+     * 删除设备缓存信息
+     */
+    @Override
+    public ApiResult<Void> deleteDeviceCache(String productCode){
+        dmpProductService.deleteDeviceCache(productCode);
+        return ApiResult.success();
+    }
 
     /**
      * 单个设备数据写入