|
@ -230,20 +230,17 @@ public class DeviceOnlineTask { |
|
|
private void incrementSummary(OnlineLog onlineLog) { |
|
|
private void incrementSummary(OnlineLog onlineLog) { |
|
|
// 获取当天日期
|
|
|
// 获取当天日期
|
|
|
String date = DateUtils.format(new Date(), "yyyy-MM-dd"); |
|
|
String date = DateUtils.format(new Date(), "yyyy-MM-dd"); |
|
|
if(ObjectUtils.isEmpty(onlineLog) || ObjectUtils.isEmpty(onlineLog.getDeviceId())){ |
|
|
|
|
|
System.out.println("数据为空"); |
|
|
|
|
|
} |
|
|
|
|
|
long deviceId = onlineLog.getDeviceId(); |
|
|
long deviceId = onlineLog.getDeviceId(); |
|
|
OnlineSum onlineSum = redisCache.getCacheMapValue(RedisKeyConstants.DEVICE_ONLINE , date+":"+deviceId); |
|
|
OnlineSum onlineSum = redisCache.getCacheMapValue(RedisKeyConstants.DEVICE_ONLINE , date+":"+deviceId); |
|
|
if (ObjectUtils.isEmpty(onlineSum)){ |
|
|
if (ObjectUtils.isEmpty(onlineSum)){ |
|
|
onlineSum = new OnlineSum().copyFromLog(onlineLog); |
|
|
onlineSum = new OnlineSum().copyFromLog(onlineLog); |
|
|
redisCache.setCacheMapValue(RedisKeyConstants.DEVICE_ONLINE, date+onlineLog.getDeviceId(), onlineSum); |
|
|
redisCache.setCacheMapValue(RedisKeyConstants.DEVICE_ONLINE, date+":"+deviceId, onlineSum); |
|
|
Long ttl = redisCache.getExpire(RedisKeyConstants.DEVICE_ONLINE); |
|
|
Long ttl = redisCache.getExpire(RedisKeyConstants.DEVICE_ONLINE); |
|
|
if(ttl == -1) redisCache.expire(RedisKeyConstants.DEVICE_ONLINE,getTimeout()); |
|
|
if(ttl == -1) redisCache.expire(RedisKeyConstants.DEVICE_ONLINE,getTimeout()); |
|
|
}else { |
|
|
}else { |
|
|
//增量计算
|
|
|
//增量计算
|
|
|
onlineSum.incrementSummary(onlineLog); |
|
|
onlineSum.incrementSummary(onlineLog); |
|
|
redisCache.setCacheMapValue(RedisKeyConstants.DEVICE_ONLINE, date+onlineLog.getDeviceId(), onlineSum); |
|
|
redisCache.setCacheMapValue(RedisKeyConstants.DEVICE_ONLINE, date+":"+deviceId, onlineSum); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|