|
@@ -94,7 +94,9 @@ public class ThreadTask implements Runnable{
|
|
//deviceType为表名
|
|
//deviceType为表名
|
|
//time为当前数据time的纳秒时间戳,已经做过整点处理了
|
|
//time为当前数据time的纳秒时间戳,已经做过整点处理了
|
|
Point pointNanos = createPointFromJson(deviceType,jsonObject,params);
|
|
Point pointNanos = createPointFromJson(deviceType,jsonObject,params);
|
|
- KprDangyangWaterBizFun.infulxDbUtil.insert(pointNanos);
|
|
|
|
|
|
+ if(pointNanos!=null) {
|
|
|
|
+ KprDangyangWaterBizFun.infulxDbUtil.insert(pointNanos);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}catch(Exception ex){
|
|
}catch(Exception ex){
|
|
@@ -105,7 +107,9 @@ public class ThreadTask implements Runnable{
|
|
public static Point createPointFromJson(String deviceType, JSONObject jsonObject,List<String> params) {
|
|
public static Point createPointFromJson(String deviceType, JSONObject jsonObject,List<String> params) {
|
|
// 获取时间戳
|
|
// 获取时间戳
|
|
long nanoTimestamp = convertToNanoTimestamp(jsonObject.getString("time"));
|
|
long nanoTimestamp = convertToNanoTimestamp(jsonObject.getString("time"));
|
|
-
|
|
|
|
|
|
+ if(nanoTimestamp==0L){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
// 创建 Point.Builder 对象
|
|
// 创建 Point.Builder 对象
|
|
Point.Builder pointBuilder = Point.measurement(KprBaseInitFun.getInstance().measurementMap.get(deviceType))
|
|
Point.Builder pointBuilder = Point.measurement(KprBaseInitFun.getInstance().measurementMap.get(deviceType))
|
|
.tag("dev_id",jsonObject.getString("deviceCode"))
|
|
.tag("dev_id",jsonObject.getString("deviceCode"))
|
|
@@ -199,6 +203,10 @@ public class ThreadTask implements Runnable{
|
|
Instant instant = zonedDateTime.toInstant();
|
|
Instant instant = zonedDateTime.toInstant();
|
|
// 计算从1970年1月1日00:00:00 UTC以来的纳秒数
|
|
// 计算从1970年1月1日00:00:00 UTC以来的纳秒数
|
|
long nanosecondsSinceEpoch = ChronoUnit.NANOS.between(Instant.EPOCH, instant);
|
|
long nanosecondsSinceEpoch = ChronoUnit.NANOS.between(Instant.EPOCH, instant);
|
|
|
|
+ long currentTimeNanos = System.currentTimeMillis() * 1_000_000L;
|
|
|
|
+ if(nanosecondsSinceEpoch>currentTimeNanos){
|
|
|
|
+ return 0L;
|
|
|
|
+ }
|
|
return nanosecondsSinceEpoch;
|
|
return nanosecondsSinceEpoch;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -210,6 +218,9 @@ public class ThreadTask implements Runnable{
|
|
|
|
|
|
// 计算最近的整分钟时间
|
|
// 计算最近的整分钟时间
|
|
Date roundedDate = getNearestTime(originalDate, collectionFrequency);
|
|
Date roundedDate = getNearestTime(originalDate, collectionFrequency);
|
|
|
|
+ if(roundedDate.after(new Date())){
|
|
|
|
+ System.out.println(1111);
|
|
|
|
+ }
|
|
|
|
|
|
// 格式化回字符串
|
|
// 格式化回字符串
|
|
String adjustedTimeStr = outputDateFormat.format(roundedDate);
|
|
String adjustedTimeStr = outputDateFormat.format(roundedDate);
|