mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增 0x25报文数据存入缓存方法
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.jsowell.pile.service;
|
||||
|
||||
import com.jsowell.common.core.domain.ykc.BMSChargeInfoData;
|
||||
import com.jsowell.common.core.domain.ykc.BMSDemandAndChargerOutputData;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
@@ -158,6 +159,12 @@ public interface PileBasicInfoService {
|
||||
*/
|
||||
void saveBMSDemandAndChargerOutputInfo2Redis(BMSDemandAndChargerOutputData bmsDemandAndChargerOutputData);
|
||||
|
||||
/**
|
||||
* 0x25数据保存到redis
|
||||
* @param bmsChargeInfoData
|
||||
*/
|
||||
void saveBMSChargeInfo2Redis(BMSChargeInfoData bmsChargeInfoData);
|
||||
|
||||
/**
|
||||
* 根据交易流水号查询0x23数据(时间倒序)
|
||||
* @param transactionCode
|
||||
|
||||
@@ -7,10 +7,7 @@ import com.jsowell.common.YouDianUtils;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||
import com.jsowell.common.core.domain.ykc.BMSDemandAndChargerOutputData;
|
||||
import com.jsowell.common.core.domain.ykc.GroundLockData;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.core.domain.ykc.*;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.DelFlagEnum;
|
||||
import com.jsowell.common.enums.lianlian.LianLianPileStatusEnum;
|
||||
@@ -674,7 +671,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
||||
return;
|
||||
}
|
||||
// 保存到redis
|
||||
String redisKey = CacheConstants.BMS_CHARGE_INFO_BY_TRANSACTION_CODE + data.getTransactionCode();
|
||||
String redisKey = CacheConstants.BMS_DEMAND_AND_CHARGER_OUTPUT_BY_TRANSACTION_CODE + data.getTransactionCode();
|
||||
// 设置接收到实时数据的时间
|
||||
Date now = new Date();
|
||||
data.setDateTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now));
|
||||
@@ -697,6 +694,33 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 0x25数据保存到redis
|
||||
* @param bmsChargeInfoData
|
||||
*/
|
||||
@Override
|
||||
public void saveBMSChargeInfo2Redis(BMSChargeInfoData bmsChargeInfoData) {
|
||||
if (StringUtils.equals(bmsChargeInfoData.getTransactionCode(), Constants.ILLEGAL_TRANSACTION_CODE)) {
|
||||
return;
|
||||
}
|
||||
// 保存到redis
|
||||
String redisKey = CacheConstants.BMS_CHARGE_INFO_BY_TRANSACTION_CODE + bmsChargeInfoData.getTransactionCode();
|
||||
// 设置接收到实时数据的时间
|
||||
Date now = new Date();
|
||||
bmsChargeInfoData.setDateTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now));
|
||||
// 保存json字符串
|
||||
String jsonMsg = JSON.toJSONString(bmsChargeInfoData);
|
||||
// 0x25数据20秒发送一次,1分钟3次,在同一分钟内,只保留最后一条实时数据
|
||||
redisCache.hset(redisKey, DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", now), jsonMsg);
|
||||
|
||||
// 设置过期时间
|
||||
try {
|
||||
redisCache.expire(redisKey, CacheConstants.cache_expire_time_3d);
|
||||
} catch (Exception e) {
|
||||
log.info("0x25存入缓存设置过期时间error", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据交易流水号查询0x23数据(时间倒序)
|
||||
* @param transactionCode
|
||||
@@ -708,7 +732,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
||||
if (StringUtils.isBlank(transactionCode)) {
|
||||
return resultList;
|
||||
}
|
||||
String redisKey = CacheConstants.BMS_CHARGE_INFO_BY_TRANSACTION_CODE + transactionCode;
|
||||
String redisKey = CacheConstants.BMS_DEMAND_AND_CHARGER_OUTPUT_BY_TRANSACTION_CODE + transactionCode;
|
||||
// 拿到所有数据
|
||||
Map<Object, Object> map = redisCache.hmget(redisKey);
|
||||
if (map != null && !map.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user