|
@@ -39,23 +39,23 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, ExtracurricularExercises> implements ExtracurricularExercisesService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExtracurricularExercisesDao extracurricularExercisesDao;
|
|
|
- @Autowired
|
|
|
- private ExtracurricularExercisesReplyDao extracurricularExercisesReplyDao;
|
|
|
- @Autowired
|
|
|
- private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
|
|
|
- @Autowired
|
|
|
- private SysMessageService sysMessageService;
|
|
|
- @Autowired
|
|
|
- private TeacherDao teacherDao;
|
|
|
- @Autowired
|
|
|
- private CourseHomeworkDao courseHomeworkDao;
|
|
|
- @Autowired
|
|
|
- private StudentServeService studentServeService;
|
|
|
- @Autowired
|
|
|
- private StudentCourseHomeworkDao studentCourseHomeworkDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExtracurricularExercisesDao extracurricularExercisesDao;
|
|
|
+ @Autowired
|
|
|
+ private ExtracurricularExercisesReplyDao extracurricularExercisesReplyDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
|
|
|
+ @Autowired
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
+ @Autowired
|
|
|
+ private TeacherDao teacherDao;
|
|
|
+ @Autowired
|
|
|
+ private CourseHomeworkDao courseHomeworkDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentServeService studentServeService;
|
|
|
+ @Autowired
|
|
|
+ private StudentCourseHomeworkDao studentCourseHomeworkDao;
|
|
|
|
|
|
@Autowired
|
|
|
private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
@@ -68,20 +68,20 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
@Autowired
|
|
|
private StudentLessonTrainingDetailService studentLessonTrainingDetailService;
|
|
|
|
|
|
- @Override
|
|
|
- public BaseDAO<Long, ExtracurricularExercises> getDAO() {
|
|
|
- return extracurricularExercisesDao;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public void createExtraExercises(ExtracurricularExercises exercises) {
|
|
|
- if(StringUtils.isBlank(exercises.getTitle())){
|
|
|
- // throw new BizException("请填写标题");
|
|
|
- }
|
|
|
- if(StringUtils.isBlank(exercises.getContent())){
|
|
|
- // throw new BizException("请填写内容");
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public BaseDAO<Long, ExtracurricularExercises> getDAO() {
|
|
|
+ return extracurricularExercisesDao;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
+ public void createExtraExercises(ExtracurricularExercises exercises) {
|
|
|
+ if(StringUtils.isBlank(exercises.getTitle())){
|
|
|
+ // throw new BizException("请填写标题");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(exercises.getContent())){
|
|
|
+ // throw new BizException("请填写内容");
|
|
|
+ }
|
|
|
if (exercises.getMusicGroupId() != null) {
|
|
|
exercises.setGroupType(ELessonTrainingType.EXTRACURRICULAR.getCode());
|
|
|
} else {
|
|
@@ -99,25 +99,25 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
exercises.setStudentIdList(StringUtils.join(studentIdList,","));
|
|
|
}
|
|
|
|
|
|
- teacherDao.getLocked(exercises.getTeacherId());
|
|
|
- Teacher teacher = teacherDao.get(exercises.getTeacherId());
|
|
|
+ teacherDao.getLocked(exercises.getTeacherId());
|
|
|
+ Teacher teacher = teacherDao.get(exercises.getTeacherId());
|
|
|
|
|
|
- ExtracurricularExercises repeatLastExercises = extracurricularExercisesDao.findRepeatLastExercises(exercises.getTeacherId(), exercises.getStudentIdList(), exercises.getContent());
|
|
|
- if(Objects.nonNull(repeatLastExercises)&&DateUtil.secondsBetween(repeatLastExercises.getCreateTime(),new Date())<60){
|
|
|
- return;
|
|
|
- }
|
|
|
+ ExtracurricularExercises repeatLastExercises = extracurricularExercisesDao.findRepeatLastExercises(exercises.getTeacherId(), exercises.getStudentIdList(), exercises.getContent());
|
|
|
+ if(Objects.nonNull(repeatLastExercises)&&DateUtil.secondsBetween(repeatLastExercises.getCreateTime(),new Date())<60){
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if(Objects.isNull(exercises.getExpireDate())){
|
|
|
- LocalDateTime localDateTime=LocalDateTime.now();
|
|
|
- localDateTime=localDateTime.plusDays(Integer.parseInt(sysConfigService.findByParamName("homework_expire_time").getParanValue()))
|
|
|
+ if(Objects.isNull(exercises.getExpireDate())){
|
|
|
+ LocalDateTime localDateTime=LocalDateTime.now();
|
|
|
+ localDateTime=localDateTime.plusDays(Integer.parseInt(sysConfigService.findByParamName("homework_expire_time").getParanValue()))
|
|
|
.withHour(21).withMinute(0).withSecond(0).withNano(0);
|
|
|
- exercises.setExpireDate(Date.from(localDateTime.atZone(DateUtil.zoneId).toInstant()));
|
|
|
- }
|
|
|
- List<Integer> studentIds = Arrays.asList(exercises.getStudentIdList().split(",")).stream().mapToInt(Integer::valueOf).boxed().collect(Collectors.toList());
|
|
|
- exercises.setBatchNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
|
|
- exercises.setExpectNum(studentIds.size());
|
|
|
- extracurricularExercisesDao.insert(exercises);
|
|
|
- String dateStr = DateUtil.dateToString(exercises.getExpireDate(), "MM月dd日HH点");
|
|
|
+ exercises.setExpireDate(Date.from(localDateTime.atZone(DateUtil.zoneId).toInstant()));
|
|
|
+ }
|
|
|
+ List<Integer> studentIds = Arrays.asList(exercises.getStudentIdList().split(",")).stream().mapToInt(Integer::valueOf).boxed().collect(Collectors.toList());
|
|
|
+ exercises.setBatchNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
|
|
+ exercises.setExpectNum(studentIds.size());
|
|
|
+ extracurricularExercisesDao.insert(exercises);
|
|
|
+ String dateStr = DateUtil.dateToString(exercises.getExpireDate(), "MM月dd日HH点");
|
|
|
|
|
|
ExtracurricularExercisesReply studentExtraExercise=new ExtracurricularExercisesReply();
|
|
|
studentExtraExercise.setExtracurricularExercisesId(exercises.getId());
|
|
@@ -148,7 +148,7 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
// 作业详情
|
|
|
studentLessonTrainingDetailList.addAll(studentLessonTrainingDetailService
|
|
|
.homeWorkDetail(musicScoreSubjectDto.getStudentLessonTrainingDetails(), musicScoreSubjectDto.getUserIdList(), exercises.getId(),
|
|
|
- ELessonTrainingType.valueOf(exercises.getGroupType())));
|
|
|
+ ELessonTrainingType.valueOf(exercises.getGroupType()),musicScoreSubjectDto.getGroup()));
|
|
|
|
|
|
}
|
|
|
} else {
|
|
@@ -160,12 +160,31 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
// 作业详情
|
|
|
studentLessonTrainingDetailList.addAll(studentLessonTrainingDetailService
|
|
|
.homeWorkDetail(exercises.getStudentLessonTrainingDetails(), studentIds,exercises.getId(),
|
|
|
- ELessonTrainingType.valueOf(exercises.getGroupType())));
|
|
|
+ ELessonTrainingType.valueOf(exercises.getGroupType()), null));
|
|
|
}
|
|
|
for (ExtracurricularExercisesReply extracurricularExercisesReply : extracurricularExercisesReplies) {
|
|
|
extracurricularExercisesReplyDao.insert(extracurricularExercisesReply);
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(studentLessonTrainingDetailList)) {
|
|
|
+ // 学生ID集合
|
|
|
+ Set<Integer> userIdList = studentLessonTrainingDetailList.stream()
|
|
|
+ .map(StudentLessonTrainingDetail::getUserId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(Long::intValue)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ // 设置声部
|
|
|
+ Map<Integer, StudentSubjectDto> subjectDtoMap = studentLessonTrainingDetailService
|
|
|
+ .getStudentMusicGroupSubject(new ArrayList<>(userIdList), exercises.getMusicGroupId());
|
|
|
+
|
|
|
+ studentLessonTrainingDetailList.forEach(studentLessonTrainingDetail -> {
|
|
|
+ if (studentLessonTrainingDetail.getUserId() == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ StudentSubjectDto studentSubjectDto = subjectDtoMap.get(studentLessonTrainingDetail.getUserId().intValue());
|
|
|
+ if (Objects.nonNull(studentSubjectDto)) {
|
|
|
+ studentLessonTrainingDetail.setSubjectId(studentSubjectDto.getSubjectId().longValue());
|
|
|
+ }
|
|
|
+ });
|
|
|
studentLessonTrainingDetailService.saveBatch(studentLessonTrainingDetailList);
|
|
|
exercises.setVersionTag("v2");
|
|
|
} else {
|
|
@@ -207,177 +226,177 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
userMap, null, 0, 3 + notifyUrl, "STUDENT",
|
|
|
teacher.getRealName(), exercises.getTitle(), dateStr);
|
|
|
}
|
|
|
- }
|
|
|
- studentServeService.updateExercisesSituation(exercises.getMusicGroupId(), new Date(), studentIds, exercises.getTeacherId());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Map<String, Object>> findExtraExercilses(ExtraExercilseQueryInfo queryInfo) {
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- MapUtil.populateMap(params, queryInfo);
|
|
|
- List<Map<String, Object>> result = new ArrayList<>();
|
|
|
-
|
|
|
- List<ExtracurricularExercises> dataList = extracurricularExercisesDao.findExtraExercises(params);
|
|
|
- if(!CollectionUtils.isEmpty(dataList)){
|
|
|
- List<Long> extraExerciseIds = dataList.stream().map(ExtracurricularExercises::getId).collect(Collectors.toList());
|
|
|
- List<ExtracurricularExercisesReply> extraExerciseStudentsByExtraExercises = extracurricularExercisesReplyDao.findExtraExerciseStudentsByExtraExercises(extraExerciseIds);
|
|
|
- Map<Long, List<ExtracurricularExercisesReply>> idStudentsMap = extraExerciseStudentsByExtraExercises.stream().collect(Collectors.groupingBy(ExtracurricularExercisesReply::getExtracurricularExercisesId));
|
|
|
- for (ExtracurricularExercises extracurricularExercises : dataList) {
|
|
|
- List<ExtracurricularExercisesReply> extracurricularExercisesReplies = idStudentsMap.get(extracurricularExercises.getId());
|
|
|
- if(CollectionUtils.isEmpty(extracurricularExercisesReplies)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- long noRepliedNum = extracurricularExercisesReplies.stream().filter(e -> e.getStatus()==1&&e.getIsReplied() == 0).count();
|
|
|
- if(noRepliedNum<=0){
|
|
|
- extracurricularExercises.setIsReplied(1);
|
|
|
- }
|
|
|
- long notSubmitNum = extracurricularExercisesReplies.stream().filter(e -> e.getStatus() == 0).count();
|
|
|
- if(notSubmitNum<=0){
|
|
|
- extracurricularExercises.setIsSubmit(1);
|
|
|
- }
|
|
|
- if(noRepliedNum>0){
|
|
|
- extracurricularExercises.setStatus(1);
|
|
|
- }else if(noRepliedNum<=0&¬SubmitNum>0){
|
|
|
- extracurricularExercises.setStatus(2);
|
|
|
- }else if(noRepliedNum<=0&¬SubmitNum<=0){
|
|
|
- extracurricularExercises.setStatus(3);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, List<ExtracurricularExercises>> collect = dataList.stream().collect(Collectors.groupingBy(e -> DateUtil.dateToString(e.getCreateTime(), "yyyy-MM-dd")));
|
|
|
- List<Date> dates=new ArrayList<>();
|
|
|
- collect.keySet().forEach(ds-> dates.add(DateUtil.stringToDate(ds,"yyyy-MM-dd")));
|
|
|
- dates.sort(Comparator.comparing(Date::getTime));
|
|
|
- dates.sort(Comparator.reverseOrder());
|
|
|
- for (Date date : dates) {
|
|
|
- String key=DateUtil.dateToString(date, "yyyy-MM-dd");
|
|
|
- Map<String, Object> r = new HashMap<>();
|
|
|
- r.put("day", key);
|
|
|
- collect.get(key).sort(Comparator.comparing(ExtracurricularExercises::getCreateTime).reversed());
|
|
|
- r.put("list", collect.get(key));
|
|
|
- result.add(r);
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<BasicUserDto> getDontServeStudents(Integer teacherId,
|
|
|
- String search,
|
|
|
- String musicGroupId,
|
|
|
- Long classGroupId,
|
|
|
- Integer subjectId,
|
|
|
- Integer hasMember,
|
|
|
- String studentIds) {
|
|
|
- LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
|
|
|
- LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
|
|
- return extracurricularExercisesDao.findNoExercisesStudentsInThisWeekWithTeacher(teacherId, monDayDate.toString(), musicGroupId, classGroupId, subjectId, search,hasMember,studentIds);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void studentServeRemind() {
|
|
|
- LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
|
|
|
- LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
|
|
- List<Map<Integer, Long>> noFinishedServiceTeacher = studentExtracurricularExercisesSituationDao.getNoFinishedServiceTeacher(monDayDate.toString());
|
|
|
- Map<Integer, Long> noFinishedServiceTeacherMap= MapUtil.convertIntegerMap(noFinishedServiceTeacher);
|
|
|
- for (Map.Entry<Integer, Long> integerLongEntry : noFinishedServiceTeacherMap.entrySet()) {
|
|
|
- Map<Integer, String> userMap = new HashMap<>();
|
|
|
- userMap.put(integerLongEntry.getKey(), integerLongEntry.getKey().toString());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TEACHER_PUSH_PUBLIC_EXTRA_REMIND,
|
|
|
- userMap, null, 0, "11" , "TEACHER", integerLongEntry.getValue());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public PageInfo<TeacherHomeworkListDto> findExtraExercilsesHomeworks(ExtraExercilseQueryInfo queryInfo) {
|
|
|
- PageInfo<TeacherHomeworkListDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- MapUtil.populateMap(params, queryInfo);
|
|
|
- int count = extracurricularExercisesDao.countExtraExercilsesHomeworks(params);
|
|
|
- List<TeacherHomeworkListDto> dataList = new ArrayList<>();
|
|
|
- if(count > 0){
|
|
|
- pageInfo.setTotal(count);
|
|
|
- params.put("offset", pageInfo.getOffset());
|
|
|
- List<ExtracurricularExercisesHomeworkListDto> homeworksExercises = extracurricularExercisesDao.findExtraExercilsesHomeworks(params);
|
|
|
- if(homeworksExercises == null || homeworksExercises.size() == 0){
|
|
|
- return pageInfo;
|
|
|
- }
|
|
|
- //课外训练
|
|
|
- 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());
|
|
|
- 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());
|
|
|
- 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));
|
|
|
- int startRow = queryInfo.getPage() * queryInfo.getRows() - queryInfo.getRows();
|
|
|
- dataList = dataList.stream().sorted(Comparator.comparing(TeacherHomeworkListDto::getDay).reversed()).
|
|
|
- sorted(Comparator.comparing(TeacherHomeworkListDto::getStatus))
|
|
|
- .skip(startRow).limit(queryInfo.getRows()).
|
|
|
- collect(Collectors.toList());
|
|
|
- pageInfo.setRows(dataList);
|
|
|
- }
|
|
|
- return pageInfo;
|
|
|
- }
|
|
|
+ }
|
|
|
+ studentServeService.updateExercisesSituation(exercises.getMusicGroupId(), new Date(), studentIds, exercises.getTeacherId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> findExtraExercilses(ExtraExercilseQueryInfo queryInfo) {
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+
|
|
|
+ List<ExtracurricularExercises> dataList = extracurricularExercisesDao.findExtraExercises(params);
|
|
|
+ if(!CollectionUtils.isEmpty(dataList)){
|
|
|
+ List<Long> extraExerciseIds = dataList.stream().map(ExtracurricularExercises::getId).collect(Collectors.toList());
|
|
|
+ List<ExtracurricularExercisesReply> extraExerciseStudentsByExtraExercises = extracurricularExercisesReplyDao.findExtraExerciseStudentsByExtraExercises(extraExerciseIds);
|
|
|
+ Map<Long, List<ExtracurricularExercisesReply>> idStudentsMap = extraExerciseStudentsByExtraExercises.stream().collect(Collectors.groupingBy(ExtracurricularExercisesReply::getExtracurricularExercisesId));
|
|
|
+ for (ExtracurricularExercises extracurricularExercises : dataList) {
|
|
|
+ List<ExtracurricularExercisesReply> extracurricularExercisesReplies = idStudentsMap.get(extracurricularExercises.getId());
|
|
|
+ if(CollectionUtils.isEmpty(extracurricularExercisesReplies)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ long noRepliedNum = extracurricularExercisesReplies.stream().filter(e -> e.getStatus()==1&&e.getIsReplied() == 0).count();
|
|
|
+ if(noRepliedNum<=0){
|
|
|
+ extracurricularExercises.setIsReplied(1);
|
|
|
+ }
|
|
|
+ long notSubmitNum = extracurricularExercisesReplies.stream().filter(e -> e.getStatus() == 0).count();
|
|
|
+ if(notSubmitNum<=0){
|
|
|
+ extracurricularExercises.setIsSubmit(1);
|
|
|
+ }
|
|
|
+ if(noRepliedNum>0){
|
|
|
+ extracurricularExercises.setStatus(1);
|
|
|
+ }else if(noRepliedNum<=0&¬SubmitNum>0){
|
|
|
+ extracurricularExercises.setStatus(2);
|
|
|
+ }else if(noRepliedNum<=0&¬SubmitNum<=0){
|
|
|
+ extracurricularExercises.setStatus(3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, List<ExtracurricularExercises>> collect = dataList.stream().collect(Collectors.groupingBy(e -> DateUtil.dateToString(e.getCreateTime(), "yyyy-MM-dd")));
|
|
|
+ List<Date> dates=new ArrayList<>();
|
|
|
+ collect.keySet().forEach(ds-> dates.add(DateUtil.stringToDate(ds,"yyyy-MM-dd")));
|
|
|
+ dates.sort(Comparator.comparing(Date::getTime));
|
|
|
+ dates.sort(Comparator.reverseOrder());
|
|
|
+ for (Date date : dates) {
|
|
|
+ String key=DateUtil.dateToString(date, "yyyy-MM-dd");
|
|
|
+ Map<String, Object> r = new HashMap<>();
|
|
|
+ r.put("day", key);
|
|
|
+ collect.get(key).sort(Comparator.comparing(ExtracurricularExercises::getCreateTime).reversed());
|
|
|
+ r.put("list", collect.get(key));
|
|
|
+ result.add(r);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BasicUserDto> getDontServeStudents(Integer teacherId,
|
|
|
+ String search,
|
|
|
+ String musicGroupId,
|
|
|
+ Long classGroupId,
|
|
|
+ Integer subjectId,
|
|
|
+ Integer hasMember,
|
|
|
+ String studentIds) {
|
|
|
+ LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
|
|
|
+ LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
|
|
+ return extracurricularExercisesDao.findNoExercisesStudentsInThisWeekWithTeacher(teacherId, monDayDate.toString(), musicGroupId, classGroupId, subjectId, search,hasMember,studentIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void studentServeRemind() {
|
|
|
+ LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
|
|
|
+ LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
|
|
+ List<Map<Integer, Long>> noFinishedServiceTeacher = studentExtracurricularExercisesSituationDao.getNoFinishedServiceTeacher(monDayDate.toString());
|
|
|
+ Map<Integer, Long> noFinishedServiceTeacherMap= MapUtil.convertIntegerMap(noFinishedServiceTeacher);
|
|
|
+ for (Map.Entry<Integer, Long> integerLongEntry : noFinishedServiceTeacherMap.entrySet()) {
|
|
|
+ Map<Integer, String> userMap = new HashMap<>();
|
|
|
+ userMap.put(integerLongEntry.getKey(), integerLongEntry.getKey().toString());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TEACHER_PUSH_PUBLIC_EXTRA_REMIND,
|
|
|
+ userMap, null, 0, "11" , "TEACHER", integerLongEntry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<TeacherHomeworkListDto> findExtraExercilsesHomeworks(ExtraExercilseQueryInfo queryInfo) {
|
|
|
+ PageInfo<TeacherHomeworkListDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ int count = extracurricularExercisesDao.countExtraExercilsesHomeworks(params);
|
|
|
+ List<TeacherHomeworkListDto> dataList = new ArrayList<>();
|
|
|
+ if(count > 0){
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ List<ExtracurricularExercisesHomeworkListDto> homeworksExercises = extracurricularExercisesDao.findExtraExercilsesHomeworks(params);
|
|
|
+ if(homeworksExercises == null || homeworksExercises.size() == 0){
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+ //课外训练
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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));
|
|
|
+ int startRow = queryInfo.getPage() * queryInfo.getRows() - queryInfo.getRows();
|
|
|
+ dataList = dataList.stream().sorted(Comparator.comparing(TeacherHomeworkListDto::getDay).reversed()).
|
|
|
+ sorted(Comparator.comparing(TeacherHomeworkListDto::getStatus))
|
|
|
+ .skip(startRow).limit(queryInfo.getRows()).
|
|
|
+ collect(Collectors.toList());
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ }
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<CourseHomeworkWrapper.WebExtraCourseHomework> findExtraExercilsesV2(ExtraExercilseQueryInfo queryInfo) {
|