From 6fc9cb85b091ecf909f3fa144005cc423ce084a3 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 20 Aug 2021 15:20:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../redis/common/CustomerStaffRedis.java | 33 ++++++- .../screen/impl/ScreenProjectServiceImpl.java | 16 ++-- .../epmet/feign/EpmetUserOpenFeignClient.java | 9 -- .../EpmetUserOpenFeignClientFallback.java | 5 -- .../epmet/controller/StaffRoleController.java | 25 ------ .../com/epmet/redis/CustomerStaffRedis.java | 47 ---------- .../java/com/epmet/redis/StaffInfoRedis.java | 75 ---------------- .../java/com/epmet/redis/StaffRoleRedis.java | 86 ------------------- .../com/epmet/service/StaffRoleService.java | 24 ++---- .../impl/CustomerStaffServiceImpl.java | 13 +-- .../service/impl/StaffRoleServiceImpl.java | 74 ++-------------- 11 files changed, 54 insertions(+), 353 deletions(-) delete mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerStaffRedis.java delete mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffInfoRedis.java delete mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java 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 af2d09cc09..3597b8e801 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 @@ -12,6 +12,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -31,12 +32,14 @@ public class CustomerStaffRedis { private RedisUtils redisUtils; @Autowired private CommonAggFeignClient commonAggFeignClient; + private static final String ROLE_MAP_KEY = "roleMap"; //@PostConstruct public void init() { CustomerStaffInfoCacheResult role = this.getStaffInfo("45687aa479955f9d06204d415238f7cc", "9e37adcce6472152e6508a19d3683e02"); role = this.getStaffInfo("45687aa479955f9d06204d415238f7cc", "7f694a66efe60a47c2114875f310248a"); System.out.println(JSON.toJSONString(role)); + System.out.println(JSON.toJSONString(this.getStaffRoleMap("45687aa479955f9d06204d415238f7cc", "7f694a66efe60a47c2114875f310248a"))); } /** @@ -56,6 +59,14 @@ public class CustomerStaffRedis { return ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoCacheResult.class); } + CustomerStaffInfoCache resultData = reloadStaffCache(staffId, key); + if (resultData == null) return null; + + return ConvertUtils.sourceToTarget(resultData,CustomerStaffInfoCacheResult.class); + } + + @Nullable + private CustomerStaffInfoCache reloadStaffCache(String staffId, String key) { Result staffResult = commonAggFeignClient.getStaffInfo(staffId); if (staffResult == null || !staffResult.success()) { throw new RenException("获取工作人员信息失败"); @@ -68,8 +79,28 @@ public class CustomerStaffRedis { Map map = BeanUtil.beanToMap(resultData, false, true); redisUtils.hMSet(key, map); + return resultData; + } - return ConvertUtils.sourceToTarget(resultData,CustomerStaffInfoCacheResult.class); + /** + * desc: 根据工作人员Id 获取某工作人员信息,如果缓存不存在则查询db返回;缓存默认一天 + * + * @param customerId + * @param staffId + * @return com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache + * @author LiuJanJun + * @date 2021/8/19 10:29 下午 + * @remark 此方法仅用于 获取某个工作人员的信息,不用于获取客户下所有工作人员信息 + */ + public Map getStaffRoleMap(String customerId, String staffId) { + String key = RedisKeys.getCustomerStaffInfoKey(customerId, staffId); + Map roleMap = (Map) redisUtils.hGet(key,ROLE_MAP_KEY); + if (!CollectionUtils.isEmpty(roleMap)) { + return roleMap; + } + + reloadStaffCache(staffId, key); + return getStaffRoleMap(customerId,staffId); } /** diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java index afd527d643..67e33d93be 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java @@ -2,6 +2,7 @@ package com.epmet.datareport.service.evaluationindex.screen.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.DataSourceConstant; @@ -10,7 +11,6 @@ import com.epmet.datareport.dao.evaluationindex.screen.ScreenEventImgDataDao; import com.epmet.datareport.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao; import com.epmet.datareport.dao.evaluationindex.screen.ScreenProjectDataDao; import com.epmet.datareport.service.evaluationindex.screen.ScreenProjectService; -import com.epmet.dto.CustomerAgencyUserRoleDTO; import com.epmet.dto.form.CustomerAgencyUserRoleFormDTO; import com.epmet.dto.form.screen.CategoryAnalysisFormDTO; import com.epmet.dto.form.screen.ColorProjectTotalFormDTO; @@ -56,7 +56,8 @@ public class ScreenProjectServiceImpl implements ScreenProjectService { private ScreenEventImgDataDao screenEventImgDataDao; @Autowired private ScreenProjectDataDao screenProjectDataDao; - + @Autowired + private CustomerStaffRedis staffRedis; @Autowired private ScreenProjectCategoryOrgDailyDao screenProjectCategoryOrgDailyDao; @Autowired @@ -117,14 +118,9 @@ public class ScreenProjectServiceImpl implements ScreenProjectService { CustomerAgencyUserRoleFormDTO userRoleFormDTO = new CustomerAgencyUserRoleFormDTO(); userRoleFormDTO.setCustomerId(formDTO.getCustomerId()); userRoleFormDTO.setStaffId(item.getReportUserId()); - - Result userRoles = userOpenFeignClient.getUserRoles(userRoleFormDTO); - if (userRoles != null && userRoles.success() && userRoles.getData() != null){ - Map roles = userRoles.getData().getRoles(); - - if (!CollectionUtils.isEmpty(roles)){ - item.setReportUserRoleSet(roles.keySet()); - } + Map staffRoleMap = staffRedis.getStaffRoleMap(formDTO.getCustomerId(), item.getReportUserId()); + if (!CollectionUtils.isEmpty(staffRoleMap)){ + item.setReportUserRoleSet(staffRoleMap.keySet()); } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 89c8a2ac36..da36b0d6bb 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -588,15 +588,6 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/staffpatrol/patroltrack") Result> patrolTrack(@RequestBody PatrolTrackFormDTO formDTO); - /** - * @Description 查询角色 - * @Param formDTO - * @author zxc - * @date 2021/6/15 3:03 下午 - */ - @PostMapping("/epmetuser/staffrole/getroles") - Result getUserRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO); - /** * 结束巡查 定时任务 * @author zhaoqifeng diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 01b2b63d57..b9f0264618 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -404,11 +404,6 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "patrolTrack", formDTO); } - @Override - public Result getUserRoles(CustomerAgencyUserRoleFormDTO formDTO) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserRoles", formDTO); - } - /** * 结束巡查 定时任务 * diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java index 949c104710..998c3eba7e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java @@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil; import com.epmet.commons.mybatis.entity.DataScope; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.CustomerAgencyUserRoleDTO; import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.StaffRoleDTO; import com.epmet.dto.form.*; @@ -183,30 +182,6 @@ public class StaffRoleController { return new Result>().ok(staffRoleService.staffGridRole(forms)); } - /** - * @Description 补全缓存 工作人员角色 - * @Param - * @author zxc - * @date 2021/6/15 2:05 下午 - */ - @PostMapping("repairstaffrolecache") - public Result repairStaffRoleCache(){ - staffRoleService.repairStaffRoleCache(); - return new Result(); - } - - /** - * @Description 查询角色 - * @Param formDTO - * @author zxc - * @date 2021/6/15 3:03 下午 - */ - @PostMapping("getroles") - public Result getUserRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO){ - ValidatorUtils.validateEntity(formDTO, CustomerAgencyUserRoleFormDTO.CustomerAgencyUserRoleForm.class); - return new Result().ok(staffRoleService.getUserRoles(formDTO)); - } - /** * 根据角色,查询里面的人,去重 * diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerStaffRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerStaffRedis.java deleted file mode 100644 index 0fb5b1b369..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerStaffRedis.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.redis; - -import com.epmet.commons.tools.redis.RedisUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * 政府工作人员表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-04-18 - */ -@Component -public class CustomerStaffRedis { - @Autowired - private RedisUtils redisUtils; - - public void delete(Object[] ids) { - - } - - public void set(){ - - } - - public String get(String id){ - return null; - } - -} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffInfoRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffInfoRedis.java deleted file mode 100644 index cf3ae77dda..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffInfoRedis.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.redis; - -import cn.hutool.core.bean.BeanUtil; -import com.epmet.commons.tools.redis.RedisKeys; -import com.epmet.commons.tools.redis.RedisUtils; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.dto.CustomerStaffInfoDTO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Map; - -import static com.epmet.commons.tools.redis.RedisUtils.NOT_EXPIRE; - -/** - * 工作人员-角色关系表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-04-22 - */ -@Component -public class StaffInfoRedis { - @Autowired - private RedisUtils redisUtils; - - /** - * @Description 查询工作人员的角色 - * @Param customerId - * @Param userId - * @author zxc - * @date 2021/6/15 3:20 下午 - */ - public CustomerStaffInfoDTO getRole(String customerId, String staffId){ - String key = RedisKeys.getCustomerStaffInfoKey(customerId,staffId); - Map roleMap = redisUtils.hGetAll(key); - boolean empty = roleMap.isEmpty(); - if (!empty){ - CustomerStaffInfoDTO result = ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoDTO.class); - return result; - } - return null; - } - - /** - * @Description 放入缓存角色 - * @Param customerId - * @Param userId - * @Param dto - * @author zxc - * @date 2021/6/15 4:01 下午 - */ - public void setRole(String customerId,String staffId,CustomerStaffInfoDTO dto){ - String key = RedisKeys.getCustomerStaffInfoKey(customerId,staffId); - Map map = BeanUtil.beanToMap(dto, false, true); - redisUtils.hMSet(key, map,NOT_EXPIRE); - } - -} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java deleted file mode 100644 index 2086c6c9e2..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.redis; - -import cn.hutool.core.bean.BeanUtil; -import com.epmet.commons.tools.redis.RedisUtils; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.dto.CustomerAgencyUserRoleDTO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Map; - -import static com.epmet.commons.tools.redis.RedisUtils.NOT_EXPIRE; - -/** - * 工作人员-角色关系表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-04-22 - */ -@Component -public class StaffRoleRedis { - @Autowired - private RedisUtils redisUtils; - - public void delete(Object[] ids) { - - } - - public void set(){ - - } - - public String get(String id){ - return null; - } - - /** - * @Description 查询工作人员的角色 - * @Param customerId - * @Param userId - * @author zxc - * @date 2021/6/15 3:20 下午 - */ - public CustomerAgencyUserRoleDTO getRole(String customerId, String userId){ - String key = "epmet:staffrole:"+customerId+":"+userId; - Map roleMap = redisUtils.hGetAll(key); - boolean empty = roleMap.isEmpty(); - if (!empty){ - CustomerAgencyUserRoleDTO result = ConvertUtils.mapToEntity(roleMap, CustomerAgencyUserRoleDTO.class); - return result; - } - return null; - } - - /** - * @Description 放入缓存角色 - * @Param customerId - * @Param userId - * @Param dto - * @author zxc - * @date 2021/6/15 4:01 下午 - */ - public void setRole(String customerId,String userId,CustomerAgencyUserRoleDTO dto){ - String key = "epmet:staffrole:"+customerId+":"+userId; - Map map = BeanUtil.beanToMap(dto, false, true); - redisUtils.hMSet(key, map,NOT_EXPIRE); - } - -} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java index 00879f88a4..e8737d7a0c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java @@ -21,9 +21,11 @@ import com.epmet.commons.mybatis.entity.DataScope; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerAgencyUserRoleDTO; import com.epmet.dto.StaffRoleDTO; -import com.epmet.dto.form.*; +import com.epmet.dto.form.CommonUserFormDTO; +import com.epmet.dto.form.CustomerStaffRoleListFormDTO; +import com.epmet.dto.form.RoleStaffIdFormDTO; +import com.epmet.dto.form.RolesUsersListFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.StaffRoleEntity; @@ -165,22 +167,6 @@ public interface StaffRoleService extends BaseService { */ List staffGridRole(List forms); - /** - * @Description 查询角色 - * @Param formDTO - * @author zxc - * @date 2021/6/15 3:03 下午 - */ - CustomerAgencyUserRoleDTO getUserRoles(CustomerAgencyUserRoleFormDTO formDTO); - - /** - * @Description 补全缓存 工作人员角色 - * @Param - * @author zxc - * @date 2021/6/15 2:05 下午 - */ - void repairStaffRoleCache(); - /** * 根据角色,查询里面的人,去重 * @@ -190,4 +176,4 @@ public interface StaffRoleService extends BaseService { * @date 2021/8/19 11:14 上午 */ Set queryRoleStaffIds(RoleStaffIdFormDTO formDTO); -} \ No newline at end of file +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 70962eaaa7..0333550df2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -18,7 +18,6 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.entity.DataScope; @@ -30,6 +29,7 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; @@ -51,14 +51,11 @@ import com.epmet.entity.UserEntity; import com.epmet.feign.AuthFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.OperCrmOpenFeignClient; -import com.epmet.redis.CustomerStaffRedis; -import com.epmet.redis.StaffRoleRedis; import com.epmet.service.CustomerStaffService; import com.epmet.service.GovStaffRoleService; import com.epmet.service.StaffRoleService; import com.epmet.service.UserService; import com.epmet.util.ModuleConstant; -import kotlin.jvm.internal.Lambda; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; @@ -83,8 +80,6 @@ import java.util.stream.Collectors; public class CustomerStaffServiceImpl extends BaseServiceImpl implements CustomerStaffService { private Logger logger = LogManager.getLogger(getClass()); @Autowired - private CustomerStaffRedis customerStaffRedis; - @Autowired private GovStaffRoleService govStaffRoleService; @Autowired private UserService userService; @@ -105,7 +100,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl page(Map params) { @@ -348,7 +343,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class)); } @@ -421,7 +416,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl implements StaffRoleService { @Autowired - private StaffRoleRedis staffRoleRedis; + private CustomerStaffRedis staffRedis; @Autowired private GovStaffRoleTemplateDao govStaffRoleTemplateDao; @@ -201,67 +202,6 @@ public class StaffRoleServiceImpl extends BaseServiceImpl rolesByDB = baseDao.getRolesByDB(staffId); - if (!CollectionUtils.isEmpty(rolesByDB)) { - CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO(); - dto.setStaffId(rolesByDB.get(NumConstant.ZERO).getStaffId()); - dto.setCustomerId(customerId); - dto.setAgencyId(rolesByDB.get(NumConstant.ZERO).getOrgId()); - Map map = new HashMap(16); - rolesByDB.forEach(l -> { - map.put(l.getRoleKey(), l.getRoleName()); - }); - dto.setRoles(map); - staffRoleRedis.setRole(customerId, staffId, dto); - return dto; - } - } - return null; - } - - /** - * @Description 补全缓存 工作人员角色 - * @Param - * @author zxc - * @date 2021/6/15 2:05 下午 - */ - @Override - public void repairStaffRoleCache() { - // 查询所有工作人员的角色 - List allRoles = baseDao.selectAllUserRoles(); - if (!CollectionUtils.isEmpty(allRoles)){ - // 根据 userId分组【staffId】 - Map> groupByStaff = allRoles.stream().collect(Collectors.groupingBy(RepairStaffRoleCacheResultDTO::getStaffId)); - groupByStaff.forEach((userId,list) -> { - CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO(); - String customerId = list.get(NumConstant.ZERO).getCustomerId(); - dto.setStaffId(list.get(NumConstant.ZERO).getStaffId()); - dto.setCustomerId(customerId); - dto.setAgencyId(list.get(NumConstant.ZERO).getOrgId()); - Map map = new HashMap(16); - list.forEach(l -> { - map.put(l.getRoleKey(), l.getRoleName()); - }); - dto.setRoles(map); - staffRoleRedis.setRole(customerId, userId, dto); - }); - } - } - /** * 根据角色,查询里面的人,去重 * @@ -278,4 +218,4 @@ public class StaffRoleServiceImpl extends BaseServiceImpl