Explorar o código

Merge remote-tracking branch 'origin/master_saas' into master_saas

zouxuan %!s(int64=2) %!d(string=hai) anos
pai
achega
5fece86d59

+ 36 - 40
.idea/httpRequests/http-requests-log.http

@@ -1,3 +1,39 @@
+GET http://127.0.0.1:8005/task/liveCourseRemind
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-13T183554.200.json
+
+###
+
+GET http://127.0.0.1:8005/task/liveCourseRemind
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-13T183425.200.json
+
+###
+
+GET http://127.0.0.1:8005/task/liveCourseRemind
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-13T183308.200.json
+
+###
+
+GET http://127.0.0.1:8005/task/liveCourseRemind
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-13T182452.200.json
+
+###
+
 GET http://127.0.0.1:9001/studentVipGroup/joinLiveRoomByShare?courseScheduleId=2179
 Authorization: bearer 093517b0-c9a4-407b-b558-0d71bf157b16
 Connection: Keep-Alive
@@ -693,43 +729,3 @@ Accept-Encoding: br,deflate,gzip,x-gzip
 
 ###
 
-GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2030
-Authorization: bearer 2cd308e9-0b8b-4b08-b3cd-f34dc50a8dfd
-Proxy-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-07T155111.200.json
-
-###
-
-GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2030
-Authorization: bearer 2cd308e9-0b8b-4b08-b3cd-f34dc50a8dfd
-Proxy-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-07T155043.200.json
-
-###
-
-GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2030
-Authorization: bearer 2cd308e9-0b8b-4b08-b3cd-f34dc50a8dfd
-Proxy-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-07T154917.200.json
-
-###
-
-GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=2030
-Authorization: bearer 2cd308e9-0b8b-4b08-b3cd-f34dc50a8dfd
-Proxy-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-07T154631.200.json
-
-###
-

+ 76 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -5,6 +5,9 @@ import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 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.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.*;
@@ -195,7 +198,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
     private LessonExaminationService lessonExaminationService;
 	@Autowired
 	private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
-
+	@Autowired
+	private LivePluginContext livePluginContext;
     @Autowired
     private ImLiveRoomVideoService imLiveRoomVideoService;
 
@@ -1172,6 +1176,18 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				courseScheduleDto.setOs(courseScheduleDto.getLiveBroadcastRoom().getOs());
 			}
         }
+
+        // 直播课判断时间,提前30分钟将课程改为进行中
+
+        Integer studentRemindTime = Integer.parseInt(sysConfigService.findByParamName(SysConfigService.LIVE_CLASS_START_REMIND_TIME).getParanValue());
+        for (CourseScheduleDto record : studentCourseSchedulesWithDate) {
+            if (CourseScheduleType.LIVE.equals(record.getType()) && CourseStatusEnum.NOT_START.equals(record.getStatus())) {
+                Date date = DateUtil.addMinutes(new Date(), studentRemindTime);
+                if (date.after(record.getStartClassTime())) {
+                    record.setStatus(CourseStatusEnum.UNDERWAY);
+                }
+            }
+        }
     }
 
     private Map<String, List<ImLiveRoomVideoVo>> getLiveRecord(List<String> roomIds) {
@@ -3020,6 +3036,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 		Map<Long, CourseSchedule> oldCourseScheduleMap = oldCourseScheduleList.stream().collect(Collectors.toMap(CourseSchedule::getId, c -> c));
 
+		List<CourseSchedule> liveCourseSchedules = Lists.newArrayList();
         for(CourseSchedule newCourseSchedule : newCourseSchedules){
 
         	//获取数据库中的记录
@@ -3075,6 +3092,17 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				}
 			}
 
+			// 直播课发送推送消息
+			if (LIVE.equals(oldCourseSchedule.getGroupType()) && StringUtils.isNotBlank(oldCourseSchedule.getLiveRoomId())) {
+				// 日期,时间,时长,主教老师不一致时,发送消息
+				if (newCourseSchedule.getClassDate() != oldCourseSchedule.getClassDate()
+						|| newCourseSchedule.getStartClassTime() != oldCourseSchedule.getStartClassTime()
+						|| newCourseSchedule.getEndClassTime() != oldCourseSchedule.getEndClassTime()
+						|| newCourseSchedule.getActualTeacherId() != oldCourseSchedule.getActualTeacherId().intValue()) {
+					liveCourseSchedules.add(oldCourseSchedule);
+				}
+			}
+
             if(!CollectionUtils.isEmpty(newCourseSchedule.getTeachingTeacherIdList())){
                 if (newCourseSchedule.getTeachingTeacherIdList().contains(newCourseSchedule.getActualTeacherId())){
                     throw new BizException("主教和助教不可重复");
@@ -3517,6 +3545,46 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
+
+		// 直播课消息推送
+		if (CollectionUtils.isNotEmpty(liveCourseSchedules)) {
+
+			liveCourseSchedules.parallelStream().forEach(item -> {
+
+				ImLiveBroadcastRoom liveRoom = imLiveBroadcastRoomService.getByRoomUid(item.getLiveRoomId());
+				if (Objects.isNull(liveRoom)) {
+					log.warn("liveRoom is null, liveRoomId:{}", item.getLiveRoomId());
+					return;
+				}
+
+				try {
+					LivePluginService pluginService = livePluginContext.getPluginService(liveRoom.getServiceProvider());
+
+					LiveRoomMessage message = new LiveRoomMessage();
+					message.setIsIncludeSender(1);
+					message.setFromUserId(item.getActualTeacherId().toString());
+					message.setToChatRoomId(item.getLiveRoomId());
+					message.setObjectName(LiveRoomMessage.LIVE_STATUS_CHANGE);
+
+					// 发送用户信息
+					LiveRoomMessage.MessageUser messageUser = LiveRoomMessage.MessageUser.builder()
+							.sendUserId("")
+							.sendUserName("")
+							.avatarUrl("")
+							.build();
+
+					message.setContent(LiveRoomMessage.MessageContent.builder()
+							.reason("课程信息已变更")
+							.targetIds(Lists.newArrayList())
+							.sendUserInfo(messageUser).build());
+
+					pluginService.sendChatRoomMessage(message);
+				} catch (Exception e) {
+					log.error("liveRoom error", e);
+				}
+			});
+
+		}
 		return BaseController.succeed();
     }
 
@@ -3992,6 +4060,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         }
         CourseAttendanceDetailHeadInfoDto courseAttendanceDetailHeadInfoDto = courseScheduleDao.findByCourse(courseScheduleId);
         courseAttendanceDetailHeadInfoDto.setLatestAttendanceTime(studentAttendanceDao.findLatestAttendanceDate(courseScheduleId));
+        courseAttendanceDetailHeadInfoDto.setStudentNum(studentAttendanceDao.getStudentNumByStatus(courseScheduleId, StudentAttendanceStatusEnum.NORMAL));
         courseAttendanceDetailHeadInfoDto.setLeaveStudentNum(studentAttendanceDao.getStudentNumByStatus(courseScheduleId, StudentAttendanceStatusEnum.LEAVE));
         courseAttendanceDetailHeadInfoDto.setTruantStudentNum(studentAttendanceDao.getStudentNumByStatus(courseScheduleId, StudentAttendanceStatusEnum.TRUANT));
         courseAttendanceDetailHeadInfoDto.setLateStudentNum(studentAttendanceDao.getStudentNumByStatus(courseScheduleId, StudentAttendanceStatusEnum.LATE));
@@ -6228,7 +6297,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		}
 
 		// 定时任务更新课程状态为进行中,判断当前课程状态是否匹配
-		if (CourseStatusEnum.NOT_START == courseSchedule.getStatus()) {
+		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);
+		// 课程是否开始
+		if(CourseStatusEnum.NOT_START.equals(courseSchedule.getStatus()) && date.after(new Date())) {
 			throw new BizException("直播课暂未开启,请稍后重试");
 		}
 		if (CourseStatusEnum.OVER == courseSchedule.getStatus()) {

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

@@ -4976,7 +4976,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     @Override
     public void liveCourseRemind() {
 
-        Integer studentRemindTime = Integer.parseInt(sysConfigService.findByParamName(SysConfigService.LIVE_CLASS_STUDENT_REMIND_TIME).getParanValue());
+        Integer studentRemindTime = Integer.parseInt(sysConfigService.findByParamName(SysConfigService.LIVE_CLASS_START_REMIND_TIME).getParanValue());
         // 查询30分钟内要开始的并且没有直播通知的直播课
         List<CourseSchedule> courseSchedules = courseScheduleDao.liveCourseRemind(studentRemindTime);
 
@@ -5237,7 +5237,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         if (Objects.isNull(sysUser)) {
             throw new BizException("用户不存在");
         }
-        if(courseSchedule.getTenantId().equals(sysUser.getTenantId())) {
+        if(!courseSchedule.getTenantId().equals(sysUser.getTenantId())) {
             throw new BizException("用户不属于此机构");
         }
 

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

@@ -205,7 +205,8 @@
             cssp.be_merged_,
             st.current_grade_num_,
             st.current_class_,
-            IF(sa.status_ IS NULL,'TRUANT',sa.status_) status_
+            IF(sa.status_ IS NULL,'TRUANT',sa.status_) status_,
+        cssp.join_course_type_ as joinCourseType
         FROM
             course_schedule_student_payment cssp
             LEFT JOIN sys_user su ON cssp.user_id_ = su.id_

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

@@ -193,6 +193,7 @@
         <result property="avatar" column="avatar_"/>
         <result property="phone" column="phone_"/>
         <result property="beMerged" column="be_merged_"/>
+        <result property="joinCourseType" column="joinCourseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result property="status" column="status_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
 

+ 17 - 1
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -130,6 +130,8 @@ public class RoomServiceImpl implements RoomService {
     private VipGroupDao vipGroupDao;
     @Autowired
     private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
+    @Autowired
+    private SysConfigService sysConfigService;
 
     @Override
     public Integer getCurrentCourseId(String roomId) {
@@ -267,8 +269,22 @@ public class RoomServiceImpl implements RoomService {
         // 网络课形式:RTC房间,直播间
         if (GroupType.LIVE == courseSchedule.getGroupType()) {
 
+            if (sysUser.getId().intValue() != courseSchedule.getActualTeacherId()) {
+                // 学生课程购买记录
+                CourseScheduleStudentPayment studentPayment = courseScheduleStudentPaymentDao.getByUserIdAndCourseId(sysUser.getId(),
+                        courseSchedule.getId());
+                if (Objects.isNull(studentPayment)) {
+                    throw new BizException(MessageFormat.format("{0}你已退学", courseSchedule.getName()));
+                }
+            }
+
             // 直播课已结束
-            if (CourseStatusEnum.NOT_START == courseSchedule.getStatus()) {
+            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);
+            // 课程是否开始
+            if(CourseStatusEnum.NOT_START.equals(courseSchedule.getStatus()) && date.after(new Date())) {
                 throw new BizException("直播课未开始");
             }
 

+ 9 - 0
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleController.java

@@ -186,6 +186,15 @@ public class CourseScheduleController extends BaseController {
                     &&!VipGroupStatusEnum.FINISHED.equals(vipGroup.getStatus())){
                 throw new BizException("非进行中课程组不允许进行此操作");
             }
+
+            // 直播课
+            if (GroupType.LIVE.equals(oldCourseSchedule.getGroupType())
+                    && org.apache.commons.lang3.StringUtils.isNotBlank(oldCourseSchedule.getLiveRoomId())) {
+                // 重置连堂课,关联直播间,消息推送状态
+                courseSchedule.setLiveRemind(0);
+                courseSchedule.setContinuousCourse(false);
+                courseSchedule.setLiveRoomId("");
+            }
         }
         if(Objects.isNull(courseSchedule.getClassGroupId())){
             courseSchedule.setClassGroupId(oldCourseSchedule.getClassGroupId());