| 
					
				 | 
			
			
				@@ -8,6 +8,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.microsvc.toolkit.middleware.live.LivePluginContext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.microsvc.toolkit.middleware.live.LivePluginService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.microsvc.toolkit.middleware.live.message.LiveRoomMessage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.microsvc.toolkit.middleware.rtc.RTCRoomPluginContext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.microsvc.toolkit.middleware.rtc.RTCRoomPluginService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.microsvc.toolkit.middleware.rtc.impl.TencentCloudRTCPlugin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.auth.api.entity.SysUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dto.*; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -36,6 +39,7 @@ import com.ym.mec.common.page.QueryInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.page.WrapperUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.service.impl.BaseServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.tenant.TenantContextHolder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.im.ImFeignService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.util.collection.ListUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.util.collection.MapUtil; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -47,7 +51,6 @@ import org.apache.commons.collections.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.collections.ListUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.collections.MapUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.lang3.SerializationUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.jetbrains.annotations.Nullable; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.joda.time.DateTime; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -59,7 +62,6 @@ import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.context.annotation.Lazy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.http.HttpStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.transaction.annotation.Propagation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.interceptor.TransactionAspectSupport; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.lang.reflect.InvocationTargetException; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -70,9 +72,6 @@ import java.time.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.format.DateTimeFormatter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.temporal.TemporalAdjusters; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.concurrent.CompletableFuture; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.concurrent.ExecutorService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.concurrent.Executors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import static com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType.MUSIC_NETWORK; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -207,11 +206,16 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ImLiveRoomVideoService imLiveRoomVideoService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RTCRoomPluginContext rtcRoomPluginContext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ImLiveRoomVideoDao imLiveRoomVideoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private LiveGroupPlusMapper liveGroupPlusMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TenantInfoService tenantInfoService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final Logger businessLogger = LoggerFactory 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             .getLogger(this.getClass()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -6206,6 +6210,91 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void rtcRoomCreate() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TenantInfo> list = tenantInfoService.list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isEmpty(list)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (TenantInfo tenantInfo : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //是否提前进入教室 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String courseBeforeBufferTime = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_BEFORE_BUFFER_TIME, tenantInfo.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (StringUtils.isEmpty(courseBeforeBufferTime)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                courseBeforeBufferTime = "5"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Integer beforeTime = Integer.parseInt(courseBeforeBufferTime) + 5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<CourseSchedule> scheduleList = courseScheduleDao.getNotStartOnlineNoLive(beforeTime, tenantInfo.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (CollectionUtils.isEmpty(scheduleList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (CourseSchedule courseSchedule : scheduleList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    RTCRoomPluginService pluginService = rtcRoomPluginContext.getPluginService(courseSchedule.getServiceProvider()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // 群组帐号注册 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Teacher teacher = teacherDao.get(courseSchedule.getTeacherId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (Objects.nonNull(teacher)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            pluginService.register(courseSchedule.getTeacherId().toString(), teacher.getRealName(), teacher.getAvatar()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            log.error("直播房间群主注册失败: userId={}", courseSchedule.getTeacherId(), e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //记录用户实际选择的房间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String roomId = courseSchedule.getId().toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (courseSchedule.getGroupType() == GroupType.COMM) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        roomId = "I" + roomId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        roomId = "S" + roomId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // 生成群组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    pluginService.chatRoomCreate(roomId, courseSchedule.getName(), courseSchedule.getTeacherId().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    courseScheduleDao.updateLiveRemind(courseSchedule.getId(),1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    log.error("创建rtc房间失败", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void destroyRtcRoom() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询结束时间在昨天到现在的课程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<CourseSchedule> scheduleList = courseScheduleDao.getEndTimeBetweenYesterdayAndNow(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isEmpty(scheduleList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (CourseSchedule courseSchedule : scheduleList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                RTCRoomPluginService pluginService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (StringUtils.isBlank(courseSchedule.getServiceProvider())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    pluginService = rtcRoomPluginContext.getPluginService(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    pluginService = rtcRoomPluginContext.getPluginService(courseSchedule.getServiceProvider()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (TencentCloudRTCPlugin.PLUGIN_NAME.equals(pluginService.pluginName())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // 腾讯云群销毁 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String roomId = courseSchedule.getId().toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (courseSchedule.getGroupType() == GroupType.COMM) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        roomId = "I" + roomId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        roomId = "S" + roomId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    pluginService.chatRoomDestroy(roomId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.error("销毁rtc房间失败", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<CourseScheduleStudentDto> queryDetailList(CourseDetailQueryInfo courseDetailQueryInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |