diff --git a/jetlinks-components/jetlinks-components.iml b/jetlinks-components/jetlinks-components.iml index 78b2cc53..3cd3157f 100644 --- a/jetlinks-components/jetlinks-components.iml +++ b/jetlinks-components/jetlinks-components.iml @@ -1,2 +1,68 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jetlinks-components/network-component/mqtt-component/mqtt-component.iml b/jetlinks-components/network-component/mqtt-component/mqtt-component.iml index 78b2cc53..394f2a7c 100644 --- a/jetlinks-components/network-component/mqtt-component/mqtt-component.iml +++ b/jetlinks-components/network-component/mqtt-component/mqtt-component.iml @@ -1,2 +1,170 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jetlinks-components/network-component/network-component.iml b/jetlinks-components/network-component/network-component.iml index 78b2cc53..3cd3157f 100644 --- a/jetlinks-components/network-component/network-component.iml +++ b/jetlinks-components/network-component/network-component.iml @@ -1,2 +1,68 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jetlinks-components/network-component/network-core/network-core.iml b/jetlinks-components/network-component/network-core/network-core.iml index 78b2cc53..fef5d711 100644 --- a/jetlinks-components/network-component/network-core/network-core.iml +++ b/jetlinks-components/network-component/network-core/network-core.iml @@ -1,2 +1,164 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/DeviceMessageController.java b/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/DeviceMessageController.java index 8d31b6a5..2a1b6e2b 100644 --- a/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/DeviceMessageController.java +++ b/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/DeviceMessageController.java @@ -4,6 +4,7 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.hswebframework.web.exception.NotFoundException; import org.hswebframework.web.id.IDGenerator; +import org.jetlinks.community.device.entity.excel.ESDevicePropertiesEntity; import org.jetlinks.core.device.DeviceOperator; import org.jetlinks.core.device.DeviceRegistry; import org.jetlinks.core.message.FunctionInvokeMessageSender; @@ -14,6 +15,8 @@ import org.jetlinks.core.message.property.ReadPropertyMessageReply; import org.jetlinks.core.message.property.WritePropertyMessageReply; import org.jetlinks.community.gateway.MessageGateway; import org.jetlinks.community.gateway.TopicMessage; +import org.jetlinks.core.metadata.PropertyMetadata; +import org.jetlinks.core.metadata.types.StringType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; @@ -79,6 +82,40 @@ public class DeviceMessageController { } + //获取标准设备属性 + @GetMapping("/standard/{deviceId}/property/{property:.+}") + @SneakyThrows + public Mono getStandardProperty(@PathVariable String deviceId, @PathVariable String property) { + return Mono.from(registry + .getDevice(deviceId) + .switchIfEmpty(Mono.error(()->new NotFoundException("设备不存在"))) + .flatMapMany(deviceOperator -> deviceOperator.messageSender() + .readProperty(property).messageId(IDGenerator.SNOW_FLAKE_STRING.generate()) + .send() + .map(ReadPropertyMessageReply::getProperties) + .flatMap(map -> { + Object value = map.get(property); + return deviceOperator.getMetadata() + .map(deviceMetadata -> deviceMetadata.getProperty(property) + .map(PropertyMetadata::getValueType) + .orElse(new StringType())) + .map(dataType -> { + ESDevicePropertiesEntity entity = new ESDevicePropertiesEntity(); + if (value != null) { + entity.setDeviceId(deviceId); + entity.setProperty(property); + entity.setValue(value.toString()); + entity.setStringValue(value.toString()); + entity.setFormatValue(dataType.format(value).toString()); + + } + return entity; + }); + }))) + ; + + } + //设备功能调用 @PostMapping("invoked/{deviceId}/functionId/{functionId}") @SneakyThrows