|  | @@ -5,9 +5,12 @@ import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  |  import com.dayaedu.cbs.common.enums.school.ECourseType;
 | 
	
		
			
				|  |  | +import com.dayaedu.cbs.common.enums.school.EKnowledgeType;
 | 
	
		
			
				|  |  |  import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
 | 
	
		
			
				|  |  |  import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsCourseTypeWrapper;
 | 
	
		
			
				|  |  | +import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareDetailWrapper;
 | 
	
		
			
				|  |  |  import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
 | 
	
		
			
				|  |  | +import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsMaterialRefWrapper;
 | 
	
		
			
				|  |  |  import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
 | 
	
		
			
				|  |  |  import com.microsvc.toolkit.common.response.paging.PageInfo;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.*;
 | 
	
	
		
			
				|  | @@ -418,4 +421,78 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return lessonCoursewareDto;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail getLessonCourseDetail(String lessonCoursewareDetailId) {
 | 
	
		
			
				|  |  | +        CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail lessonCoursewareDetail = coursewareFeignService.lessonCoursewareDetailDetail(Long.parseLong(lessonCoursewareDetailId)).feignData();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 过滤调未应用到项目的去练习曲目
 | 
	
		
			
				|  |  | +        List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList = lessonCoursewareDetail.getKnowledgePointList();
 | 
	
		
			
				|  |  | +        List<CbsMaterialRefWrapper.AddMaterialRef> addMaterialRefs = getMaterialRefList(knowledgePointList);
 | 
	
		
			
				|  |  | +        List<Long> cbsMusicSheetIdList =
 | 
	
		
			
				|  |  | +            addMaterialRefs.stream().filter(next -> EKnowledgeType.MUSIC.equals(next.getKnowledgeType())).map(CbsMaterialRefWrapper.AddMaterialRef::getResourceId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        if (!org.springframework.util.CollectionUtils.isEmpty(cbsMusicSheetIdList)) {
 | 
	
		
			
				|  |  | +            Map<Long, Long> idMap = musicSheetService.lambdaQuery()
 | 
	
		
			
				|  |  | +                .in(MusicSheet::getCbsMusicSheetId, cbsMusicSheetIdList)
 | 
	
		
			
				|  |  | +                .eq(MusicSheet::getDelFlag, false)
 | 
	
		
			
				|  |  | +                .eq(MusicSheet::getState, 1)
 | 
	
		
			
				|  |  | +                .list()
 | 
	
		
			
				|  |  | +                .stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(MusicSheet::getCbsMusicSheetId, MusicSheet::getId,(o1,o2)->o1));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (CbsMaterialRefWrapper.AddMaterialRef addMaterialRef : addMaterialRefs) {
 | 
	
		
			
				|  |  | +                Long resourceId = addMaterialRef.getResourceId();
 | 
	
		
			
				|  |  | +                if (idMap.containsKey(resourceId)) {
 | 
	
		
			
				|  |  | +                    addMaterialRef.setResourceId(idMap.get(resourceId));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            // 过滤掉没有对应的曲目
 | 
	
		
			
				|  |  | +            filterMaterialRefList(knowledgePointList,new ArrayList<>(idMap.values()));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return lessonCoursewareDetail;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void filterMaterialRefList(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList,List<Long> cbsMusicSheetIds) {
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(knowledgePointList)) {
 | 
	
		
			
				|  |  | +            for (CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall : knowledgePointList) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (CollectionUtils.isNotEmpty(knowledgePointSmall.getChildren())) {
 | 
	
		
			
				|  |  | +                    filterMaterialRefList(knowledgePointSmall.getChildren(),cbsMusicSheetIds);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialList = knowledgePointSmall.getMaterialList();
 | 
	
		
			
				|  |  | +                if (CollectionUtils.isNotEmpty(materialList)) {
 | 
	
		
			
				|  |  | +                    for (CbsLessonCoursewareDetailWrapper.MaterialSmall materialSmall : materialList) {
 | 
	
		
			
				|  |  | +                        if (CollectionUtils.isNotEmpty(materialSmall.getMaterialRefs())) {
 | 
	
		
			
				|  |  | +                            List<CbsMaterialRefWrapper.AddMaterialRef> refList = materialSmall.getMaterialRefs().stream()
 | 
	
		
			
				|  |  | +                                .filter(next -> !(EKnowledgeType.MUSIC.equals(next.getKnowledgeType()) && !cbsMusicSheetIds.contains(next.getResourceId())))
 | 
	
		
			
				|  |  | +                                .collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                            materialSmall.setMaterialRefs(refList);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<CbsMaterialRefWrapper.AddMaterialRef> getMaterialRefList(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList) {
 | 
	
		
			
				|  |  | +        List<CbsMaterialRefWrapper.AddMaterialRef> materialRefList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(knowledgePointList)) {
 | 
	
		
			
				|  |  | +            for (CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall : knowledgePointList) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (CollectionUtils.isNotEmpty(knowledgePointSmall.getChildren())) {
 | 
	
		
			
				|  |  | +                    materialRefList.addAll(getMaterialRefList(knowledgePointSmall.getChildren()));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialList = knowledgePointSmall.getMaterialList();
 | 
	
		
			
				|  |  | +                if (CollectionUtils.isNotEmpty(materialList)) {
 | 
	
		
			
				|  |  | +                    for (CbsLessonCoursewareDetailWrapper.MaterialSmall materialSmall : materialList) {
 | 
	
		
			
				|  |  | +                        if (CollectionUtils.isNotEmpty(materialSmall.getMaterialRefs())) {
 | 
	
		
			
				|  |  | +                            materialRefList.addAll(materialSmall.getMaterialRefs());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return materialRefList;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |