|
|
@ -20,6 +20,7 @@ package com.epmet.service.impl; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
@ -490,16 +491,53 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public CustomerAgencyDTO getAgencyById(String agencyId) { |
|
|
|
CustomerAgencyDTO cachedAgency = customerAgencyRedis.get(agencyId); |
|
|
|
if (cachedAgency == null) { |
|
|
|
cachedAgency = new CustomerAgencyDTO(); |
|
|
|
AgencyInfoCache agencyInfoCache = customerAgencyRedis.get(agencyId); |
|
|
|
if (agencyInfoCache == null) { |
|
|
|
agencyInfoCache = new AgencyInfoCache(); |
|
|
|
CustomerAgencyEntity agencyEntity = customerAgencyDao.selectById(agencyId); |
|
|
|
if (agencyEntity != null) { |
|
|
|
BeanUtils.copyProperties(agencyEntity, cachedAgency); |
|
|
|
//设置行政地区编码全路径
|
|
|
|
if (StringUtils.isNotBlank(agencyEntity.getAreaCode()) && StringUtils.isNotBlank(agencyEntity.getParentAreaCode())) { |
|
|
|
agencyInfoCache.setAreaCodePath(queryAreaCodePath(agencyEntity)); |
|
|
|
} |
|
|
|
BeanUtils.copyProperties(agencyEntity, agencyInfoCache); |
|
|
|
} |
|
|
|
customerAgencyRedis.set(agencyId, cachedAgency); |
|
|
|
customerAgencyRedis.set(agencyId, agencyInfoCache); |
|
|
|
} |
|
|
|
CustomerAgencyDTO customerAgencyDTO=ConvertUtils.sourceToTarget(agencyInfoCache,CustomerAgencyDTO.class); |
|
|
|
return customerAgencyDTO; |
|
|
|
} |
|
|
|
|
|
|
|
private List<String> queryAreaCodePath(CustomerAgencyEntity customerAgencyEntity) { |
|
|
|
List<String> areaCodePath = new ArrayList<>(); |
|
|
|
switch (customerAgencyEntity.getLevel()) { |
|
|
|
case Constant.COMMUNITY: |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.TWO)); |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.FOUR)); |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.SIX)); |
|
|
|
areaCodePath.add(customerAgencyEntity.getParentAreaCode()); |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode()); |
|
|
|
break; |
|
|
|
case Constant.STREET: |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.TWO)); |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.FOUR)); |
|
|
|
areaCodePath.add(customerAgencyEntity.getParentAreaCode()); |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode()); |
|
|
|
break; |
|
|
|
case Constant.DISTRICT: |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.TWO)); |
|
|
|
areaCodePath.add(customerAgencyEntity.getParentAreaCode()); |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode()); |
|
|
|
break; |
|
|
|
case Constant.CITY: |
|
|
|
areaCodePath.add(customerAgencyEntity.getParentAreaCode()); |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode()); |
|
|
|
break; |
|
|
|
case Constant.PROVINCE: |
|
|
|
areaCodePath.add(customerAgencyEntity.getAreaCode()); |
|
|
|
break; |
|
|
|
} |
|
|
|
return cachedAgency; |
|
|
|
return areaCodePath; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|