优化物模型拓展配置作用域
This commit is contained in:
parent
e0b9c4f170
commit
ac51b0f77c
|
|
@ -2,6 +2,7 @@ package org.jetlinks.community.device.service;
|
|||
|
||||
import org.jetlinks.community.device.spi.DeviceConfigMetadataSupplier;
|
||||
import org.jetlinks.core.metadata.ConfigMetadata;
|
||||
import org.jetlinks.core.metadata.ConfigScope;
|
||||
import org.jetlinks.core.metadata.DeviceConfigScope;
|
||||
import org.jetlinks.core.metadata.DeviceMetadataType;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
|
|
@ -54,10 +55,14 @@ public class DefaultDeviceConfigMetadataManager implements DeviceConfigMetadataM
|
|||
public Flux<ConfigMetadata> getMetadataExpandsConfig(String productId,
|
||||
DeviceMetadataType metadataType,
|
||||
String metadataId,
|
||||
String typeId) {
|
||||
String typeId,
|
||||
ConfigScope... scopes) {
|
||||
return Flux.fromIterable(suppliers)
|
||||
.flatMap(supplier -> supplier.getMetadataExpandsConfig(productId, metadataType, metadataId, typeId))
|
||||
.sort(Comparator.comparing(ConfigMetadata::getName));
|
||||
.sort(Comparator.comparing(ConfigMetadata::getName))
|
||||
.filter(metadata -> metadata.hasAnyScope(scopes))
|
||||
.map(metadata -> metadata.copy(scopes))
|
||||
.filter(meta -> org.apache.commons.collections4.CollectionUtils.isNotEmpty(meta.getProperties()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import org.jetlinks.community.device.spi.DeviceConfigMetadataSupplier;
|
|||
import org.jetlinks.core.message.codec.Transport;
|
||||
import org.jetlinks.core.metadata.ConfigMetadata;
|
||||
import org.jetlinks.core.metadata.ConfigPropertyMetadata;
|
||||
import org.jetlinks.core.metadata.ConfigScope;
|
||||
import org.jetlinks.core.metadata.DeviceMetadataType;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
|
|
@ -74,6 +75,7 @@ public interface DeviceConfigMetadataManager {
|
|||
Flux<ConfigMetadata> getMetadataExpandsConfig(String productId,
|
||||
DeviceMetadataType metadataType,
|
||||
String metadataId,
|
||||
String typeId);
|
||||
String typeId,
|
||||
ConfigScope... scopes);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,9 +47,7 @@ import org.jetlinks.core.message.DeviceMessage;
|
|||
import org.jetlinks.core.message.Message;
|
||||
import org.jetlinks.core.message.MessageType;
|
||||
import org.jetlinks.core.message.RepayableDeviceMessage;
|
||||
import org.jetlinks.core.metadata.ConfigMetadata;
|
||||
import org.jetlinks.core.metadata.ConfigPropertyMetadata;
|
||||
import org.jetlinks.core.metadata.DeviceMetadata;
|
||||
import org.jetlinks.core.metadata.*;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.data.util.Lazy;
|
||||
|
|
@ -133,6 +131,20 @@ public class DeviceInstanceController implements
|
|||
return metadataManager.getDeviceConfigMetadata(id);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id:.+}/config-metadata/{metadataType}/{metadataId}/{typeId}")
|
||||
@QueryAction
|
||||
@Operation(summary = "获取设备物模型的拓展配置定义")
|
||||
public Flux<ConfigMetadata> getExpandsConfigMetadata(@PathVariable @Parameter(description = "设备ID") String id,
|
||||
@PathVariable @Parameter(description = "物模型类型") DeviceMetadataType metadataType,
|
||||
@PathVariable @Parameter(description = "物模型ID") String metadataId,
|
||||
@PathVariable @Parameter(description = "类型ID") String typeId) {
|
||||
return service
|
||||
.findById(id)
|
||||
.flatMapMany(device -> metadataManager
|
||||
.getMetadataExpandsConfig(device.getProductId(), metadataType, metadataId, typeId, DeviceConfigScope.device));
|
||||
}
|
||||
|
||||
@GetMapping("/bind-providers")
|
||||
@QueryAction
|
||||
@Operation(summary = "获取支持的云云对接")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import org.jetlinks.community.device.service.data.DeviceDataStoragePolicy;
|
|||
import org.jetlinks.community.device.web.request.AggRequest;
|
||||
import org.jetlinks.community.timeseries.query.AggregationData;
|
||||
import org.jetlinks.core.metadata.ConfigMetadata;
|
||||
import org.jetlinks.core.metadata.DeviceConfigScope;
|
||||
import org.jetlinks.core.metadata.DeviceMetadataCodec;
|
||||
import org.jetlinks.core.metadata.DeviceMetadataType;
|
||||
import org.jetlinks.supports.official.JetLinksDeviceMetadataCodec;
|
||||
|
|
@ -80,7 +81,7 @@ public class DeviceProductController implements ReactiveServiceCrudController<De
|
|||
@PathVariable @Parameter(description = "物模型类型") DeviceMetadataType metadataType,
|
||||
@PathVariable @Parameter(description = "物模型ID") String metadataId,
|
||||
@PathVariable @Parameter(description = "类型ID") String typeId) {
|
||||
return configMetadataManager.getMetadataExpandsConfig(id, metadataType, metadataId, typeId);
|
||||
return configMetadataManager.getMetadataExpandsConfig(id, metadataType, metadataId, typeId, DeviceConfigScope.product);
|
||||
}
|
||||
|
||||
@GetMapping("/metadata/codecs")
|
||||
|
|
|
|||
Loading…
Reference in New Issue