|
@@ -1,5 +1,6 @@
|
|
|
package com.fdkankan.tk.service;
|
|
|
import cn.hutool.core.date.DateUnit;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fdkankan.tk.common.PageInfo;
|
|
|
import com.fdkankan.tk.common.util.JwtUtil;
|
|
@@ -261,70 +262,25 @@ public class DataCountService {
|
|
|
}
|
|
|
|
|
|
public Page<UserMsgVo> roomMsgList(String token ,String roomTitle, String startTime, String endTime, Integer pageNum, Integer pageSize) {
|
|
|
- List<Room> roomList = roomService.getRoomByToken(token);
|
|
|
- List<String> roomIdsDb = roomList.stream().map(Room::getRoomId).collect(Collectors.toList());
|
|
|
- List<String> roomIds = roomIdsDb;
|
|
|
-
|
|
|
- if(StringUtils.isNotBlank(roomTitle)){
|
|
|
- List<Room> roomListLike = roomService.getLikeTitle(roomTitle);
|
|
|
- if(roomList.size() >0){
|
|
|
- List<String> roomIds2 = roomListLike.stream().map(Room::getRoomId).collect(Collectors.toList());
|
|
|
- roomIds = roomIdsDb.stream().filter(roomIds2::contains).collect(Collectors.toList());
|
|
|
- }
|
|
|
- }
|
|
|
- if(roomIds.isEmpty()){
|
|
|
- return new Page<>(pageNum,pageSize);
|
|
|
- }
|
|
|
-
|
|
|
+ String userName = JwtUtil.getUserName(token);
|
|
|
startTime = Dateutils.formatStartTime(startTime);
|
|
|
endTime = Dateutils.formatEndTime(endTime);
|
|
|
|
|
|
- Page<UserMsgVo> page = roomDanmakuService.pageList(new Page<>(pageNum,pageSize) ,roomIds,startTime,endTime);
|
|
|
- Set<String> roomIdsVo = page.getRecords().stream().map(UserMsgVo::getRoomId).collect(Collectors.toSet());
|
|
|
- HashMap<String, Room> roomHashMap = roomService.getByIds(roomIdsVo);
|
|
|
+ Page<UserMsgVo> page = roomDanmakuService.pageList(new Page<>(pageNum,pageSize) ,userName,roomTitle,startTime,endTime);
|
|
|
|
|
|
- HashMap<String,List<RoomVisitLog>> roomVisitLogsMap = new HashMap<>();
|
|
|
HashMap<String,List<RoomDanmaku>> danmakusMap = new HashMap<>();
|
|
|
|
|
|
for (UserMsgVo record : page.getRecords()) {
|
|
|
- List<RoomVisitLog> roomVisitLogs = roomVisitLogsMap.get(record.getRoomId());
|
|
|
- if(roomVisitLogs == null){
|
|
|
- roomVisitLogs = roomVisitLogService.getByRoomId(record.getRoomId());
|
|
|
- roomVisitLogsMap.put(record.getRoomId(),roomVisitLogs);
|
|
|
- }
|
|
|
- Long time = 0L;
|
|
|
- Date firstOutTime = null;
|
|
|
- Date endOutTime = null;
|
|
|
- for (RoomVisitLog roomVisitLog : roomVisitLogs) {
|
|
|
- Room room = roomHashMap.get(roomVisitLog.getRoomId());
|
|
|
- if(room == null){
|
|
|
- continue;
|
|
|
- }
|
|
|
- Date outRoomTime = roomVisitLog.getOutRoomTime() == null ? room.getUseEndTime() : roomVisitLog.getOutRoomTime();
|
|
|
- if(outRoomTime == null || roomVisitLog.getInRoomTime() == null){
|
|
|
- continue;
|
|
|
- }
|
|
|
- if(firstOutTime == null){
|
|
|
- firstOutTime = roomVisitLog.getInRoomTime();
|
|
|
- }else {
|
|
|
- firstOutTime = firstOutTime.getTime() <= roomVisitLog.getInRoomTime().getTime() ? firstOutTime : roomVisitLog.getInRoomTime();
|
|
|
- }
|
|
|
- if(endOutTime == null){
|
|
|
- endOutTime = outRoomTime;
|
|
|
- }else {
|
|
|
- endOutTime = endOutTime.getTime() >= outRoomTime.getTime() ? endOutTime : outRoomTime;
|
|
|
- }
|
|
|
- time += (outRoomTime.getTime() - roomVisitLog.getInRoomTime().getTime());
|
|
|
- }
|
|
|
List<RoomDanmaku> danmakus = danmakusMap.get(record.getRoomId()+record.getWxUserId());
|
|
|
if(danmakus == null){
|
|
|
danmakus = roomDanmakuService.getByRoomId(record.getRoomId(),record.getWxUserId());
|
|
|
danmakusMap.put(record.getRoomId()+record.getWxUserId(),danmakus);
|
|
|
}
|
|
|
List<String> collect = danmakus.stream().map(RoomDanmaku::getText).collect(Collectors.toList());
|
|
|
- record.setOnlineTime(time/1000/60);
|
|
|
- record.setFirstInRoomTime(firstOutTime);
|
|
|
- record.setLastOutRoomTime(endOutTime);
|
|
|
+ if(record.getFirstInRoomTime() != null && record.getLastOutRoomTime()!=null){
|
|
|
+ Long time = DateUtil.between(record.getFirstInRoomTime(),record.getLastOutRoomTime(),DateUnit.MINUTE);
|
|
|
+ record.setOnlineTime(time);
|
|
|
+ }
|
|
|
record.setTextCount(Long.valueOf(danmakus.size()));
|
|
|
record.setTexts(collect);
|
|
|
}
|