Browse Source

根组织缓存

master
zxc 3 years ago
parent
commit
38249c5586
  1. 8
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 29
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java
  3. 133
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoDTOCache.java
  4. 14
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java
  5. 9
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  6. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  7. 11
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java
  8. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java
  9. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java
  10. 19
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  11. 6
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

8
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); 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 网格信息 * @description 网格信息
* *

29
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.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache; 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.ConvertUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -138,4 +139,32 @@ public class CustomerStaffRedis {
return customerStaffRedis.redisUtils.delete(key); 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<String, Object> 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);
}
} }

133
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;
}

14
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; package com.epmet.controller.yantai;
import com.epmet.commons.tools.constant.NumConstant; 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.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.yantai.DataSyncOrgDataDao; import com.epmet.dao.yantai.DataSyncOrgDataDao;
import com.epmet.dao.yantai.DataSyncUserDataDao; 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.DataSyncOrgDataDTO;
import com.epmet.dto.result.yantai.YtUserPageResDTO; import com.epmet.dto.result.yantai.YtUserPageResDTO;
import com.epmet.entity.yantai.DataSyncOrgDataEntity; import com.epmet.entity.yantai.DataSyncOrgDataEntity;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.service.DataSyncOrgDataService; import com.epmet.service.DataSyncOrgDataService;
import com.epmet.service.DataSyncUserDataService; import com.epmet.service.DataSyncUserDataService;
import com.epmet.utils.OrgData; import com.epmet.utils.OrgData;
@ -46,10 +49,19 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService
private DataSyncOrgDataService dataSyncOrgDataService; private DataSyncOrgDataService dataSyncOrgDataService;
@Autowired @Autowired
private DataSyncUserDataService dataSyncUserDataService; private DataSyncUserDataService dataSyncUserDataService;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
/**
* Desc: 从org表查询组织在根据组织去查询用户
* @param organizationId
* @author zxc
* @date 2022/10/19 13:27
*/
@Override @Override
public Boolean yanTaiSyncUser(String organizationId) { public Boolean yanTaiSyncUser(String organizationId) {
List<UserData> data = YantaiApi.getUserByOuGuid(organizationId); epmetUserOpenFeignClient
// List<UserData> data = YantaiApi.getUserByOuGuid(organizationId);
//todo 更新或插入数据 //todo 更新或插入数据
return false; return false;
} }

9
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

@ -924,4 +924,13 @@ public interface EpmetUserOpenFeignClient {
@PostMapping("/epmetuser/dataSyncConfig/natInfoScanTask") @PostMapping("/epmetuser/dataSyncConfig/natInfoScanTask")
Result natInfoScanTask(@RequestBody NatInfoScanTaskFormDTO formDTO); 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);
} }

5
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) { public Result natInfoScanTask(NatInfoScanTaskFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "natInfoScanTask", 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);
}
} }

11
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java

@ -618,5 +618,16 @@ public class CustomerStaffController {
return new Result<List<GridStaffUploadResultDTO>>().ok(customerStaffService.customerStaff(formDTO)); return new Result<List<GridStaffUploadResultDTO>>().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();
}
} }

2
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java

@ -251,5 +251,7 @@ public interface CustomerStaffDao extends BaseDao<CustomerStaffEntity> {
List<GridStaffUploadResultDTO> getStaffByCustomerId(@Param("customerId") String customerId); List<GridStaffUploadResultDTO> getStaffByCustomerId(@Param("customerId") String customerId);
List<CustomerStaffDTO> getAllStaffByCustomerId(@Param("customerId") String customerId);
void edit(CustomerStaffDTO formDTO); void edit(CustomerStaffDTO formDTO);
} }

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java

@ -398,4 +398,6 @@ public interface CustomerStaffService extends BaseService<CustomerStaffEntity> {
void editToStaff(CustomerStaffDTO formDTO); void editToStaff(CustomerStaffDTO formDTO);
List<GridStaffUploadResultDTO> customerStaff(GridStaffUploadtFormDTO formDTO); List<GridStaffUploadResultDTO> customerStaff(GridStaffUploadtFormDTO formDTO);
void allCustomerStaffInCache(String customerId);
} }

19
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -1153,4 +1154,22 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
return baseDao.getStaffByCustomerId(formDTO.getCustomerId()); return baseDao.getStaffByCustomerId(formDTO.getCustomerId());
} }
@Override
public void allCustomerStaffInCache(String customerId) {
Integer no = NumConstant.ONE;
Integer size;
do {
List<CustomerStaffDTO> 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<String, Object> map = BeanUtil.beanToMap(c, false, true);
redisUtils.hMSet(key,map);
});
}
no++;
}while (size == NumConstant.ONE_HUNDRED);
}
} }

6
epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

@ -514,5 +514,11 @@
AND enable_flag = 'enable' AND enable_flag = 'enable'
AND customer_id = #{customerId} AND customer_id = #{customerId}
</select> </select>
<select id="getAllStaffByCustomerId" resultType="com.epmet.dto.CustomerStaffDTO">
select * FROM customer_staff
WHERE del_flag = '0'
AND enable_flag = 'enable'
AND customer_id = #{customerId}
</select>
</mapper> </mapper>

Loading…
Cancel
Save