通过桩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

@@ -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