|
|
@@ -55,20 +55,16 @@ public class InsertUserStateUtil {
|
|
|
List<String> userLists =baseUserMapper.getUserLists();
|
|
|
|
|
|
|
|
|
- // 使用Set提高查找性能
|
|
|
- Set<String> onlineSet = new HashSet<>(onlineUser);
|
|
|
- Set<String> userSet = new HashSet<>(userIdList);
|
|
|
- Set<String> userAll = new HashSet<>(userIdsAll);
|
|
|
|
|
|
// 计算差集和交集
|
|
|
- Set<String> offlineUsers = userSet.stream()
|
|
|
- .filter(userId -> !onlineSet.contains(userId))
|
|
|
+ Set<String> offlineUsers = userIdList.stream()
|
|
|
+ .filter(userId -> !onlineUser.contains(userId))
|
|
|
.collect(Collectors.toSet());
|
|
|
- Set<String> offlineUsersAll = userAll.stream()
|
|
|
- .filter(userId -> !onlineSet.contains(userId))
|
|
|
+ Set<String> offlineUsersAll = userIdsAll.stream()
|
|
|
+ .filter(userId -> !onlineUser.contains(userId))
|
|
|
.collect(Collectors.toSet());
|
|
|
- Set<String> onlineUsers = onlineSet.stream()
|
|
|
- .filter(userSet::contains)
|
|
|
+ Set<String> onlineUsers = onlineUser.stream()
|
|
|
+ .filter(userIdList::contains)
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
// 批量查询用户信息,减少数据库查询
|