Browse Source

pref: selectUserList 5

shc 8 months ago
parent
commit
5f2173e2c4

+ 2 - 3
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/SysUserController.java

@@ -1108,7 +1108,6 @@ public class SysUserController {
         // 获取操作人的角色
         Set<Integer> operatorRoleIds = new HashSet<>(SecurityUtils.getRoles());
 
-
         Set<Integer> targetRoleIds = new HashSet<>();
 
 
@@ -1164,7 +1163,6 @@ public class SysUserController {
         }
 
         // 获取所有三级区域
-
         String areaCacheKey = "sys:area:lv3";
         Set<Long> areaEntities;
         if (Boolean.TRUE.equals(redisTemplate.hasKey(areaCacheKey))) {
@@ -1181,7 +1179,8 @@ public class SysUserController {
             areas = userAreaService.listUserAreas(Long.valueOf(SecurityUtils.getUser().getId()));
         }
 
-        query.setAreaCodes(new LinkedList<>(CollUtil.intersectionDistinct(areaEntities, areas)));
+        // 如果实际三级区域于查询三级区域相等,也就是全国的时候,默认直接查询全国
+        query.setAreaCodes((areaEntities.size() == areas.size()) ? Collections.emptyList() : new LinkedList<>(CollUtil.intersectionDistinct(areaEntities, areas)));
         query.setRole(new LinkedList<>(targetRoleIds));
 
         Page<?> userVosPage = userService.pageUser(query, SecurityUtils.getUser());

+ 11 - 6
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysUserServiceImpl.java

@@ -57,6 +57,7 @@ import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.collections4.SetUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -247,16 +248,20 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
         Page<SysUser> toPage = new Page<>(query.getCurrent(), query.getSize());
 
-
         Set<Integer> areaUserIds = null;
         if (CollUtil.isNotEmpty(query.getAreaCodes())) {
-            areaUserIds = userAreaService.listAreaUser(query.getAreaCodes()).stream().map(Long::intValue).collect(Collectors.toSet());
-        }
 
-        if (CollUtil.isEmpty(areaUserIds)) {
-            return toPage;
-        }
+            List<List<Long>> partition = ListUtils.partition(query.getAreaCodes(), 300);
+            areaUserIds = new HashSet<>();
 
+            for (List<Long> areaIds : partition) {
+                Set<Integer> collect = userAreaService.listAreaUser(areaIds).stream().map(Long::intValue).collect(Collectors.toSet());
+                areaUserIds.addAll(collect);
+            }
+
+            // Set<Integer> collect = partition.parallelStream().flatMap(ac -> userAreaService.listAreaUser(ac).stream()).map(Long::intValue).collect(Collectors.toSet());
+            // areaUserIds = userAreaService.listAreaUser(query.getAreaCodes()).stream().map(Long::intValue).collect(Collectors.toSet());
+        }
 
         List<SysUserRole> userRoles = sysUserRoleService.list(Wrappers.<SysUserRole>lambdaQuery()
                 .in(CollUtil.isNotEmpty(areaUserIds), SysUserRole::getUserId, areaUserIds)