Browse Source

修改REDIS key

develop
gaoguangchao 4 months ago
parent
commit
7c94c57a49
  1. 7
      zc-business/src/main/java/com/zc/business/task/DeviceOnlineTask.java

7
zc-business/src/main/java/com/zc/business/task/DeviceOnlineTask.java

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

Loading…
Cancel
Save