Browse Source

管乐迷作业新增课件

zouxuan 1 year ago
parent
commit
95b95057ea

+ 1 - 1
mec-application/src/main/java/com/ym/mec/interceptor/TenantInterceptor.java

@@ -19,7 +19,7 @@ public class TenantInterceptor extends HandlerInterceptorAdapter {
 
 	@Override
 	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
-		tenantInfoService.saveTenantContextHolder(request);
+//		tenantInfoService.saveTenantContextHolder(request);
 		return true;
 	}
 

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

@@ -73,6 +73,9 @@ public class StudentLessonTrainingDetailWrapper {
         @ApiModelProperty("曲目名称")
         private String  musicScoreName;
 
+        @ApiModelProperty("作业类型,VIDEO,MUSIC_SCORE")
+        private String homeworkType = "MUSIC_SCORE";
+
         @ApiModelProperty("分谱")
         private Integer partIndex;
 

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentLessonTrainingDetail.java

@@ -36,7 +36,6 @@ public class StudentLessonTrainingDetail implements Serializable {
     @TableField(value = "type_")
     private ELessonTrainingType type;
 
-
     @ApiModelProperty("作业分组")
     @TableField(value = "group_")
     private Integer group;
@@ -82,9 +81,11 @@ public class StudentLessonTrainingDetail implements Serializable {
     private Integer times;
 
     @ApiModelProperty("作业类型,VIDEO,MUSIC_SCORE")
+    @TableField(value = "homework_type_")
     private String homeworkType = "MUSIC_SCORE";
 
     @ApiModelProperty("曲目名称")
+    @TableField(value = "music_score_name_")
     private String musicScoreName;
 
     @ApiModelProperty("创建时间") 

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

@@ -73,7 +73,7 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
         }
         List<MusicScoreSubjectDto> scoreSubjectDtoList = exercises.getMusicScoreSubjectDtos();
         if(StringUtils.isBlank(exercises.getStudentIdList())){
-            if(CollectionUtils.isNotEmpty(scoreSubjectDtoList)){
+            if(CollectionUtils.isEmpty(scoreSubjectDtoList)){
                 throw new BizException("请指定学生");
             }
             List<Integer> studentIdList = new ArrayList<>();
@@ -114,7 +114,7 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
         List<ExtracurricularExercisesReply> extracurricularExercisesReplies = new ArrayList<>();
 
         List<StudentLessonTrainingDetail> studentLessonTrainingDetailList = new ArrayList<>();
-        if(!CollectionUtils.isEmpty(scoreSubjectDtoList)){
+        if(CollectionUtils.isNotEmpty(scoreSubjectDtoList)){
             for (MusicScoreSubjectDto musicScoreSubjectDto : scoreSubjectDtoList) {
                 // 原本作业逻辑
                 for (Integer userId : musicScoreSubjectDto.getUserIdList()) {
@@ -149,7 +149,7 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
         for (ExtracurricularExercisesReply extracurricularExercisesReply : extracurricularExercisesReplies) {
             extracurricularExercisesReplyDao.insert(extracurricularExercisesReply);
         }
-        if (!CollectionUtils.isEmpty(studentLessonTrainingDetailList)) {
+        if (CollectionUtils.isNotEmpty(studentLessonTrainingDetailList)) {
             // 学生ID集合
             Set<Integer> userIdList = studentLessonTrainingDetailList.stream()
                     .map(StudentLessonTrainingDetail::getUserId)

+ 54 - 21
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentLessonTrainingDetailServiceImpl.java

@@ -2,6 +2,10 @@ package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
+import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsMaterialWrapper;
+import com.microsvc.toolkit.common.response.paging.PageInfo;
+import com.microsvc.toolkit.common.response.template.R;
 import com.ym.mec.biz.dal.dao.CourseHomeworkDao;
 import com.ym.mec.biz.dal.dao.StudentLessonTrainingDetailMapper;
 import com.ym.mec.biz.dal.dao.SubjectDao;
@@ -16,11 +20,10 @@ 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.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
-
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.function.Function;
@@ -44,6 +47,8 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
     private SubjectService subjectService;
     @Resource
     private ExtracurricularExercisesService extracurricularExercisesService;
+    @Resource
+    private CoursewareFeignService coursewareFeignService;
 
     /**
      * 查询详情
@@ -152,26 +157,54 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
             JSON.toJSONString(list), StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail.class);
 
          // 曲目id集合
-        List<Long> collect = studentLessonTrainingDetails.stream()
-                                                         .map(
-                                                             StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail::getMusicScoreId)
-                                                         .distinct()
-                                                         .collect(Collectors.toList());
-
-        List<SysMusicScore> scoreList = sysMusicScoreDao.findByIds(
-            collect.stream().map(String::valueOf).collect(Collectors.joining(",")));
-
-        // id 分组
-        Map<Integer, SysMusicScore> musicScoreMap = scoreList.stream()
-                                                     .collect(Collectors.toMap(SysMusicScore::getId, Function.identity()));
-
-        for (StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail studentLessonTrainingDetail : studentLessonTrainingDetails) {
-            SysMusicScore sysMusicScore = musicScoreMap.get(studentLessonTrainingDetail.getMusicScoreId().intValue());
-            if (sysMusicScore != null) {
-                studentLessonTrainingDetail.setMusicScoreName(sysMusicScore.getName());
+        List<Long> musicScoreIdList = studentLessonTrainingDetails.stream()
+                 .filter(o-> StringUtils.isEmpty(o.getHomeworkType()) || o.getHomeworkType().equals("MUSIC_SCORE"))
+                 .map(StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail::getMusicScoreId)
+                 .distinct()
+                 .collect(Collectors.toList());
+        if(CollectionUtils.isNotEmpty(musicScoreIdList)){
+            List<SysMusicScore> scoreList = sysMusicScoreDao.findByIds(musicScoreIdList.stream().map(String::valueOf).collect(Collectors.joining(",")));
+            if(CollectionUtils.isNotEmpty(scoreList)){
+                Map<Integer, SysMusicScore> musicScoreMap = scoreList.stream().collect(Collectors.toMap(SysMusicScore::getId, Function.identity()));
+                for (StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail studentLessonTrainingDetail : studentLessonTrainingDetails) {
+                    if(!StringUtils.equals(studentLessonTrainingDetail.getHomeworkType(),"VIDEO")){
+                        SysMusicScore sysMusicScore = musicScoreMap.get(studentLessonTrainingDetail.getMusicScoreId().intValue());
+                        if (sysMusicScore != null) {
+                            studentLessonTrainingDetail.setMusicScoreName(sysMusicScore.getName());
+                        }
+                    }
+                }
+            }
+        }
+        //课件素材编号列表
+        List<Long> materialList = studentLessonTrainingDetails.stream()
+                .filter(o->"VIDEO".equals(o.getHomeworkType()))
+                .map(StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail::getMusicScoreId)
+                .distinct()
+                .collect(Collectors.toList());
+        if(CollectionUtils.isNotEmpty(materialList)){
+            CbsMaterialWrapper.MaterialQuery var1 = new CbsMaterialWrapper.MaterialQuery();
+            var1.setMaterialIdList(materialList);
+            var1.setPage(1);
+            var1.setRows(materialList.size());
+            R<PageInfo<CbsMaterialWrapper.MaterialDto>> pageInfoR = coursewareFeignService.materialPage(var1);
+            if(pageInfoR.getCode() != 200){
+                log.error("查询课件素材失败:{}",pageInfoR.getMessage());
+            }
+            List<CbsMaterialWrapper.MaterialDto> materialDtoList = pageInfoR.getData().getRows();
+            if(CollectionUtils.isNotEmpty(materialDtoList)){
+                Map<Long, CbsMaterialWrapper.MaterialDto> materialDtoMap = materialDtoList.stream()
+                        .collect(Collectors.toMap(CbsMaterialWrapper.MaterialDto::getId, Function.identity()));
+                for (StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail studentLessonTrainingDetail : studentLessonTrainingDetails) {
+                    if(StringUtils.equals(studentLessonTrainingDetail.getHomeworkType(),"VIDEO")){
+                        CbsMaterialWrapper.MaterialDto materialDto = materialDtoMap.get(studentLessonTrainingDetail.getMusicScoreId());
+                        if (materialDto != null) {
+                            studentLessonTrainingDetail.setMusicScoreName(materialDto.getName());
+                        }
+                    }
+                }
             }
         }
-
         // 声部
         List<Integer> subjectIdList = studentLessonTrainingDetails.stream()
                                                           .map(o -> {

+ 1 - 1
mec-common/audit-log/src/main/java/com/yonge/log/interceptor/AuditLogInterceptor.java

@@ -41,7 +41,7 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
 
     @Override
     public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
-        syncSaveLog(request, handler);
+//        syncSaveLog(request, handler);
     }
 
     public void syncSaveLog(HttpServletRequest request, Object handler) {