|  | @@ -49,7 +49,6 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.collection.MapUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.excel.POIUtil;
 | 
	
		
			
				|  |  | -import com.ym.mec.util.http.HttpUtil;
 | 
	
		
			
				|  |  |  import org.apache.commons.collections.CollectionUtils;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 | 
	
	
		
			
				|  | @@ -738,7 +737,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
 | 
	
		
			
				|  |  |              liveData.setLikeNum(like);
 | 
	
		
			
				|  |  |              liveData.setTotalUserNum(CollectionUtils.isNotEmpty(memberList) ? memberList.size() : 0);
 | 
	
		
			
				|  |  |              liveData.setUpdatedTime(now);
 | 
	
		
			
				|  |  | -            liveData.setLiveTime(getLookMinutes(speakerInfo.getStartLiveTime(), now, speakerInfo.getTotalLiveTime()));
 | 
	
		
			
				|  |  | +            liveData.setLiveTime(getLookMillisecond(speakerInfo.getStartLiveTime(), now, speakerInfo.getTotalLiveTime()));
 | 
	
		
			
				|  |  |              liveBroadcastRoomDataService.save(liveData);
 | 
	
		
			
				|  |  |              //删除房间主讲人数据
 | 
	
		
			
				|  |  |              speakerCache.delete();
 | 
	
	
		
			
				|  | @@ -1423,10 +1422,10 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
 | 
	
		
			
				|  |  |              roomSpeakerInfo.setEndLiveTime(now);
 | 
	
		
			
				|  |  |              roomSpeakerInfo.setState(1);
 | 
	
		
			
				|  |  |              //如果开播时间和本次操作结束播放时间小于1分钟则不计算观看时间
 | 
	
		
			
				|  |  | -            int liveMinutes = getLookMinutes(roomSpeakerInfo.getStartLiveTime(), null);
 | 
	
		
			
				|  |  | +            int liveMinutes = getLookMillisecond(roomSpeakerInfo.getStartLiveTime(), null);
 | 
	
		
			
				|  |  |              if (liveMinutes > 1) {
 | 
	
		
			
				|  |  |                  //写入本次直播时长
 | 
	
		
			
				|  |  | -                roomSpeakerInfo.setTotalLiveTime(getLookMinutes(roomSpeakerInfo.getStartLiveTime(), roomSpeakerInfo.getTotalLiveTime()));
 | 
	
		
			
				|  |  | +                roomSpeakerInfo.setTotalLiveTime(getLookMillisecond(roomSpeakerInfo.getStartLiveTime(), roomSpeakerInfo.getTotalLiveTime()));
 | 
	
		
			
				|  |  |                  //关闭直播后异步执行计算房间人员观看时长
 | 
	
		
			
				|  |  |                  CompletableFuture.runAsync(() -> this.asyncOpsLiveLookTime(roomSpeakerInfo.getRoomUid(), 2, now));
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -1903,7 +1902,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
 | 
	
		
			
				|  |  |          imLiveBroadcastRoom.setSpeakerStatus(liveRoom.getSpeakerStatus());
 | 
	
		
			
				|  |  |          imLiveBroadcastRoom.setPushStatus(liveRoom.getPushStatus());
 | 
	
		
			
				|  |  |          imLiveBroadcastRoom.setBanStatus(liveRoom.getBanStatus());
 | 
	
		
			
				|  |  | -        imLiveBroadcastRoom.setLiveTotalTime(liveRoom.getLiveTotalTime());
 | 
	
		
			
				|  |  | +        // 不用前端传时间
 | 
	
		
			
				|  |  | +        // imLiveBroadcastRoom.setLiveTotalTime(liveRoom.getLiveTotalTime());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return this.updateById(imLiveBroadcastRoom);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -2068,6 +2068,35 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 更新直播推流时间
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param event TencentData.CallbackStreamStateEvent
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void updateLiveRoomPushStreamTime(TencentData.CallbackStreamStateEvent event) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 直播间ROOM_UID
 | 
	
		
			
				|  |  | +        String roomId = event.getStreamId().split("_")[0];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        ImLiveBroadcastRoomVo room = getImLiveBroadcastRoomVo(roomId);
 | 
	
		
			
				|  |  | +        if (Objects.isNull(room)) {
 | 
	
		
			
				|  |  | +            log.warn("updateLiveRoomPushStreamTime 无效的直播间ID, roomId:{}", roomId);
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 更新直播时长
 | 
	
		
			
				|  |  | +        ImLiveBroadcastRoom entity = new ImLiveBroadcastRoom();
 | 
	
		
			
				|  |  | +        // 主键ID
 | 
	
		
			
				|  |  | +        entity.setId(room.getId());
 | 
	
		
			
				|  |  | +        // 直播累积播放时长
 | 
	
		
			
				|  |  | +        int liveTotalTime = Optional.ofNullable(room.getLiveTotalTime()).orElse(0) + Integer.parseInt(event.getPushDuration());
 | 
	
		
			
				|  |  | +        // 累积播放时长
 | 
	
		
			
				|  |  | +        entity.setLiveTotalTime(liveTotalTime);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        updateById(entity);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询直播间所有用户信息
 | 
	
	
		
			
				|  | @@ -2166,6 +2195,41 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
 | 
	
		
			
				|  |  |          return Math.max(minutesBetween, 0);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 计算观看时长差-毫秒数
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param startDT    开始时间
 | 
	
		
			
				|  |  | +     * @param nowMinutes 现在观看时长
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private int getLookMillisecond(Date startDT, Integer nowMinutes) {
 | 
	
		
			
				|  |  | +        return getLookMillisecond(startDT, new Date(), nowMinutes);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 计算观看时长差-毫秒数
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param startDT    开始时间
 | 
	
		
			
				|  |  | +     * @param endDT      结束时间
 | 
	
		
			
				|  |  | +     * @param nowMinutes 现在观看时长
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private int getLookMillisecond(Date startDT, Date endDT, Integer nowMinutes) {
 | 
	
		
			
				|  |  | +        if (Objects.isNull(nowMinutes)) {
 | 
	
		
			
				|  |  | +            nowMinutes = 0;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (Objects.isNull(startDT)) {
 | 
	
		
			
				|  |  | +            return nowMinutes;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (startDT.getTime() > endDT.getTime()) {
 | 
	
		
			
				|  |  | +            return nowMinutes;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //课程结束时间-课程开始时间
 | 
	
		
			
				|  |  | +        long durationTime = endDT.getTime() - startDT.getTime();
 | 
	
		
			
				|  |  | +        //相差多少分钟
 | 
	
		
			
				|  |  | +        int minutesBetween = new Long(durationTime).intValue();
 | 
	
		
			
				|  |  | +        minutesBetween += nowMinutes;
 | 
	
		
			
				|  |  | +        return Math.max(minutesBetween, 0);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 判断Integer是否相等-null值不相等
 | 
	
		
			
				|  |  |       *
 |