feat(设备管理): 增加查询列式存储时全部属性的API
This commit is contained in:
parent
69282edfce
commit
2bf841c408
|
|
@ -238,6 +238,28 @@ public interface DeviceDataService {
|
|||
return queryEventPage(deviceId, event, query, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备属性数据,但是不返回分页结果
|
||||
*
|
||||
* @param deviceId 设备ID
|
||||
* @param query 查询条件
|
||||
* @return 查询结果
|
||||
*/
|
||||
@Nonnull
|
||||
Flux<DeviceProperties> queryProperties(@Nonnull String deviceId,
|
||||
@Nonnull QueryParamEntity query);
|
||||
|
||||
/**
|
||||
* 根据产品分页查询属性数据,一个属性为一列,仅支持部分存储策略
|
||||
*
|
||||
* @param productId 产品ID
|
||||
* @param query 查询条件
|
||||
* @return 查询结果
|
||||
*/
|
||||
@Nonnull
|
||||
Mono<PagerResult<DeviceProperties>> queryPropertiesPageByProduct(@Nonnull String productId,
|
||||
@Nonnull QueryParamEntity query);
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package org.jetlinks.community.device.service.data;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.jetlinks.community.things.data.ThingProperties;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
public class DeviceProperties extends HashMap<String, Object> {
|
||||
|
||||
private final String deviceId;
|
||||
|
||||
public DeviceProperties(Map<String, Object> data) {
|
||||
super(data);
|
||||
this.deviceId = (String) data.get("deviceId");
|
||||
}
|
||||
|
||||
public DeviceProperties(ThingProperties data) {
|
||||
super(data);
|
||||
this.deviceId = (String) data.get("thingId");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import org.hswebframework.web.api.crud.entity.PagerResult;
|
|||
import org.hswebframework.web.api.crud.entity.QueryParamEntity;
|
||||
import org.hswebframework.web.bean.FastBeanCopier;
|
||||
import org.jetlinks.community.things.data.AggregationRequest;
|
||||
import org.jetlinks.community.things.data.operations.ColumnModeQueryOperations;
|
||||
import org.jetlinks.community.things.data.operations.SaveOperations;
|
||||
import org.jetlinks.core.device.DeviceThingType;
|
||||
import org.jetlinks.core.message.DeviceMessage;
|
||||
|
|
@ -219,4 +220,23 @@ public class ThingsBridgingDeviceDataService implements DeviceDataService {
|
|||
.map(page ->convertPage(page,DeviceEvent::new));
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Flux<DeviceProperties> queryProperties(@Nonnull String deviceId, @Nonnull QueryParamEntity query) {
|
||||
return repository
|
||||
.opsForThing(thingType, deviceId)
|
||||
.flatMapMany(opt -> opt.forQuery().unwrap(ColumnModeQueryOperations.class).queryAllProperties(query))
|
||||
.map(DeviceProperties::new);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Mono<PagerResult<DeviceProperties>> queryPropertiesPageByProduct(@Nonnull String productId, @Nonnull QueryParamEntity query) {
|
||||
return repository
|
||||
.opsForTemplate(thingType, productId)
|
||||
.flatMap(opt -> opt.forQuery().unwrap(ColumnModeQueryOperations.class).queryAllPropertiesPage(query))
|
||||
.map(page -> convertPage(page,DeviceProperties::new));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ import org.jetlinks.community.device.service.DeviceConfigMetadataManager;
|
|||
import org.jetlinks.community.device.service.LocalDeviceInstanceService;
|
||||
import org.jetlinks.community.device.service.LocalDeviceProductService;
|
||||
import org.jetlinks.community.device.service.data.DeviceDataService;
|
||||
import org.jetlinks.community.device.service.data.DeviceProperties;
|
||||
import org.jetlinks.community.device.web.excel.DeviceExcelImporter;
|
||||
import org.jetlinks.community.device.web.excel.DeviceExcelInfo;
|
||||
import org.jetlinks.community.device.web.excel.DeviceWrapper;
|
||||
import org.jetlinks.community.device.web.excel.PropertyMetadataExcelInfo;
|
||||
import org.jetlinks.community.device.web.excel.PropertyMetadataWrapper;
|
||||
import org.jetlinks.community.device.web.excel.*;
|
||||
import org.jetlinks.community.device.web.request.AggRequest;
|
||||
import org.jetlinks.community.io.excel.AbstractImporter;
|
||||
|
|
@ -836,6 +842,17 @@ public class DeviceInstanceController implements
|
|||
.map(AggregationData::values);
|
||||
}
|
||||
|
||||
//查询属性列表
|
||||
@PostMapping("/{deviceId:.+}/properties/_query/no-paging")
|
||||
@QueryAction
|
||||
@Operation(summary = "不分页查询设备的全部属性(一个属性为一列)",
|
||||
description = "设备使用列式存储模式才支持")
|
||||
public Flux<DeviceProperties> queryDevicePropertiesNoPaging(@PathVariable
|
||||
@Parameter(description = "设备ID") String deviceId,
|
||||
@RequestBody Mono<QueryParamEntity> entity) {
|
||||
return entity.flatMapMany(q -> deviceDataService.queryProperties(deviceId, q));
|
||||
}
|
||||
|
||||
//发送设备指令
|
||||
@PostMapping("/{deviceId:.+}/message")
|
||||
@SneakyThrows
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import lombok.Setter;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.hswebframework.reactor.excel.ReactorExcel;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.hswebframework.web.api.crud.entity.QueryOperation;
|
||||
import org.hswebframework.web.api.crud.entity.QueryParamEntity;
|
||||
import org.hswebframework.web.authorization.annotation.QueryAction;
|
||||
import org.hswebframework.web.authorization.annotation.Resource;
|
||||
import org.hswebframework.web.authorization.annotation.SaveAction;
|
||||
|
|
@ -20,6 +23,7 @@ import org.jetlinks.community.device.entity.DeviceProductEntity;
|
|||
import org.jetlinks.community.device.service.DeviceConfigMetadataManager;
|
||||
import org.jetlinks.community.device.service.LocalDeviceProductService;
|
||||
import org.jetlinks.community.device.service.data.DeviceDataService;
|
||||
import org.jetlinks.community.device.service.data.DeviceProperties;
|
||||
import org.jetlinks.community.device.web.excel.PropertyMetadataExcelInfo;
|
||||
import org.jetlinks.community.device.web.excel.PropertyMetadataWrapper;
|
||||
import org.jetlinks.community.device.web.request.AggRequest;
|
||||
|
|
@ -193,6 +197,17 @@ public class DeviceProductController implements ReactiveServiceCrudController<De
|
|||
.map(AggregationData::values);
|
||||
}
|
||||
|
||||
//查询属性列表
|
||||
@PostMapping("/{productId}/properties/_query")
|
||||
@QueryAction
|
||||
@QueryOperation(summary = "查询设备的全部属性(一个属性为一列)",
|
||||
description = "产品使用列式存储模式才支持")
|
||||
public Mono<PagerResult<DeviceProperties>> queryDevicePropertiesAll(@PathVariable
|
||||
@Parameter(description = "产品ID") String productId,
|
||||
@RequestBody Mono<QueryParamEntity> entity) {
|
||||
return entity.flatMap(q -> deviceDataService.queryPropertiesPageByProduct(productId, q));
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
|
|
|
|||
Loading…
Reference in New Issue