فهرست منبع

修改influxdb时序数据库查询全量设备数据RPC接口,封装ApiResult<>

james 1 هفته پیش
والد
کامیت
c1c532d16d

+ 1 - 1
data-tsdb-proxy/data-tsdb-proxy-api/src/main/java/com/usky/demo/RemoteTsdbProxyService.java

@@ -24,7 +24,7 @@ public interface RemoteTsdbProxyService {
      * @return
      */
     @PostMapping("getAllDeviceRealTime")
-    List<Map<String, Object>> getAllDeviceRealTime();
+    ApiResult<List<Map<String, Object>>> getAllDeviceRealTime();
 
     /**
      * 单个设备实时数据查询

+ 1 - 1
data-tsdb-proxy/data-tsdb-proxy-api/src/main/java/com/usky/demo/factory/RemoteTsdbProxyFallbackFactory.java

@@ -44,7 +44,7 @@ public class RemoteTsdbProxyFallbackFactory implements FallbackFactory<RemoteTsd
             }
 
             @Override
-            public List<Map<String, Object>> getAllDeviceRealTime()
+            public ApiResult<List<Map<String, Object>>> getAllDeviceRealTime()
             {
                 throw new BusinessException("查询influxdb所有表实时数据:" + throwable.getMessage());
             }

+ 2 - 2
data-tsdb-proxy/data-tsdb-proxy-biz/src/main/java/com/usky/demo/controller/api/DataTsdbProxyControllerApi.java

@@ -45,8 +45,8 @@ public class DataTsdbProxyControllerApi implements RemoteTsdbProxyService {
      * @return
      */
     @Override
-    public List<Map<String, Object>> getAllDeviceRealTime(){
-        return queryInfluxdbDataService.getAllDeviceRealTime();
+    public ApiResult<List<Map<String, Object>>> getAllDeviceRealTime(){
+        return ApiResult.success(queryInfluxdbDataService.getAllDeviceRealTime());
     }
 
     /**

+ 1 - 2
data-tsdb-proxy/data-tsdb-proxy-biz/src/main/java/com/usky/demo/service/impl/QueryInfluxdbDataServiceImpl.java

@@ -243,9 +243,8 @@ public class QueryInfluxdbDataServiceImpl extends AbstractCrudService<QueryInflu
     public List<Map<String, Object>> getAllDeviceRealTime(){
         // 构建查询语句,获取所有 measurement 的最新数据
         String queryStr = "SELECT * FROM /.*/ ORDER BY time DESC LIMIT 1";
-        List<Map<String, Object>> result = tsdbUtils.fetchRealTimeRecords(queryStr);
 
-        return result;
+        return tsdbUtils.fetchRealTimeRecords(queryStr);
     }
 
     @Override