Browse Source

删除无用方法

dev_shibei_match
jianjun 4 years ago
parent
commit
6fc9cb85b0
  1. 33
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java
  2. 16
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java
  3. 9
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  4. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  5. 25
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java
  6. 47
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerStaffRedis.java
  7. 75
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffInfoRedis.java
  8. 86
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java
  9. 24
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java
  10. 13
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  11. 74
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java

33
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<CustomerStaffInfoCache> staffResult = commonAggFeignClient.getStaffInfo(staffId);
if (staffResult == null || !staffResult.success()) {
throw new RenException("获取工作人员信息失败");
@ -68,8 +79,28 @@ public class CustomerStaffRedis {
Map<String, Object> 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<String,String> getStaffRoleMap(String customerId, String staffId) {
String key = RedisKeys.getCustomerStaffInfoKey(customerId, staffId);
Map<String, String> roleMap = (Map<String, String>) redisUtils.hGet(key,ROLE_MAP_KEY);
if (!CollectionUtils.isEmpty(roleMap)) {
return roleMap;
}
reloadStaffCache(staffId, key);
return getStaffRoleMap(customerId,staffId);
}
/**

16
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<CustomerAgencyUserRoleDTO> userRoles = userOpenFeignClient.getUserRoles(userRoleFormDTO);
if (userRoles != null && userRoles.success() && userRoles.getData() != null){
Map<String,String> roles = userRoles.getData().getRoles();
if (!CollectionUtils.isEmpty(roles)){
item.setReportUserRoleSet(roles.keySet());
}
Map<String, String> staffRoleMap = staffRedis.getStaffRoleMap(formDTO.getCustomerId(), item.getReportUserId());
if (!CollectionUtils.isEmpty(staffRoleMap)){
item.setReportUserRoleSet(staffRoleMap.keySet());
}
}

9
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<List<PatrolTrackResultDTO>> patrolTrack(@RequestBody PatrolTrackFormDTO formDTO);
/**
* @Description 查询角色
* @Param formDTO
* @author zxc
* @date 2021/6/15 3:03 下午
*/
@PostMapping("/epmetuser/staffrole/getroles")
Result<CustomerAgencyUserRoleDTO> getUserRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO);
/**
* 结束巡查 定时任务
* @author zhaoqifeng

5
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<CustomerAgencyUserRoleDTO> getUserRoles(CustomerAgencyUserRoleFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserRoles", formDTO);
}
/**
* 结束巡查 定时任务
*

25
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<List<GridStaffResultDTO>>().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<CustomerAgencyUserRoleDTO> getUserRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, CustomerAgencyUserRoleFormDTO.CustomerAgencyUserRoleForm.class);
return new Result<CustomerAgencyUserRoleDTO>().ok(staffRoleService.getUserRoles(formDTO));
}
/**
* 根据角色查询里面的人去重
*

47
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerStaffRedis.java

@ -1,47 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}

75
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffInfoRedis.java

@ -1,75 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<String, Object> 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<String, Object> map = BeanUtil.beanToMap(dto, false, true);
redisUtils.hMSet(key, map,NOT_EXPIRE);
}
}

86
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java

@ -1,86 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<String, Object> 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<String, Object> map = BeanUtil.beanToMap(dto, false, true);
redisUtils.hMSet(key, map,NOT_EXPIRE);
}
}

24
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<StaffRoleEntity> {
*/
List<GridStaffResultDTO> staffGridRole(List<GridStaffResultDTO> 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<StaffRoleEntity> {
* @date 2021/8/19 11:14 上午
*/
Set<String> queryRoleStaffIds(RoleStaffIdFormDTO formDTO);
}
}

13
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<CustomerStaffDao, CustomerStaffEntity> 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<CustomerStaffDao,
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired
private StaffRoleRedis staffRoleRedis;
private CustomerStaffRedis staffRedis;
@Override
public PageData<CustomerStaffDTO> page(Map<String, Object> params) {
@ -348,7 +343,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
m.put(r.getRoleKey(),r.getRoleName());
});
dto.setRoles(m);
staffRoleRedis.setRole(dto.getCustomerId(), dto.getStaffId(),dto);
staffRedis.delStaffInfoFormCache(dto.getCustomerId(), dto.getStaffId());
return new Result<CustomerStaffDTO>().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class));
}
@ -421,7 +416,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
m.put(r.getRoleKey(),r.getRoleName());
});
dto.setRoles(m);
staffRoleRedis.setRole(dto.getCustomerId(), dto.getStaffId(),dto);
staffRedis.delStaffInfoFormCache(dto.getCustomerId(), dto.getStaffId());
return new Result();
}

74
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java

@ -24,16 +24,18 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData;
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.dao.GovStaffRoleTemplateDao;
import com.epmet.dao.StaffRoleDao;
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;
import com.epmet.redis.StaffRoleRedis;
import com.epmet.service.StaffRoleService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,7 +44,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* 工作人员-角色关系表
@ -54,7 +55,7 @@ import java.util.stream.Collectors;
public class StaffRoleServiceImpl extends BaseServiceImpl<StaffRoleDao, StaffRoleEntity> implements StaffRoleService {
@Autowired
private StaffRoleRedis staffRoleRedis;
private CustomerStaffRedis staffRedis;
@Autowired
private GovStaffRoleTemplateDao govStaffRoleTemplateDao;
@ -201,67 +202,6 @@ public class StaffRoleServiceImpl extends BaseServiceImpl<StaffRoleDao, StaffRol
return result;
}
/**
* @Description 查询角色
* @Param formDTO
* @author zxc
* @date 2021/6/15 3:03 下午
*/
@Override
public CustomerAgencyUserRoleDTO getUserRoles(CustomerAgencyUserRoleFormDTO formDTO) {
String staffId = formDTO.getStaffId();
String customerId = formDTO.getCustomerId();
CustomerAgencyUserRoleDTO role = staffRoleRedis.getRole(customerId, staffId);
if (null != role){
return role;
}else {
List<RoleKeyValueResultDTO> 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<RepairStaffRoleCacheResultDTO> allRoles = baseDao.selectAllUserRoles();
if (!CollectionUtils.isEmpty(allRoles)){
// 根据 userId分组【staffId】
Map<String, List<RepairStaffRoleCacheResultDTO>> 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<StaffRoleDao, StaffRol
return baseDao.selectRoleStaffIds(formDTO.getCustomerId(),formDTO.getRoleIds());
}
}
}

Loading…
Cancel
Save