update 更新桩清缓存

This commit is contained in:
2023-04-07 08:23:04 +08:00
parent 7a9c888125
commit 7c76a874a9
3 changed files with 35 additions and 39 deletions

View File

@@ -94,6 +94,16 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
return pileBasicInfoMapper.selectPileBasicInfoById(id);
}
/**
* 清除缓存
* @param pileSn
*/
private void cleanRedisCache(String pileSn) {
List<String> keys = Lists.newArrayList();
keys.add(CacheConstants.SELECT_PILE_BASIC_INFO_BY_SN + pileSn);
redisCache.deleteObject(keys);
}
@Override
public PileBasicInfo selectPileBasicInfoBySN(String pileSn) {
// 加缓存
@@ -143,8 +153,7 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
public int updatePileBasicInfo(PileBasicInfo pileBasicInfo) {
// pileBasicInfo.setUpdateBy(SecurityUtils.getUsername());
// 清缓存
String redisKey = CacheConstants.SELECT_PILE_BASIC_INFO_BY_SN + pileBasicInfo.getSn();
redisCache.deleteObject(redisKey);
cleanRedisCache(pileBasicInfo.getSn());
pileBasicInfo.setUpdateTime(DateUtils.getNowDate());
return pileBasicInfoMapper.updatePileBasicInfo(pileBasicInfo);
}
@@ -262,6 +271,7 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
*/
@Override
public int replaceMerchantStationByPileIds(ReplaceMerchantStationDTO dto) {
dto.setUpdateBy(SecurityUtils.getUsername());
dto.setUpdateTime(DateUtils.getNowDate());
int num = pileBasicInfoMapper.replaceMerchantStationByPileIds(dto);
@@ -271,6 +281,8 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
pileConnectorInfoService.deletePileConnectorInfoByPileSnList(dto.getPileSnList());
List<PileConnectorInfo> connectorInfoList = Lists.newArrayList();
for (String pileSn : dto.getPileSnList()) {
// 清缓存
cleanRedisCache(pileSn);
for (int i = 1; i < dto.getConnectorNum() + 1; i++) {
// 组装pile_connector_info表数据
PileConnectorInfo connectorInfo = new PileConnectorInfo();
@@ -358,38 +370,6 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
return pileInfoVOS;
}
/**
* 通过桩sn号查询站点id
*
* @param sn 桩sn号
* @return 站点id
*/
// @Override
// public String selectStationIdBySn(String sn) {
// return pileBasicInfoMapper.selectStationIdBySn(sn);
// }
/**
* uniApp通过桩号查询桩详情
*
* @param pileSn 桩号
* @return
*/
// @Override
// public PileDetailVO uniAppGetPileDetailByPileSn(String pileSn) {
// PileDetailVO pileDetailVO = pileBasicInfoMapper.uniAppGetPileDetailByPileSn(pileSn);
// // 查询计费模板
// BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
// if (Objects.nonNull(billingTemplateVO)) {
// pileDetailVO.setBillingTemplate(billingTemplateVO);
//
// }
// // 查询枪口相关信息
// List<ConnectorVO> connectorList = new ArrayList<>();
//
// return pileDetailVO;
// }
/**
* 修改状态
* 用于登陆协议,心跳包协议,上传实时数据协议 更新状态的方法
@@ -407,6 +387,8 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
*/
@Override
public void updateStatus(String frameType, String pileSn, String connectorCode, String status, String putGunType) {
// 清缓存
cleanRedisCache(pileSn);
// log.info("updateStatus传参帧类型:{}, 桩编号:{}, 枪口号:{}, 状态:{}, 插拔枪:{}", "0x" + frameType, pileSn, connectorCode, status, putGunType);
/*
0x01 登陆认证
@@ -530,6 +512,8 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
@Override
public void updatePileSimInfo(String pileSn, String iccid) {
// 清缓存
cleanRedisCache(pileSn);
PileBasicInfo basicInfo = selectPileBasicInfoBySN(pileSn);
if (basicInfo == null) {
return;