Просмотр исходного кода

排查调用获取单个设备多指标实时数据(对内)接口调用查看时序数据库数据失败的问题,转换时间戳精度,改为毫秒级时间戳存储

james 3 месяцев назад
Родитель
Сommit
4def9ce901

+ 1 - 1
data-transfer/data-transfer-api/src/main/java/com/usky/transfer/domain/DeviceDataWriteVO.java

@@ -27,7 +27,7 @@ public class DeviceDataWriteVO implements Serializable {
     /**
      * 数据上报时间
      */
-    private long timestamp;
+    private Long timestamp;
 
     /**
      * 标签集合

+ 1 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/mqtt/datacollector/DataCollector.java

@@ -31,7 +31,7 @@ public class DataCollector implements MqttStrategy {
         Map<String, Object> fields = new HashMap<>();
         Map map_data = JsonUtils.fromJson(mqttBaseVO.getData().toString(), Map.class);
         String productCode = map_data.get("product_id").toString().toLowerCase();
-        Long timestamp = Long.valueOf(map_data.get("timestamp").toString()+"000");
+        long timestamp = Long.valueOf(map_data.get("timestamp").toString())*1000L+1L;
         String deviceId = map_data.get("device_id").toString();
 
         tags.put("device_id",deviceId);

+ 2 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/mqtt/info/Info.java

@@ -37,7 +37,8 @@ public class Info implements MqttStrategy {
         Map<String, Object> fields = new HashMap<>();
         Map map_data = JsonUtils.fromJson(mqttBaseVO.getData().toString(), Map.class);
         String productCode = map_data.get("productCode").toString().toLowerCase();
-        Long timestamp = Long.valueOf(map_data.get("timestamp").toString()+"000");
+
+        long timestamp = Long.valueOf(map_data.get("timestamp").toString());
 
         Object tg = JSONObject.toJSONString(map_data.get("tags"));
         JSONObject tag = JSON.parseObject(tg.toString());