|
|
@@ -12,6 +12,7 @@ import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.live.domain.*;
|
|
|
import com.fs.live.mapper.*;
|
|
|
import com.fs.live.param.LiveDataParam;
|
|
|
+import com.fs.live.domain.LiveMsg;
|
|
|
import com.fs.live.service.ILiveDataService;
|
|
|
import com.fs.live.service.ILiveUserFavoriteService;
|
|
|
import com.fs.live.service.ILiveUserFollowService;
|
|
|
@@ -78,6 +79,8 @@ public class LiveDataServiceImpl implements ILiveDataService {
|
|
|
private LiveOrderMapper liveOrderMapper;
|
|
|
@Autowired
|
|
|
private LiveMapper liveMapper;
|
|
|
+ @Autowired
|
|
|
+ private LiveMsgMapper liveMsgMapper;
|
|
|
/**
|
|
|
* 查询直播数据
|
|
|
*
|
|
|
@@ -940,6 +943,37 @@ public class LiveDataServiceImpl implements ILiveDataService {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
+ // 批量查询用户状态和消息数量,优化性能
|
|
|
+ List<Long> userIds = userDetailList.stream()
|
|
|
+ .map(LiveUserDetailVo::getUserId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 批量查询用户状态(分批查询,每批1000条)
|
|
|
+ Map<Long, Integer> userStatusMap = new HashMap<>();
|
|
|
+ int batchSize = 1000;
|
|
|
+ for (int i = 0; i < userIds.size(); i += batchSize) {
|
|
|
+ int end = Math.min(i + batchSize, userIds.size());
|
|
|
+ List<Long> batchUserIds = userIds.subList(i, end);
|
|
|
+ List<FsUser> statusList = fsUserMapper.selectUserStatusByIds(batchUserIds);
|
|
|
+ if (statusList != null) {
|
|
|
+ for (FsUser tempUser : statusList) {
|
|
|
+
|
|
|
+ if (tempUser.getUserId() != null && tempUser.getStatus() != null) {
|
|
|
+ Long userId = tempUser.getUserId();
|
|
|
+ Integer status = tempUser.getStatus();
|
|
|
+ userStatusMap.put(userId, status);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量查询消息数量:只查询用户ID列表,然后统计
|
|
|
+ List<Long> msgUserIds = liveMsgMapper.selectUserIdListByLiveId(liveId);
|
|
|
+ Map<Long, Long> msgCountMap = msgUserIds.stream()
|
|
|
+ .collect(Collectors.groupingBy(userId -> userId, Collectors.counting()));
|
|
|
+
|
|
|
// 转换为导出VO列表
|
|
|
List<LiveUserDetailExportVO> exportList = new ArrayList<>();
|
|
|
for (LiveUserDetailVo userDetail : userDetailList) {
|
|
|
@@ -949,6 +983,18 @@ public class LiveDataServiceImpl implements ILiveDataService {
|
|
|
exportVO.setUserId(userDetail.getUserId());
|
|
|
exportVO.setUserName(userDetail.getUserName());
|
|
|
|
|
|
+ // 设置用户状态
|
|
|
+ Integer status = userStatusMap.get(userDetail.getUserId());
|
|
|
+ if (status != null) {
|
|
|
+ exportVO.setUserStatus(status == 1 ? "正常" : "禁止");
|
|
|
+ } else {
|
|
|
+ exportVO.setUserStatus("未知");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置消息数量
|
|
|
+ Long msgCount = msgCountMap.get(userDetail.getUserId());
|
|
|
+ exportVO.setMsgCount(msgCount != null ? msgCount.intValue() : 0);
|
|
|
+
|
|
|
// 观看时长(秒转分钟)
|
|
|
exportVO.setLiveWatchDuration(formatSecondsToMinutes(userDetail.getLiveWatchDuration()));
|
|
|
exportVO.setPlaybackWatchDuration(formatSecondsToMinutes(userDetail.getPlaybackWatchDuration()));
|