@@ -99,4 +99,14 @@ public interface RegionCacheHelper { | |||||
**/ | **/ | ||||
String getDisplayName(String regionCode, Integer regionLevel); | String getDisplayName(String regionCode, Integer regionLevel); | ||||
/** | |||||
* 获取用于前端回显示使用的unionList 仅用于返回前端的时候使用 | |||||
* | |||||
* @param code 区域编码 | |||||
* @param level 区域层级 | |||||
* @return | |||||
*/ | |||||
String getUnionPathStr(String code, Integer level); | |||||
} | } |
@@ -1,6 +1,5 @@ | |||||
package com.ningdatech.pmapi.common.helper.basic; | package com.ningdatech.pmapi.common.helper.basic; | ||||
import cn.hutool.core.lang.Assert; | |||||
import com.github.benmanes.caffeine.cache.Caffeine; | import com.github.benmanes.caffeine.cache.Caffeine; | ||||
import com.github.benmanes.caffeine.cache.LoadingCache; | import com.github.benmanes.caffeine.cache.LoadingCache; | ||||
import com.ningdatech.pmapi.common.model.RegionMapKey; | import com.ningdatech.pmapi.common.model.RegionMapKey; | ||||
@@ -28,10 +27,12 @@ import java.util.concurrent.TimeUnit; | |||||
@Slf4j | @Slf4j | ||||
public abstract class AbstractRegionCacheHelper implements InitializingBean { | public abstract class AbstractRegionCacheHelper implements InitializingBean { | ||||
private static final String PARENT_CODE_ROOT = "-1"; | |||||
@Autowired | @Autowired | ||||
private IRegionService regionService; | private IRegionService regionService; | ||||
private LoadingCache<RegionMapKey, RegionDTO> regionsCache; | |||||
protected LoadingCache<RegionMapKey, RegionDTO> regionsCache; | |||||
private void initRegionCache() { | private void initRegionCache() { | ||||
List<RegionDTO> allRegions = regionService.all(); | List<RegionDTO> allRegions = regionService.all(); | ||||
@@ -71,4 +72,7 @@ public abstract class AbstractRegionCacheHelper implements InitializingBean { | |||||
initRegionCache(); | initRegionCache(); | ||||
} | } | ||||
public String getParentCodeRoot() { | |||||
return PARENT_CODE_ROOT; | |||||
} | |||||
} | } |
@@ -185,4 +185,29 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements | |||||
.collect(Collectors.toList()); | .collect(Collectors.toList()); | ||||
} | } | ||||
@Override | |||||
public String getUnionPathStr(String code, Integer level) { | |||||
if (StringUtils.isBlank(code) || Objects.isNull(level)) { | |||||
return null; | |||||
} | |||||
List<String> unionPathStrList = new ArrayList<>(); | |||||
buildUnionPathStrList(code, level, unionPathStrList); | |||||
Collections.reverse(unionPathStrList); | |||||
if (CollectionUtils.isEmpty(unionPathStrList)) { | |||||
return null; | |||||
} | |||||
return String.join("@@", unionPathStrList); | |||||
} | |||||
protected void buildUnionPathStrList(String code, Integer level, List<String> unionPathStrList) { | |||||
if (level <= 0 || super.getParentCodeRoot().equals(code)) { | |||||
return; | |||||
} | |||||
RegionDTO regionDTO = getByCodeAndLevel(code, level); | |||||
unionPathStrList.add(regionDTO.getRegionCode() + "##" + regionDTO.getRegionName() + "##" + regionDTO.getRegionLevel()); | |||||
if (!super.getParentCodeRoot().equals(regionDTO.getParentCode())) { | |||||
buildUnionPathStrList(regionDTO.getParentCode(), level - 1, unionPathStrList); | |||||
} | |||||
} | |||||
} | } |
@@ -4,6 +4,7 @@ package com.ningdatech.pmapi.expert.assembler; | |||||
import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
import com.ningdatech.file.entity.vo.result.AttachFileVo; | import com.ningdatech.file.entity.vo.result.AttachFileVo; | ||||
import com.ningdatech.pmapi.common.enumeration.BoolDisplayEnum; | import com.ningdatech.pmapi.common.enumeration.BoolDisplayEnum; | ||||
import com.ningdatech.pmapi.common.helper.RegionCacheHelper; | |||||
import com.ningdatech.pmapi.common.model.FileBasicInfo; | import com.ningdatech.pmapi.common.model.FileBasicInfo; | ||||
import com.ningdatech.pmapi.expert.constant.ExpertApplyTypeEnum; | import com.ningdatech.pmapi.expert.constant.ExpertApplyTypeEnum; | ||||
import com.ningdatech.pmapi.expert.entity.ExpertAvoidCompany; | import com.ningdatech.pmapi.expert.entity.ExpertAvoidCompany; | ||||
@@ -41,7 +42,7 @@ public class ExpertUserInfoAssembler { | |||||
private final TagCache tagCache; | private final TagCache tagCache; | ||||
private final DictionaryCache dictionaryCache; | private final DictionaryCache dictionaryCache; | ||||
// private final RegionCache regionCache; | |||||
private final RegionCacheHelper regionCacheHelper; | |||||
public ExpertFullInfoVO buildExpertFullInfoVO(List<AttachFileVo> attachFiles | public ExpertFullInfoVO buildExpertFullInfoVO(List<AttachFileVo> attachFiles | ||||
, ExpertFullInfoAllDTO expertUserFullInfoAll) { | , ExpertFullInfoAllDTO expertUserFullInfoAll) { | ||||
@@ -83,7 +84,7 @@ public class ExpertUserInfoAssembler { | |||||
ExpertRegionInfo expertApplyIntentionWorkRegion = new ExpertRegionInfo(); | ExpertRegionInfo expertApplyIntentionWorkRegion = new ExpertRegionInfo(); | ||||
expertApplyIntentionWorkRegion.setRegionLevel(r.getRegionLevel()); | expertApplyIntentionWorkRegion.setRegionLevel(r.getRegionLevel()); | ||||
expertApplyIntentionWorkRegion.setRegionCode(r.getRegionCode()); | expertApplyIntentionWorkRegion.setRegionCode(r.getRegionCode()); | ||||
// expertApplyIntentionWorkRegion.setRegionName(regionCache.getUnionPathStr(r.getRegionCode(), r.getRegionLevel())); | |||||
expertApplyIntentionWorkRegion.setRegionName(regionCacheHelper.getUnionPathStr(r.getRegionCode(), r.getRegionLevel())); | |||||
return expertApplyIntentionWorkRegion; | return expertApplyIntentionWorkRegion; | ||||
}).collect(Collectors.toList()); | }).collect(Collectors.toList()); | ||||