|
@@ -7,18 +7,29 @@ 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.CourseHomeworkWrapper;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentLessonTrainingDetailWrapper;
|
|
|
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.ExtracurricularExercisesReplyService;
|
|
|
+import com.ym.mec.biz.service.MusicGroupService;
|
|
|
+import com.ym.mec.biz.service.StudentService;
|
|
|
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;
|
|
@@ -105,6 +116,12 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
@Autowired
|
|
|
private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ExtracurricularExercisesReplyService extracurricularExercisesReplyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupService musicGroupService;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Long, StudentCourseHomework> getDAO() {
|
|
|
return studentCourseHomeworkDao;
|
|
@@ -381,7 +398,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 +421,47 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
if (count == 0) {
|
|
|
dataList = new ArrayList<>();
|
|
|
}
|
|
|
+
|
|
|
+ // 构建返回数据
|
|
|
+
|
|
|
+ // 乐团信息
|
|
|
+
|
|
|
+ // 乐团信息
|
|
|
+ List<String> musicGroupIds = dataList.stream().map(e -> e.getMusicGroupId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<MusicGroup> musicGroups = musicGroupService.queryListByIds(new HashSet<>(musicGroupIds));
|
|
|
+ Map<String, MusicGroup> musicGroupMap = musicGroups.stream().collect(Collectors.toMap(MusicGroup::getId, Function.identity()));
|
|
|
+
|
|
|
+
|
|
|
+ // 班级名称
|
|
|
+
|
|
|
+ List<Integer> classIds = dataList.stream().map(e -> e.getClassGroupId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<ClassGroup> classGroups = classGroupDao.queryByIds(classIds);
|
|
|
+ Map<Integer, ClassGroup> 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.getStatus() == 0) {
|
|
|
+ studentHomeworkRecordDto.setFinishStatus(false);
|
|
|
+ } else {
|
|
|
+ studentHomeworkRecordDto.setFinishStatus(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
pageInfo.setRows(dataList);
|
|
|
return pageInfo;
|
|
|
}
|
|
@@ -672,4 +730,216 @@ 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 = findStudentCourseHomeworkByCourse(
|
|
|
+ query.getCourseScheduleId().longValue(), null, null);
|
|
|
+ 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::getId, 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().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);
|
|
|
+ for (StudentCourseHomework studentCourseHomework : extraExerciseStudents) {
|
|
|
+ studentCourseHomework.setType(ELessonTrainingType.EXTRACURRICULAR);
|
|
|
+ }
|
|
|
+ return getStudentCourseHomeworks(extraExerciseStudents);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 学生端查看练习详情
|
|
|
+ *
|
|
|
+ * @param query
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CourseHomeworkWrapper.StudentCourseHomeworkDetail findStudentHomeworkRecordDetail(CourseHomeworkWrapper.StudentCourseHomeworkQuery query) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加学生作业练习记录
|
|
|
+ *
|
|
|
+ * @param record
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean addStudentHomeworkRecord(CourseHomeworkWrapper.AddStudentHomeworkRecord record) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 老师查看学生作业练习详情
|
|
|
+ *
|
|
|
+ * @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().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 userInfo = getUserInfo(userId);
|
|
|
+
|
|
|
+ // extracurricularExercisesReplyDao.findExtraExerciseStudentDetail(courseScheduleId, userId);
|
|
|
+
|
|
|
+ // 作业完成情况 TODO
|
|
|
+
|
|
|
+ return userInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @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;
|
|
|
+ }
|
|
|
}
|