From 38249c5586e6723352181846cd04a3633e875d76 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 19 Oct 2022 14:31:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E7=BB=84=E7=BB=87=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/redis/RedisKeys.java | 8 ++ .../redis/common/CustomerStaffRedis.java | 29 ++++ .../bean/CustomerStaffInfoDTOCache.java | 133 ++++++++++++++++++ .../yantai/DataSyncUserAndOrgServiceImpl.java | 14 +- .../epmet/feign/EpmetUserOpenFeignClient.java | 9 ++ .../EpmetUserOpenFeignClientFallback.java | 5 + .../controller/CustomerStaffController.java | 11 ++ .../java/com/epmet/dao/CustomerStaffDao.java | 2 + .../epmet/service/CustomerStaffService.java | 2 + .../impl/CustomerStaffServiceImpl.java | 19 +++ .../resources/mapper/CustomerStaffDao.xml | 6 + 11 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoDTOCache.java 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 c09f13f2f4..6d55e66238 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 @@ -533,6 +533,14 @@ public class RedisKeys { return rootPrefix.concat("gov:staff:").concat(customerId).concat(StrConstant.COLON).concat(staffId); } + public static String getCustomerAllStaffInfoKey(String customerId) { + return rootPrefix.concat("gov:allCustomerStaff:").concat(customerId).concat(StrConstant.COLON).concat("*"); + } + + public static String getCustomerStaffInfoKeyByMobile(String customerId,String mobile) { + return rootPrefix.concat("gov:allCustomerStaff:").concat(customerId).concat(StrConstant.COLON).concat(mobile); + } + /** * @description 网格信息 * 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 37904be02b..66abe790f3 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 @@ -9,6 +9,7 @@ import com.epmet.commons.tools.feign.CommonAggFeignClient; 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.redis.common.bean.CustomerStaffInfoDTOCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import lombok.extern.slf4j.Slf4j; @@ -138,4 +139,32 @@ public class CustomerStaffRedis { return customerStaffRedis.redisUtils.delete(key); } + /** + * Desc: 拉取烟台用户时使用。 + * 根据客户ID 手机号获取工作人员信息,没有返回null + * @param customerId + * @param mobile + * @author zxc + * @date 2022/10/19 14:18 + */ + public static CustomerStaffInfoDTOCache getStaffInfoByMobile(String customerId, String mobile){ + String key = RedisKeys.getCustomerStaffInfoKeyByMobile(customerId, mobile); + Map roleMap = customerStaffRedis.redisUtils.hGetAll(key); + if (!CollectionUtils.isEmpty(roleMap)) { + return ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoDTOCache.class); + } + return null; + } + + /** + * Desc: 【烟台用】删除所有工作人员信息 + * @param customerId + * @author zxc + * @date 2022/10/19 14:28 + */ + public static void delAllCustomerStaff(String customerId){ + String key = RedisKeys.getCustomerAllStaffInfoKey(customerId); + customerStaffRedis.redisUtils.deleteByPattern(key); + } + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoDTOCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoDTOCache.java new file mode 100644 index 0000000000..70d5da942a --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoDTOCache.java @@ -0,0 +1,133 @@ +package com.epmet.commons.tools.redis.common.bean; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Author zxc + * @DateTime 2022/10/19 14:26 + * @DESC + */ +@Data +public class CustomerStaffInfoDTOCache implements Serializable { + + private static final long serialVersionUID = 6967736754443092229L; + + + /** + * ID + */ + private String id; + + /** + * 关联User表的主键Id + */ + private String userId; + + /** + * 账户 + */ + private String userAccount; + + /** + * 真实姓名 + */ + private String realName; + + /** + * 性别0.未知,1男,2.女 + */ + private Integer gender; + + /** + * 邮箱 + */ + private String email; + + /** + * 手机号-唯一键 + */ + private String mobile; + + /** + * 地址 + */ + private String address; + + /** + * 删除标识 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * fulltime专职parttime兼职 + */ + private String workType; + + /** + * 头像 + */ + private String headPhoto; + + /** + * inactive未激活,active已激活 + */ + private String activeFlag; + + /** + * 激活时间 + */ + private Date activeTime; + + /** + * 未禁用enable,已禁用diabled + */ + private String enableFlag; + + /** + * 客户id + */ + private String customerId; + + /** + * 角色名称 + */ + private String roleName; + + /** + * 登录密码 + */ + private String password; + + /** + * 身份证号 + */ + private String idCard; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java index df431a925e..0eca37a078 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java @@ -1,7 +1,9 @@ package com.epmet.controller.yantai; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; 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.dao.yantai.DataSyncOrgDataDao; import com.epmet.dao.yantai.DataSyncUserDataDao; @@ -9,6 +11,7 @@ import com.epmet.dto.form.yantai.YtUserPageFormDTO; import com.epmet.dto.result.yantai.DataSyncOrgDataDTO; import com.epmet.dto.result.yantai.YtUserPageResDTO; import com.epmet.entity.yantai.DataSyncOrgDataEntity; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.DataSyncOrgDataService; import com.epmet.service.DataSyncUserDataService; import com.epmet.utils.OrgData; @@ -46,10 +49,19 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService private DataSyncOrgDataService dataSyncOrgDataService; @Autowired private DataSyncUserDataService dataSyncUserDataService; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + /** + * Desc: 从org表查询组织,在根据组织去查询用户 + * @param organizationId + * @author zxc + * @date 2022/10/19 13:27 + */ @Override public Boolean yanTaiSyncUser(String organizationId) { - List data = YantaiApi.getUserByOuGuid(organizationId); + epmetUserOpenFeignClient +// List data = YantaiApi.getUserByOuGuid(organizationId); //todo 更新或插入数据 return false; } 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 a2398b2d92..0137e8eb7c 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 @@ -924,4 +924,13 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/dataSyncConfig/natInfoScanTask") Result natInfoScanTask(@RequestBody NatInfoScanTaskFormDTO formDTO); + + /** + * Desc: 客户下所有工作人员放缓存 + * @param customerId + * @author zxc + * @date 2022/10/19 14:07 + */ + @PostMapping("/epmetuser/customerstaff/allCustomerStaffInCache") + Result allCustomerStaffInCache(@RequestParam("customerId")String customerId); } 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 4601ca1ef3..212252ab99 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 @@ -716,4 +716,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result natInfoScanTask(NatInfoScanTaskFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "natInfoScanTask", formDTO); } + + @Override + public Result allCustomerStaffInCache(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "allCustomerStaffInCache", customerId); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index 6c9d46dbb5..8bea2e4fbf 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -618,5 +618,16 @@ public class CustomerStaffController { return new Result>().ok(customerStaffService.customerStaff(formDTO)); } + /** + * Desc: 客户下所有工作人员放缓存 + * @param customerId + * @author zxc + * @date 2022/10/19 14:07 + */ + @PostMapping("allCustomerStaffInCache") + public Result allCustomerStaffInCache(@RequestParam("customerId")String customerId){ + customerStaffService.allCustomerStaffInCache(customerId); + return new Result(); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index 1c127d7aa5..682c279996 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -251,5 +251,7 @@ public interface CustomerStaffDao extends BaseDao { List getStaffByCustomerId(@Param("customerId") String customerId); + List getAllStaffByCustomerId(@Param("customerId") String customerId); + void edit(CustomerStaffDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java index b2a3442172..8c88c7680d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java @@ -398,4 +398,6 @@ public interface CustomerStaffService extends BaseService { void editToStaff(CustomerStaffDTO formDTO); List customerStaff(GridStaffUploadtFormDTO formDTO); + + void allCustomerStaffInCache(String customerId); } 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 54a44f35a5..657e590d64 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 @@ -17,6 +17,7 @@ package com.epmet.service.impl; +import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -1153,4 +1154,22 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl customerStaffs = baseDao.getAllStaffByCustomerId(customerId); + size = customerStaffs.size(); + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(customerStaffs)){ + customerStaffs.forEach(c -> { + String key = RedisKeys.getCustomerStaffInfoKeyByMobile(customerId, c.getMobile()); + Map map = BeanUtil.beanToMap(c, false, true); + redisUtils.hMSet(key,map); + }); + } + no++; + }while (size == NumConstant.ONE_HUNDRED); + } + } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index 60b32c4d32..88eca3f734 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -514,5 +514,11 @@ AND enable_flag = 'enable' AND customer_id = #{customerId} +