|
@@ -2,6 +2,7 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
@@ -15,6 +16,7 @@ import com.ym.mec.biz.dal.mapper.CourseSchedulePlusMapper;
|
|
import com.ym.mec.biz.dal.page.*;
|
|
import com.ym.mec.biz.dal.page.*;
|
|
import com.ym.mec.biz.dal.school.dto.ClassesForDayDto;
|
|
import com.ym.mec.biz.dal.school.dto.ClassesForDayDto;
|
|
import com.ym.mec.biz.dal.school.dto.CourseStudentDto;
|
|
import com.ym.mec.biz.dal.school.dto.CourseStudentDto;
|
|
|
|
+import com.ym.mec.biz.dal.vo.CourseScheduleWrapper;
|
|
import com.ym.mec.biz.dal.wrapper.DailySummaryOfClassesForTheCurrentSemesterWrapper;
|
|
import com.ym.mec.biz.dal.wrapper.DailySummaryOfClassesForTheCurrentSemesterWrapper;
|
|
import com.ym.mec.biz.dal.wrapper.TeachingPointWrapper;
|
|
import com.ym.mec.biz.dal.wrapper.TeachingPointWrapper;
|
|
import com.ym.mec.biz.event.source.CourseEventSource;
|
|
import com.ym.mec.biz.event.source.CourseEventSource;
|
|
@@ -43,6 +45,8 @@ import org.apache.commons.collections.ListUtils;
|
|
import org.apache.commons.collections.MapUtils;
|
|
import org.apache.commons.collections.MapUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
+import org.joda.time.DateTime;
|
|
|
|
+import org.joda.time.format.DateTimeFormat;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -55,6 +59,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.text.MessageFormat;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.time.*;
|
|
import java.time.*;
|
|
@@ -188,6 +193,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
private TeacherAttendanceService teacherAttendanceService;
|
|
private TeacherAttendanceService teacherAttendanceService;
|
|
@Autowired
|
|
@Autowired
|
|
private LessonExaminationService lessonExaminationService;
|
|
private LessonExaminationService lessonExaminationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
|
|
|
|
+
|
|
|
|
|
|
private final Logger businessLogger = LoggerFactory
|
|
private final Logger businessLogger = LoggerFactory
|
|
.getLogger(this.getClass());
|
|
.getLogger(this.getClass());
|
|
@@ -5759,7 +5767,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
|
|
+ @Override
|
|
public List<CourseStudentDto> queryCourseStudentList(Long courseId) {
|
|
public List<CourseStudentDto> queryCourseStudentList(Long courseId) {
|
|
List<CourseStudentDto> courseStudentDtos = studentAttendanceDao.queryCourseStudentList(courseId);
|
|
List<CourseStudentDto> courseStudentDtos = studentAttendanceDao.queryCourseStudentList(courseId);
|
|
if(CollectionUtils.isNotEmpty(courseStudentDtos)){
|
|
if(CollectionUtils.isNotEmpty(courseStudentDtos)){
|
|
@@ -5836,4 +5844,125 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取老师直播课程时间
|
|
|
|
+ *
|
|
|
|
+ * @param courseScheduleId 课程编号
|
|
|
|
+ * @return CourseScheduleWrapper.CourseSchedule
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public CourseScheduleWrapper.LiveCourseSchedule getLiveCourseScheduleTime(Long courseScheduleId) {
|
|
|
|
+
|
|
|
|
+ CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleId);
|
|
|
|
+ if (Objects.isNull(courseSchedule)) {
|
|
|
|
+ throw new BizException("课程不存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (courseSchedule.getTeachMode() == TeachModeEnum.OFFLINE) {
|
|
|
|
+ throw new BizException("请前往线下教室");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<CourseScheduleWrapper.CourseScheduleTime> courseScheduleTimes = Lists.newArrayList();
|
|
|
|
+ courseScheduleTimes.add(CourseScheduleWrapper.CourseScheduleTime.builder()
|
|
|
|
+ .startTime(getDateTime(courseSchedule.getClassDate(), courseSchedule.getStartClassTime()).getMillis())
|
|
|
|
+ .endTime(getDateTime(courseSchedule.getClassDate(), courseSchedule.getEndClassTime()).getMillis())
|
|
|
|
+ .build());
|
|
|
|
+
|
|
|
|
+ // 是否是连堂课
|
|
|
|
+ String continueCourseTime = sysTenantConfigService.getTenantConfigValue(SysConfigService.ONLINE_CONTINUE_COURSE_TIME, courseSchedule.getTenantId());
|
|
|
|
+ if (StringUtils.isEmpty(continueCourseTime)) {
|
|
|
|
+ continueCourseTime = "5";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CourseSchedule schedule = courseSchedule;
|
|
|
|
+ // 如果当前课程是连堂课,那么获取第一节课的课程编号
|
|
|
|
+ while (true) {
|
|
|
|
+ String classDate = DateUtil.format(schedule.getClassDate(), DateUtil.DEFAULT_PATTERN);
|
|
|
|
+ String startClassTime = DateUtil.format(schedule.getStartClassTime(), DateUtil.EXPANDED_TIME_FORMAT);
|
|
|
|
+ schedule = courseScheduleDao.getFirstCourse(schedule.getClassGroupId(), classDate + " " + startClassTime, schedule.getActualTeacherId(), continueCourseTime);
|
|
|
|
+ if (schedule != null) {
|
|
|
|
+ courseScheduleTimes.add(CourseScheduleWrapper.CourseScheduleTime.builder()
|
|
|
|
+ .startTime(getDateTime(schedule.getClassDate(), schedule.getStartClassTime()).getMillis())
|
|
|
|
+ .endTime(getDateTime(schedule.getClassDate(), schedule.getEndClassTime()).getMillis())
|
|
|
|
+ .build());
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (courseScheduleTimes.size() <= 1) {
|
|
|
|
+
|
|
|
|
+ // 定时任务更新课程状态为进行中,判断当前课程状态是否匹配
|
|
|
|
+ if (CourseStatusEnum.NOT_START == courseSchedule.getStatus()) {
|
|
|
|
+ throw new BizException("直播课暂未开启,请稍后重试");
|
|
|
|
+ }
|
|
|
|
+ if (CourseStatusEnum.OVER == courseSchedule.getStatus()) {
|
|
|
|
+ throw new BizException("直播课已结束");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 直播间配置
|
|
|
|
+ ImLiveBroadcastRoom liveBroadcastRoom = imLiveBroadcastRoomService.lambdaQuery()
|
|
|
|
+ .eq(ImLiveBroadcastRoom::getRoomUid, courseSchedule.getLiveRoomId())
|
|
|
|
+ .last("LIMIT 1")
|
|
|
|
+ .one();
|
|
|
|
+ if (Objects.isNull(liveBroadcastRoom)) {
|
|
|
|
+ throw new BizException("请先进入直播课教室");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 当前时间
|
|
|
|
+ DateTime now = DateTime.now();
|
|
|
|
+
|
|
|
|
+ return CourseScheduleWrapper.LiveCourseSchedule.builder()
|
|
|
|
+ .liveRoomId(courseSchedule.getLiveRoomId())
|
|
|
|
+ .subjectId(liveBroadcastRoom.getSubjectId())
|
|
|
|
+ .autoCloseFlag(true)
|
|
|
|
+ .autoCloseNetworkRoomTime(getCloseNetworkRoomTime(courseSchedule, continueCourseTime))
|
|
|
|
+ .surplusTime(DateUtil.secondsBetween(new Date(), courseSchedule.getEndClassTime()))
|
|
|
|
+ .timestamp(now.getMillis())
|
|
|
|
+ .courseScheduleTimes(courseScheduleTimes)
|
|
|
|
+ .build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 课程开始时间
|
|
|
|
+ * @param day 开始天
|
|
|
|
+ * @param time 开始时间
|
|
|
|
+ * @return DateTime
|
|
|
|
+ */
|
|
|
|
+ private DateTime getDateTime(Date day, Date time) {
|
|
|
|
+ String liveStartTime = MessageFormat.format("{0} {1}", DateUtil.format(day, DateUtil.DEFAULT_PATTERN),
|
|
|
|
+ DateUtil.format(time, DateUtil.EXPANDED_TIME_FORMAT));
|
|
|
|
+
|
|
|
|
+ return DateTime.parse(liveStartTime, DateTimeFormat.forPattern(DateUtil.DEFAULT_PATTERN + " " + DateUtil.EXPANDED_TIME_FORMAT));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 课程结束后多少分钟关闭网络教室
|
|
|
|
+ * @param courseSchedule CourseSchedule
|
|
|
|
+ * @param continueCourseTime 连堂课延迟时间
|
|
|
|
+ * @return String
|
|
|
|
+ */
|
|
|
|
+ public String getCloseNetworkRoomTime(CourseSchedule courseSchedule, String continueCourseTime) {
|
|
|
|
+
|
|
|
|
+ String autoCloseNetworkRoomTime = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_AFTER_BUFFER_TIME, courseSchedule.getTenantId());
|
|
|
|
+ if (StringUtils.isEmpty(autoCloseNetworkRoomTime)) {
|
|
|
|
+ autoCloseNetworkRoomTime = "15";
|
|
|
|
+ }
|
|
|
|
+ CourseSchedule schedule = courseSchedule;
|
|
|
|
+ //如果当前课程是连堂课,那么获取第一节课的课程编号
|
|
|
|
+ while (true) {
|
|
|
|
+ String classDate = DateUtil.format(schedule.getClassDate(), DateUtil.DEFAULT_PATTERN);
|
|
|
|
+ String endClassTime = DateUtil.format(schedule.getEndClassTime(), DateUtil.EXPANDED_TIME_FORMAT);
|
|
|
|
+ schedule = courseScheduleDao.getLastCourse(schedule.getClassGroupId(), classDate + " " + endClassTime, schedule.getActualTeacherId(), continueCourseTime);
|
|
|
|
+ if (schedule != null) {
|
|
|
|
+ autoCloseNetworkRoomTime = String.valueOf(DateUtil.minutesBetween(new Date(), schedule.getEndClassTime()));
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return autoCloseNetworkRoomTime;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|