From 61a66d43b2b753e6eef954f117a4e95fd91ce07a Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Thu, 21 Nov 2024 14:28:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E6=A1=A9sn=E5=8F=B7=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=AE=A1=E8=B4=B9=E6=A8=A1=E6=9D=BF=20=E5=8A=A0?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/java/SpringBootTestController.java | 8 ++++++++ .../com/jsowell/common/constant/CacheConstants.java | 5 +++++ .../service/impl/PileBillingTemplateServiceImpl.java | 11 ++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index 98bc2258d..27ce2fa2c 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -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(); diff --git a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java index 10d374ee3..6d5c6822a 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java +++ b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java @@ -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:"; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java index 9b04e29a9..888c5b0da 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java @@ -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