From 7c94c57a494ff477c82012d9ad162c7f341d7cab Mon Sep 17 00:00:00 2001 From: gaoguangchao <443960933@qq.com> Date: Tue, 16 Jul 2024 18:27:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9REDIS=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/zc/business/task/DeviceOnlineTask.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/task/DeviceOnlineTask.java b/zc-business/src/main/java/com/zc/business/task/DeviceOnlineTask.java index f8b35257..ea98f764 100644 --- a/zc-business/src/main/java/com/zc/business/task/DeviceOnlineTask.java +++ b/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); } }