update 拿到所有数据取出最后一条数据,对比数据变化

This commit is contained in:
2024-05-07 12:02:39 +08:00
parent 9e26213b36
commit 902d9b98e7

View File

@@ -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<Object, Object> 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);