forked from rongchao/epmet-cloud-rizhao
13 changed files with 414 additions and 16 deletions
@ -0,0 +1,93 @@ |
|||
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.CommonAggFeignClient; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import com.epmet.commons.tools.redis.common.bean.*; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import javax.annotation.PostConstruct; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/11/5 2:29 下午 |
|||
* @DESC |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class CustomerOrgRedis { |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
@Autowired |
|||
private CommonAggFeignClient commonAggFeignClient; |
|||
|
|||
private static CustomerOrgRedis customerOrgRedis; |
|||
private static final String ROLE_MAP_KEY = "roleMap"; |
|||
|
|||
@PostConstruct |
|||
public void init() { |
|||
customerOrgRedis = this; |
|||
customerOrgRedis.redisUtils = this.redisUtils; |
|||
customerOrgRedis.commonAggFeignClient = this.commonAggFeignClient; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取网格信息 |
|||
* @param gridId |
|||
* @author zxc |
|||
* @date 2021/11/5 3:12 下午 |
|||
*/ |
|||
public static GridInfoCache getGridInfo(String gridId){ |
|||
String key = RedisKeys.getGridInfoKey(gridId); |
|||
Map<String, Object> grid = customerOrgRedis.redisUtils.hGetAll(key); |
|||
if (!CollectionUtils.isEmpty(grid)) { |
|||
return ConvertUtils.mapToEntity(grid, GridInfoCache.class); |
|||
} |
|||
Result<GridInfoCache> gridInfoResult = customerOrgRedis.commonAggFeignClient.getGridInfo(gridId); |
|||
if (!gridInfoResult.success()){ |
|||
throw new RenException("查询网格信息失败..."); |
|||
} |
|||
if (null == gridInfoResult.getData()){ |
|||
throw new RenException("没有此网格信息..."); |
|||
} |
|||
Map<String, Object> map = BeanUtil.beanToMap(gridInfoResult.getData(), false, true); |
|||
customerOrgRedis.redisUtils.hMSet(key, map); |
|||
return gridInfoResult.getData(); |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取组织信息 |
|||
* @param agencyId |
|||
* @author zxc |
|||
* @date 2021/11/5 3:12 下午 |
|||
*/ |
|||
public static AgencyInfoCache getAgencyInfo(String agencyId){ |
|||
String key = RedisKeys.getAgencyByIdKey(agencyId); |
|||
Map<String, Object> agency = customerOrgRedis.redisUtils.hGetAll(key); |
|||
if (!CollectionUtils.isEmpty(agency)) { |
|||
return ConvertUtils.mapToEntity(agency, AgencyInfoCache.class); |
|||
} |
|||
Result<AgencyInfoCache> agencyInfoResult = customerOrgRedis.commonAggFeignClient.getAgencyInfo(agencyId); |
|||
if (!agencyInfoResult.success()){ |
|||
throw new RenException("查询组织信息失败..."); |
|||
} |
|||
if (null == agencyInfoResult.getData()){ |
|||
throw new RenException("没有此组织信息..."); |
|||
} |
|||
Map<String, Object> map = BeanUtil.beanToMap(agencyInfoResult.getData(), false, true); |
|||
customerOrgRedis.redisUtils.hMSet(key, map); |
|||
return agencyInfoResult.getData(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,126 @@ |
|||
package com.epmet.commons.tools.redis.common.bean; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/11/5 2:45 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class AgencyInfoCache implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -1332373159954084159L; |
|||
|
|||
/** |
|||
* ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 上级组织机构ID |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 所有上级组织机构ID(以英文:隔开) |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 所有上级名称,以-连接 |
|||
*/ |
|||
private String allParentName; |
|||
|
|||
/** |
|||
* 组织名称 |
|||
*/ |
|||
private String organizationName; |
|||
|
|||
/** |
|||
* 机关级别(社区级:community, |
|||
乡(镇、街道)级:street, |
|||
区县级: district, |
|||
市级: city |
|||
省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province) |
|||
*/ |
|||
private String level; |
|||
|
|||
/** |
|||
* 地区编码 |
|||
*/ |
|||
private String areaCode; |
|||
|
|||
/** |
|||
* 删除标识 |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 总人数 |
|||
*/ |
|||
private Integer totalUser; |
|||
|
|||
/** |
|||
* 省 |
|||
*/ |
|||
private String province; |
|||
|
|||
/** |
|||
* 市 |
|||
*/ |
|||
private String city; |
|||
|
|||
/** |
|||
* 区县 |
|||
*/ |
|||
private String district; |
|||
|
|||
/** |
|||
* 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701 |
|||
*/ |
|||
private String parentAreaCode; |
|||
|
|||
/** |
|||
* 街道 |
|||
*/ |
|||
private String street; |
|||
|
|||
/** |
|||
* 社区 |
|||
*/ |
|||
private String community; |
|||
} |
@ -0,0 +1,111 @@ |
|||
package com.epmet.commons.tools.redis.common.bean; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/11/5 2:24 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class GridInfoCache implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -6159429894486235267L; |
|||
|
|||
|
|||
/** |
|||
* ID 唯一标识 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 网格名称 |
|||
*/ |
|||
private String gridName; |
|||
|
|||
/** 组织-网格 */ |
|||
private String gridNamePath; |
|||
|
|||
/** |
|||
* 中心位置经度 |
|||
*/ |
|||
private String longitude; |
|||
|
|||
/** |
|||
* 中心位置纬度 |
|||
*/ |
|||
private String latitude; |
|||
|
|||
/** |
|||
* 所属地区码(所属组织地区码) |
|||
*/ |
|||
private String areaCode; |
|||
|
|||
/** |
|||
* 删除标识:0.未删除 1.已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 管辖区域 |
|||
*/ |
|||
private String manageDistrict; |
|||
|
|||
/** |
|||
* 当前网格总人数 |
|||
*/ |
|||
private Integer totalUser; |
|||
|
|||
/** |
|||
* 所属组织机构ID(customer_organization.id) |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 所有上级组织ID |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 所属组织机构名 |
|||
*/ |
|||
private String agencyName; |
|||
|
|||
/** |
|||
* 所有上级组织名 |
|||
*/ |
|||
private String allParentName; |
|||
} |
Loading…
Reference in new issue