From 67c5e2c8847f125a820ddf9334cb1c0f77caea80 Mon Sep 17 00:00:00 2001 From: zhou-hao Date: Thu, 1 Apr 2021 13:41:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=A7=E5=93=81ID=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../official/JetLinksMqttDeviceMessageCodec.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jetlinks/protocol/official/JetLinksMqttDeviceMessageCodec.java b/src/main/java/org/jetlinks/protocol/official/JetLinksMqttDeviceMessageCodec.java index 7441d52..b6594f0 100644 --- a/src/main/java/org/jetlinks/protocol/official/JetLinksMqttDeviceMessageCodec.java +++ b/src/main/java/org/jetlinks/protocol/official/JetLinksMqttDeviceMessageCodec.java @@ -85,9 +85,12 @@ public class JetLinksMqttDeviceMessageCodec implements DeviceMessageCodec { if (convertResult == null) { return Mono.empty(); } - return context - .getDevice() - .getConfig(DeviceConfigKey.productId) + return Mono + .justOrEmpty(deviceMessage.getHeader("productId").map(String::valueOf)) + .switchIfEmpty(context.getDevice(deviceMessage.getDeviceId()) + .flatMap(device -> device + .getConfig(DeviceConfigKey.productId)) + ) .defaultIfEmpty("null") .map(productId -> SimpleMqttMessage .builder()