From 902d9b98e7beb4dfbf040031433cbdc9d562664b Mon Sep 17 00:00:00 2001 From: Guoqs Date: Tue, 7 May 2024 12:02:39 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=8B=BF=E5=88=B0=E6=89=80=E6=9C=89?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8F=96=E5=87=BA=E6=9C=80=E5=90=8E=E4=B8=80?= =?UTF-8?q?=E6=9D=A1=E6=95=B0=E6=8D=AE=EF=BC=8C=E5=AF=B9=E6=AF=94=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PileBasicInfoServiceImpl.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index c9fff6116..d685bff81 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -560,6 +560,15 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { // 保存到redis String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + realTimeMonitorData.getPileConnectorCode() + "_" + realTimeMonitorData.getTransactionCode(); + // 设置过期时间 + try { + if (redisCache.getExpire(redisKey) < 0) { + redisCache.expire(redisKey, CacheConstants.cache_expire_time_1d); + } + } catch (Exception e) { + log.info("设置过期时间error", e); + } + // 拿到所有数据取出最后一条数据,对比数据变化 Map map = redisCache.hmget(redisKey); if (map != null && !map.isEmpty()) { @@ -594,15 +603,6 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { // 上传实时数据每10秒发送一次,1分钟6次,在同一分钟内,只保留最后一条实时数据 redisCache.hset(redisKey, DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", now), jsonMsg); - try { - // 设置过期时间 - if (redisCache.getExpire(redisKey) < 0) { - redisCache.expire(redisKey, CacheConstants.cache_expire_time_1d); - } - } catch (Exception e) { - log.info("设置过期时间error", e); - } - // 把充电桩正在充电中的状态存到redis String pileIsChargingKey = CacheConstants.PILE_IS_CHARGING + realTimeMonitorData.getPileConnectorCode(); redisCache.setCacheObject(pileIsChargingKey, realTimeMonitorData.getTransactionCode(), 20);