From 3521a1aaec2ffc16eb6600ed0aa266359f8edfff Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 27 Aug 2021 16:13:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../redis/common/CustomerStaffRedis.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java index 831d2f177d..509b12339f 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java @@ -2,6 +2,7 @@ package com.epmet.commons.tools.redis.common; import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.CommonAggFeignClient; @@ -102,14 +103,17 @@ public class CustomerStaffRedis { * @param staffId */ public static Map getStaffRoleMap(String customerId, String staffId) { - String key = RedisKeys.getCustomerStaffInfoKey(customerId, staffId); - Map roleMap = (Map) customerStaffRedis.redisUtils.hGet(key, ROLE_MAP_KEY); - if (!CollectionUtils.isEmpty(roleMap)) { - return roleMap; - } - - reloadStaffCache(staffId, key); - return getStaffRoleMap(customerId, staffId); + int retryTime = 0; + do { + String key = RedisKeys.getCustomerStaffInfoKey(customerId, staffId); + Map roleMap = (Map) customerStaffRedis.redisUtils.hGet(key, ROLE_MAP_KEY); + if (!CollectionUtils.isEmpty(roleMap)) { + return roleMap; + } + retryTime++; + reloadStaffCache(staffId, key); + } while (retryTime < NumConstant.TWO); + return null; } /**