|
@@ -5,7 +5,9 @@ import com.ym.mec.biz.dal.dao.StudentCourseHomeworkDao;
|
|
import com.ym.mec.biz.dal.dto.Mapper;
|
|
import com.ym.mec.biz.dal.dto.Mapper;
|
|
import com.ym.mec.biz.dal.dto.TeacherHomeworkListDto;
|
|
import com.ym.mec.biz.dal.dto.TeacherHomeworkListDto;
|
|
import com.ym.mec.biz.dal.entity.CourseHomework;
|
|
import com.ym.mec.biz.dal.entity.CourseHomework;
|
|
|
|
+import com.ym.mec.biz.dal.entity.StudentCourseHomework;
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
|
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
import com.ym.mec.biz.dal.page.CourseHomeworkQueryInfo;
|
|
import com.ym.mec.biz.dal.page.CourseHomeworkQueryInfo;
|
|
import com.ym.mec.biz.service.CourseHomeworkService;
|
|
import com.ym.mec.biz.service.CourseHomeworkService;
|
|
import com.ym.mec.biz.service.SysMessageService;
|
|
import com.ym.mec.biz.service.SysMessageService;
|
|
@@ -13,11 +15,11 @@ import com.ym.mec.common.dal.BaseDAO;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
-
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -51,22 +53,19 @@ public class CourseHomeworkServiceImpl extends BaseServiceImpl<Long, CourseHomew
|
|
int count = courseHomeworkDao.countByClassGroupAndTeacher(params);
|
|
int count = courseHomeworkDao.countByClassGroupAndTeacher(params);
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
dataList = courseHomeworkDao.findByClassGroupAndTeacher(params);
|
|
dataList = courseHomeworkDao.findByClassGroupAndTeacher(params);
|
|
- // List<Integer> courseScheduleIds=dataList.stream()
|
|
|
|
- // .map(TeacherHomeworkListDto::getCourseScheduleId)
|
|
|
|
- // .distinct()
|
|
|
|
- // .collect(Collectors.toList());
|
|
|
|
- // List<Map<Integer, Integer>> courseTimeByClassGroup = teacherAttendanceDao.findCourseTimeByCourseSchedules(courseScheduleIds);
|
|
|
|
- // Map<Integer, Integer> map = MapUtil.convertIntegerMap(courseTimeByClassGroup);
|
|
|
|
- // dataList.forEach(teacherHomeworkListDto -> {
|
|
|
|
- // teacherHomeworkListDto.setCurrentClassTimes(map.get(teacherHomeworkListDto.getCourseScheduleId().longValue()));
|
|
|
|
- // });
|
|
|
|
- // List<Integer> courseScheduleIds = dataList.stream().map(TeacherHomeworkListDto::getCourseScheduleId).collect(Collectors.toList());
|
|
|
|
- // if (!CollectionUtils.isEmpty(courseScheduleIds)) {
|
|
|
|
- // Map<Integer, Integer> courseScheduleCurrentTimes = courseScheduleService.findCourseScheduleCurrentTimes(courseScheduleIds);
|
|
|
|
- // dataList.forEach(teacherHomeworkListDto -> {
|
|
|
|
- // teacherHomeworkListDto.setCurrentClassTimes(courseScheduleCurrentTimes.get(teacherHomeworkListDto.getCourseScheduleId()));
|
|
|
|
- // });
|
|
|
|
- // }
|
|
|
|
|
|
+ List<Long> courseIds = dataList.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 : dataList) {
|
|
|
|
+ List<StudentCourseHomework> studentCourseHomeworks = homeworkStudentMap.get(teacherHomeworkListDto.getCourseScheduleId().longValue());
|
|
|
|
+ if(CollectionUtils.isEmpty(studentCourseHomeworks)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Map<YesOrNoEnum, List<StudentCourseHomework>> replyStudentsMap = studentCourseHomeworks.stream().collect(Collectors.groupingBy(StudentCourseHomework::getIsReplied));
|
|
|
|
+ if(CollectionUtils.isEmpty(replyStudentsMap.get(YesOrNoEnum.NO))){
|
|
|
|
+ teacherHomeworkListDto.setIsReplied(YesOrNoEnum.YES.getCode());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (count != 0) {
|
|
if (count != 0) {
|
|
Map<String, List<TeacherHomeworkListDto>> collect = dataList.stream().collect(Collectors.groupingBy(TeacherHomeworkListDto::getDay));
|
|
Map<String, List<TeacherHomeworkListDto>> collect = dataList.stream().collect(Collectors.groupingBy(TeacherHomeworkListDto::getDay));
|