linwei
2024-01-31 b3b566ebdfed4005aaa513da3d5d2fd3924903cc
src/main/java/org/springblade/modules/district/service/impl/DistrictServiceImpl.java
@@ -87,6 +87,33 @@
    */
   @Override
   public Object getDistrictTree(DistrictVO district) {
      // 判断角色,物业角色只能查询当前小区的
      String userRole = AuthUtil.getUserRole();
      if (userRole.contains("wygly") || userRole.contains("wyxmjl")) {
         if (district.getFilterFlag().equals(1)) {
            // 查询小区id
            IPropertyDistrictUserService propertyDistrictUserService = SpringUtils.getBean(IPropertyDistrictUserService.class);
            List<String> districtIds = propertyDistrictUserService.selectPropertyDistrictByUserId(AuthUtil.getUserId());
            // 通过用户机构查询用户的物业公司
            // 通过用户机构查询用户的物业公司
            IPropertyCompanyService bean = SpringUtil.getBean(IPropertyCompanyService.class);
            PropertyCompanyEntity one = bean.getOne(Wrappers.<PropertyCompanyEntity>lambdaQuery().eq(PropertyCompanyEntity::getDeptId, AuthUtil.getDeptId()));
            if (one != null) {
               IPropertyCompanyDistrictService bean2 = SpringUtils.getBean(IPropertyCompanyDistrictService.class);
               // 通过物业公司,查询小区
               List<PropertyCompanyDistrictEntity> list = bean2.list(Wrappers.<PropertyCompanyDistrictEntity>lambdaQuery()
                  .eq(PropertyCompanyDistrictEntity::getPropertyCompanyId, one.getId()));
               if (list.size() > 0) {
                  List<String> collect = list.stream().map(i -> i.getDistrictId()).collect(Collectors.toList());
                  districtIds.addAll(collect);
               }
            }
            district.setDistrictIdList(districtIds);
            if (districtIds.size() == 0) {
               return new ArrayList<>();
            }
         }
      }
      Map<String, TreeStringNode> districtTree = baseMapper.getDistrictTree(district);
      List<TreeStringNode> stringNodeTree = NodeTreeUtil.getStringNodeTree(districtTree);
      stringNodeTree.forEach(node -> recursion(node));