浏览代码

Merge remote-tracking branch 'origin/saas' into saas

zouxuan 2 年之前
父节点
当前提交
797ad14886
共有 21 个文件被更改,包括 767 次插入305 次删除
  1. 52 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseHomeworkWrapper.java
  2. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicScoreSubjectDto.java
  3. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentLessonExaminationSaveDto.java
  4. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentLessonTrainingDetailWrapper.java
  5. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentLessonExaminationDetail.java
  6. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentLessonTrainingDetail.java
  7. 21 3
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentLessonTrainingDetailService.java
  8. 16 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseHomeworkServiceImpl.java
  9. 30 14
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesReplyServiceImpl.java
  10. 239 220
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesServiceImpl.java
  11. 4 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCourseHomeworkServiceImpl.java
  12. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentLessonExaminationDetailServiceImpl.java
  13. 29 8
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentLessonExaminationServiceImpl.java
  14. 191 31
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentLessonTrainingDetailServiceImpl.java
  15. 22 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherAttendanceServiceImpl.java
  16. 1 1
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  17. 7 3
      mec-biz/src/main/resources/config/mybatis/StudentCourseHomeworkMapper.xml
  18. 2 2
      mec-biz/src/main/resources/config/mybatis/SubjectMapper.xml
  19. 51 0
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/CourseHomeworkController.java
  20. 37 8
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherController.java
  21. 14 5
      mec-web/src/main/java/com/ym/mec/web/controller/TeacherController.java

+ 52 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseHomeworkWrapper.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dto;
 
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.StudentCourseHomework;
 import com.ym.mec.biz.dal.enums.EHomeWorkStatus;
 import com.ym.mec.biz.dal.enums.ELessonTrainingType;
 import com.ym.mec.biz.dal.enums.ImSendTypeEnum;
@@ -146,6 +147,38 @@ public class CourseHomeworkWrapper {
 
         private String studentIdList;
 
+
+        @ApiModelProperty("练习内容")
+        private List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> trainingDetailList;
+
+        @ApiModelProperty("练习组内容")
+        private List<StudentLessonTrainingStat> trainingGroupList;
+    }
+
+
+    @Data
+    @ApiModel(value = "StudentLessonTrainingStat-练习组统计")
+    public static class StudentLessonTrainingStat {
+
+        @ApiModelProperty("练习组")
+        private Integer group;
+
+        @ApiModelProperty("声部名 逗号隔开")
+        private String subjectName;
+
+        @ApiModelProperty("练习组人数")
+        private Integer studentNum;
+
+        @ApiModelProperty("应提交人数")
+        private Integer shouldSubmitNum;
+
+        @ApiModelProperty("提交人数")
+        private Integer submitNum;
+
+        @ApiModelProperty("达标人数")
+        private Integer passNum;
+
+
         @ApiModelProperty("练习内容")
         private List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> trainingDetailList;
     }
@@ -335,4 +368,23 @@ public class CourseHomeworkWrapper {
     }
 
 
+
+
+    @Data
+    @ApiModel(value = "StudentHomeworkRecordStat-学生作业记录统计")
+    public static class StudentHomeworkRecordStat {
+
+        @ApiModelProperty(value = "全部")
+        private Integer allNum;
+
+        @ApiModelProperty(value = "已完成")
+        private Integer finishNum;
+
+        @ApiModelProperty(value = "未完成")
+        private Integer unFinishNum;
+
+        @ApiModelProperty(value = "列表")
+        private  List<StudentCourseHomework> studentCourseHomeworkList;
+
+    }
 }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicScoreSubjectDto.java

@@ -12,6 +12,10 @@ public class MusicScoreSubjectDto {
     @ApiModelProperty(value = "学员编号",required = false)
     private List<Integer> userIdList;
 
+
+    @ApiModelProperty(value = "分组号")
+    private Integer group;
+
     @ApiModelProperty(value = "曲目编号(兼容旧数据)",required = false)
     private List<Integer> musicScoreIdList;
 
@@ -61,4 +65,12 @@ public class MusicScoreSubjectDto {
     public void setMusicScoreIdList(List<Integer> musicScoreIdList) {
         this.musicScoreIdList = musicScoreIdList;
     }
+
+    public Integer getGroup() {
+        return group;
+    }
+
+    public void setGroup(Integer group) {
+        this.group = group;
+    }
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentLessonExaminationSaveDto.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dto;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -20,6 +21,10 @@ public class StudentLessonExaminationSaveDto {
     @ApiModelProperty(value = "声部")
     private Integer subjectId;
 
+
+    @ApiModelProperty("作业分组")
+    private Integer group;
+
     @ApiModelProperty(value = "作业内容")
     private List<LessonExaminationDetailDto> examinationDetailDtos;
 }

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentLessonTrainingDetailWrapper.java

@@ -82,6 +82,10 @@ public class StudentLessonTrainingDetailWrapper {
 
         @ApiModelProperty("声部名称")
         private String subjectName;
+
+
+        @ApiModelProperty("作业分组")
+        private Integer group;
         
         public String jsonString() {
             return JSON.toJSONString(this);
@@ -115,6 +119,25 @@ public class StudentLessonTrainingDetailWrapper {
 	}
 
 
+    @Data
+    @ApiModel(" HomeworkGroupInfoQuery-作业内容查询")
+    public static class HomeworkGroupInfoQuery {
+
+
+        @ApiModelProperty(value = "课程编号",required = true)
+        @NotNull(message = "课程编号不能为空")
+        private Integer courseScheduleId;
+
+        @ApiModelProperty(value = "作业类型 来源(HOMEWORK,EXTRACURRICULAR,EXTRA)",required = true)
+        @NotNull(message = "作业类型不能为空")
+        private ELessonTrainingType type;
+
+        @ApiModelProperty(value = "组号",required = true)
+        @NotNull(message = "组号不能为空")
+        private Integer group;
+
+    }
+
 
     @Data
     @ApiModel(" StudentLessonTraining-学生练习内容查询对象")

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentLessonExaminationDetail.java

@@ -38,6 +38,10 @@ public class StudentLessonExaminationDetail implements Serializable {
     @ApiModelProperty(value = "曲目id")
     private Long musicScoreId;
 
+    @ApiModelProperty("作业分组")
+    @TableField(value = "group_")
+    private Integer group;
+
     @TableField("heard_level_")
     @ApiModelProperty(value = "评测难度")
     private HardLevelEnum heardLevel;

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentLessonTrainingDetail.java

@@ -36,6 +36,12 @@ public class StudentLessonTrainingDetail implements Serializable {
     @TableField(value = "type_")
     private ELessonTrainingType type;
 
+
+    @ApiModelProperty("作业分组")
+    @TableField(value = "group_")
+    private Integer group;
+
+
     @ApiModelProperty("练习编号") 
 	@TableField(value = "course_homework_id_")
     private Long courseHomeworkId;

+ 21 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/StudentLessonTrainingDetailService.java

@@ -1,12 +1,15 @@
 package com.ym.mec.biz.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.dto.CourseHomeworkWrapper;
 import com.ym.mec.biz.dal.dto.StudentLessonTrainingDetailWrapper;
+import com.ym.mec.biz.dal.dto.StudentSubjectDto;
 import com.ym.mec.biz.dal.entity.StudentLessonTrainingDetail;
 import com.ym.mec.biz.dal.enums.ELessonTrainingType;
+import org.jetbrains.annotations.NotNull;
 
-import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 练习内容
@@ -39,9 +42,10 @@ public interface StudentLessonTrainingDetailService extends IService<StudentLess
      * 将作业标准 转换为 需要的作业详情
      *
      * @param studentLessonTrainingDetails 作业标准
-     * @param userIdList 学生ID
+     * @param userIdList                   学生ID
+     * @param group
      */
-    List<StudentLessonTrainingDetail> homeWorkDetail(List<StudentLessonTrainingDetailWrapper.AddStudentLessonTrainingDetail> studentLessonTrainingDetails, List<Integer> userIdList,Long homeworkId,ELessonTrainingType type);
+    List<StudentLessonTrainingDetail> homeWorkDetail(List<StudentLessonTrainingDetailWrapper.AddStudentLessonTrainingDetail> studentLessonTrainingDetails, List<Integer> userIdList, Long homeworkId, ELessonTrainingType type, Integer group);
 
     /**
      * 查询布置的作业详情
@@ -59,4 +63,18 @@ public interface StudentLessonTrainingDetailService extends IService<StudentLess
      * @param userId 学生ID
      */
     List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> getBaseLessonTrainingDetail(Long courseHomeworkId, ELessonTrainingType type, Long userId);
+
+    /**
+     * 查询作业详情练习组
+     *
+     * @param courseHomeworkId 作业ID
+     * @param trainingType 作业类型
+     */
+    List<CourseHomeworkWrapper.StudentLessonTrainingStat> getLessonTrainingStat(Long courseHomeworkId, ELessonTrainingType trainingType);
+
+    @NotNull
+    Map<Integer, StudentSubjectDto> getStudentMusicGroupSubject(List<Integer> userIdList, String musicGroupId);
+
+    @NotNull
+    Map<Integer, List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail>> getGroupMap(Long courseHomeworkId, ELessonTrainingType trainingType);
 }

+ 16 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseHomeworkServiceImpl.java

@@ -269,6 +269,14 @@ public class CourseHomeworkServiceImpl extends BaseServiceImpl<Long, CourseHomew
         List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> baseLessonTrainingDetail = studentLessonTrainingDetailService.getBaseLessonTrainingDetail(
             courseHomeworkList.getCourseHomeworkId(), ELessonTrainingType.HOMEWORK);
 
+
+        // 练习组
+        List<CourseHomeworkWrapper.StudentLessonTrainingStat> trainingStatList =  studentLessonTrainingDetailService
+                .getLessonTrainingStat(courseHomeworkList.getCourseHomeworkId(), ELessonTrainingType.HOMEWORK);
+
+
+
+        courseHomeworkList.setTrainingGroupList(trainingStatList);
         courseHomeworkList.setTrainingDetailList(baseLessonTrainingDetail);
         courseHomeworkList.setType(ELessonTrainingType.HOMEWORK);
         return courseHomeworkList;
@@ -300,9 +308,15 @@ public class CourseHomeworkServiceImpl extends BaseServiceImpl<Long, CourseHomew
             return courseHomeworkList;
         }
 
-        List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> baseLessonTrainingDetail = studentLessonTrainingDetailService.getBaseLessonTrainingDetail(
-            courseHomeworkList.getCourseHomeworkId(),courseHomeworkList.getType());
+        List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> baseLessonTrainingDetail = studentLessonTrainingDetailService
+                .getBaseLessonTrainingDetail(courseHomeworkList.getCourseHomeworkId(),courseHomeworkList.getType());
+
+        // 练习组信息
+        List<CourseHomeworkWrapper.StudentLessonTrainingStat> practiceGroupList = studentLessonTrainingDetailService
+                .getLessonTrainingStat(courseHomeworkList.getCourseHomeworkId(),courseHomeworkList.getType());
+
 
+        courseHomeworkList.setTrainingGroupList(practiceGroupList);
         courseHomeworkList.setTrainingDetailList(baseLessonTrainingDetail);
         return courseHomeworkList;
     }

+ 30 - 14
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesReplyServiceImpl.java

@@ -3,24 +3,13 @@ package com.ym.mec.biz.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.CourseHomeworkStudentDetailDto;
-import com.ym.mec.biz.dal.dto.CourseHomeworkWrapper;
-import com.ym.mec.biz.dal.dto.EduHomeworkCardDto;
-import com.ym.mec.biz.dal.dto.ExtraExerciseStudentsDto;
-import com.ym.mec.biz.dal.dto.SimpleUserDto;
-import com.ym.mec.biz.dal.dto.StudentHomeworkRecordDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.ExtraExercilseQueryInfo;
 import com.ym.mec.biz.dal.page.ExtraExercilseReplyQueryInfo;
 import com.ym.mec.biz.dal.page.StudentCourseHomeWorkQueryInfo;
-import com.ym.mec.biz.service.CourseHomeworkService;
-import com.ym.mec.biz.service.ExtracurricularExercisesReplyService;
-import com.ym.mec.biz.service.ExtracurricularExercisesService;
-import com.ym.mec.biz.service.MusicGroupService;
-import com.ym.mec.biz.service.StudentServeService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysMessageService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
@@ -73,6 +62,9 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
     @Autowired
     private CourseHomeworkService courseHomeworkService;
 
+    @Autowired
+    private StudentLessonTrainingDetailService studentLessonTrainingDetailService;
+
 	@Override
 	public BaseDAO<Long, ExtracurricularExercisesReply> getDAO() {
 		return extracurricularExercisesReplyDao;
@@ -90,6 +82,21 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
             throw new BizException("课外训练不存在");
         }
 
+
+        // 设置乐团声部
+        Map<Integer, StudentSubjectDto> subjectDtoMap= new HashMap<>();
+        if (StringUtils.isNotBlank(extracurricularExercises.getMusicGroupId())) {
+
+            // 学生ID集合
+            Set<Integer> userIdList = extraExerciseStudents.stream()
+                    .map(ExtracurricularExercisesReply::getUserId)
+                    .filter(Objects::nonNull)
+                    .collect(Collectors.toSet());
+            // 设置声部
+            subjectDtoMap = studentLessonTrainingDetailService
+                    .getStudentMusicGroupSubject(new ArrayList<>(userIdList), extracurricularExercises.getMusicGroupId());
+        }
+
         List<StudentCourseHomework> studentCourseHomeworks=new ArrayList<>();
         for (ExtraExerciseStudentsDto extraExerciseStudent : extraExerciseStudents) {
             StudentCourseHomework studentCourseHomework= JSON.parseObject(JSON.toJSONString(extraExerciseStudent),StudentCourseHomework.class);
@@ -103,8 +110,17 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 			studentCourseHomework.setIsView(extraExerciseStudent.getIsView()==0?YesOrNoEnum.NO:YesOrNoEnum.YES);
 			studentCourseHomework.setAvatar(extraExerciseStudent.getHeadUrl());
             studentCourseHomework.setType(ELessonTrainingType.valueOf(extracurricularExercises.getGroupType()));
-			studentCourseHomeworks.add(studentCourseHomework);
+
+            StudentSubjectDto studentSubjectDto = subjectDtoMap.get(extraExerciseStudent.getUserId());
+            if (studentSubjectDto != null) {
+                studentCourseHomework.setSubjectId(studentSubjectDto.getSubjectId());
+                studentCourseHomework.setSubjectName(studentSubjectDto.getSubjectName());
+            }
+
+            studentCourseHomeworks.add(studentCourseHomework);
 		}
+
+
 		return studentCourseHomeworks;
 	}
 

+ 239 - 220
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesServiceImpl.java

@@ -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&&notSubmitNum>0){
-					extracurricularExercises.setStatus(2);
-				}else if(noRepliedNum<=0&&notSubmitNum<=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&&notSubmitNum>0){
-							homeworkListDto.setStatus(2);
-						}else if(noRepliedNum<=0&&notSubmitNum<=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&&notSubmitNum>0){
-							teacherHomeworkListDto.setStatus(2);
-						}else if(noRepliedNum<=0&&notSubmitNum<=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&&notSubmitNum>0){
+                    extracurricularExercises.setStatus(2);
+                }else if(noRepliedNum<=0&&notSubmitNum<=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&&notSubmitNum>0){
+                            homeworkListDto.setStatus(2);
+                        }else if(noRepliedNum<=0&&notSubmitNum<=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&&notSubmitNum>0){
+                            teacherHomeworkListDto.setStatus(2);
+                        }else if(noRepliedNum<=0&&notSubmitNum<=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) {

+ 4 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCourseHomeworkServiceImpl.java

@@ -807,7 +807,9 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
                 } else {
                     studentCourseHomework.setVipFlag(true);
                 }
-                studentCourseHomework.setSubjectId(Integer.parseInt(student.getSubjectIdList()));
+                if (studentCourseHomework.getSubjectId() == null) {
+                    studentCourseHomework.setSubjectId(Integer.parseInt(student.getSubjectIdList()));
+                }
             }
         }
 
@@ -815,7 +817,7 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
         // 设置声部
 
         // 获取声部id集合
-        List<Integer> voicePartIds = students.stream().map(Student::getSubjectIdList).map(Integer::parseInt).collect(Collectors.toList());
+        List<Integer> voicePartIds = studentCourseHomeworkByCourse.stream().map(o -> o.getSubjectId()).collect(Collectors.toList());
 
         if (CollectionUtils.isEmpty(voicePartIds)) {
             return studentCourseHomeworkByCourse;

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentLessonExaminationDetailServiceImpl.java

@@ -57,6 +57,7 @@ public class StudentLessonExaminationDetailServiceImpl extends ServiceImpl<Stude
                     studentLessonExaminationDetail.setMusicScoreId(vo.getMusicScoreId());
                     studentLessonExaminationDetail.setHeardLevel(vo.getHeardLevel());
                     studentLessonExaminationDetail.setStandardScore(vo.getScore());
+                    studentLessonExaminationDetail.setGroup(dto.getGroup());
                     if(i == 0){
                         studentLessonExaminationDetail.setAvgScore(score + subScore);
                     }else {

+ 29 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentLessonExaminationServiceImpl.java

@@ -5,18 +5,13 @@ import com.ym.mec.biz.dal.dao.LessonExaminationDao;
 import com.ym.mec.biz.dal.dao.StudentExtracurricularExercisesSituationDao;
 import com.ym.mec.biz.dal.dao.StudentLessonExaminationDao;
 import com.ym.mec.biz.dal.dao.StudentLessonExaminationDetailDao;
-import com.ym.mec.biz.dal.dto.LessonExaminationSubmitDto;
-import com.ym.mec.biz.dal.dto.StudentLessonExaminationDto;
-import com.ym.mec.biz.dal.dto.StudentLessonExaminationDto1;
-import com.ym.mec.biz.dal.dto.StudentLessonExaminationSaveDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.LessonExamination;
 import com.ym.mec.biz.dal.entity.StudentLessonExamination;
 import com.ym.mec.biz.dal.entity.StudentLessonExaminationDetail;
+import com.ym.mec.biz.dal.entity.StudentLessonTrainingDetail;
 import com.ym.mec.biz.dal.page.StudentLessonExaminationQueryInfo;
-import com.ym.mec.biz.service.LessonExaminationService;
-import com.ym.mec.biz.service.StudentExtracurricularExercisesSituationService;
-import com.ym.mec.biz.service.StudentLessonExaminationDetailService;
-import com.ym.mec.biz.service.StudentLessonExaminationService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.util.collection.MapUtil;
@@ -28,6 +23,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 学生进度评测表(StudentLessonExamination)表服务实现类
@@ -45,8 +41,13 @@ public class StudentLessonExaminationServiceImpl extends ServiceImpl<StudentLess
     @Autowired
     private LessonExaminationDao lessonExaminationDao;
     @Autowired
+    private LessonExaminationService lessonExaminationService;
+    @Autowired
     private StudentExtracurricularExercisesSituationService studentExtracurricularExercisesSituationService;
 
+    @Autowired
+    private StudentLessonTrainingDetailService studentLessonTrainingDetailService;
+
     @Override
     public StudentLessonExaminationDao getDao() {
         return this.baseMapper;
@@ -69,6 +70,26 @@ public class StudentLessonExaminationServiceImpl extends ServiceImpl<StudentLess
                 studentLessonExaminations.add(studentLessonExamination);
             }
         }
+        LessonExamination examination = lessonExaminationService.getById(lessonExaminationId);
+
+        // 学生ID集合
+        Set<Integer> userIdList = studentLessonExaminations.stream()
+                .map(StudentLessonExamination::getUserId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+        // 设置声部
+        Map<Integer, StudentSubjectDto> subjectDtoMap = studentLessonTrainingDetailService
+                .getStudentMusicGroupSubject(new ArrayList<>(userIdList), examination.getMusicGroupId());
+
+        studentLessonExaminations.forEach(studentLessonTrainingDetail -> {
+            if (studentLessonTrainingDetail.getUserId() == null) {
+                return;
+            }
+            StudentSubjectDto studentSubjectDto = subjectDtoMap.get(studentLessonTrainingDetail.getUserId());
+            if (Objects.nonNull(studentSubjectDto)) {
+                studentLessonTrainingDetail.setSubjectId(studentSubjectDto.getSubjectId());
+            }
+        });
 
         baseMapper.insertBatch(studentLessonExaminations);
         return studentIdList;

+ 191 - 31
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentLessonTrainingDetailServiceImpl.java

@@ -2,25 +2,27 @@ package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.biz.dal.dao.CourseHomeworkDao;
 import com.ym.mec.biz.dal.dao.StudentLessonTrainingDetailMapper;
 import com.ym.mec.biz.dal.dao.SubjectDao;
 import com.ym.mec.biz.dal.dao.SysMusicScoreDao;
+import com.ym.mec.biz.dal.dto.CourseHomeworkWrapper;
 import com.ym.mec.biz.dal.dto.StudentLessonTrainingDetailWrapper;
-import com.ym.mec.biz.dal.entity.StudentLessonTrainingDetail;
-import com.ym.mec.biz.dal.entity.Subject;
-import com.ym.mec.biz.dal.entity.SysMusicScore;
+import com.ym.mec.biz.dal.dto.StudentSubjectDto;
+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.ExtracurricularExercisesService;
 import com.ym.mec.biz.service.StudentLessonTrainingDetailService;
+import com.ym.mec.biz.service.SubjectService;
 import lombok.extern.slf4j.Slf4j;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -38,25 +40,34 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
     @Autowired
     private SubjectDao subjectDao;
 
-	/**
+    @Autowired
+    private CourseHomeworkDao courseHomeworkDao;
+
+    @Autowired
+    private SubjectService subjectService;
+
+    @Autowired
+    private ExtracurricularExercisesService extracurricularExercisesService;
+
+    /**
      * 查询详情
      * @param id 详情ID
      * @return StudentLessonTrainingDetail
      */
-	@Override
+    @Override
     public StudentLessonTrainingDetail detail(Long id) {
-        
+
         return baseMapper.selectById(id);
     }
-	
+
     /**
      * 添加
      * @param studentLessonTrainingDetail StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail
      * @return Boolean
      */
     @Override
-    public Boolean add(StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail studentLessonTrainingDetail) {    	
-        
+    public Boolean add(StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail studentLessonTrainingDetail) {
+
         return this.save(JSON.parseObject(studentLessonTrainingDetail.jsonString(), StudentLessonTrainingDetail.class));
     }
 
@@ -68,39 +79,42 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
     @Override
     public Boolean update(StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail studentLessonTrainingDetail){
 
-        return this.updateById(JSON.parseObject(studentLessonTrainingDetail.jsonString(), StudentLessonTrainingDetail.class));       
+        return this.updateById(JSON.parseObject(studentLessonTrainingDetail.jsonString(), StudentLessonTrainingDetail.class));
     }
 
     /**
      * 将作业标准 转换为 需要的作业详情
      *
      * @param detailList 作业标准
-     * @param userIdList                   学生ID
+     * @param userIdList 学生ID
+     * @param group
      */
     @Override
-    public List<StudentLessonTrainingDetail> homeWorkDetail(List<StudentLessonTrainingDetailWrapper.AddStudentLessonTrainingDetail> detailList, List<Integer> userIdList,Long homeworkId,ELessonTrainingType type) {
+    public List<StudentLessonTrainingDetail> homeWorkDetail(List<StudentLessonTrainingDetailWrapper.AddStudentLessonTrainingDetail> detailList,
+                                                            List<Integer> userIdList, Long homeworkId, ELessonTrainingType type, Integer group) {
         log.info("将作业标准 转换为 需要的作业详情 {},{}", detailList, userIdList);
         // 保存作业标准
         if (CollectionUtils.isEmpty(detailList) || CollectionUtils.isEmpty(userIdList)) {
             return new ArrayList<>();
         }
+        if (group == null) {
+            group = 1;
+        }
 
         List<StudentLessonTrainingDetail> result = new ArrayList<>();
 
-        if (!CollectionUtils.isEmpty(detailList)) {
-            List<StudentLessonTrainingDetail> details = JSON.parseArray(
+        List<StudentLessonTrainingDetail> details = JSON.parseArray(
+            JSON.toJSONString(detailList), StudentLessonTrainingDetail.class);
+        result.addAll(details);
+        // 根据声部添加学生作业详情
+        userIdList.forEach(userId -> {
+            List<StudentLessonTrainingDetail> detailsUser = JSON.parseArray(
                 JSON.toJSONString(detailList), StudentLessonTrainingDetail.class);
-            result.addAll(details);
-            // 根据声部添加学生作业详情
-            userIdList.forEach(userId -> {
-                List<StudentLessonTrainingDetail> detailsUser = JSON.parseArray(
-                    JSON.toJSONString(detailList), StudentLessonTrainingDetail.class);
-                for (StudentLessonTrainingDetail studentLessonTrainingDetail : detailsUser) {
-                    studentLessonTrainingDetail.setUserId(userId.longValue());
-                }
-                result.addAll(detailsUser);
-            });
-        }
+            for (StudentLessonTrainingDetail studentLessonTrainingDetail : detailsUser) {
+                studentLessonTrainingDetail.setUserId(userId.longValue());
+            }
+            result.addAll(detailsUser);
+        });
         for (StudentLessonTrainingDetail studentLessonTrainingDetail : result) {
 
             studentLessonTrainingDetail.setCourseHomeworkId(homeworkId);
@@ -108,6 +122,7 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
             studentLessonTrainingDetail.setTrainingStatus(StandardEnum.NOT_START);
             studentLessonTrainingDetail.setCreateTime(new Date());
             studentLessonTrainingDetail.setUpdateTime(new Date());
+            studentLessonTrainingDetail.setGroup(group);
             studentLessonTrainingDetail.setType(type);
 
         }
@@ -135,8 +150,7 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
     @Override
     public List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> getBaseLessonTrainingDetail(Long courseHomeworkId, ELessonTrainingType type, Long userId) {
         List<StudentLessonTrainingDetail> list = this.lambdaQuery()
-                                                     .eq(StudentLessonTrainingDetail::getCourseHomeworkId,
-                                                         courseHomeworkId)
+                                                     .eq(StudentLessonTrainingDetail::getCourseHomeworkId,courseHomeworkId)
                                                      .isNull(userId == null,StudentLessonTrainingDetail::getUserId)
                                                      .eq(StudentLessonTrainingDetail::getType, type)
                                                      .eq(userId != null, StudentLessonTrainingDetail::getUserId, userId)
@@ -196,4 +210,150 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
 
         return studentLessonTrainingDetails;
     }
+
+
+    /**
+     * 查询作业详情练习组
+     *
+     * @param courseHomeworkId 作业ID
+     * @param trainingType 作业类型
+     */
+    @Override
+    public List<CourseHomeworkWrapper.StudentLessonTrainingStat> getLessonTrainingStat(Long courseHomeworkId, ELessonTrainingType trainingType) {
+        List<StudentLessonTrainingDetail> list = this.lambdaQuery()
+                                                     .eq(StudentLessonTrainingDetail::getCourseHomeworkId,courseHomeworkId)
+                                                     .eq(StudentLessonTrainingDetail::getType, trainingType)
+                                                    .isNotNull(StudentLessonTrainingDetail::getUserId)
+                                                     .list();
+        if (CollectionUtils.isEmpty(list)) {
+            return new ArrayList<>();
+        }
+
+        // 用户ID集合
+        List<Integer> userIdList = list.stream()
+                                    .map(StudentLessonTrainingDetail::getUserId)
+                                    .filter(Objects::nonNull)
+                                    .distinct()
+                                    .map(Long::intValue)
+                                    .collect(Collectors.toList());
+        String musicGroupId = null;
+        if (trainingType.equals(ELessonTrainingType.HOMEWORK)) {
+            CourseHomework courseHomework = courseHomeworkDao.get(courseHomeworkId);
+            if (courseHomework == null) {
+                return new ArrayList<>();
+            }
+            musicGroupId = courseHomework.getMusicGroupId();
+        } else {
+            ExtracurricularExercises exercises = extracurricularExercisesService.get(courseHomeworkId);
+            if (exercises == null) {
+                return new ArrayList<>();
+            }
+            musicGroupId = exercises.getMusicGroupId();
+        }
+
+        Map<Integer, StudentSubjectDto> studentSubjectDtoMap = getStudentMusicGroupSubject(userIdList, musicGroupId);
+
+        // 根据group 分组
+        Map<Integer, List<StudentLessonTrainingDetail>> groupMap = list.stream()
+                                                                           .collect(Collectors.groupingBy(StudentLessonTrainingDetail::getGroup));
+
+
+        Map<Integer, List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail>> groupDetailMap = getGroupMap(courseHomeworkId, trainingType);
+
+
+        List<CourseHomeworkWrapper.StudentLessonTrainingStat> studentLessonTrainingStats = new ArrayList<>();
+
+        // 根据分组数据统计声部, 完成人数
+        groupMap.forEach((k,v) -> {
+            CourseHomeworkWrapper.StudentLessonTrainingStat studentLessonTrainingStat = new CourseHomeworkWrapper.StudentLessonTrainingStat();
+            studentLessonTrainingStat.setGroup(k);
+            Set<Integer> userIds = v.stream().map(o -> o.getUserId().intValue()).collect(Collectors.toSet());
+            // 课后作业和课外作业查询学生在当前乐团声部
+            Set<String> subjectNameList = new HashSet<>();
+            if(!CollectionUtils.isEmpty(userIds)) {
+                for (Integer userId : userIds) {
+                    StudentSubjectDto studentSubjectDto = studentSubjectDtoMap.get(userId);
+                    if (studentSubjectDto != null) {
+                        subjectNameList.add(studentSubjectDto.getSubjectName());
+                    }
+                }
+            }
+            // 按人分组
+            Map<Long, List<StudentLessonTrainingDetail>> userMap = v.stream()
+                                                                    .collect(Collectors.groupingBy(StudentLessonTrainingDetail::getUserId));
+            int submitNum = 0;
+            int passNum = 0;
+            for (Map.Entry<Long, List<StudentLessonTrainingDetail>> entry : userMap.entrySet()) {
+                List<StudentLessonTrainingDetail> v1 = entry.getValue();
+                Set<StandardEnum> standardEnumSet = v1.stream().map(o -> o.getTrainingStatus()).filter(Objects::nonNull).collect(Collectors.toSet());
+                if (standardEnumSet.size() > 1 || standardEnumSet.contains(StandardEnum.NOT_STANDARD)) {
+                    submitNum++;
+                }  else {
+                    if (standardEnumSet.contains(StandardEnum.STANDARD)) {
+                        submitNum++;
+                        passNum++;
+                    }
+                }
+
+            }
+
+            studentLessonTrainingStat.setSubjectName(subjectNameList.stream().collect(Collectors.joining(",")));
+            studentLessonTrainingStat.setStudentNum(userIds.size());
+            studentLessonTrainingStat.setShouldSubmitNum(userIds.size());
+            studentLessonTrainingStat.setSubmitNum(submitNum);
+            studentLessonTrainingStat.setPassNum(passNum);
+
+            //设置基本作业内容
+            List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> studentLessonTrainingDetails = groupDetailMap.get(k);
+            if (!CollectionUtils.isEmpty(studentLessonTrainingDetails)) {
+                studentLessonTrainingStat.setTrainingDetailList(studentLessonTrainingDetails);
+            }
+            studentLessonTrainingStats.add(studentLessonTrainingStat);
+
+        });
+
+
+        return studentLessonTrainingStats;
+    }
+
+    @NotNull
+    @Override
+    public Map<Integer, StudentSubjectDto> getStudentMusicGroupSubject(List<Integer> userIdList, String musicGroupId) {
+        // 课后作业和课外作业查询学生在当前乐团声部
+        Map<Integer, StudentSubjectDto> studentSubjectDtoMap = new HashMap<>();
+        if (!StringUtils.isEmpty(musicGroupId)) {
+            List<StudentRegistration> registerSubject = subjectDao.getRegisterSubject(musicGroupId, userIdList);
+            if (!CollectionUtils.isEmpty(registerSubject)) {
+                registerSubject.forEach(o -> {
+                    StudentSubjectDto studentSubjectDto = new StudentSubjectDto();
+                    studentSubjectDto.setSubjectId(o.getActualSubjectId());
+                    studentSubjectDto.setSubjectName(o.getSubjectName());
+                    studentSubjectDto.setStudentId(o.getUserId());
+                    studentSubjectDtoMap.put(o.getUserId(), studentSubjectDto);
+                });
+            }
+        }
+
+        // 额外作业查询学生声部
+        Map<Integer, StudentSubjectDto> subjectDtoMap = subjectService.getSubjectByStudentId(new HashSet(userIdList));
+        subjectDtoMap.forEach((k,v) -> {
+            if (!studentSubjectDtoMap.containsKey(k)) {
+                studentSubjectDtoMap.put(k, v);
+            }
+        });
+        return studentSubjectDtoMap;
+    }
+
+    @NotNull
+    @Override
+    public Map<Integer, List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail>> getGroupMap(Long courseHomeworkId, ELessonTrainingType trainingType) {
+        // 作业内容
+        List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail> baseLessonTrainingDetail = getBaseLessonTrainingDetail(
+                courseHomeworkId, trainingType);
+
+        // 按组分组
+        Map<Integer, List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail>> groupDetailMap = baseLessonTrainingDetail.stream()
+                                .collect(Collectors.groupingBy(StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail::getGroup,LinkedHashMap::new,Collectors.toList()));
+        return groupDetailMap;
+    }
 }

+ 22 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherAttendanceServiceImpl.java

@@ -1,6 +1,5 @@
 package com.ym.mec.biz.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -37,10 +36,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.math.BigDecimal;
-import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -429,7 +425,8 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
                                 studentLessonTrainingDetail.setSubjectId(scoreSubjectDto.getSubjectId());
                             }
                             studentLessonTrainingDetails.addAll(studentLessonTrainingDetailService
-                                                                    .homeWorkDetail(scoreSubjectDto.getStudentLessonTrainingDetails(), userIdList,courseHomework.getId(),ELessonTrainingType.HOMEWORK));
+                                                                    .homeWorkDetail(scoreSubjectDto.getStudentLessonTrainingDetails(), userIdList,
+                                                                            courseHomework.getId(),ELessonTrainingType.HOMEWORK, scoreSubjectDto.getGroup()));
 
 						}
 					}else {
@@ -443,7 +440,7 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
                                                                       .map(StudentCourseHomework::getUserId)
                                                                       .collect(Collectors.toList());
                         studentLessonTrainingDetails.addAll(studentLessonTrainingDetailService
-                                                                .homeWorkDetail(courseHomeworkInfo.getStudentLessonTrainingDetails(), userIdList,courseHomework.getId(),ELessonTrainingType.HOMEWORK));
+                                                                .homeWorkDetail(courseHomeworkInfo.getStudentLessonTrainingDetails(), userIdList,courseHomework.getId(),ELessonTrainingType.HOMEWORK,null));
 
 					}
 					if(CollectionUtils.isEmpty(studentCourseHomeworks)){
@@ -509,6 +506,25 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 						}
 					}
                     if (!CollectionUtils.isEmpty(studentLessonTrainingDetails)) {
+                        // 学生ID集合
+                        Set<Integer> userIdList = studentLessonTrainingDetails.stream()
+                                                                              .map(StudentLessonTrainingDetail::getUserId)
+                                                                                .filter(Objects::nonNull)
+                                                                                .map(Long::intValue)
+                                                                              .collect(Collectors.toSet());
+                        // 设置声部
+                        Map<Integer, StudentSubjectDto> subjectDtoMap = studentLessonTrainingDetailService
+                                .getStudentMusicGroupSubject(new ArrayList<>(userIdList), classGroup.getMusicGroupId());
+
+                        studentLessonTrainingDetails.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(studentLessonTrainingDetails);
                     }
 				}else{

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -4275,7 +4275,7 @@
                 and cs.type_ = #{param.classType}
             </if>
 
-            <if test="param.musicGroupId != null ">
+            <if test="param.musicGroupId != null and  param.musicGroupId != ''">
                 and #{param.musicGroupId} = cs.music_group_id_
             </if>
             <if test="param.homeWorkStatus != null">

+ 7 - 3
mec-biz/src/main/resources/config/mybatis/StudentCourseHomeworkMapper.xml

@@ -28,6 +28,7 @@
         <result column="music_score_id_" property="musicScoreId"/>
         <result column="music_score_content_" property="musicScoreContent"/>
         <result column="tenant_id_" property="tenantId"/>
+        <result column="subject_id_" property="subjectId"/>
         <result column="standard_flag_" property="standardFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
 
@@ -710,15 +711,18 @@
         sch.*,
         su.username_,
         su.avatar_,
-        su.phone_
+        su.phone_,
+        sr.actual_subject_id_ as subject_id_
         FROM
         student_course_homework sch
+        left join course_homework ch on ch.id_ = sch.course_homework_id_
         LEFT JOIN sys_user su ON sch.user_id_=su.id_
-        left join student s on s.user_id_ = su.id_
+        left join student s2 on s2.user_id_ = su.id_
+        left join student_registration sr on sr.user_id_ = sch.user_id_ and sr.music_group_id_ = ch.music_group_id_
         <where>
             sch.course_schedule_id_=#{query.courseScheduleId}
             <if test="query.subjectId != null">
-                and s.subject_id_list_ = #{query.subjectId}
+                and (sr.actual_subject_id_ = #{query.subjectId} or (sr.actual_subject_id_ is null and s2.subject_id_list_ = #{query.subjectId}))
             </if>
         </where>
     </select>

+ 2 - 2
mec-biz/src/main/resources/config/mybatis/SubjectMapper.xml

@@ -260,9 +260,9 @@
     </select>
 
     <select id="getRegisterSubject" resultMap="com.ym.mec.biz.dal.dao.StudentRegistrationDao.StudentRegistration">
-        SELECT sr.user_id_, s.name_ subject_name_ FROM student_registration sr
+        SELECT sr.user_id_, s.name_ subject_name_,sr.actual_subject_id_ FROM student_registration sr
         LEFT JOIN subject s ON sr.actual_subject_id_=s.id_
-        WHERE sr.music_group_id_=#{musicGroupId} AND s.del_flag_ = 0 AND sr.music_group_status_ != 'QUIT'
+        WHERE sr.music_group_id_=#{musicGroupId} AND s.del_flag_ = 0
         AND sr.user_id_ IN
         <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
             #{userId}

+ 51 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/CourseHomeworkController.java

@@ -2,6 +2,7 @@ package com.ym.mec.teacher.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.CourseHomeworkDao;
 import com.ym.mec.biz.dal.dto.CourseHomeworkStudentDetailDto;
 import com.ym.mec.biz.dal.dto.CourseHomeworkWrapper;
 import com.ym.mec.biz.dal.dto.StudentLessonTrainingDetailWrapper;
@@ -14,6 +15,7 @@ import com.ym.mec.biz.dal.page.CourseHomeworkQueryInfo;
 import com.ym.mec.biz.service.CourseHomeworkService;
 import com.ym.mec.biz.service.ExtracurricularExercisesReplyService;
 import com.ym.mec.biz.service.StudentCourseHomeworkService;
+import com.ym.mec.biz.service.StudentLessonTrainingDetailService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
@@ -30,7 +32,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -51,6 +55,12 @@ public class CourseHomeworkController extends BaseController {
     @Autowired
     private SysUserFeignService sysUserFeignService;
 
+    @Autowired
+    private StudentLessonTrainingDetailService studentLessonTrainingDetailService;
+
+    @Autowired
+    private CourseHomeworkDao courseHomeworkDao;
+
     @ApiOperation(value = "布置课堂作业")
     @GetMapping("/addCourseHomework")
     @AuditLogAnnotation(operateName = "布置课堂作业")
@@ -171,6 +181,47 @@ public class CourseHomeworkController extends BaseController {
 
 
 
+    @ApiOperation(value = "根据课程计划获取需要交作业的学生统计")
+    @PostMapping("/findCourseStudentsPublicSubject/v2")
+    public HttpResponseResult<CourseHomeworkWrapper.StudentHomeworkRecordStat> findCourseStudentsPublicSubjectV2(@Validated @RequestBody StudentLessonTrainingDetailWrapper.StudentLessonTrainingQuery query){
+        List<StudentCourseHomework> list;
+        if(ELessonTrainingType.HOMEWORK.equals(query.getType())){
+            if (Objects.isNull(query.getCourseScheduleId())) {
+                throw new BizException("请指定课程");
+            }
+            list =  (studentCourseHomeworkService.findStudentCourseHomeworkByCourseV2(query));
+        }else{
+            list =  (studentCourseHomeworkService.findExtraExerciseStudentsV2(query));
+        }
+
+        CourseHomeworkWrapper.StudentHomeworkRecordStat stat = new CourseHomeworkWrapper.StudentHomeworkRecordStat();
+        stat.setAllNum(list.size());
+        stat.setFinishNum((int) list.stream().filter(StudentCourseHomework::getFinishFlag).count());
+        stat.setUnFinishNum(stat.getAllNum()-stat.getFinishNum());
+        stat.setStudentCourseHomeworkList(list);
+        return succeed(stat);
+
+    }
+
+
+    @ApiOperation(value = "老师练习详情的练习组内作业信息")
+    @PostMapping("/findHomeworkGroupInfo")
+    public HttpResponseResult<List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail>> findHomeworkGroupInfo(@Validated @RequestBody StudentLessonTrainingDetailWrapper.HomeworkGroupInfoQuery query){
+
+        if (ELessonTrainingType.HOMEWORK.equals(query.getType())) {
+            CourseHomework courseHomework = courseHomeworkDao.findByCourseSchedule(query.getCourseScheduleId().longValue());
+            if(Objects.isNull(courseHomework)){
+                throw new BizException("作业不存在");
+            }
+            query.setCourseScheduleId(courseHomework.getId().intValue());
+        }
+        Map<Integer, List<StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail>> groupMap = studentLessonTrainingDetailService.getGroupMap(query.getCourseScheduleId().longValue(), query.getType());
+
+
+        return succeed(groupMap.get(query.getGroup()));
+
+    }
+
     @ApiOperation(value = "查询单个学生的训练")
     @GetMapping("/findCourseHomeworkStudentDetailPublic/v2")
     public HttpResponseResult<StudentLessonTrainingDetailWrapper.StudentLessonTraining> findCourseHomeworkStudentDetailPublicV2(@RequestParam Long courseScheduleId, @RequestParam Long userId, @RequestParam ELessonTrainingType type){

+ 37 - 8
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherController.java

@@ -4,7 +4,10 @@ import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 import com.ym.mec.biz.dal.dao.SubjectDao;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.CooperationOrgan;
+import com.ym.mec.biz.dal.entity.StudentCourseHomework;
+import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.Teacher;
+import com.ym.mec.biz.dal.enums.ELessonTrainingType;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
@@ -15,14 +18,11 @@ import com.ym.mec.common.page.QueryInfo;
 import io.swagger.annotations.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
 import java.util.stream.Collectors;
 
 @RequestMapping("teacher")
@@ -47,6 +47,9 @@ public class TeacherController extends BaseController {
 	@Autowired
     private StudentRegistrationService studentRegistrationService;
 
+    @Autowired
+    private StudentCourseHomeworkService studentCourseHomeworkService;
+
     @ApiOperation(value = "修改教师个人中心信息")
     @PostMapping("/update")
     public Object update(Teacher teacher) {
@@ -191,4 +194,30 @@ public class TeacherController extends BaseController {
         return succeed(teacherService.queryTeacherMusicStudentOverViewV2(queryInfo));
     }
 
+
+
+    @ApiOperation(value = "根据课程计划获取需要交作业的学生声部-公用")
+    @PostMapping("/findCourseStudentsSubjectPublic/v2")
+    public HttpResponseResult<List<Subject>> findCourseStudentsSubjectPublicV2(@Validated @RequestBody StudentLessonTrainingDetailWrapper.StudentLessonTrainingQuery query){
+        List<StudentCourseHomework> studentCourseHomeworkByCourseV2;
+        if(ELessonTrainingType.HOMEWORK.equals(query.getType())){
+            if (Objects.isNull(query.getCourseScheduleId())) {
+                throw new BizException("请指定课程");
+            }
+            studentCourseHomeworkByCourseV2 = studentCourseHomeworkService.findStudentCourseHomeworkByCourseV2(
+                    query);
+        }else{
+            studentCourseHomeworkByCourseV2 = studentCourseHomeworkService.findExtraExerciseStudentsV2(query);
+        }
+
+        if (CollectionUtils.isEmpty(studentCourseHomeworkByCourseV2)) {
+            return succeed(new ArrayList<>());
+        }
+        // 获取声部
+        List<Integer> collect = studentCourseHomeworkByCourseV2.stream().map(StudentCourseHomework::getSubjectId).collect(
+                Collectors.toList());
+
+        return succeed(subjectService.findBySubjectByIdList(collect));
+
+    }
 }

+ 14 - 5
mec-web/src/main/java/com/ym/mec/web/controller/TeacherController.java

@@ -3,6 +3,7 @@ package com.ym.mec.web.controller;
 import com.ym.mec.biz.dal.dto.*;
 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.dal.page.*;
 import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.CourseHomeworkService;
@@ -76,8 +77,8 @@ public class TeacherController extends BaseController {
     public HttpResponseResult<PageInfo<Teacher>> queryPage(TeacherQueryInfo queryInfo) {
         queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
         if(queryInfo.getTenantId() == 28){
-        	queryInfo.setTenantId(1);
-        	queryInfo.setOrganId(null);
+            queryInfo.setTenantId(1);
+            queryInfo.setOrganId(null);
         }
         return succeed(teacherService.queryPageDetail(queryInfo));
     }
@@ -116,7 +117,7 @@ public class TeacherController extends BaseController {
         organId = organizationService.getEmployeeOrgan(organId);
         demissionFlag = false;
         if(isForzenWithQueryCondition == null){
-        	isForzenWithQueryCondition = false;
+            isForzenWithQueryCondition = false;
         }
         return succeed(teacherService.findTeachers(organId,demissionFlag,isForzenWithQueryCondition));
     }
@@ -236,14 +237,22 @@ public class TeacherController extends BaseController {
     @ApiOperation(value = "根据课程计划获取需要交作业的学生-公用")
     @PostMapping("/findCourseStudentsPublic/v2")
     public HttpResponseResult<List<StudentCourseHomework>> findCourseStudentsPublicV2(@Validated @RequestBody StudentLessonTrainingDetailWrapper.StudentLessonTrainingQuery query){
+        List<StudentCourseHomework>  result = new ArrayList<>();
         if(ELessonTrainingType.HOMEWORK.equals(query.getType())){
             if (Objects.isNull(query.getCourseScheduleId())) {
                 throw new BizException("请指定课程");
             }
-            return succeed(studentCourseHomeworkService.findStudentCourseHomeworkByCourseV2(query));
+            result = studentCourseHomeworkService.findStudentCourseHomeworkByCourseV2(query);
         }else{
-            return succeed(studentCourseHomeworkService.findExtraExerciseStudentsV2(query));
+            result = studentCourseHomeworkService.findExtraExerciseStudentsV2(query);
         }
+        // 完成才返回提交时间
+        for (StudentCourseHomework studentCourseHomework : result) {
+            if (!StandardEnum.STANDARD.equals(studentCourseHomework.getStandardFlag())) {
+                studentCourseHomework.setSubmitTime(null);
+            }
+        }
+        return succeed(result);
     }