|
@@ -4,9 +4,11 @@ import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.entity.ExtracurricularExercises;
|
|
|
import com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentCourseHomework;
|
|
|
import com.ym.mec.biz.dal.entity.Teacher;
|
|
|
import com.ym.mec.biz.dal.enums.ImSendTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.biz.dal.page.ExtraExercilseQueryInfo;
|
|
|
import com.ym.mec.biz.service.ExtracurricularExercisesService;
|
|
|
import com.ym.mec.biz.service.StudentServeService;
|
|
@@ -49,6 +51,8 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
private CourseHomeworkDao courseHomeworkDao;
|
|
|
@Autowired
|
|
|
private StudentServeService studentServeService;
|
|
|
+ @Autowired
|
|
|
+ private StudentCourseHomeworkDao studentCourseHomeworkDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, ExtracurricularExercises> getDAO() {
|
|
@@ -236,13 +240,67 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
List<ExtracurricularExercisesHomeworkListDto> exercises = homeworksExercises.stream().filter(e -> e.getType().equals("EXERCISES")).collect(Collectors.toList());
|
|
|
if(exercises.size() > 0){
|
|
|
List<Integer> exercisesIdList = exercises.stream().map(e -> e.getHomeworkId()).collect(Collectors.toList());
|
|
|
- dataList.addAll(extracurricularExercisesDao.findByIdList(exercisesIdList));
|
|
|
+ List<TeacherHomeworkListDto> byIdList = extracurricularExercisesDao.findByIdList(exercisesIdList);
|
|
|
+ if(byIdList != null && byIdList.size() > 0){
|
|
|
+ List<Integer> extraExerciseIds = byIdList.stream().map(TeacherHomeworkListDto::getHomeworkId).collect(Collectors.toList());
|
|
|
+ List<ExtracurricularExercisesReply> extraExerciseStudentsByExtraExercises = extracurricularExercisesReplyDao.findExtraExerciseStudentsByExtraExercises(extraExerciseIds);
|
|
|
+ Map<Long, List<ExtracurricularExercisesReply>> idStudentsMap = extraExerciseStudentsByExtraExercises.stream().collect(Collectors.groupingBy(ExtracurricularExercisesReply::getExtracurricularExercisesId));
|
|
|
+ for (TeacherHomeworkListDto homeworkListDto : byIdList) {
|
|
|
+ List<ExtracurricularExercisesReply> extracurricularExercisesReplies = idStudentsMap.get(homeworkListDto.getHomeworkId().longValue());
|
|
|
+ if(CollectionUtils.isEmpty(extracurricularExercisesReplies)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ long noRepliedNum = extracurricularExercisesReplies.stream().filter(e -> e.getStatus()==1&&e.getIsReplied() == 0).count();
|
|
|
+ if(noRepliedNum<=0){
|
|
|
+ homeworkListDto.setIsReplied(1);
|
|
|
+ }
|
|
|
+ long notSubmitNum = extracurricularExercisesReplies.stream().filter(e -> e.getStatus() == 0).count();
|
|
|
+ if(notSubmitNum<=0){
|
|
|
+ homeworkListDto.setIsSubmit(1);
|
|
|
+ }
|
|
|
+ if(noRepliedNum>0){
|
|
|
+ homeworkListDto.setStatus(1);
|
|
|
+ }else if(noRepliedNum<=0&¬SubmitNum>0){
|
|
|
+ homeworkListDto.setStatus(2);
|
|
|
+ }else if(noRepliedNum<=0&¬SubmitNum<=0){
|
|
|
+ homeworkListDto.setStatus(3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataList.addAll(byIdList);
|
|
|
+ }
|
|
|
}
|
|
|
//课后作业
|
|
|
List<ExtracurricularExercisesHomeworkListDto> homeworkList = homeworksExercises.stream().filter(e -> e.getType().equals("HOMEWORK")).collect(Collectors.toList());
|
|
|
if(homeworkList.size() > 0){
|
|
|
List<Integer> homeworkIdList = homeworkList.stream().map(e -> e.getHomeworkId()).collect(Collectors.toList());
|
|
|
- dataList.addAll(courseHomeworkDao.findByIdList(homeworkIdList));
|
|
|
+ List<TeacherHomeworkListDto> byIdList = courseHomeworkDao.findByIdList(homeworkIdList);
|
|
|
+ if(byIdList != null && byIdList.size() > 0){
|
|
|
+ List<Long> courseIds = byIdList.stream().mapToLong(TeacherHomeworkListDto::getCourseScheduleId).boxed().collect(Collectors.toList());
|
|
|
+ List<StudentCourseHomework> allStudentCourseHomeworks = studentCourseHomeworkDao.findByCourses(courseIds);
|
|
|
+ Map<Long, List<StudentCourseHomework>> homeworkStudentMap = allStudentCourseHomeworks.stream().collect(Collectors.groupingBy(StudentCourseHomework::getCourseScheduleId));
|
|
|
+ for (TeacherHomeworkListDto teacherHomeworkListDto : byIdList) {
|
|
|
+ List<StudentCourseHomework> studentCourseHomeworks = homeworkStudentMap.get(teacherHomeworkListDto.getCourseScheduleId().longValue());
|
|
|
+ if(CollectionUtils.isEmpty(studentCourseHomeworks)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ long noRepliedNum=studentCourseHomeworks.stream().filter(e -> YesOrNoEnum.YES.equals(e.getStatus())&&YesOrNoEnum.NO.equals(e.getIsReplied())).count();
|
|
|
+ if(noRepliedNum<=0){
|
|
|
+ teacherHomeworkListDto.setIsReplied(YesOrNoEnum.YES.getCode());
|
|
|
+ }
|
|
|
+ long notSubmitNum = studentCourseHomeworks.stream().filter(e -> e.getStatus().equals(YesOrNoEnum.NO)).count();
|
|
|
+ if(notSubmitNum<=0){
|
|
|
+ teacherHomeworkListDto.setIsSubmit(1);
|
|
|
+ }
|
|
|
+ if(noRepliedNum>0){
|
|
|
+ teacherHomeworkListDto.setStatus(1);
|
|
|
+ }else if(noRepliedNum<=0&¬SubmitNum>0){
|
|
|
+ teacherHomeworkListDto.setStatus(2);
|
|
|
+ }else if(noRepliedNum<=0&¬SubmitNum<=0){
|
|
|
+ teacherHomeworkListDto.setStatus(3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataList.addAll(byIdList);
|
|
|
+ }
|
|
|
}
|
|
|
dataList.removeAll(Collections.singleton(null));
|
|
|
dataList = dataList.stream().sorted(Comparator.comparing(TeacherHomeworkListDto::getDay).reversed()).collect(Collectors.toList());
|