|
@@ -1,17 +1,22 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
|
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
|
|
|
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.StudentLessonTrainingDetail;
|
|
|
import com.ym.mec.biz.dal.entity.Teacher;
|
|
|
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
|
|
|
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.StudentLessonTrainingDetailService;
|
|
|
import com.ym.mec.biz.service.StudentServeService;
|
|
|
import com.ym.mec.biz.service.SysMessageService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
@@ -21,6 +26,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -55,6 +61,12 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
@Autowired
|
|
|
private StudentCourseHomeworkDao studentCourseHomeworkDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentLessonTrainingDetailService studentLessonTrainingDetailService;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Long, ExtracurricularExercises> getDAO() {
|
|
|
return extracurricularExercisesDao;
|
|
@@ -70,16 +82,28 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
throw new BizException("请填写内容");
|
|
|
}
|
|
|
List<MusicScoreSubjectDto> scoreSubjectDtoList = exercises.getMusicScoreSubjectDtos();
|
|
|
- if(StringUtils.isBlank(exercises.getStudentIdList())){
|
|
|
- if(scoreSubjectDtoList == null || scoreSubjectDtoList.size() == 0){
|
|
|
- throw new BizException("请指定学生");
|
|
|
- }
|
|
|
+
|
|
|
+ if (exercises.getClassGroupId() != null) {
|
|
|
+ List<ClassGroupStudentMapper> studentMapperList = classGroupStudentMapperDao.findByClassGroup(
|
|
|
+ exercises.getClassGroupId());
|
|
|
+ if (CollectionUtils.isEmpty(studentMapperList)) {
|
|
|
+ throw new BizException("班级学生为空");
|
|
|
+ }
|
|
|
+ List<Integer> studentIdList = studentMapperList.stream()
|
|
|
+ .filter(o -> !o.getStatus().equals(ClassGroupStudentStatusEnum.QUIT))
|
|
|
+ .map(ClassGroupStudentMapper::getUserId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ exercises.setStudentIdList(StringUtils.join(studentIdList,","));
|
|
|
+
|
|
|
+ } else if(StringUtils.isNotBlank(exercises.getStudentIdList()) || CollectionUtils.isEmpty(scoreSubjectDtoList)) {
|
|
|
List<Integer> studentIdList = new ArrayList<>();
|
|
|
for (MusicScoreSubjectDto musicScoreSubjectDto : scoreSubjectDtoList) {
|
|
|
studentIdList.addAll(musicScoreSubjectDto.getUserIdList());
|
|
|
}
|
|
|
exercises.setStudentIdList(StringUtils.join(studentIdList,","));
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ throw new BizException("请指定学生");
|
|
|
+ }
|
|
|
|
|
|
teacherDao.getLocked(exercises.getTeacherId());
|
|
|
Teacher teacher = teacherDao.get(exercises.getTeacherId());
|
|
@@ -100,32 +124,45 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
extracurricularExercisesDao.insert(exercises);
|
|
|
String dateStr = DateUtil.dateToString(exercises.getExpireDate(), "MM月dd日HH点");
|
|
|
|
|
|
- Map<List<Integer>, List<MusicScoreSubjectDto>> collect = null;
|
|
|
- Set<List<Integer>> lists = null;
|
|
|
- if(!CollectionUtils.isEmpty(scoreSubjectDtoList)){
|
|
|
- collect = scoreSubjectDtoList.stream().collect(Collectors.groupingBy(e -> e.getUserIdList()));
|
|
|
- lists = collect.keySet();
|
|
|
- }
|
|
|
- for (Integer studentId : studentIds) {
|
|
|
- ExtracurricularExercisesReply studentExtraExercise=new ExtracurricularExercisesReply();
|
|
|
- studentExtraExercise.setExtracurricularExercisesId(exercises.getId());
|
|
|
- studentExtraExercise.setUserId(studentId);
|
|
|
- studentExtraExercise.setStatus(0);
|
|
|
- studentExtraExercise.setIsReplied(0);
|
|
|
- studentExtraExercise.setIsView(0);
|
|
|
- studentExtraExercise.setIsRepliedTimely(0);
|
|
|
- studentExtraExercise.setMusicScoreId(exercises.getMusicScoreId());
|
|
|
- if(!CollectionUtils.isEmpty(scoreSubjectDtoList)){
|
|
|
- for (List<Integer> list : lists) {
|
|
|
- if(list.contains(studentId)){
|
|
|
- MusicScoreSubjectDto musicScoreSubjectDto = collect.get(list).get(0);
|
|
|
- studentExtraExercise.setMusicScoreId(StringUtils.join(musicScoreSubjectDto.getMusicScoreIdList(),","));
|
|
|
- studentExtraExercise.setMusicScoreContent(JSONObject.toJSONString(musicScoreSubjectDto.getMusicScoreHomeworkDtoList()));
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- extracurricularExercisesReplyDao.insert(studentExtraExercise);
|
|
|
+ ExtracurricularExercisesReply studentExtraExercise=new ExtracurricularExercisesReply();
|
|
|
+ studentExtraExercise.setExtracurricularExercisesId(exercises.getId());
|
|
|
+ studentExtraExercise.setStatus(0);
|
|
|
+ studentExtraExercise.setIsReplied(0);
|
|
|
+ studentExtraExercise.setIsView(0);
|
|
|
+ studentExtraExercise.setIsRepliedTimely(0);
|
|
|
+ studentExtraExercise.setMusicScoreId(exercises.getMusicScoreId());
|
|
|
+
|
|
|
+ List<ExtracurricularExercisesReply> extracurricularExercisesReplies = new ArrayList<>();
|
|
|
+
|
|
|
+ List<StudentLessonTrainingDetail> studentLessonTrainingDetailList = new ArrayList<>();
|
|
|
+ if(!CollectionUtils.isEmpty(scoreSubjectDtoList)){
|
|
|
+ for (MusicScoreSubjectDto musicScoreSubjectDto : scoreSubjectDtoList) {
|
|
|
+ // 原本作业逻辑
|
|
|
+ for (Integer userId : musicScoreSubjectDto.getUserIdList()) {
|
|
|
+ studentExtraExercise.setUserId(userId);
|
|
|
+ studentExtraExercise.setMusicScoreId(StringUtils.join(musicScoreSubjectDto.getMusicScoreIdList(),","));
|
|
|
+ studentExtraExercise.setMusicScoreContent(JSONObject.toJSONString(musicScoreSubjectDto.getMusicScoreHomeworkDtoList()));
|
|
|
+ extracurricularExercisesReplies.add(ObjectUtils.clone(studentExtraExercise));
|
|
|
+ }
|
|
|
+ // 作业详情
|
|
|
+ studentLessonTrainingDetailList.addAll(studentLessonTrainingDetailService
|
|
|
+ .homeWorkDetail(musicScoreSubjectDto.getStudentLessonTrainingDetails(), musicScoreSubjectDto.getUserIdList(),exercises.getId()));
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (Integer studentId : studentIds) {
|
|
|
+ studentExtraExercise.setUserId(studentId);
|
|
|
+ extracurricularExercisesReplies.add(ObjectUtils.clone(studentExtraExercise));
|
|
|
+ }
|
|
|
+ // 作业详情
|
|
|
+ studentLessonTrainingDetailList.addAll(studentLessonTrainingDetailService
|
|
|
+ .homeWorkDetail(exercises.getStudentLessonTrainingDetails(), studentIds,exercises.getId()));
|
|
|
+ }
|
|
|
+ extracurricularExercisesReplyDao.batchInsert(extracurricularExercisesReplies);
|
|
|
+ studentLessonTrainingDetailService.saveBatch(studentLessonTrainingDetailList);
|
|
|
+
|
|
|
+ for (ExtracurricularExercisesReply extracurricularExercisesReply : extracurricularExercisesReplies) {
|
|
|
+ Integer studentId = extracurricularExercisesReply.getUserId();
|
|
|
|
|
|
String notifyUrl = "?courseScheduleID=" + studentExtraExercise.getId() + "&studentCourseHomeworkId=" + studentExtraExercise.getId() + "&extra=1";
|
|
|
String extra = "dayaedu" + notifyUrl + "&userId=" + studentId;
|