diff --git a/src/main/java/cn/lihongjie/coal/dataCollector/listener/YbIotListener.java b/src/main/java/cn/lihongjie/coal/dataCollector/listener/YbIotListener.java index 27edb0d1..bacc06f7 100644 --- a/src/main/java/cn/lihongjie/coal/dataCollector/listener/YbIotListener.java +++ b/src/main/java/cn/lihongjie/coal/dataCollector/listener/YbIotListener.java @@ -15,6 +15,7 @@ import cn.lihongjie.coal.rabbitmq.RabbitMQConfiguration; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -98,7 +99,8 @@ public class YbIotListener { return; } - JsonNode jsonNode = objectMapper.readTree(body); + + ObjectNode jsonNode = objectMapper.readValue(objectMapper.readTree(body).asText(), ObjectNode.class); DataCollectorLogEntity logEntity = new DataCollectorLogEntity(); logEntity.setOrganizationId(dataCollector.getOrganizationId()); @@ -116,19 +118,19 @@ public class YbIotListener { JsonNode data = jsonNode.get("data"); if (code.asInt() != 200) { - log.error("ybiot code is not 200: {} {}", code, msg.asText()); + log.warn("ybiot code is not 200: {} {}", code, msg.asText()); return; } if (data == null) { - log.error("ybiot data is null"); + log.warn("ybiot data is null"); return; } JsonNode list = data.get("list"); if (list == null) { - log.error("ybiot list is null"); + log.warn("ybiot list is null"); return; } @@ -136,7 +138,7 @@ public class YbIotListener { List productIds = StreamSupport.stream(list.spliterator(), false) - .map(x -> x.get("ProductId").asText()) + .map(x -> x.get("ProductID").asText()) .toList(); List meters = meterService.findByProductIDs(productIds); @@ -152,7 +154,7 @@ public class YbIotListener { String productID = node.get("ProductID").asText(); if (StringUtils.isBlank(productID)) { - log.error("productID is blank"); + log.warn("productID is blank"); continue; } @@ -160,7 +162,7 @@ public class YbIotListener { if (!node.has("MeterPositiveFlow")) { - log.error("MeterPositiveFlow is null"); + log.warn("MeterPositiveFlow is null"); continue; } @@ -168,7 +170,7 @@ public class YbIotListener { if (!node.has("LastOnlineDate")) { - log.error("LastOnlineDate is null"); + log.warn("LastOnlineDate is null"); continue; } @@ -185,7 +187,7 @@ public class YbIotListener { MeterEntity meter = meterMap.get(productID); if (meter == null) { - log.error("meter not found: {}", productID); + log.warn("meter not found: {}", productID); continue; }