Browse Source

代码暂存 避免大量冲突

dev_shibei_match
jianjun 4 years ago
parent
commit
f35debd77c
  1. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java
  2. 26
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java
  3. 19
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallBackFactory.java
  4. 23
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java
  5. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  6. 100
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java
  7. 62
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java
  8. 54
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/StaffOrgsCache.java
  9. 63
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java
  10. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DemoController.java
  11. 14
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java
  12. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  13. 19
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  14. 62
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffInfoDTO.java
  15. 54
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffOrgsDTO.java
  16. 75
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffInfoRedis.java

4
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";
}

26
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<CustomerStaffInfoCache> getStaffInfo(@PathVariable("staffId") String staffId);
}

19
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<CommonUserFeignClient> {
private CommonUserFeignClientFallback fallback = new CommonUserFeignClientFallback();
@Override
public CommonUserFeignClient create(Throwable cause) {
log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause)));
return fallback;
}
}

23
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<CustomerStaffInfoCache> getStaffInfo(String staffId) {
return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "getStaffInfo", staffId);
}
}

10
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);
}
}

100
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
* <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.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<String, Object> roleMap = redisUtils.hGetAll(key);
boolean empty = roleMap.isEmpty();
if (!empty){
CustomerStaffInfoCache result = ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoCache.class);
return result;
}
try {
Result<CustomerStaffInfoCache> staffResult = commonUserFeignClient.getStaffInfo(staffId);
if (staffResult == null || !staffResult.success()){
throw new RenException("获取工作人员信息失败");
}
if (staffResult.getData() == null){
return null;
}
Map<String, Object> 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<String, Object> map = BeanUtil.beanToMap(dto, false, true);
redisUtils.hMSet(key, map,NOT_EXPIRE);
}
}

62
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<String,String> roleMap;
/**
* 工作人员所在网格及部门列表
*/
private StaffOrgsCache orgInfo;
}

54
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
* <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.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<IdAndName> gridList;
/**
* 所属部门
*/
private List<IdAndName> deptList;
@Data
class IdAndName {
private String id;
private String name;
}
}

63
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<String,String> roleMap;
/**
* 工作人员所在网格及部门列表
*/
private StaffOrgsCache orgInfo;
}

9
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();
}
}

14
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<List<ListStaffResultDTO>>().ok(epmetUserService.listStaff(formDTO));
}
/**
* 根据staffId查询用户基本信息
* remark:
*/
@PostMapping("getStaffInfo/{staffId}")
public Result getStaffInfo(@PathVariable(name = "staffId") String staffId){
return new Result<CustomerStaffResultDTO>().ok(epmetUserService.getStaffInfo(staffId));
}
}

17
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<StaffRoleListResultDTO> 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<ListStaffResultDTO> listStaff(ListStaffFormDTO formDTO);
/**
* desc:根据工作人员Id 获取工作人员全部信息
* @param staffId
* @return
*/
CustomerStaffResultDTO getStaffInfo(String staffId);
}

19
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<CustomerStaffEntity> 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<CustomerGridDTO> list = govOrgService.getGridList(staffId);
if (list.size() < NumConstant.ONE) {
return resultList;
}*/
return result;
}
}

62
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<String,String> roleMap;
/**
* 工作人员所在网格及部门列表
*/
private StaffOrgsDTO orgInfo;
}

54
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffOrgsDTO.java

@ -0,0 +1,54 @@
/**
* 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.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<IdAndName> gridList;
/**
* 所属部门
*/
private List<IdAndName> deptList;
@Data
class IdAndName {
private String id;
private String name;
}
}

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

@ -0,0 +1,75 @@
/**
* 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);
}
}
Loading…
Cancel
Save