소스 검색

Merge branch 'feature/0529-live' of http://git.dayaedu.com/yonge/mec into zx-06-15-live

 Conflicts:
	mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
zouxuan 2 년 전
부모
커밋
80ca335de3

+ 121 - 191
.idea/httpRequests/http-requests-log.http

@@ -1,3 +1,124 @@
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T221721.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T221523.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T221236.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T220649.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/getCourseSchedulesWithDate?date=2023-06-05 00:00:00
+Content-Type: application/json
+Authorization: bearer 4d8e23a1-3acd-42e4-a1ca-b4d595506d98
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T220555.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T220546.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T220439.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T220236.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T215903.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T215426.200.json
+
+###
+
+GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2548
+Authorization: bearer e70c68c9-05e3-4502-aed4-f7001a0e2766
+Proxy-Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T215131.200.json
+
+###
+
+POST https://online.lexiaoya.cn/api-backend/open/schoolTeacherStudent/importPlan?fileUrl=https://polestar-oss.oss-cn-shenzhen.aliyuncs.com/assets/excel/0614/0614单簧管导入表.xlsx
+Content-Length: 0
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-15T100514.200.json
+
+###
+
 POST http://127.0.0.1:9002/teacherCourseSchedule/liveCoursePage
 authorization: bearer 0071d90f-5623-4ee9-a88e-c7adb09efb1c
 Content-Type: application/json
@@ -497,194 +618,3 @@ Accept-Encoding: br,deflate,gzip,x-gzip
 
 ###
 
-GET http://127.0.0.1:9002/teacherCourseSchedule/findCourseAttendanceDetailHeadInfo?courseScheduleId=2002
-authorization: bearer 97fd8e85-bb3c-4967-8a07-47c44957f94a
-Content-Type: application/json
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-08T162615.200.json
-
-###
-
-POST http://127.0.0.1:9002/teacherCourseSchedule/liveCoursePage
-authorization: bearer fe63240c-4f7d-4b67-90f8-7d51eaafdfb7
-Content-Type: application/json
-Content-Length: 152
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-  "page": 1,
-  "rows": 10,
-//  "startTime": "2023-06-06 10:14:57",
-//  "endTime": "2023-06-08 10:14:57",
-//  "search": "",
-//  "status": "NOT_START"
-}
-
-<> 2023-06-08T162147.200.json
-
-###
-
-POST http://127.0.0.1:9002/teacherAttendance/getLiveCurrentCourseStudents
-authorization: bearer 97fd8e85-bb3c-4967-8a07-47c44957f94a
-Content-Type: application/json
-Content-Length: 70
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-  "courseScheduleId": 2001,
-  "status": "PURCHASE",
-  "search": ""
-}
-
-<> 2023-06-08T162015.200.json
-
-###
-
-POST http://127.0.0.1:9002/teacherAttendance/getLiveCurrentCourseStudents
-authorization: bearer 97fd8e85-bb3c-4967-8a07-47c44957f94a
-Content-Type: application/json
-Content-Length: 67
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-  "courseScheduleId": 2001,
-  "status": "SHARE",
-  "search": ""
-}
-
-<> 2023-06-08T161954.200.json
-
-###
-
-GET http://127.0.0.1:8005/task/closeLiveCourseRoom
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-08T161900.200.json
-
-###
-
-GET http://127.0.0.1:8005/task/closeLiveCourseRoom
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-08T161723.200.json
-
-###
-
-GET http://127.0.0.1:8005/task/closeLiveCourseRoom
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-08T161420.200.json
-
-###
-
-POST http://127.0.0.1:9002/teacherCourseSchedule/liveCoursePage
-authorization: bearer 1238347b-3b06-444e-9d35-d122639121ad
-Content-Type: application/json
-Content-Length: 152
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-  "page": 1,
-  "rows": 10,
-//  "startTime": "2023-06-06 10:14:57",
-//  "endTime": "2023-06-08 10:14:57",
-//  "search": "",
-//  "status": "NOT_START"
-}
-
-<> 2023-06-08T155851.200.json
-
-###
-
-POST http://127.0.0.1:9002/teacherCourseSchedule/liveCoursePage
-authorization: bearer 1238347b-3b06-444e-9d35-d122639121ad
-Content-Type: application/json
-Content-Length: 152
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-  "page": 1,
-  "rows": 10,
-//  "startTime": "2023-06-06 10:14:57",
-//  "endTime": "2023-06-08 10:14:57",
-//  "search": "",
-//  "status": "NOT_START"
-}
-
-<> 2023-06-08T155845.200.json
-
-###
-
-POST http://127.0.0.1:9002/teacherAttendance/getLiveCurrentCourseStudents
-authorization: bearer 97fd8e85-bb3c-4967-8a07-47c44957f94a
-Content-Type: application/json
-Content-Length: 70
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-  "courseScheduleId": 2001,
-//  "status": "NORMAL",
-  "search": ""
-}
-
-<> 2023-06-08T155815.200.json
-
-###
-
-POST http://127.0.0.1:9002/teacherAttendance/getLiveCurrentCourseStudents
-authorization: bearer 97fd8e85-bb3c-4967-8a07-47c44957f94a
-Content-Type: application/json
-Content-Length: 70
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-  "courseScheduleId": 2001,
-//  "status": "NORMAL",
-  "search": ""
-}
-
-<> 2023-06-08T155623.200.json
-
-###
-
-POST http://127.0.0.1:9002/teacherAttendance/getLiveCurrentCourseStudents
-authorization: bearer 97fd8e85-bb3c-4967-8a07-47c44957f94a
-Content-Type: application/json
-Content-Length: 70
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-  "courseScheduleId": 2001,
-//  "status": "NORMAL",
-  "search": ""
-}
-
-<> 2023-06-08T155544.200.json
-
-###
-

+ 144 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -2503,6 +2503,17 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 //			courseScheduleTeacherSalaryDao.batchUpdateCourseSalarys(courseScheduleIds, teacherSalary);
 
+			// 直播课数据清除
+			for (CourseSchedule item : courseSchedules) {
+				if (LIVE == item.getGroupType()) {
+					// 消息提醒
+					item.setLiveRemind(0);
+					// 直播间关联
+					item.setLiveRoomId("");
+					// 连堂课标识
+					item.setContinuousCourse(false);
+				}
+			}
 		}
 
         courseScheduleDao.batchUpdate(courseSchedules);
@@ -3165,7 +3176,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
             //课程结束时间必须在21:00之前
             if(DateUtil.getHour(newCourseSchedule.getEndClassTime()) > 20 && DateUtil.getMinute(newCourseSchedule.getEndClassTime()) > 0){
-            	throw new BizException("课程结束时间不能超过21:00,请重新调整上课时间");
+				throw new BizException("课程结束时间不能超过21:00,请重新调整上课时间");
             }
 
             //判断上课时间是否跨天
@@ -6297,10 +6308,10 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		// 课程时间长计算
 		List<CourseScheduleWrapper.CourseScheduleTime> courseScheduleTimes = Lists.newArrayList();
 		// 直播课关联直播间编号
-		String liveRoomId = getCourseScheduleLiveRoomId(courseSchedule, continueCourseTime, newCourseSchedules, courseScheduleTimes);
+		String liveRoomId = getCourseScheduleLiveRoomId(courseSchedule, continueCourseTime, newCourseSchedules, courseScheduleTimes, true);
 
 		// 定时任务更新课程状态为进行中,判断当前课程状态是否匹配
-		int studentRemindTime = Integer.parseInt(sysConfigService.findByParamName(SysConfigService.LIVE_CLASS_START_REMIND_TIME).getParanValue());
+		/*int studentRemindTime = Integer.parseInt(sysConfigService.findByParamName(SysConfigService.LIVE_CLASS_START_REMIND_TIME).getParanValue());
 
 		Date date = DateUtil.startDateAndEndTime(courseSchedule.getClassDate(), courseSchedule.getStartClassTime());
 		date = DateUtil.addMinutes(date, -studentRemindTime);
@@ -6310,7 +6321,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		}
 		if (CourseStatusEnum.OVER == courseSchedule.getStatus()) {
 			throw new BizException("直播课已结束");
-		}
+		}*/
 
 		// 直播间配置
 		ImLiveBroadcastRoom liveBroadcastRoom = imLiveBroadcastRoomService.lambdaQuery()
@@ -6321,11 +6332,17 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			throw new BizException("请先进入直播课教室");
 		}
 
+		String autoCloseNetworkRoomTime = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_AFTER_BUFFER_TIME, courseSchedule.getTenantId());
+		if (StringUtils.isEmpty(autoCloseNetworkRoomTime)) {
+			autoCloseNetworkRoomTime = "15";
+		}
+
 		return CourseScheduleWrapper.LiveCourseSchedule.builder()
 				.liveRoomId(liveRoomId)
 				.subjectId(liveBroadcastRoom.getSubjectId())
 				.autoCloseFlag(true)
-				.autoCloseNetworkRoomTime(getCloseNetworkRoomTime(courseSchedule, continueCourseTime))
+				//.autoCloseNetworkRoomTime(getCloseNetworkRoomTime(courseSchedule, continueCourseTime))
+				.autoCloseNetworkRoomTime(autoCloseNetworkRoomTime)
 				.surplusTime(DateUtil.secondsBetween(new Date(), courseSchedule.getEndClassTime()))
 				.timestamp(DateTime.now().getMillis())
 				.courseScheduleTimes(courseScheduleTimes)
@@ -6343,7 +6360,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 	private String getCourseScheduleLiveRoomId(CourseSchedule courseSchedule,
 											   String continueCourseTime,
 											   List<CourseSchedule> newCourseSchedules,
-											   List<CourseScheduleWrapper.CourseScheduleTime> courseScheduleTimes) {
+											   List<CourseScheduleWrapper.CourseScheduleTime> courseScheduleTimes,
+											   Boolean updateFlag) {
 		String liveRoomId;
 		// 课程开始时间
 		courseSchedule.setStartClassTime(getDateTime(courseSchedule.getClassDate(), courseSchedule.getStartClassTime()).toDate());
@@ -6380,6 +6398,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			if (item.getId().longValue() == courseSchedule.getId()) {
 				continue;
 			}
+			// 重置连堂状态
+			item.setContinuousCourse(false);
 
 			schedule = JSON.parseObject(JSON.toJSONString(item), CourseSchedule.class);
 			if (item.getEndClassTime().getTime() <= courseSchedule.getStartClassTime().getTime()) {
@@ -6391,6 +6411,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			}
 		}
 
+		courseSchedule.setContinuousCourse(false);
 		// 当前课程之前连堂课
 		beforeCourse.add(JSON.parseObject(JSON.toJSONString(courseSchedule), CourseSchedule.class));
 		// 当前课程之后连堂课
@@ -6401,17 +6422,73 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 		// 课程连堂状态
 		if (beforeCourse.get(beforeCourse.size() - 1).getContinuousCourse()) {
-			List<CourseSchedule> collect = beforeCourse.stream()
+
+			// 倒序排序
+			beforeCourse = beforeCourse.stream()
+					.sorted(Comparator.comparing(CourseSchedule::getStartClassTime).reversed())
+					.collect(Collectors.toList());
+
+			for (int i = 0; i < beforeCourse.size(); i++) {
+				CourseSchedule current = beforeCourse.get(i);
+				if (current.getContinuousCourse()) {
+					newCourseSchedules.add(current);
+				}
+
+				if (i + 1 < beforeCourse.size()) {
+					CourseSchedule next = beforeCourse.get(i + 1);
+
+					if (!next.getContinuousCourse()) {
+						newCourseSchedules.add(next);
+						break;
+					}
+				}
+			}
+
+			// 正序排序
+			beforeCourse = beforeCourse.stream()
+					.sorted(Comparator.comparing(CourseSchedule::getStartClassTime))
+					.collect(Collectors.toList());
+
+			/*for (int i = beforeCourse.size() - 1; i >= 0 ; i--) {
+				CourseSchedule current = beforeCourse.get(i);
+				CourseSchedule next = null;
+				if ((i - 1) >= 0) {
+					next = beforeCourse.get(i - 1);
+				}
+				if (next != null && current.getContinuousCourse() && next.getContinuousCourse()) {
+					newCourseSchedules.addAll(Lists.newArrayList(current, next));
+				}
+			}*/
+
+			/*List<CourseSchedule> collect = beforeCourse.stream()
 					.filter(CourseSchedule::getContinuousCourse)
 					.collect(Collectors.toList());
 			if (CollectionUtils.isNotEmpty(collect)) {
 				newCourseSchedules.addAll(collect);
-			}
+			}*/
 		}
 
 		// 课程后连堂状态
 		updateContinuousCourseStatus(continueCourseTime, afterCourse);
 		if (afterCourse.get(0).getContinuousCourse()) {
+
+			for (int i = 0; i < afterCourse.size(); i++) {
+				CourseSchedule current = afterCourse.get(i);
+				if (current.getContinuousCourse()) {
+					newCourseSchedules.add(current);
+				}
+
+				if (i + 1 < afterCourse.size()) {
+					CourseSchedule next = afterCourse.get(i + 1);
+
+					if (!next.getContinuousCourse()) {
+						newCourseSchedules.add(next);
+						break;
+					}
+				}
+			}
+
+			/*
 			List<CourseSchedule> collect = afterCourse.stream()
 					.filter(CourseSchedule::getContinuousCourse)
 					.collect(Collectors.toList());
@@ -6422,11 +6499,16 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				} else {
 					newCourseSchedules.addAll(collect.subList(1, collect.size()));
 				}
-			}
+			}*/
 		}
 
 		if (CollectionUtils.isNotEmpty(newCourseSchedules)) {
 
+			// 课程按开始时间排序
+			newCourseSchedules = newCourseSchedules.stream()
+					.sorted(Comparator.comparing(CourseSchedule::getStartClassTime))
+					.collect(Collectors.toList());
+
 			// 连党课程信息
 			for (CourseSchedule item : newCourseSchedules) {
 				courseScheduleTimes.add(CourseScheduleWrapper.CourseScheduleTime.builder()
@@ -6437,27 +6519,64 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 			// 获取连堂课第一节信息
 			CourseSchedule finalCourseSchedule = newCourseSchedules.get(0);
-			CompletableFuture.runAsync(() -> {
 
-				List<Long> collect = newCourseSchedules.stream()
-						.map(CourseSchedule::getId)
-						.distinct().collect(Collectors.toList());
-				try {
+			List<Long> collect = newCourseSchedules.stream()
+					.map(CourseSchedule::getId)
+					.distinct().collect(Collectors.toList());
+			try {
 
+				if (Optional.ofNullable(updateFlag).orElse(true)) {
 					// 关联直播间编号
 					courseScheduleDao.batchUpdateLiveRoomId(collect, finalCourseSchedule.getLiveRoomId());
+				}
 
+				if (CollectionUtils.size(collect) > 1) {
 					collect = newCourseSchedules.subList(0, newCourseSchedules.size() - 1).stream()
 							.map(CourseSchedule::getId)
 							.distinct().collect(Collectors.toList());
+
 					// 更新连堂课状态
 					courseScheduleDao.batchUpdateContinuousCourse(collect, true);
+				}
 
-				} catch (Exception e) {
-				    log.error("getLiveCourseScheduleTime courseScheduleIds={}", collect, e);
+				if (!Optional.ofNullable(updateFlag).orElse(true)) {
+
+					// 课程连堂状态
+					if (beforeCourse.get(beforeCourse.size() - 1).getContinuousCourse()) {
+
+						int size = beforeCourse.size();
+						collect = beforeCourse.subList(size - 2, size).stream()
+								.map(CourseSchedule::getId)
+								.distinct().collect(Collectors.toList());
+						if (CollectionUtils.isNotEmpty(collect)) {
+							// 更新连堂课状态
+							courseScheduleDao.batchUpdateContinuousCourse(collect, false);
+						}
+					}
+
+					// 课程后连堂状态
+					if (afterCourse.get(0).getContinuousCourse()) {
+						collect = afterCourse.stream().map(CourseSchedule::getId).distinct().collect(Collectors.toList());
+
+						if (CollectionUtils.isNotEmpty(collect)) {
+							// 关联直播间编号
+							courseScheduleDao.batchUpdateLiveRoomId(collect, "");
+							// 更新连堂课状态
+							courseScheduleDao.batchUpdateContinuousCourse(collect, false);
+						}
+					}
 				}
 
-			});
+				// 更新连堂课状态,最后一节课重置
+				CourseSchedule lastCourseSchedule = newCourseSchedules.get(newCourseSchedules.size() - 1);
+				if (Objects.nonNull(lastCourseSchedule)) {
+					courseScheduleDao.batchUpdateContinuousCourse(Lists.newArrayList(lastCourseSchedule.getId()), false);
+				}
+
+			} catch (Exception e) {
+				log.error("getLiveCourseScheduleTime courseScheduleIds={}", collect, e);
+			}
+
 			// 连堂课直播间编号
 			liveRoomId = finalCourseSchedule.getLiveRoomId();
 		} else {
@@ -6468,6 +6587,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 					.endTime(courseSchedule.getEndClassTime().getTime())
 					.build());
 
+			// 更新连堂课状态
+			courseScheduleDao.batchUpdateContinuousCourse(Lists.newArrayList(courseSchedule.getId()), false);
+
 			liveRoomId = courseSchedule.getLiveRoomId();
 		}
 		return liveRoomId;
@@ -6493,13 +6615,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 				startTime = getDateTime(current.getClassDate(), current.getEndClassTime());
 				endTime = getDateTime(next.getClassDate(), next.getStartClassTime());
-				// 如果当前课程结束时间和下一节课开始时间间隔小于5分钟,那么合并时间
-				if (startTime.isBefore(endTime)
-						&& startTime.plusMinutes(Integer.parseInt(continueCourseTime) + 1).isAfter(endTime)) {
+				// 如果当前课程结束时间和下一节课开始时间间隔小于5分钟,那么合并时间(修复代码合并)
+				if ((startTime.isBefore(endTime) || startTime.isEqual(endTime))
+						&& startTime.plusSeconds(Integer.parseInt(continueCourseTime) * 60 + 10).isAfter(endTime)) {
 					// 上节连堂状态
 					current.setContinuousCourse(true);
 					// 下节连堂状态
 					next.setContinuousCourse(true);
+				} else {
+					current.setContinuousCourse(false);
 				}
 			}
 		}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java

@@ -1891,6 +1891,16 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         roomMember.setLiveRoomStatus(1);
         roomMember.setMicrophoneFlag(microphoneFlag);
 
+        ImLiveBroadcastRoomMember liveRoomMember = liveBroadcastRoomMemberService.lambdaQuery()
+                .eq(ImLiveBroadcastRoomMember::getTenantId, userInfo.getTenantId())
+                .eq(ImLiveBroadcastRoomMember::getRoomUid, imLiveBroadcastRoomVo.getRoomUid())
+                .eq(ImLiveBroadcastRoomMember::getUserId, userInfo.getUserId())
+                .list().stream().findFirst().orElse(null);
+        if (Objects.nonNull(liveRoomMember)) {
+           return userInfo;
+        }
+
+
         // 保存直播间用户信息
         liveBroadcastRoomMemberService.save(roomMember);
 

+ 45 - 36
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -5049,41 +5049,45 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                 continue;
             }
 
-            // 通知老师
-            Integer actualTeacherId = courseSchedule.getActualTeacherId();
-            if (actualTeacherId != null) {
-                Map<Integer, String> userMap = new HashMap<>();
-                userMap.put(actualTeacherId, actualTeacherId.toString());
-
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.JIGUANG_LIVE_COURSE_START,
-                        userMap, null, 0,teacherUrl , "TEACHER", classGroup.getName());
-            }
-
-            // 通知学生
-            List<SimpleUserDto> courseStudents = courseScheduleStudentPaymentService.getCourseStudents(Lists.newArrayList(courseSchedule.getId()));
-            if (!CollectionUtils.isEmpty(courseStudents)) {
-                Map<Integer, String> userMap = new HashMap<>();
-                courseStudents.forEach(data -> {
-                    userMap.put(data.getUserId(), data.getUserId().toString());
-                });
-
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.JIGUANG_LIVE_COURSE_START_STUDENT,
-                        userMap, null, 0, studentUrl, "STUDENT", classGroup.getName());
-            }
             ImLiveBroadcastRoomVo imLiveBroadcastRoomVo = imLiveBroadcastRoomService.queryRoomInfo(courseSchedule.getLiveRoomId());
+            if (Objects.isNull(imLiveBroadcastRoomVo)) {
+                continue;
+            }
 
-            // im消息
-            imUrl = MessageFormatter.arrayFormat(imUrl,courseSchedule.getId(), imLiveBroadcastRoomVo.getSubjectId());
-            sysMessageService.batchSendImGroupMessage(MessageTypeEnum.IM_LIVE_COURSE_START_GROUP, courseSchedule.getActualTeacherId().toString(), imUrl,
-                    new String[]{classGroup.getId().toString()},null, classGroup.getName());
+            try {
+                // 通知老师
+                Integer actualTeacherId = courseSchedule.getActualTeacherId();
+                if (actualTeacherId != null) {
+                    Map<Integer, String> userMap = new HashMap<>();
+                    userMap.put(actualTeacherId, actualTeacherId.toString());
+
+                    sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.JIGUANG_LIVE_COURSE_START,
+                            userMap, null, 0,teacherUrl , "TEACHER", classGroup.getName());
+                }
 
-        }
+                // 通知学生
+                List<SimpleUserDto> courseStudents = courseScheduleStudentPaymentService.getCourseStudents(Lists.newArrayList(courseSchedule.getId()));
+                if (!CollectionUtils.isEmpty(courseStudents)) {
+                    Map<Integer, String> userMap = new HashMap<>();
+                    courseStudents.forEach(data -> {
+                        userMap.put(data.getUserId(), data.getUserId().toString());
+                    });
 
-        // id 集合
-        List<Long> ids = courseSchedules.stream().map(CourseSchedule::getId).collect(Collectors.toList());
+                    sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.JIGUANG_LIVE_COURSE_START_STUDENT,
+                            userMap, null, 0, studentUrl, "STUDENT", classGroup.getName());
+                }
+                // im消息
+                imUrl = MessageFormatter.arrayFormat(imUrl,courseSchedule.getId(), imLiveBroadcastRoomVo.getSubjectId());
+                sysMessageService.batchSendImGroupMessage(MessageTypeEnum.IM_LIVE_COURSE_START_GROUP, courseSchedule.getActualTeacherId().toString(), imUrl,
+                        new String[]{classGroup.getId().toString()},null, classGroup.getName());
+            } catch (Exception e) {
+                log.error("直播课程提醒失败", e);
+            }
+
+            // 更新通知状态
+            courseScheduleDao.updateRemindStatus(Lists.newArrayList(courseSchedule.getId()));
+        }
 
-        // 更新通知状态
-        courseScheduleDao.updateRemindStatus(ids);
         CompletableFuture.runAsync(() -> {
             for (CourseSchedule courseSchedule : courseSchedules) {
                 vipGroupService.createVipGroupLiveRoom(courseSchedule.getId().toString(), courseSchedule);
@@ -5165,8 +5169,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         schedule.setId(courseSchedule.getId());
         schedule.setTenantId(courseSchedule.getTenantId());
         schedule.setLiveRoomId(roomUid);
-        courseSchedule.setLiveRoomId(roomUid);
-        courseScheduleDao.update(schedule);
+        CourseSchedule courseSchedule1 = courseScheduleDao.get(courseSchedule.getId());
+        if (StringUtils.isBlank(courseSchedule1.getLiveRoomId())) {
+            courseSchedule.setLiveRoomId(roomUid);
+            courseScheduleDao.update(schedule);
+        } else {
+            courseSchedule.setLiveRoomId(courseSchedule1.getLiveRoomId());
+        }
 
     }
 
@@ -5221,13 +5230,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                         try {
                             imLiveBroadcastRoomService.sendForcedOffline(imLiveBroadcastRoomVo);
 
-                            courseScheduleDao.updateLiveRemind(data.getId(), 1);
+                            courseScheduleDao.updateLiveRemind(data.getId(), 2);
                         } catch (Exception e) {
                             log.error("发送直播间退出消息失败", e);
                         }
                     } else if (imLiveBroadcastRoomVo.getLiveState() == 2) {
                         // 直播未开始 设置通知状态
-                        courseScheduleDao.updateLiveRemind(data.getId(), 2);
+                        courseScheduleDao.updateLiveRemind(data.getId(), 3);
                     }
                 }
             });
@@ -5246,14 +5255,14 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                         boolean b = imLiveBroadcastRoomService.tryDestroyLiveRoom(imLiveBroadcastRoomVo);
                         if (b) {
                             // 直播已关闭 设置通知状态
-                            courseScheduleDao.updateLiveRemind(data.getId(), 2);
+                            courseScheduleDao.updateLiveRemind(data.getId(), 3);
                         }
                     } catch (Exception e) {
                         log.error("关闭直播间失败", e);
                     }
                 } else if (imLiveBroadcastRoomVo.getLiveState() == 2) {
                     // 直播已关闭 设置通知状态
-                    courseScheduleDao.updateLiveRemind(data.getId(), 2);
+                    courseScheduleDao.updateLiveRemind(data.getId(), 3);
                 }
             }
 

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -1122,6 +1122,6 @@
 	</select>
 
 	<select id="getByUserIdAndCourseId" resultMap="CourseScheduleStudentPayment">
-        SELECT * FROM `course_schedule_student_payment` WHERE `user_id_` = #{userId} AND `course_schedule_id_` = #{courseScheduleId}
+        SELECT * FROM `course_schedule_student_payment` WHERE `user_id_` = #{userId} AND `course_schedule_id_` = #{courseScheduleId} limit 1
     </select>
 </mapper>

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/CourseShareMapper.xml

@@ -197,6 +197,6 @@
     <select id="getByUserIdAndCourseId" resultMap="courseShare">
         SELECT *
         FROM course_share
-        WHERE user_id_ = #{studentId} AND course_id_ = #{courseScheduleId}
+        WHERE user_id_ = #{studentId} AND course_id_ = #{courseScheduleId} limit 1
     </select>
 </mapper>