From f35debd77cefdc3ee829425f0a42d3d7f459b16c Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 19 Aug 2021 15:36:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9A=82=E5=AD=98=20?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=A4=A7=E9=87=8F=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/constant/ServiceConstant.java | 4 +- .../tools/feign/CommonUserFeignClient.java | 26 +++++ .../CommonUserFeignClientFallBackFactory.java | 19 ++++ .../CommonUserFeignClientFallback.java | 23 ++++ .../epmet/commons/tools/redis/RedisKeys.java | 10 ++ .../redis/common/CustomerStaffRedis.java | 100 ++++++++++++++++++ .../common/bean/CustomerStaffInfoCache.java | 62 +++++++++++ .../redis/common/bean/StaffOrgsCache.java | 54 ++++++++++ .../result/CustomerStaffResultDTO.java | 63 +++++++++++ .../dataaggre/controller/DemoController.java | 9 ++ .../controller/EpmetUserController.java | 14 ++- .../service/epmetuser/EpmetUserService.java | 17 ++- .../epmetuser/impl/EpmetUserServiceImpl.java | 19 ++++ .../com/epmet/dto/CustomerStaffInfoDTO.java | 62 +++++++++++ .../main/java/com/epmet/dto/StaffOrgsDTO.java | 54 ++++++++++ .../java/com/epmet/redis/StaffInfoRedis.java | 75 +++++++++++++ 16 files changed, 600 insertions(+), 11 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallBackFactory.java create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/StaffOrgsCache.java create mode 100644 epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffInfoDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffOrgsDTO.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffInfoRedis.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java index e104c83e54..221d7d3f69 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java @@ -140,7 +140,7 @@ public interface ServiceConstant { String EPMET_POINT_SERVER = "epmet-point-server"; /** - * 开放接口服务 + * 聚合查询服务 */ - String EPMET_EXT_SERVER = "epmet-ext-server"; + String DATA_AGGREGATOR_SERVER = "data-aggregator-server"; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java new file mode 100644 index 0000000000..70b2a1abc5 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java @@ -0,0 +1,26 @@ +package com.epmet.commons.tools.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.feign.fallback.CommonUserFeignClientFallBackFactory; +import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache; +import com.epmet.commons.tools.utils.Result; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + + +/** + * @Description + * @Author sun + */ +@FeignClient(name = ServiceConstant.DATA_AGGREGATOR_SERVER, fallbackFactory = CommonUserFeignClientFallBackFactory.class) +public interface CommonUserFeignClient { + + /** + * desc:根据工作人员Id 获取工作人员信息 + * @param staffId + * @return + */ + @PostMapping("/data/aggregator/epmetuser/getStaffInfo/{staffId}") + Result getStaffInfo(@PathVariable("staffId") String staffId); +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallBackFactory.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallBackFactory.java new file mode 100644 index 0000000000..af8bd61954 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallBackFactory.java @@ -0,0 +1,19 @@ +package com.epmet.commons.tools.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.feign.CommonUserFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class CommonUserFeignClientFallBackFactory implements FallbackFactory { + private CommonUserFeignClientFallback fallback = new CommonUserFeignClientFallback(); + + @Override + public CommonUserFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java new file mode 100644 index 0000000000..7dca0b3552 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java @@ -0,0 +1,23 @@ +package com.epmet.commons.tools.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.feign.CommonUserFeignClient; +import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import org.springframework.stereotype.Component; + +/** + * 调用政府端权限 + * @Author wxz + * @Description + * @Date 2020/4/24 11:17 + **/ +@Component +public class CommonUserFeignClientFallback implements CommonUserFeignClient { + + @Override + public Result getStaffInfo(String staffId) { + return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "getStaffInfo", staffId); + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 046802e321..8f669a3656 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -490,4 +490,14 @@ public class RedisKeys { public static String getNoRepeatSubmitKey(String key) { return rootPrefix.concat("no_repeat_submit:").concat(key); } + + /** + * desc:根据工作人员Id 获取工作人员缓存key + * @param customerId + * @param staffId + * @return + */ + public static String getCustomerStaffInfoKey(String customerId, String staffId) { + return rootPrefix.concat(customerId).concat(StrConstant.COLON).concat(staffId); + } } 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 new file mode 100644 index 0000000000..f45e1b46f8 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java @@ -0,0 +1,100 @@ +/** + * 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.commons.tools.redis.common; + +import cn.hutool.core.bean.BeanUtil; +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.CommonUserFeignClient; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +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 CustomerStaffRedis { + @Autowired + private RedisUtils redisUtils; + @Autowired + private CommonUserFeignClient commonUserFeignClient; + + //@PostConstruct + public void init(){ + CustomerStaffInfoCache role = this.getRole("45687aa479955f9d06204d415238f7cc", "9e37adcce6472152e6508a19d3683e02"); + System.out.println(JSON.toJSONString(role)); + } + + /** + * @Description 查询工作人员的角色 + * @Param customerId + * @Param userId + * @author zxc + * @date 2021/6/15 3:20 下午 + */ + public CustomerStaffInfoCache getRole(String customerId, String staffId){ + String key = RedisKeys.getCustomerStaffInfoKey(customerId,staffId); + Map roleMap = redisUtils.hGetAll(key); + boolean empty = roleMap.isEmpty(); + if (!empty){ + CustomerStaffInfoCache result = ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoCache.class); + return result; + } + try { + Result staffResult = commonUserFeignClient.getStaffInfo(staffId); + if (staffResult == null || !staffResult.success()){ + throw new RenException("获取工作人员信息失败"); + } + if (staffResult.getData() == null){ + return null; + } + Map map = BeanUtil.beanToMap(staffResult.getData(), false, true); + redisUtils.hMSet(key,map); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * @Description 放入缓存角色 + * @Param customerId + * @Param userId + * @Param dto + * @author zxc + * @date 2021/6/15 4:01 下午 + */ + public void setRole(String customerId, String staffId, CustomerStaffInfoCache dto){ + String key = RedisKeys.getCustomerStaffInfoKey(customerId,staffId); + Map map = BeanUtil.beanToMap(dto, false, true); + redisUtils.hMSet(key, map,NOT_EXPIRE); + } + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java new file mode 100644 index 0000000000..63eaa7ccf0 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java @@ -0,0 +1,62 @@ +package com.epmet.commons.tools.redis.common.bean; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Author zxc + * @DateTime 2021/6/15 10:00 上午 + * @DESC + */ +@Data +public class CustomerStaffInfoCache implements Serializable { + + private static final long serialVersionUID = -4078910245000135305L; + /** + * 工作人员所属组织ID + */ + private String agencyId; + + /** + * 工作人员所属组织名称 + */ + private String agencyName; + + /** + * 工作人员ID + */ + private String staffId; + + /** + * 真实姓名 + */ + private String realName; + + /** + * 性别0.未知,1男,2.女 + */ + private Integer gender; + + /** + * 手机号-唯一键 + */ + private String mobile; + + /** + * 头像 + */ + private String headPhoto; + + /** + * 角色map key为角色key value 为角色名称 + */ + private Map roleMap; + + /** + * 工作人员所在网格及部门列表 + */ + private StaffOrgsCache orgInfo; + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/StaffOrgsCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/StaffOrgsCache.java new file mode 100644 index 0000000000..db790af859 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/StaffOrgsCache.java @@ -0,0 +1,54 @@ +/** + * 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.commons.tools.redis.common.bean; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * desc: 工作人员所属的组织关系 + * @date 2021/8/19 10:07 上午 + */ +@Data +public class StaffOrgsCache implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 所属组织的上级组织 + */ + private IdAndName parentAgency; + + /** + * 所属网格列表 + */ + private List gridList; + + /** + * 所属部门 + */ + private List deptList; + + @Data + class IdAndName { + private String id; + private String name; + } +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java new file mode 100644 index 0000000000..03f7f669be --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java @@ -0,0 +1,63 @@ +package com.epmet.dataaggre.dto.epmetuser.result; + +import com.epmet.commons.tools.redis.common.bean.StaffOrgsCache; +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Author zxc + * @DateTime 2021/6/15 10:00 上午 + * @DESC + */ +@Data +public class CustomerStaffResultDTO implements Serializable { + + private static final long serialVersionUID = 6989603307304337912L; + /** + * 工作人员所属组织ID + */ + private String agencyId; + + /** + * 工作人员所属组织名称 + */ + private String agencyName; + + /** + * 工作人员ID + */ + private String staffId; + + /** + * 真实姓名 + */ + private String realName; + + /** + * 性别0.未知,1男,2.女 + */ + private Integer gender; + + /** + * 手机号-唯一键 + */ + private String mobile; + + /** + * 头像 + */ + private String headPhoto; + + /** + * 角色map key为角色key value 为角色名称 + */ + private Map roleMap; + + /** + * 工作人员所在网格及部门列表 + */ + private StaffOrgsCache orgInfo; + +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DemoController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DemoController.java index b3300e3fb4..e8fb5e18e3 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DemoController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DemoController.java @@ -1,6 +1,8 @@ package com.epmet.dataaggre.controller; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.dataaggre.service.DemoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -17,7 +19,14 @@ public class DemoController { @GetMapping("doIt") public Result doIt() { demoService.doIt(); + + + CustomerStaffRedis bean = SpringContextUtils.getBean(CustomerStaffRedis.class); + bean.init(); + return new Result(); } + + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java index 52d33309e4..0dc3beadd6 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java @@ -13,10 +13,7 @@ import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.service.epmetuser.EpmetUserService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.HashMap; @@ -217,4 +214,13 @@ public class EpmetUserController { return new Result>().ok(epmetUserService.listStaff(formDTO)); } + /** + * 根据staffId查询用户基本信息 + * remark: + */ + @PostMapping("getStaffInfo/{staffId}") + public Result getStaffInfo(@PathVariable(name = "staffId") String staffId){ + return new Result().ok(epmetUserService.getStaffInfo(staffId)); + } + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java index add57d7886..b6eaaeb78c 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java @@ -47,7 +47,7 @@ public interface EpmetUserService { /** * 历史巡查日期查询 * @author zhaoqifeng - * @date 2021/6/10 14:36 + * @date 2021/6/10 14:36 * @param formDTO * @return com.epmet.dataaggre.dto.epmetuser.result.PatrolDateListResultDTO */ @@ -83,13 +83,13 @@ public interface EpmetUserService { * @Author sun **/ List getStaffRoleList(String customerId, String userId); - + /** * 我要报事-人大代表个人中心(尹) 是否显示@我,是否显示红点 - * - * @param userId + * + * @param userId * @return com.epmet.dataaggre.dto.epmetuser.result.UserEventLogoResultDTO - * @author yinzuomei + * @author yinzuomei * @date 2021/8/3 15:09 */ UserEventLogoResultDTO mentionMeEvent(String userId); @@ -100,4 +100,11 @@ public interface EpmetUserService { * @author sun */ List listStaff(ListStaffFormDTO formDTO); + + /** + * desc:根据工作人员Id 获取工作人员全部信息 + * @param staffId + * @return + */ + CustomerStaffResultDTO getStaffInfo(String staffId); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java index 3039f4a9c2..484810bcd5 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java @@ -1,7 +1,9 @@ package com.epmet.dataaggre.service.epmetuser.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.BadgeConstant; import com.epmet.dataaggre.constant.DataSourceConstant; @@ -14,6 +16,7 @@ import com.epmet.dataaggre.dto.epmetuser.result.*; import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO; import com.epmet.dataaggre.dto.govorg.CustomerGridDTO; import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO; +import com.epmet.dataaggre.entity.epmetuser.CustomerStaffEntity; import com.epmet.dataaggre.entity.epmetuser.ResiUserBadgeEntity; import com.epmet.dataaggre.service.epmetuser.EpmetUserService; import com.epmet.dataaggre.service.epmetuser.StaffPatrolDetailService; @@ -432,5 +435,21 @@ public class EpmetUserServiceImpl implements EpmetUserService { return null; } + @Override + public CustomerStaffResultDTO getStaffInfo(String staffId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CustomerStaffEntity::getUserId,staffId) + .eq(CustomerStaffEntity::getDelFlag,NumConstant.ZERO_STR); + CustomerStaffEntity staffEntity = customerStaffDao.selectOne(queryWrapper); + CustomerStaffResultDTO result = ConvertUtils.sourceToTarget(staffEntity, CustomerStaffResultDTO.class); + + //1.查询当前人员所属组织及下级所有网格列表数据,供后续封装数据使用 + /*List list = govOrgService.getGridList(staffId); + if (list.size() < NumConstant.ONE) { + return resultList; + }*/ + return result; + } + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffInfoDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffInfoDTO.java new file mode 100644 index 0000000000..3ec1fae999 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffInfoDTO.java @@ -0,0 +1,62 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Author zxc + * @DateTime 2021/6/15 10:00 上午 + * @DESC + */ +@Data +public class CustomerStaffInfoDTO implements Serializable { + + private static final long serialVersionUID = -4078910245000135305L; + /** + * 工作人员所属组织ID + */ + private String agencyId; + + /** + * 工作人员所属组织名称 + */ + private String agencyName; + + /** + * 工作人员ID + */ + private String staffId; + + /** + * 真实姓名 + */ + private String realName; + + /** + * 性别0.未知,1男,2.女 + */ + private Integer gender; + + /** + * 手机号-唯一键 + */ + private String mobile; + + /** + * 头像 + */ + private String headPhoto; + + /** + * 角色map key为角色key value 为角色名称 + */ + private Map roleMap; + + /** + * 工作人员所在网格及部门列表 + */ + private StaffOrgsDTO orgInfo; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffOrgsDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffOrgsDTO.java new file mode 100644 index 0000000000..ae9e0f7a9a --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffOrgsDTO.java @@ -0,0 +1,54 @@ +/** + * 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.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * desc: 工作人员所属的组织关系 + * @date 2021/8/19 10:07 上午 + */ +@Data +public class StaffOrgsDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 所属组织的上级组织 + */ + private IdAndName parentAgency; + + /** + * 所属网格列表 + */ + private List gridList; + + /** + * 所属部门 + */ + private List deptList; + + @Data + class IdAndName { + private String id; + private String name; + } +} 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 new file mode 100644 index 0000000000..cf3ae77dda --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffInfoRedis.java @@ -0,0 +1,75 @@ +/** + * 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); + } + +}