优化产品ID处理

This commit is contained in:
zhou-hao 2021-04-01 13:41:02 +08:00
parent 66a09c951c
commit 67c5e2c884
1 changed files with 6 additions and 3 deletions

View File

@ -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()