|
@@ -7,18 +7,26 @@ import java.time.LocalDateTime;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.enums.ELessonTrainingType;
|
|
|
+import com.ym.mec.biz.dal.enums.StandardEnum;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -26,14 +34,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.biz.dal.dto.CourseHomeworkDto;
|
|
|
-import com.ym.mec.biz.dal.dto.CourseHomeworkStudentDetailDto;
|
|
|
-import com.ym.mec.biz.dal.dto.EduHomeworkCardDto;
|
|
|
-import com.ym.mec.biz.dal.dto.EduHomeworkStatDto;
|
|
|
-import com.ym.mec.biz.dal.dto.SimpleUserDto;
|
|
|
-import com.ym.mec.biz.dal.dto.StudentCourseHomeworkDto;
|
|
|
-import com.ym.mec.biz.dal.dto.StudentHomeworkRecordDto;
|
|
|
-import com.ym.mec.biz.dal.dto.StudentVisitCourseHomeWorkDto;
|
|
|
import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
|
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
@@ -42,12 +42,6 @@ import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
|
|
|
import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.biz.dal.page.CourseHomeworkQueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.StudentCourseHomeWorkQueryInfo;
|
|
|
-import com.ym.mec.biz.service.CourseHomeworkService;
|
|
|
-import com.ym.mec.biz.service.MusicGroupTrainPlanService;
|
|
|
-import com.ym.mec.biz.service.StudentCourseHomeworkService;
|
|
|
-import com.ym.mec.biz.service.StudentServeService;
|
|
|
-import com.ym.mec.biz.service.SysConfigService;
|
|
|
-import com.ym.mec.biz.service.SysMessageService;
|
|
|
import com.ym.mec.common.constant.CommonConstants;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
@@ -101,9 +95,24 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
@Autowired
|
|
|
private SysMusicScoreDao sysMusicScoreDao;
|
|
|
@Autowired
|
|
|
- private MusicGroupTrainPlanService musicGroupTrainPlanService;
|
|
|
+ private MusicGroupTrainPlanService musicGroupTrainPlanService;
|
|
|
@Autowired
|
|
|
- private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
|
|
|
+ private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExtracurricularExercisesReplyService extracurricularExercisesReplyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupService musicGroupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentLessonExaminationDao studentLessonExaminationDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentLessonTrainingDetailService studentLessonTrainingDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExtracurricularExercisesDao extracurricularExercisesDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, StudentCourseHomework> getDAO() {
|
|
@@ -213,27 +222,27 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleID);
|
|
|
|
|
|
if(courseSchedule == null){
|
|
|
- throw new BizException("课程不存在");
|
|
|
+ throw new BizException("课程不存在");
|
|
|
}
|
|
|
|
|
|
MusicGroupTrainPlan musicGroupTrainPlan = null;
|
|
|
- //获取课程规划
|
|
|
- MusicGroupTrainPlanSaveDto schoolTerm = musicGroupTrainPlanService.getSchoolTerm(courseSchedule);
|
|
|
- int courseNumNo = courseScheduleDao.getCourseNumNo(schoolTerm);
|
|
|
- List<MusicGroupTrainPlan> planList = musicGroupTrainPlanService.queryPlan(schoolTerm);
|
|
|
- if(planList.size() >= courseNumNo){
|
|
|
- musicGroupTrainPlan = planList.get(courseNumNo - 1);
|
|
|
- }
|
|
|
-
|
|
|
+ //获取课程规划
|
|
|
+ MusicGroupTrainPlanSaveDto schoolTerm = musicGroupTrainPlanService.getSchoolTerm(courseSchedule);
|
|
|
+ int courseNumNo = courseScheduleDao.getCourseNumNo(schoolTerm);
|
|
|
+ List<MusicGroupTrainPlan> planList = musicGroupTrainPlanService.queryPlan(schoolTerm);
|
|
|
+ if(planList.size() >= courseNumNo){
|
|
|
+ musicGroupTrainPlan = planList.get(courseNumNo - 1);
|
|
|
+ }
|
|
|
+
|
|
|
CourseHomeworkStudentDetailDto courseHomeworkStudentDetail = studentCourseHomeworkDao.findCourseHomeworkStudentDetail(courseScheduleID, userId);
|
|
|
if(courseHomeworkStudentDetail == null){
|
|
|
- courseHomeworkStudentDetail = new CourseHomeworkStudentDetailDto();
|
|
|
- courseHomeworkStudentDetail.setMusicGroupTrainPlan(musicGroupTrainPlan);
|
|
|
- return courseHomeworkStudentDetail;
|
|
|
+ courseHomeworkStudentDetail = new CourseHomeworkStudentDetailDto();
|
|
|
+ courseHomeworkStudentDetail.setMusicGroupTrainPlan(musicGroupTrainPlan);
|
|
|
+ return courseHomeworkStudentDetail;
|
|
|
}
|
|
|
courseHomeworkStudentDetail.setExpire(DateUtil.isOverdue(courseHomeworkStudentDetail.getSubmitTime(),
|
|
|
sysConfigDao.findConfigValue("file_expiration_time")));
|
|
|
- courseHomeworkStudentDetail.setMusicGroupTrainPlan(musicGroupTrainPlan);
|
|
|
+ courseHomeworkStudentDetail.setMusicGroupTrainPlan(musicGroupTrainPlan);
|
|
|
|
|
|
SysUser sysUser = teacherDao.getUser(userId.intValue());
|
|
|
courseHomeworkStudentDetail.setStudentId(userId.intValue());
|
|
@@ -349,15 +358,40 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
|
|
|
@Override
|
|
|
public void homeworkRemind() {
|
|
|
+ // 课后作业通知
|
|
|
List<StudentCourseHomework> list = studentCourseHomeworkDao.queryNotDoneHomeworkList();
|
|
|
StringBuffer sb;
|
|
|
for (StudentCourseHomework sch : list) {
|
|
|
- sb = new StringBuffer("courseScheduleID=").append(sch.getCourseScheduleId()).append("&studentCourseHomeworkId=").append(sch.getId());
|
|
|
+ sb = new StringBuffer("homeworkId=").append(sch.getCourseScheduleId()).append("&homeworkType=HOMEWORK");
|
|
|
Map<Integer, String> receivers = new HashMap<Integer, String>(1);
|
|
|
receivers.put(sch.getUserId(), sch.getUserId() + "");
|
|
|
- sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_JOB_MESSAGE, receivers, null, 0, "3?" + sb, "STUDENT", sch.getCourseHomework()
|
|
|
- .getMusicGroup().getName(), sch.getCourseHomework().getClassGroup().getName());
|
|
|
+ sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_JOB_MESSAGE_V2, receivers, null, 0, "homework?" + sb, "STUDENT");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 课外作业通知
|
|
|
+ List<ExtracurricularExercisesReply> extraList = extracurricularExercisesReplyDao.queryNotDoneHomeworkList();
|
|
|
+ for (ExtracurricularExercisesReply reply : extraList) {
|
|
|
+ sb = new StringBuffer("homeworkId=").append(reply.getExtracurricularExercisesId())
|
|
|
+ .append("&homeworkType=")
|
|
|
+ .append(reply.getExtracurricularExercises().getGroupType());
|
|
|
+ Map<Integer, String> receivers = new HashMap<Integer, String>(1);
|
|
|
+ receivers.put(reply.getUserId(), reply.getUserId() + "");
|
|
|
+ sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_JOB_MESSAGE_EXTRA_V2, receivers, null, 0, "homework?" + sb, "STUDENT");
|
|
|
}
|
|
|
+
|
|
|
+ //获取即将截止的测评
|
|
|
+ String date = DateUtil.dateToString(DateUtil.addDays(new Date(), 1),DateUtil.ISO_EXPANDED_DATE_FORMAT);
|
|
|
+ List<StudentLessonExamination> examinations = studentLessonExaminationDao.queryEndList(date);
|
|
|
+ if(!CollectionUtils.isEmpty(examinations)){
|
|
|
+ Map<Long, List<StudentLessonExamination>> listMap = examinations.stream().collect(Collectors.groupingBy(e -> e.getLessonExaminationId()));
|
|
|
+ for (Long lessonExaminationId : listMap.keySet()) {
|
|
|
+ List<StudentLessonExamination> studentLessonExaminations = listMap.get(lessonExaminationId);
|
|
|
+ Map<Integer, String> receivers = studentLessonExaminations.stream().collect(Collectors.toMap(e -> e.getUserId(), e -> e.getUserId().toString()));
|
|
|
+ sb = new StringBuffer("evaluating?evaluateId=").append(lessonExaminationId);
|
|
|
+ sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.PUSH_NO_SUBMIT_LESSON_EXAMINATION, receivers, null, 0, sb.toString(), "STUDENT");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -381,7 +415,7 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo findStudentHomeworkRecord(CourseHomeworkQueryInfo queryInfo) {
|
|
|
+ public PageInfo<StudentHomeworkRecordDto> findStudentHomeworkRecord(CourseHomeworkQueryInfo queryInfo) {
|
|
|
PageInfo<StudentHomeworkRecordDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
@@ -404,6 +438,59 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
if (count == 0) {
|
|
|
dataList = new ArrayList<>();
|
|
|
}
|
|
|
+
|
|
|
+ // 构建返回数据
|
|
|
+
|
|
|
+ // 乐团信息
|
|
|
+
|
|
|
+ // 乐团信息
|
|
|
+ Map<String, MusicGroup> musicGroupMap = new HashMap<>();
|
|
|
+ List<String> musicGroupIds = dataList.stream().map(e -> e.getMusicGroupId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(musicGroupIds)) {
|
|
|
+ List<MusicGroup> musicGroups = musicGroupService.queryListByIds(new HashSet<>(musicGroupIds));
|
|
|
+ musicGroupMap = musicGroups.stream().collect(Collectors.toMap(MusicGroup::getId, Function.identity()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 班级名称
|
|
|
+
|
|
|
+ List<Integer> classIds = dataList.stream().map(e -> e.getClassGroupId()).collect(Collectors.toList());
|
|
|
+ Map<Integer, ClassGroup> classGroupMap = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(classIds)) {
|
|
|
+
|
|
|
+ List<ClassGroup> classGroups = classGroupDao.queryByIds(classIds);
|
|
|
+ classGroupMap = classGroups.stream().collect(Collectors.toMap(ClassGroup::getId, Function.identity()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (StudentHomeworkRecordDto studentHomeworkRecordDto : dataList) {
|
|
|
+ // 乐团信息
|
|
|
+ MusicGroup musicGroup = musicGroupMap.get(studentHomeworkRecordDto.getMusicGroupId());
|
|
|
+ if (Objects.nonNull(musicGroup)) {
|
|
|
+ studentHomeworkRecordDto.setMusicGroupName(musicGroup.getName());
|
|
|
+ studentHomeworkRecordDto.setMusicGroupImg(musicGroup.getImg());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 班级信息
|
|
|
+ ClassGroup classGroup = classGroupMap.get(studentHomeworkRecordDto.getClassGroupId());
|
|
|
+ if (Objects.nonNull(classGroup)) {
|
|
|
+ studentHomeworkRecordDto.setClassGroupName(classGroup.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置完成状态
|
|
|
+ if (studentHomeworkRecordDto.getStandardFlag() == null) {
|
|
|
+ studentHomeworkRecordDto.setFinishStatus(false);
|
|
|
+ } else
|
|
|
+ if (studentHomeworkRecordDto.getStandardFlag().equals(StandardEnum.STANDARD)
|
|
|
+ || studentHomeworkRecordDto.getStandardFlag().equals(StandardEnum.EXCELLENT)){
|
|
|
+ studentHomeworkRecordDto.setFinishStatus(true);
|
|
|
+ } else {
|
|
|
+ studentHomeworkRecordDto.setFinishStatus(false);
|
|
|
+ }
|
|
|
+ studentHomeworkRecordDto.setType(ELessonTrainingType.HOMEWORK);
|
|
|
+ }
|
|
|
+
|
|
|
pageInfo.setRows(dataList);
|
|
|
return pageInfo;
|
|
|
}
|
|
@@ -672,4 +759,428 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
}
|
|
|
return dataList;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据课程计划id查询学生作业列表
|
|
|
+ *
|
|
|
+ * @param courseScheduleIds 课程计划id列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<StudentCourseHomework> queryByCourseScheduleIds(List<Integer> courseScheduleIds) {
|
|
|
+ return studentCourseHomeworkDao.findByCourseScheduleIds(courseScheduleIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StudentCourseHomework> findStudentCourseHomeworkByCourseV2(StudentLessonTrainingDetailWrapper.StudentLessonTrainingQuery query) {
|
|
|
+ List<StudentCourseHomework> studentCourseHomeworkByCourse = studentCourseHomeworkDao.findStudentCourseHomeworkByCourse(query);
|
|
|
+ for (StudentCourseHomework studentCourseHomework : studentCourseHomeworkByCourse) {
|
|
|
+ studentCourseHomework.setType(ELessonTrainingType.HOMEWORK);
|
|
|
+ }
|
|
|
+ return getStudentCourseHomeworks(studentCourseHomeworkByCourse);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private List<StudentCourseHomework> getStudentCourseHomeworks(List<StudentCourseHomework> studentCourseHomeworkByCourse) {
|
|
|
+ if (CollectionUtils.isEmpty(studentCourseHomeworkByCourse)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置是否会员
|
|
|
+
|
|
|
+ // 获取用户id集合
|
|
|
+ List<Integer> userIds = studentCourseHomeworkByCourse.stream().map(StudentCourseHomework::getUserId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取学生列表
|
|
|
+ List<Student> students = studentDao.findByStudentIds(userIds);
|
|
|
+ if (CollectionUtils.isEmpty(students)) {
|
|
|
+ return studentCourseHomeworkByCourse;
|
|
|
+ }
|
|
|
+ // 转map
|
|
|
+ Map<Integer, Student> studentMap = students.stream().collect(Collectors.toMap(Student::getUserId, s -> s, (s1, s2) -> s1));
|
|
|
+ for (StudentCourseHomework studentCourseHomework : studentCourseHomeworkByCourse) {
|
|
|
+ if (studentMap.containsKey(studentCourseHomework.getUserId())) {
|
|
|
+ Student student = studentMap.get(studentCourseHomework.getUserId());
|
|
|
+ if ((student.getMembershipEndTime() == null || student.getMembershipEndTime().compareTo(new Date()) < 0) &&
|
|
|
+ (student.getExperienceMembershipEndTime() == null || student.getExperienceMembershipEndTime().compareTo(new Date()) < 0)) {
|
|
|
+ studentCourseHomework.setVipFlag(false);
|
|
|
+ } else {
|
|
|
+ studentCourseHomework.setVipFlag(true);
|
|
|
+ }
|
|
|
+ studentCourseHomework.setSubjectId(Integer.parseInt(student.getSubjectIdList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 设置声部
|
|
|
+
|
|
|
+ // 获取声部id集合
|
|
|
+ List<Integer> voicePartIds = students.stream().map(Student::getSubjectIdList).map(Integer::parseInt).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(voicePartIds)) {
|
|
|
+ return studentCourseHomeworkByCourse;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Subject> subjectList = subjectDao.findBySubjectIds(voicePartIds);
|
|
|
+ // 转map
|
|
|
+ Map<Integer, Subject> subjectMap = subjectList.stream().collect(Collectors.toMap(Subject::getId, s -> s, (s1, s2) -> s1));
|
|
|
+ for (StudentCourseHomework studentCourseHomework : studentCourseHomeworkByCourse) {
|
|
|
+ if (subjectMap.containsKey(studentCourseHomework.getSubjectId())) {
|
|
|
+ studentCourseHomework.setSubjectName(subjectMap.get(studentCourseHomework.getSubjectId()).getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置完成状态
|
|
|
+ for (StudentCourseHomework studentCourseHomework : studentCourseHomeworkByCourse) {
|
|
|
+ if (studentCourseHomework.getStandardFlag() == null) {
|
|
|
+ studentCourseHomework.setFinishFlag(false);
|
|
|
+ } else
|
|
|
+ if( studentCourseHomework.getStandardFlag().equals(StandardEnum.STANDARD) || studentCourseHomework.getStandardFlag().equals(StandardEnum.EXCELLENT)) {
|
|
|
+ studentCourseHomework.setFinishFlag(true);
|
|
|
+ } else {
|
|
|
+ studentCourseHomework.setFinishFlag(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置每个学生的作业完成情况
|
|
|
+ List<Integer> studentIds = studentCourseHomeworkByCourse.stream().map(StudentCourseHomework::getUserId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ StudentCourseHomework studentCourseHomework = studentCourseHomeworkByCourse.get(0);
|
|
|
+ List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> studentLessonTrainingDetails = studentCourseHomeworkDao
|
|
|
+ .findByStudentIdsAndCourseScheduleId(studentIds, studentCourseHomework.getCourseHomeworkId(),studentCourseHomework.getType());
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(studentLessonTrainingDetails)) {
|
|
|
+ // 按userid分组 ,
|
|
|
+ Map<Long, List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail>> studentLessonTrainingDetailMap = studentLessonTrainingDetails.stream()
|
|
|
+ .collect(Collectors.groupingBy(StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail::getUserId,
|
|
|
+ LinkedHashMap::new, Collectors.toList()));
|
|
|
+
|
|
|
+ for (StudentCourseHomework studentCourseHomework1 : studentCourseHomeworkByCourse) {
|
|
|
+ if (studentLessonTrainingDetailMap.containsKey(studentCourseHomework1.getUserId().longValue())) {
|
|
|
+ List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> studentLessonTrainingDetails1 = studentLessonTrainingDetailMap.get(studentCourseHomework1.getUserId().longValue());
|
|
|
+ studentCourseHomework1.setStudentLessonTrainingDetail(studentLessonTrainingDetails1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return studentCourseHomeworkByCourse;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StudentCourseHomework> findExtraExerciseStudentsV2(StudentLessonTrainingDetailWrapper.StudentLessonTrainingQuery query) {
|
|
|
+ List<StudentCourseHomework> extraExerciseStudents = extracurricularExercisesReplyService.findExtraExerciseStudents(
|
|
|
+ query.getCourseScheduleId().longValue(), null);
|
|
|
+
|
|
|
+ List<StudentCourseHomework> studentCourseHomeworks = getStudentCourseHomeworks(extraExerciseStudents);
|
|
|
+ if (query.getSubjectId() != null) {
|
|
|
+ studentCourseHomeworks = studentCourseHomeworks.stream()
|
|
|
+ .filter(o ->o.getSubjectId() != null)
|
|
|
+ .filter(o -> o.getSubjectId().equals(query.getSubjectId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return studentCourseHomeworks;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 学生端查看练习详情
|
|
|
+ *
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CourseHomeworkWrapper.CourseHomeworkList findStudentHomeworkRecordDetail(CourseHomeworkWrapper.StudentCourseHomeworkQuery query) {
|
|
|
+ CourseHomeworkWrapper.CourseHomeworkList courseHomeworkDetail = null;
|
|
|
+ if (ELessonTrainingType.HOMEWORK.equals(query.getType())) {
|
|
|
+ courseHomeworkDetail= courseHomeworkService.findCourseHomeworkDetail(
|
|
|
+ query.getCourseScheduleId());
|
|
|
+
|
|
|
+ StudentCourseHomework homework = studentCourseHomeworkDao
|
|
|
+ .getHomeworkByUserIdAndCourseHomeworkId(query.getUserId(), courseHomeworkDetail.getCourseHomeworkId());
|
|
|
+ if (homework == null) {
|
|
|
+ throw new BizException("作业不存在");
|
|
|
+ }
|
|
|
+ courseHomeworkDetail.setSubmitTime(homework.getSubmitTime());
|
|
|
+ } else {
|
|
|
+ courseHomeworkDetail = courseHomeworkService.findCourseExtraHomeworkDetail(query.getCourseScheduleId());
|
|
|
+ ExtracurricularExercisesReply exercisesReply = extracurricularExercisesReplyDao.getByExtraIdAndUserId(courseHomeworkDetail.getCourseHomeworkId(), query.getUserId());
|
|
|
+ if (exercisesReply == null) {
|
|
|
+ throw new BizException("作业不存在");
|
|
|
+ }
|
|
|
+ courseHomeworkDetail.setSubmitTime(exercisesReply.getSubmitTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取作业信息
|
|
|
+ List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> detailList = studentLessonTrainingDetailService.getBaseLessonTrainingDetail(
|
|
|
+ courseHomeworkDetail.getCourseHomeworkId(), query.getType(), query.getUserId());
|
|
|
+
|
|
|
+ long count = detailList.stream().filter(o -> o.getTrainingTimes() < o.getTimes()).count();
|
|
|
+ if (count >0) {
|
|
|
+ courseHomeworkDetail.setFinishStatus(false);
|
|
|
+ } else {
|
|
|
+ courseHomeworkDetail.setFinishStatus(true);
|
|
|
+ }
|
|
|
+ courseHomeworkDetail.setTrainingDetailList(detailList);
|
|
|
+
|
|
|
+ return courseHomeworkDetail;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加学生作业练习记录
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean addStudentHomeworkRecord(CourseHomeworkWrapper.AddStudentHomeworkRecord record) {
|
|
|
+
|
|
|
+ StudentLessonTrainingDetail studentLessonTrainingDetail = studentLessonTrainingDetailService.getById(record.getId());
|
|
|
+ if (studentLessonTrainingDetail == null) {
|
|
|
+ throw new BizException("练习记录不存在");
|
|
|
+ }
|
|
|
+ // 设置个人作业练习详情记录
|
|
|
+ studentLessonTrainingDetail.setTrainingTimes(studentLessonTrainingDetail.getTrainingTimes() +1);
|
|
|
+
|
|
|
+ if (studentLessonTrainingDetail.getTrainingTimes() >= studentLessonTrainingDetail.getTimes()) {
|
|
|
+ studentLessonTrainingDetail.setTrainingStatus(StandardEnum.STANDARD);
|
|
|
+ } else {
|
|
|
+ studentLessonTrainingDetail.setTrainingStatus(StandardEnum.NOT_STANDARD);
|
|
|
+
|
|
|
+ }
|
|
|
+ studentLessonTrainingDetail.setUpdateTime(new Date());
|
|
|
+ studentLessonTrainingDetailService.updateById(studentLessonTrainingDetail);
|
|
|
+
|
|
|
+ // 查询当前作业的其他作业,判断是否全部完成
|
|
|
+ List<StudentLessonTrainingDetail> list = studentLessonTrainingDetailService.lambdaQuery()
|
|
|
+ .eq(StudentLessonTrainingDetail::getCourseHomeworkId,
|
|
|
+ studentLessonTrainingDetail.getCourseHomeworkId())
|
|
|
+ .eq(StudentLessonTrainingDetail::getUserId,
|
|
|
+ record.getUserId())
|
|
|
+ .eq(StudentLessonTrainingDetail::getType,
|
|
|
+ studentLessonTrainingDetail.getType())
|
|
|
+ .in(StudentLessonTrainingDetail::getTrainingStatus,
|
|
|
+ StandardEnum.NOT_START,
|
|
|
+ StandardEnum.NOT_STANDARD)
|
|
|
+ .list();
|
|
|
+ Boolean finish = false;
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ finish = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置个人作业练习记录
|
|
|
+
|
|
|
+ if (studentLessonTrainingDetail.getType().equals(ELessonTrainingType.HOMEWORK)) {
|
|
|
+
|
|
|
+ StudentCourseHomework studentCourseHomework = studentCourseHomeworkDao.getHomeworkByUserIdAndCourseHomeworkId(
|
|
|
+ record.getUserId(), studentLessonTrainingDetail.getCourseHomeworkId());
|
|
|
+
|
|
|
+ if (studentCourseHomework == null) {
|
|
|
+ throw new BizException("学生作业记录不存在");
|
|
|
+ }
|
|
|
+ Boolean success = false;
|
|
|
+ if (studentCourseHomework.getStandardFlag() == null) {
|
|
|
+
|
|
|
+ } else
|
|
|
+ if (studentCourseHomework.getStandardFlag().equals(StandardEnum.STANDARD)
|
|
|
+ || studentCourseHomework.getStandardFlag().equals(StandardEnum.EXCELLENT)){
|
|
|
+ success = true;
|
|
|
+ }
|
|
|
+ // 设置作业完成
|
|
|
+ if (Boolean.TRUE.equals(finish)) {
|
|
|
+ studentCourseHomework.setStandardFlag(StandardEnum.STANDARD);
|
|
|
+ }
|
|
|
+ studentCourseHomework.setUpdateTime(new Date());
|
|
|
+ studentCourseHomework.setSubmitTime(new Date());
|
|
|
+ studentCourseHomeworkDao.update(studentCourseHomework);
|
|
|
+
|
|
|
+ if (Boolean.TRUE.equals(finish) && Boolean.TRUE.equals(!success)) {
|
|
|
+ // 添加完成人数
|
|
|
+ CourseHomework courseHomework = courseHomeworkDao.get(studentLessonTrainingDetail.getCourseHomeworkId());
|
|
|
+ if (courseHomework == null) {
|
|
|
+ throw new BizException("课程作业不存在");
|
|
|
+ }
|
|
|
+ if (courseHomework.getExpiryDate().compareTo(new Date()) < 0) {
|
|
|
+ throw new BizException("作业已截止");
|
|
|
+ }
|
|
|
+ courseHomeworkDao.updateFinishNum(studentLessonTrainingDetail.getCourseHomeworkId());
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ ExtracurricularExercisesReply exercisesReply = extracurricularExercisesReplyDao.getByExtraIdAndUserId(
|
|
|
+ studentLessonTrainingDetail.getCourseHomeworkId(), record.getUserId());
|
|
|
+
|
|
|
+ if (exercisesReply == null) {
|
|
|
+ throw new BizException("学生作业记录不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ Boolean success = false;
|
|
|
+ if (exercisesReply.getStandardFlag() == null) {
|
|
|
+
|
|
|
+ } else
|
|
|
+ if (exercisesReply.getStandardFlag().equals(StandardEnum.STANDARD)
|
|
|
+ || exercisesReply.getStandardFlag().equals(StandardEnum.EXCELLENT)){
|
|
|
+ success = true;
|
|
|
+ }
|
|
|
+ // 设置作业完成
|
|
|
+ if (Boolean.TRUE.equals(finish)) {
|
|
|
+ exercisesReply.setStandardFlag(StandardEnum.STANDARD);
|
|
|
+ }
|
|
|
+ exercisesReply.setUpdateTime(new Date());
|
|
|
+ exercisesReply.setSubmitTime(new Date());
|
|
|
+ extracurricularExercisesReplyDao.update(exercisesReply);
|
|
|
+ // 添加完成人数
|
|
|
+ if (Boolean.TRUE.equals(finish) && Boolean.TRUE.equals(!success)) {
|
|
|
+ ExtracurricularExercises extracurricularExercises = extracurricularExercisesDao.get(studentLessonTrainingDetail.getCourseHomeworkId());
|
|
|
+ if (extracurricularExercises == null) {
|
|
|
+ throw new BizException("课外作业不存在");
|
|
|
+ }
|
|
|
+ if (extracurricularExercises.getExpireDate().compareTo(new Date()) < 0) {
|
|
|
+ throw new BizException("作业已截止");
|
|
|
+ }
|
|
|
+ extracurricularExercisesDao.updateFinishNum(studentLessonTrainingDetail.getCourseHomeworkId());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 老师查看学生作业练习详情
|
|
|
+ *
|
|
|
+ * @param courseScheduleId 课程计划id
|
|
|
+ * @param userId 学生id
|
|
|
+ * @param type 作业类型
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public StudentLessonTrainingDetailWrapper.StudentLessonTraining findCourseHomeworkStudentDetailPublicV2(Long courseScheduleId, Long userId, ELessonTrainingType type) {
|
|
|
+
|
|
|
+ StudentLessonTrainingDetailWrapper.StudentLessonTraining studentLessonTraining = getUserInfo(userId);
|
|
|
+
|
|
|
+ // 作业信息
|
|
|
+ CourseHomeworkStudentDetailDto courseHomeworkStudentDetail = studentCourseHomeworkDao.findCourseHomeworkStudentDetail(
|
|
|
+ courseScheduleId, userId);
|
|
|
+ if (courseHomeworkStudentDetail == null) {
|
|
|
+ throw new BizException("作业不存在");
|
|
|
+ }
|
|
|
+ studentLessonTraining.setStandardFlag(courseHomeworkStudentDetail.getStandardFlag());
|
|
|
+
|
|
|
+ // 作业完成情况
|
|
|
+ if (courseHomeworkStudentDetail.getStandardFlag() == null) {
|
|
|
+ studentLessonTraining.setFinishFlag(false);
|
|
|
+ } else
|
|
|
+ if( courseHomeworkStudentDetail.getStandardFlag().equals(StandardEnum.STANDARD) || courseHomeworkStudentDetail.getStandardFlag().equals(StandardEnum.EXCELLENT)) {
|
|
|
+ studentLessonTraining.setFinishFlag(true);
|
|
|
+ } else {
|
|
|
+ studentLessonTraining.setFinishFlag(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 练习内容
|
|
|
+ List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> studentLessonTrainingDetails = studentCourseHomeworkDao
|
|
|
+ .findByStudentIdsAndCourseScheduleId(Collections.singletonList(userId.intValue()), courseHomeworkStudentDetail.getCourseHomeworkId(),type);
|
|
|
+
|
|
|
+ studentLessonTraining.setStudentLessonTrainingDetail(studentLessonTrainingDetails);
|
|
|
+ return studentLessonTraining;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public StudentLessonTrainingDetailWrapper.StudentLessonTraining findExtracurricularExercisesDetailPublicV2(Long courseScheduleId, Long userId, ELessonTrainingType type) {
|
|
|
+ StudentLessonTrainingDetailWrapper.StudentLessonTraining studentLessonTraining = getUserInfo(userId);
|
|
|
+
|
|
|
+
|
|
|
+ // 作业信息
|
|
|
+ ExtracurricularExercisesReply exercisesReply = extracurricularExercisesReplyDao.getByExtraIdAndUserId(
|
|
|
+ courseScheduleId, userId);
|
|
|
+ if (exercisesReply == null) {
|
|
|
+ throw new BizException("作业不存在");
|
|
|
+ }
|
|
|
+ studentLessonTraining.setStandardFlag(exercisesReply.getStandardFlag());
|
|
|
+
|
|
|
+ // 作业完成情况
|
|
|
+ if (exercisesReply.getStandardFlag() == null) {
|
|
|
+ studentLessonTraining.setFinishFlag(false);
|
|
|
+ } else if( exercisesReply.getStandardFlag().equals(StandardEnum.STANDARD) || exercisesReply.getStandardFlag().equals(StandardEnum.EXCELLENT)) {
|
|
|
+ studentLessonTraining.setFinishFlag(true);
|
|
|
+ } else {
|
|
|
+ studentLessonTraining.setFinishFlag(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 练习内容
|
|
|
+ List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> studentLessonTrainingDetails = studentCourseHomeworkDao
|
|
|
+ .findByStudentIdsAndCourseScheduleId(Collections.singletonList(userId.intValue()), exercisesReply.getExtracurricularExercisesId(),type);
|
|
|
+
|
|
|
+ studentLessonTraining.setStudentLessonTrainingDetail(studentLessonTrainingDetails);
|
|
|
+ return studentLessonTraining;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void pushEndMsg() {
|
|
|
+ // 课后作业
|
|
|
+ List<CourseHomeworkListDto> courseHomeworks = courseHomeworkDao.findEndHomework();
|
|
|
+ StringBuffer sb;
|
|
|
+ for (CourseHomeworkListDto courseHomework : courseHomeworks) {
|
|
|
+ sb = new StringBuffer("homeworkId=").append(courseHomework.getCourseScheduleId())
|
|
|
+ .append("&homeworkType=HOMEWORK");
|
|
|
+ Map<Integer, String> receivers = new HashMap<Integer, String>(1);
|
|
|
+ String dateToString = DateUtil.dateToString(courseHomework.getCreateTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
|
|
|
+ receivers.put(courseHomework.getTeacherId(), courseHomework.getTeacherId() + "");
|
|
|
+ sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.TEACHER_PUSH_JOB_MESSAGE_V2, receivers, null, 0, "homework?" + sb, "TEACHER",dateToString);
|
|
|
+ }
|
|
|
+ if (courseHomeworks.size() > 0) {
|
|
|
+ // id 集合
|
|
|
+ List<Long> ids = courseHomeworks.stream().map(CourseHomeworkListDto::getId).collect(Collectors.toList());
|
|
|
+ courseHomeworkDao.updatePushFlag(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 课外作业
|
|
|
+ List<ExtracurricularExercises> extracurricularExercises = extracurricularExercisesDao.findEndHomework();
|
|
|
+ for (ExtracurricularExercises exercises : extracurricularExercises) {
|
|
|
+ sb = new StringBuffer("homeworkId=").append(exercises.getId())
|
|
|
+ .append("&homeworkType=")
|
|
|
+ .append(exercises.getGroupType());
|
|
|
+ Map<Integer, String> receivers = new HashMap<Integer, String>(1);
|
|
|
+ String dateToString = DateUtil.dateToString(exercises.getCreateTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
|
|
|
+ receivers.put(exercises.getTeacherId(), exercises.getTeacherId() + "");
|
|
|
+ sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.TEACHER_PUSH_JOB_MESSAGE_EXTRA_V2, receivers, null, 0, "homework?" + sb, "TEACHER",dateToString);
|
|
|
+ }
|
|
|
+ if (extracurricularExercises.size() > 0) {
|
|
|
+ // id 集合
|
|
|
+ List<Long> ids = extracurricularExercises.stream().map(ExtracurricularExercises::getId).collect(Collectors.toList());
|
|
|
+ extracurricularExercisesDao.updatePushFlag(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private StudentLessonTrainingDetailWrapper.StudentLessonTraining getUserInfo(Long userId) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(userId.intValue());
|
|
|
+ if (sysUser == null) {
|
|
|
+ throw new BizException("用户不存在");
|
|
|
+ }
|
|
|
+ StudentLessonTrainingDetailWrapper.StudentLessonTraining studentLessonTraining = new StudentLessonTrainingDetailWrapper.StudentLessonTraining();
|
|
|
+
|
|
|
+ studentLessonTraining.setUserId(userId.longValue());
|
|
|
+ studentLessonTraining.setUserName(sysUser.getRealName());
|
|
|
+ studentLessonTraining.setAvatar(sysUser.getAvatar());
|
|
|
+ Student student = studentDao.get(studentLessonTraining.getUserId().intValue());
|
|
|
+ if (student == null) {
|
|
|
+ throw new BizException("学生不存在");
|
|
|
+ }
|
|
|
+ if ((student.getMembershipEndTime() == null || student.getMembershipEndTime().compareTo(new Date()) < 0) &&
|
|
|
+ (student.getExperienceMembershipEndTime() == null || student.getExperienceMembershipEndTime().compareTo(new Date()) < 0)) {
|
|
|
+ studentLessonTraining.setVipFlag(false);
|
|
|
+ } else {
|
|
|
+ studentLessonTraining.setVipFlag(true);
|
|
|
+ }
|
|
|
+ // 声部
|
|
|
+ Subject subject = subjectDao.get(Integer.parseInt(student.getSubjectIdList()));
|
|
|
+ if (subject == null) {
|
|
|
+ throw new BizException("声部不存在");
|
|
|
+ }
|
|
|
+ studentLessonTraining.setSubjectId(subject.getId());
|
|
|
+ studentLessonTraining.setSubjectName(subject.getName());
|
|
|
+ return studentLessonTraining;
|
|
|
+ }
|
|
|
}
|