zhongrj
2024-03-16 aca33b1ff34ea0f2db3290d4c0b5d898f66de108
src/main/java/org/springblade/common/cache/SysCache.java
@@ -359,6 +359,35 @@
   }
   /**
    * 获取民警(公安)下级所有区域code
    *
    * @return regionCode
    */
   public static List<String> getPoliceRegionChildCodesByDeptId(String deptId) {
      //多个部门按逗号分割
      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 = getPoliceRegionChildCodes(dept.getRegionCode());
            //行政区划不为空添加进集合
            if (list.size()>0){
               allRegionList.addAll(list);
            }
         }
      });
      // 去重
      List<String> collect = allRegionList.stream().distinct().collect(Collectors.toList());
      return collect;
   }
   /**
    * 获取下级所有区域code
    *
    * @return regionCode
@@ -382,6 +411,38 @@
   }
   /**
    * 获取公安下级所有区域code
    *
    * @return regionCode
    */
   public static List<String> getPoliceRegionChildCodes(String regionCode) {
      if (regionCode == null) {
         return null;
      }
      List<String> regionCodeList = CacheUtil.get(SYS_CACHE, REGION_CHILDCODES_CODE, regionCode, List.class);
      if (regionCodeList == null || regionCodeList.size()==0) {
         regionCodeList = new ArrayList<>();
         List<Region> deptChild = getPoliceRegionChild(regionCode);
         if (deptChild != null) {
            List<String> collect = deptChild.stream().map(Region::getCode).collect(Collectors.toList());
            regionCodeList.addAll(collect);
         }
         regionCodeList.add(regionCode);
         CacheUtil.put(SYS_CACHE, REGION_CHILDCODES_CODE, regionCode, regionCodeList);
      }
      return regionCodeList;
   }
   /**
    * 获取民警下级区域
    * @param regionCode
    * @return
    */
   private static List<Region> getPoliceRegionChild(String regionCode) {
      return CacheUtil.get(SYS_CACHE, REGION_CHILD_CODE, regionCode, () -> regionService.getPoliceRegionChild(regionCode));
   }
   /**
    * 获取下级区域
    * @param regionCode
    * @return