| | |
| | | import org.springblade.modules.system.service.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | * @return regionCode |
| | | */ |
| | | public static List<String> getRegionChildCodesByDeptId(String deptId) { |
| | | List<String> list = new ArrayList<>(); |
| | | // 查询对应的区域编号code |
| | | Dept dept = deptService.getById(deptId); |
| | | if (null!=dept && !Strings.isBlank(dept.getRegionCode()) && !AuthUtil.isAdministrator()){ |
| | | list = getRegionChildCodes(dept.getRegionCode()); |
| | | } |
| | | return list; |
| | | //多个部门按逗号分割 |
| | | List<String> deptIdList = Arrays.asList(deptId.split(",")); |
| | | |
| | | //所有行政区划code |
| | | List<String> allRegionList = new ArrayList<>(); |
| | | deptIdList.forEach(id->{ |
| | | |
| | | List<String> list = new ArrayList<>(); |
| | | // 查询对应的区域编号code |
| | | Dept dept = deptService.getById(id); |
| | | if (null!=dept && !Strings.isBlank(dept.getRegionCode()) && !AuthUtil.isAdministrator()){ |
| | | list = getRegionChildCodes(dept.getRegionCode()); |
| | | |
| | | //行政区划不为空添加进集合 |
| | | if (list.size()>0){ |
| | | allRegionList.addAll(list); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | // 去重 |
| | | List<String> collect = allRegionList.stream().distinct().collect(Collectors.toList()); |
| | | return collect; |
| | | } |
| | | |
| | | /** |
| | |
| | | return null; |
| | | } |
| | | List<String> regionCodeList = CacheUtil.get(SYS_CACHE, REGION_CHILDCODES_CODE, regionCode, List.class); |
| | | if (regionCodeList == null) { |
| | | if (regionCodeList == null || regionCodeList.size()==0) { |
| | | regionCodeList = new ArrayList<>(); |
| | | List<Region> deptChild = getRegionChild(regionCode); |
| | | if (deptChild != null) { |
| | | List<String> collect = deptChild.stream().map(Region::getCode).collect(Collectors.toList()); |
| | | regionCodeList.addAll(collect); |
| | | } |
| | | // regionCodeList.add(regionCode); |
| | | regionCodeList.add(regionCode); |
| | | CacheUtil.put(SYS_CACHE, REGION_CHILDCODES_CODE, regionCode, regionCodeList); |
| | | } |
| | | return regionCodeList; |