|
@@ -15,6 +15,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -42,32 +43,49 @@ public class StudentLessonExaminationDetailServiceImpl extends ServiceImpl<Stude
|
|
|
for (StudentLessonExaminationSaveDto dto : studentLessonExaminationSaveDtos) {
|
|
|
String[] studentIds = dto.getStudentIds().split(",");
|
|
|
List<LessonExaminationDetailDto> detailDtos = dto.getExaminationDetailDtos();
|
|
|
- if (CollectionUtils.isEmpty(detailDtos)) {
|
|
|
- throw new BizException("有部分声部未选择曲目");
|
|
|
+ if (CollectionUtils.isEmpty(detailDtos) && StringUtils.isEmpty(dto.getMemo())) {
|
|
|
+ throw new BizException("有部分声部未设置作业内容");
|
|
|
}
|
|
|
- for (String id : studentIds) {
|
|
|
- Integer studentId = Integer.parseInt(id);
|
|
|
- Integer score = 100/detailDtos.size();
|
|
|
- Integer subScore = 100 - score * detailDtos.size();
|
|
|
- for (int i = 0; i < detailDtos.size(); i++) {
|
|
|
- LessonExaminationDetailDto vo = detailDtos.get(i);
|
|
|
- StudentLessonExaminationDetail studentLessonExaminationDetail = new StudentLessonExaminationDetail();
|
|
|
- studentLessonExaminationDetail.setUserId(studentId);
|
|
|
- studentLessonExaminationDetail.setMemo(dto.getMemo());
|
|
|
- studentLessonExaminationDetail.setLessonExaminationId(lessonExaminationId);
|
|
|
- studentLessonExaminationDetail.setMusicScoreId(vo.getMusicScoreId());
|
|
|
- studentLessonExaminationDetail.setHeardLevel(vo.getHeardLevel());
|
|
|
- studentLessonExaminationDetail.setStandardScore(vo.getScore());
|
|
|
- studentLessonExaminationDetail.setStart(vo.getStart());
|
|
|
- studentLessonExaminationDetail.setEnd(vo.getEnd());
|
|
|
- studentLessonExaminationDetail.setGroup(dto.getGroup());
|
|
|
- if(i == 0){
|
|
|
- studentLessonExaminationDetail.setAvgScore(score + subScore);
|
|
|
- }else {
|
|
|
- studentLessonExaminationDetail.setAvgScore(score);
|
|
|
+ if (CollectionUtils.isEmpty(detailDtos)) {
|
|
|
+// throw new BizException("有部分声部未选择曲目");
|
|
|
+ for (String id : studentIds) {
|
|
|
+ Integer studentId = Integer.parseInt(id);
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ StudentLessonExaminationDetail studentLessonExaminationDetail = new StudentLessonExaminationDetail();
|
|
|
+ studentLessonExaminationDetail.setUserId(studentId);
|
|
|
+ studentLessonExaminationDetail.setMemo(dto.getMemo());
|
|
|
+ studentLessonExaminationDetail.setLessonExaminationId(lessonExaminationId);
|
|
|
+ studentLessonExaminationDetail.setGroup(dto.getGroup());
|
|
|
+ studentLessonExaminationDetail.setType("DESCRIPTION");
|
|
|
+ detailList.add(studentLessonExaminationDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (String id : studentIds) {
|
|
|
+ Integer studentId = Integer.parseInt(id);
|
|
|
+ Integer score = 100 / detailDtos.size();
|
|
|
+ Integer subScore = 100 - score * detailDtos.size();
|
|
|
+ for (int i = 0; i < detailDtos.size(); i++) {
|
|
|
+ LessonExaminationDetailDto vo = detailDtos.get(i);
|
|
|
+ StudentLessonExaminationDetail studentLessonExaminationDetail = new StudentLessonExaminationDetail();
|
|
|
+ studentLessonExaminationDetail.setUserId(studentId);
|
|
|
+ studentLessonExaminationDetail.setMemo(dto.getMemo());
|
|
|
+ studentLessonExaminationDetail.setLessonExaminationId(lessonExaminationId);
|
|
|
+ studentLessonExaminationDetail.setMusicScoreId(vo.getMusicScoreId());
|
|
|
+ studentLessonExaminationDetail.setHeardLevel(vo.getHeardLevel());
|
|
|
+ studentLessonExaminationDetail.setStandardScore(vo.getScore());
|
|
|
+ studentLessonExaminationDetail.setStart(vo.getStart());
|
|
|
+ studentLessonExaminationDetail.setType("MUSIC_SCORE");
|
|
|
+ studentLessonExaminationDetail.setEnd(vo.getEnd());
|
|
|
+ studentLessonExaminationDetail.setGroup(dto.getGroup());
|
|
|
+ if (i == 0) {
|
|
|
+ studentLessonExaminationDetail.setAvgScore(score + subScore);
|
|
|
+ } else {
|
|
|
+ studentLessonExaminationDetail.setAvgScore(score);
|
|
|
+ }
|
|
|
+ studentLessonExaminationDetail.setPartIndex(vo.getPartIndex());
|
|
|
+ detailList.add(studentLessonExaminationDetail);
|
|
|
}
|
|
|
- studentLessonExaminationDetail.setPartIndex(vo.getPartIndex());
|
|
|
- detailList.add(studentLessonExaminationDetail);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -79,5 +97,13 @@ public class StudentLessonExaminationDetailServiceImpl extends ServiceImpl<Stude
|
|
|
return baseMapper.queryAll(query);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<StudentLessonExaminationDetail> queryByStudent(Integer userId, Long lessonExaminationId) {
|
|
|
+ return this.lambdaQuery()
|
|
|
+ .eq(StudentLessonExaminationDetail::getUserId, userId)
|
|
|
+ .eq(StudentLessonExaminationDetail::getLessonExaminationId, lessonExaminationId)
|
|
|
+ .list();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|