通过桩sn号查询计费模板 加缓存

This commit is contained in:
Guoqs
2024-11-21 14:28:39 +08:00
parent b011f640f7
commit 61a66d43b2
3 changed files with 23 additions and 1 deletions

View File

@@ -635,6 +635,14 @@ public class SpringBootTestController {
// memberAdapayRecordService.unfreezeAmountAndUpdateSpendAmount("test01", payAmount, refundAmt);
}
@Test
public void selectBillingTemplateDetailByPileSnTest() {
String pileSn = "88000000000001";
// 查询充电桩的计费模板
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
System.out.println(JSON.toJSONString(billingTemplateVO));
}
// 生成订单
private OrderBasicInfo generateAnOrder() throws ParseException {
GenerateOrderDTO dto = new GenerateOrderDTO();

View File

@@ -344,4 +344,9 @@ public class CacheConstants {
* 验证码有效期时长 redis key
*/
public static final String SMS_VERIFICATION_CODE_KEY = "sms_verification_code:";
/**
* 根据桩号查询计费模板
*/
public static final String BILLING_TEMPLATE_BY_PILE_SN = "billing_template_by_pile_sn:";
}

View File

@@ -839,7 +839,16 @@ public class PileBillingTemplateServiceImpl implements PileBillingTemplateServic
*/
@Override
public BillingTemplateVO selectBillingTemplateDetailByPileSn(String pileSn) {
return pileBillingTemplateMapper.selectBillingTemplateByPileSn(pileSn);
String redisKey = CacheConstants.BILLING_TEMPLATE_BY_PILE_SN + pileSn;
Object cacheObject = redisCache.getCacheObject(redisKey);
if (cacheObject != null) {
return JSON.parseObject(cacheObject.toString(), BillingTemplateVO.class);
}
BillingTemplateVO billingTemplateVO = pileBillingTemplateMapper.selectBillingTemplateByPileSn(pileSn);
if (billingTemplateVO != null) {
redisCache.setCacheObject(redisKey, JSON.toJSONString(billingTemplateVO), CacheConstants.cache_expire_time_1d);
}
return billingTemplateVO;
}
@Override