| | |
| | | package org.springblade.modules.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.common.cache.RegionCache.*; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public List<TreeStringNode> getTownTree(String code) { |
| | | Dept dept = deptService.getById(AuthUtil.getDeptId()); |
| | | String regionCode = null; |
| | | if (null != dept) { |
| | | regionCode = dept.getRegionCode(); |
| | | if (StringUtils.isNotBlank(regionCode) && regionCode.equals("361100")) { |
| | | regionCode = "361102"; |
| | | if (!AuthUtil.isAdministrator() && !AuthUtil.isAdmin()){ |
| | | Dept dept = deptService.getById(AuthUtil.getDeptId()); |
| | | if (null != dept) { |
| | | regionCode = dept.getRegionCode(); |
| | | if (StringUtils.isNotBlank(regionCode) && regionCode.equals("361100")) { |
| | | regionCode = "361102"; |
| | | } |
| | | } |
| | | } |
| | | return NodeTreeUtil.getStringNodeTree(baseMapper.getTownTree(regionCode)); |
| | |
| | | */ |
| | | @Override |
| | | public List<Region> getRegionChild(String regionCode) { |
| | | return baseMapper.getRegionChildList(regionCode); |
| | | // 创建区域对象 |
| | | List<Region> list = new ArrayList<>(); |
| | | // 查询公安相关的区域数据 |
| | | List<Region> regionList = baseMapper.getPoliceList(); |
| | | if (regionList.size()>0) { |
| | | List<Region> policeList = treeRegionList(regionList,regionCode, list); |
| | | list.addAll(policeList); |
| | | } |
| | | // 查询综治区域集合 |
| | | List<Region> regionChildList = baseMapper.getRegionChildList(regionCode); |
| | | list.addAll(regionChildList); |
| | | // 返回 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取某个父节点下面的所有子节点 |
| | | * @param regionList |
| | | * @param parentCode |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public static List<Region> treeRegionList( List<Region> regionList, String parentCode,List<Region> list){ |
| | | for(Region region: regionList){ |
| | | //遍历出父id等于参数的id,add进子节点集合 |
| | | if(region.getParentCode().equals(parentCode)){ |
| | | list.add(region); |
| | | //递归遍历下一级 |
| | | treeRegionList(regionList,region.getCode(),list); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | } |