没人的房间缓存修复

This commit is contained in:
tianfeng 2025-09-16 21:37:59 +08:00
parent 4c448efe22
commit f207f329f9
2 changed files with 10 additions and 11 deletions

View File

@ -81,9 +81,16 @@ public class RoomVoiceDiscoverQryExe {
// 按照listDiscover的过滤规则过滤空房间
List<ActiveVoiceRoom> matchedEmptyRooms = filterEmptyRoomsByRegion(emptyRooms, cmd.requireReqSysOrigin(), cmd.isAllRegion(), region);
if (CollectionUtils.isNotEmpty(matchedEmptyRooms)) {
// 创建新的可修改列表合并活跃房间和空房间
// 创建新的可修改列表合并活跃房间和空房间并去重
List<ActiveVoiceRoom> allRooms = new ArrayList<>(activeVoiceRooms);
allRooms.addAll(matchedEmptyRooms);
// 获取已存在的房间ID
Set<Long> existingRoomIds = activeVoiceRooms.stream()
.map(ActiveVoiceRoom::getId)
.collect(Collectors.toSet());
// 只添加不存在的空房间
matchedEmptyRooms.stream()
.filter(room -> !existingRoomIds.contains(room.getId()))
.forEach(allRooms::add);
activeVoiceRooms = allRooms;
}
}

View File

@ -93,20 +93,12 @@ public class ActiveVoiceRoomClientServiceImpl implements ActiveVoiceRoomClientSe
.setExpiredTime(TimestampUtils.nowPlusMinutes(topRoomForeverOnline ? 60 : 3))
.setCreateTime(TimestampUtils.now())
.setUpdateTime(TimestampUtils.now())
.setOnlineQuantity(getAvRoomOnlineMemberNum(room))
.setOnlineQuantity(0L)
.setWeights(weights)
.setSuperVipLevel(Objects.toString(
userSVipGateway.checkSVipIdentity(room.getUserId()))
);
}
private Long getAvRoomOnlineMemberNum(RoomProfile roomProfile) {
Long resultQuantity = liveMicClient.getLiveRoomUserSize(roomProfile.getId()).getBody();
if (Objects.nonNull(resultQuantity)) {
roomManagerCacheService.setNumberPeople(roomProfile.getRoomAccount(), resultQuantity);
return resultQuantity;
}
return 0L;
}
}