Procházet zdrojové kódy

修复数据采集问题

lihui007 před 4 roky
rodič
revize
a71ba11740

+ 8 - 2
sms_water/src/main/java/com/huaxu/rabbitmq/ReceiveClearData.java

@@ -68,6 +68,7 @@ public class ReceiveClearData {
             log.debug("rabbitMq接收消息:"+new String(receivedData));
             receivedDataHandle(receivedData);
         } catch (Exception e) {
+            e.printStackTrace();
             log.error(ExceptionUtils.getStackTrace(e));
             // 发送异常时消息返回队列
 //            receiveDataRabbitTemplate.convertAndSend(rabbitmqQueue, receivedData);
@@ -79,7 +80,6 @@ public class ReceiveClearData {
         JSONObject jsonObject = JSONObject.parseObject(new String(receivedData));
         String eventTime      = jsonObject.getString("eventTime");
         String deviceCode     = jsonObject.getString("unitIdentifier");
-        log.info("【数据采集】deviceCode : {},时间: {}", deviceCode ,eventTime);
         // 对象有时间、有设备编码、有数据则解析,任何一个位空直接退出
         if (!jsonObject.containsKey("eventTime") || !jsonObject.containsKey("unitIdentifier") ||
                 !jsonObject.containsKey("parsedData")) {
@@ -107,7 +107,13 @@ public class ReceiveClearData {
             if (!receiveData.containsKey(monitorDataValueEntity.getIdentifier())) {
                 continue;
             }
-            BigDecimal bigDecimal = new BigDecimal(receiveData.getDouble(monitorDataValueEntity.getIdentifier()));
+            BigDecimal bigDecimal = null;
+            try {
+                bigDecimal = new BigDecimal(receiveData.getDouble(monitorDataValueEntity.getIdentifier()));
+            } catch (NumberFormatException e) {
+                log.error("double 转换 error ->", e);
+                continue;
+            }
             // 整数超过10位直接变更为0
             if (String.valueOf(bigDecimal.intValue()).length() > 10 ){
                 monitorDataValueEntity.setDataValue(0.0);