This commit is contained in:
2023-04-06 16:32:49 +08:00
5 changed files with 60 additions and 11 deletions

View File

@@ -16,8 +16,10 @@ import com.jsowell.pile.domain.PileBillingTemplate;
import com.jsowell.pile.dto.PublishBillingTemplateDTO;
import com.jsowell.pile.service.IPileBasicInfoService;
import com.jsowell.pile.service.IPileBillingTemplateService;
import com.jsowell.pile.service.IPileStationInfoService;
import com.jsowell.pile.vo.web.BillingTemplateVO;
import com.jsowell.pile.vo.web.PileDetailVO;
import com.jsowell.pile.vo.web.PileStationVO;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,6 +43,9 @@ public class PileRemoteService {
@Autowired
private YKCPushCommandService ykcPushCommandService;
@Autowired
private IPileStationInfoService pileStationInfoService;
/**
* 获取充电桩实时数据信息
*
@@ -108,9 +113,11 @@ public class PileRemoteService {
public void issueQRCode(String pileSn) {
IssueQRCodeCommand command = IssueQRCodeCommand.builder().pileSn(pileSn).build();
// 查询充电站info
ykcPushCommandService.pushIssueQRCodeCommand(command);
PileStationVO pileStationVO = pileStationInfoService.getStationInfoByPileSn(pileSn);
if (StringUtils.isNotBlank(pileStationVO.getQrcodePrefix())) {
command.setQrcodePrefix(pileStationVO.getQrcodePrefix());
ykcPushCommandService.pushIssueQRCodeCommand(command);
}
}
/**

View File

@@ -54,6 +54,16 @@ public class CacheConstants {
*/
public static final String PILE_CONNECTOR_STATUS_KEY = "pile_connector_status:";
/**
* 查询设备管理
*/
public static final String SELECT_PILE_BASIC_INFO_BY_SN = "select_pile_basic_info_by_sn:";
/**
* 查询站点信息
*/
public static final String SELECT_PILE_STATION_INFO_BY_ID = "select_pile_station_info_by_id:";
/**
* 充电桩sn生成 key
*/

View File

@@ -16,13 +16,11 @@ import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.YKCUtils;
import com.jsowell.netty.command.ykc.*;
import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService;
import com.jsowell.pile.service.IPileBasicInfoService;
import com.jsowell.pile.service.IPileBillingTemplateService;
import com.jsowell.pile.service.IPileConnectorInfoService;
import com.jsowell.pile.service.IPileModelInfoService;
import com.jsowell.pile.service.IPileMsgRecordService;
import com.jsowell.pile.domain.PileBasicInfo;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.web.BillingTemplateVO;
import com.jsowell.pile.vo.web.PileModelInfoVO;
import com.jsowell.pile.vo.web.PileStationVO;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
@@ -49,6 +47,9 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
@Autowired
private IPileBasicInfoService pileBasicInfoService;
@Autowired
private IPileStationInfoService pileStationInfoService;
@Autowired
private RedisCache redisCache;
@@ -226,7 +227,8 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
// String qrCodePrefix = pileBasicInfoService.getPileQrCodeUrl(null);
String qrCodePrefix = "";
if (StringUtils.isBlank(command.getQrcodePrefix())) {
qrCodePrefix = pileConnectorInfoService.getPileConnectorQrCodeUrl(null);
// 为空则给平台二维码前缀
qrCodePrefix = pileBasicInfoService.getPileQrCodeUrl(null);
}else {
qrCodePrefix = command.getQrcodePrefix();
}

View File

@@ -47,6 +47,7 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@@ -96,7 +97,16 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
@Override
public PileBasicInfo selectPileBasicInfoBySN(String pileSn) {
// 加缓存
return pileBasicInfoMapper.selectPileBasicInfoBySn(pileSn);
String redisKey = CacheConstants.SELECT_PILE_BASIC_INFO_BY_SN + pileSn;
PileBasicInfo pileBasicInfo = redisCache.getCacheObject(redisKey);
if (pileBasicInfo == null) {
// 查数据库
pileBasicInfo = pileBasicInfoMapper.selectPileBasicInfoBySn(pileSn);
if (pileBasicInfo != null) {
redisCache.setCacheObject(redisKey, pileBasicInfo, 5, TimeUnit.MINUTES);
}
}
return pileBasicInfo;
}
/**
@@ -132,6 +142,9 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
@Override
public int updatePileBasicInfo(PileBasicInfo pileBasicInfo) {
// pileBasicInfo.setUpdateBy(SecurityUtils.getUsername());
// 清缓存
String redisKey = CacheConstants.SELECT_PILE_BASIC_INFO_BY_SN + pileBasicInfo.getSn();
redisCache.deleteObject(redisKey);
pileBasicInfo.setUpdateTime(DateUtils.getNowDate());
return pileBasicInfoMapper.updatePileBasicInfo(pileBasicInfo);
}

View File

@@ -2,10 +2,12 @@ package com.jsowell.pile.service.impl;
import cn.hutool.core.util.PageUtil;
import com.google.common.collect.Lists;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.entity.SysDept;
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
import com.jsowell.common.core.page.PageResponse;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.DistanceUtils;
import com.jsowell.common.util.SecurityUtils;
@@ -34,6 +36,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@@ -63,6 +66,9 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
@Autowired
private IPileBasicInfoService pileBasicInfoService;
@Autowired
private RedisCache redisCache;
/**
* 查询充电站信息
*
@@ -71,7 +77,15 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
*/
@Override
public PileStationInfo selectPileStationInfoById(Long id) {
return pileStationInfoMapper.selectPileStationInfoById(id);
// 加缓存
String redisKey = CacheConstants.SELECT_PILE_STATION_INFO_BY_ID + id;
PileStationInfo pileStationInfo = redisCache.getCacheObject(redisKey);
if (pileStationInfo == null) {
// 查数据库
pileStationInfo = pileStationInfoMapper.selectPileStationInfoById(id);
redisCache.setCacheObject(redisKey, pileStationInfo, 5, TimeUnit.MINUTES);
}
return pileStationInfo;
}
/**
@@ -225,6 +239,9 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
*/
@Override
public int updatePileStationInfo(PileStationInfo pileStationInfo) {
// 清缓存
String redisKey = CacheConstants.SELECT_PILE_STATION_INFO_BY_ID + pileStationInfo.getId();
redisCache.deleteObject(redisKey);
pileStationInfo.setUpdateBy(SecurityUtils.getUsername());
pileStationInfo.setUpdateTime(DateUtils.getNowDate());
return pileStationInfoMapper.updatePileStationInfo(pileStationInfo);