优化产品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) { if (convertResult == null) {
return Mono.empty(); return Mono.empty();
} }
return context return Mono
.getDevice() .justOrEmpty(deviceMessage.getHeader("productId").map(String::valueOf))
.getConfig(DeviceConfigKey.productId) .switchIfEmpty(context.getDevice(deviceMessage.getDeviceId())
.flatMap(device -> device
.getConfig(DeviceConfigKey.productId))
)
.defaultIfEmpty("null") .defaultIfEmpty("null")
.map(productId -> SimpleMqttMessage .map(productId -> SimpleMqttMessage
.builder() .builder()