zouxuan 3 місяців тому
батько
коміт
e8bd4a0f80

+ 16 - 5
mec-application/src/main/java/com/ym/mec/student/controller/LessonCoursewareController.java

@@ -8,10 +8,7 @@ import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
-import com.ym.mec.biz.dal.entity.LessonCourseware;
-import com.ym.mec.biz.dal.entity.MemberRankCategoryMapper;
-import com.ym.mec.biz.dal.entity.MemberRankCourseTypeMapper;
-import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.ClientEnum;
 import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
 import com.ym.mec.biz.service.*;
@@ -29,7 +26,9 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @RequestMapping("${app-config.url.student:}/lessonCourseware")
@@ -57,6 +56,9 @@ public class LessonCoursewareController extends BaseController {
     @Resource
     private MemberRankCategoryMapperService memberRankCategoryMapperService;
 
+    @Resource
+    private SysMusicScoreService sysMusicScoreService;
+
 	@ApiOperation(value = "分页查询已添加的课件")
 	@PostMapping("/queryLessonCourseware")
 	public HttpResponseResult<PageInfo<LessonCoursewareWrapper.LessonCoursewareDto>> queryLessonCourseware(@RequestBody LessonCoursewareWrapper.LessonCoursewareQuery query){
@@ -156,7 +158,16 @@ public class LessonCoursewareController extends BaseController {
             query1.setUserType(ClientEnum.STUDENT);
             query1.setTenantCategoriesIdList(categoryIdList);
             query1.setStudentCategoriesIdList(categoryIds);
-            courseScheduleCoursewareDetails.forEach(e->lessonCoursewareService.setTreeResourceId(e.getKnowledgePointList(),query1));
+            //获取课件下面包含的所有的曲目编号
+            List<Long> musicScoreIds = lessonCoursewareService.getMusicScoreIds(courseScheduleCoursewareDetails);
+            Map<Long, SysMusicScore> musicScoreMap = new HashMap<>();
+            if (CollectionUtils.isNotEmpty(musicScoreIds)) {
+                List<SysMusicScore> musicScores = sysMusicScoreService.getDao().findByCbsId(musicScoreIds,false);
+                musicScoreMap = musicScores.stream().collect(Collectors.toMap(e -> e.getId().longValue(), o -> o));
+            }
+            for (CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail e : courseScheduleCoursewareDetails) {
+                lessonCoursewareService.setTreeResourceId(e.getKnowledgePointList(), query1, musicScoreMap);
+            }
             if(StringUtils.isNotEmpty(search)){
                 courseScheduleCoursewareDetails.removeIf(courseScheduleCoursewareDetail -> !filterAndUpdateKnowledgePointList(courseScheduleCoursewareDetail, search));
             }

+ 16 - 8
mec-application/src/main/java/com/ym/mec/teacher/controller/LessonCoursewareController.java

@@ -9,13 +9,11 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.entity.SysMusicScore;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.enums.ClientEnum;
 import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
-import com.ym.mec.biz.service.CbsMusicScoreCategoriesService;
-import com.ym.mec.biz.service.LessonCoursewareService;
-import com.ym.mec.biz.service.OrganizationService;
-import com.ym.mec.biz.service.SysUserService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
@@ -24,12 +22,14 @@ import com.ym.mec.common.page.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @RequestMapping("${app-config.url.teacher:}/lessonCourseware")
 @Api(tags = "课件教材")
@@ -45,6 +45,8 @@ public class LessonCoursewareController extends BaseController {
 	@Resource
 	private OrganizationService organizationService;
 	@Resource
+	private SysMusicScoreService sysMusicScoreService;
+	@Resource
 	private CbsMusicScoreCategoriesService cbsMusicScoreCategoriesService;
 	@Resource
 	private TeacherDao teacherDao;
@@ -88,9 +90,15 @@ public class LessonCoursewareController extends BaseController {
 			LessonCoursewareWrapper.LessonCoursewareDetailQuery query1 = new LessonCoursewareWrapper.LessonCoursewareDetailQuery();
 			query1.setUserType(ClientEnum.TEACHER);
 			query1.setTenantCategoriesIdList(categoryIdList);
-			courseScheduleCoursewareDetails.forEach(e->lessonCoursewareService.setTreeResourceId(e.getKnowledgePointList(),query1));
-			if(StringUtils.isNotEmpty(search)){
-				courseScheduleCoursewareDetails.removeIf(courseScheduleCoursewareDetail -> !filterAndUpdateKnowledgePointList(courseScheduleCoursewareDetail, search));
+			//获取课件下面包含的所有的曲目编号
+			List<Long> musicScoreIds = lessonCoursewareService.getMusicScoreIds(courseScheduleCoursewareDetails);
+			Map<Long, SysMusicScore> musicScoreMap = new HashMap<>();
+			if (CollectionUtils.isNotEmpty(musicScoreIds)) {
+				List<SysMusicScore> musicScores = sysMusicScoreService.getDao().findByCbsId(musicScoreIds,false);
+				musicScoreMap = musicScores.stream().collect(Collectors.toMap(e -> e.getId().longValue(), o -> o));
+			}
+			for (CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail e : courseScheduleCoursewareDetails) {
+				lessonCoursewareService.setTreeResourceId(e.getKnowledgePointList(), query1, musicScoreMap);
 			}
 			String jsonString = JSONObject.toJSONString(courseScheduleCoursewareDetails);
 			List<LessonCoursewareWrapper.CourseScheduleCoursewareDetail> courseScheduleCoursewareDetailList =

+ 8 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/LessonCoursewareService.java

@@ -3,11 +3,14 @@ package com.ym.mec.biz.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareDetailWrapper;
+import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
+import com.ym.mec.biz.dal.entity.SysMusicScore;
 import com.ym.mec.biz.dal.mapper.LessonCoursewareMapper;
 import com.ym.mec.biz.dal.entity.LessonCourseware;
 import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
 
 import java.util.List;
+import java.util.Map;
 
 public interface LessonCoursewareService extends IService<LessonCourseware> {
 
@@ -31,6 +34,10 @@ public interface LessonCoursewareService extends IService<LessonCourseware> {
     List<LessonCourseware> getByLessonCoursewareIds(List<Integer> categoryIds);
 
     //递归处理CbsLessonCoursewareDetailWrapper.KnowledgePointSmall
-    void setTreeResourceId(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList, LessonCoursewareWrapper.LessonCoursewareDetailQuery query);
+    void setTreeResourceId(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList,
+                           LessonCoursewareWrapper.LessonCoursewareDetailQuery query,
+                           Map<Long, SysMusicScore> musicScores);
+
+    List<Long> getMusicScoreIds(List<CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail> courseScheduleCoursewareDetails);
 }
 

+ 59 - 28
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareServiceImpl.java

@@ -204,8 +204,16 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
         if (detail == null) {
             return null;
         }
+        //获取课件下面包含的所有的曲目编号
+        List<Long> musicScoreIds = new ArrayList<>();
+        this.setMusicSheetId(detail.getKnowledgePointList(),musicScoreIds);
+        Map<Long, SysMusicScore> musicScoreMap = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(musicScoreIds)) {
+            List<SysMusicScore> musicScores = sysMusicScoreService.getDao().findByCbsId(musicScoreIds,false);
+            musicScoreMap = musicScores.stream().collect(Collectors.toMap(e -> e.getId().longValue(), o -> o));
+        }
         //获取知识点下的素材列表、下面关联的资源列表,如果applicationIdList是空的,那么把他剔除掉
-        this.setTreeResourceId(detail.getKnowledgePointList(),query);
+        this.setTreeResourceId(detail.getKnowledgePointList(),query,musicScoreMap);
         return detail;
     }
 
@@ -350,32 +358,67 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
 
     //递归处理CbsLessonCoursewareDetailWrapper.KnowledgePointSmall
     @Override
-    public void setTreeResourceId(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList,LessonCoursewareWrapper.LessonCoursewareDetailQuery query){
+    public void setTreeResourceId(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList,
+                                  LessonCoursewareWrapper.LessonCoursewareDetailQuery query,
+                                  Map<Long, SysMusicScore> musicScores){
         if(CollectionUtils.isNotEmpty(knowledgePointList)){
             knowledgePointList.forEach(knowledgePointSmall -> {
-                this.setResourceId(knowledgePointSmall,query);
+                this.setResourceId(knowledgePointSmall,query,musicScores);
                 List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> children = knowledgePointSmall.getChildren();
                 if(CollectionUtils.isNotEmpty(children)){
-                    this.setTreeResourceId(children,query);
+                    this.setTreeResourceId(children,query,musicScores);
                 }
             });
         }
     }
 
+    @Override
+    public List<Long> getMusicScoreIds(List<CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail> courseScheduleCoursewareDetails) {
+        List<Long> musicScoreIds = new ArrayList<>();
+        //获取所有曲目的ID
+        if(CollectionUtils.isNotEmpty(courseScheduleCoursewareDetails)){
+            courseScheduleCoursewareDetails.forEach(courseScheduleCoursewareDetail -> {
+                this.setMusicSheetId(courseScheduleCoursewareDetail.getKnowledgePointList(),musicScoreIds);
+            });
+        }
+        return musicScoreIds;
+    }
 
-    private void setResourceId(CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall,LessonCoursewareWrapper.LessonCoursewareDetailQuery query){
-        List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialList = knowledgePointSmall.getMaterialList();
-        if(CollectionUtils.isNotEmpty(materialList)){
-            //获取所有曲目的ID
-            List<Long> musicScoreIds = materialList.stream().filter(materialSmall -> materialSmall.getType() == EMaterialType.SONG)
-                    .map(materialSmall -> Long.parseLong(materialSmall.getContent())).collect(Collectors.toList());
-            Map<Long, SysMusicScore> musicScoreMap = new HashMap<>();
-            if(CollectionUtils.isNotEmpty(musicScoreIds)){
-                List<SysMusicScore> musicScores = sysMusicScoreService.getDao().findByCbsId(musicScoreIds,false);
-                if(CollectionUtils.isNotEmpty(musicScores)){
-                    musicScoreMap = musicScores.stream().collect(Collectors.toMap(e->e.getId().longValue(), o -> o));
+    private void setMusicSheetId(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList,List<Long> musicScoreIds){
+        if(CollectionUtils.isNotEmpty(knowledgePointList)){
+            for (CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall : knowledgePointList) {
+                List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialList = knowledgePointSmall.getMaterialList();
+                if(CollectionUtils.isNotEmpty(materialList)){
+                    //获取所有曲目的ID
+                    List<Long> musicScoreIds1 = materialList.stream().filter(materialSmall -> materialSmall.getType() == EMaterialType.SONG)
+                            .map(materialSmall -> Long.parseLong(materialSmall.getContent())).collect(Collectors.toList());
+                    musicScoreIds.addAll(musicScoreIds1);
+                    for (CbsLessonCoursewareDetailWrapper.MaterialSmall materialSmall : materialList) {
+                        List<CbsMaterialRefWrapper.AddMaterialRef> materialRefs = materialSmall.getMaterialRefs();
+                        if(CollectionUtils.isNotEmpty(materialRefs)){
+                            //获取所有曲目的ID
+                            List<Long> musicScoreIds2 = materialRefs.stream().filter(materialRef -> materialRef.getRelateMaterialInfo() != null
+                                    && StringUtils.equals(materialRef.getRelateMaterialInfo().getType(),"SONG")
+                                    && CollectionUtils.isNotEmpty(materialRef.getRelateMaterialInfo().getApplicationIdList()))
+                                    .map(materialRef -> materialRef.getRelateMaterialInfo().getId()).collect(Collectors.toList());
+                            musicScoreIds.addAll(musicScoreIds2);
+                        }
+                    }
+                }
+                List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> children = knowledgePointSmall.getChildren();
+                if(CollectionUtils.isNotEmpty(children)){
+                    this.setMusicSheetId(children,musicScoreIds);
                 }
             }
+        }
+    }
+
+
+    private void setResourceId(CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall,
+                               LessonCoursewareWrapper.LessonCoursewareDetailQuery query,
+                               Map<Long, SysMusicScore> musicScoreMap){
+        List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialList = knowledgePointSmall.getMaterialList();
+        if(CollectionUtils.isNotEmpty(materialList)){
             for (CbsLessonCoursewareDetailWrapper.MaterialSmall materialSmall : materialList) {
                 if(materialSmall.getType() == EMaterialType.SONG){
                     SysMusicScore musicScore = musicScoreMap.get(Long.parseLong(materialSmall.getContent()));
@@ -389,23 +432,11 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
                 //
                 List<CbsMaterialRefWrapper.AddMaterialRef> materialRefs = materialSmall.getMaterialRefs();
                 if (CollectionUtils.isNotEmpty(materialRefs)){
-                    //获取所有曲目的ID
-                    List<Long> musicScoreIds1 = materialRefs.stream().filter(materialRef -> materialRef.getRelateMaterialInfo() != null
-                            && StringUtils.equals(materialRef.getRelateMaterialInfo().getType(),"SONG")
-                            && CollectionUtils.isNotEmpty(materialRef.getRelateMaterialInfo().getApplicationIdList()))
-                            .map(materialRef -> materialRef.getRelateMaterialInfo().getId()).collect(Collectors.toList());
-                    Map<Long, SysMusicScore> musicScoreMap1 = new HashMap<>();
-                    if(CollectionUtils.isNotEmpty(musicScoreIds1)){
-                        List<SysMusicScore> musicScores = sysMusicScoreService.getDao().findByCbsId(musicScoreIds1,false);
-                        if(CollectionUtils.isNotEmpty(musicScores)){
-                            musicScoreMap1 = musicScores.stream().collect(Collectors.toMap(e->e.getId().longValue(), o -> o));
-                        }
-                    }
                     for (CbsMaterialRefWrapper.AddMaterialRef materialRef : materialRefs) {
                         CbsMaterialRefWrapper.RelateMaterialInfo relateMaterialInfo = materialRef.getRelateMaterialInfo();
                         if(relateMaterialInfo != null && StringUtils.equals(relateMaterialInfo.getType(),"SONG")
                                 && CollectionUtils.isNotEmpty(relateMaterialInfo.getApplicationIdList())){
-                            SysMusicScore musicScore = musicScoreMap1.get(relateMaterialInfo.getId());
+                            SysMusicScore musicScore = musicScoreMap.get(relateMaterialInfo.getId());
                             if(musicScore != null && musicScore.getShowFlag() == 1 && musicScore.getClientShowFlag() == 1
                                     && query.getTenantCategoriesIdList().contains(musicScore.getCbsMusicCategoriesId())) {
                                 materialRef.setResourceIdStr(musicScore.getId().toString());