|
@@ -14,24 +14,21 @@ import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
|
|
|
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.microsvc.toolkit.common.response.template.R;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.*;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMusicMapper;
|
|
|
-import com.yonge.cooleshow.biz.dal.mapper.UserTenantAlbumRecordMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.LessonCoursewareDetailWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.LessonCoursewareWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumMusicWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumWrapper;
|
|
|
import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
-import com.yonge.cooleshow.common.enums.YesOrNoEnum;
|
|
|
-import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
@@ -41,6 +38,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -252,6 +250,30 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
|
|
|
return page.setRecords(musicSheets);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public IPage<TenantAlbumMusicWrapper.MusicSheetSimpleDto> selectPageSimple(IPage<TenantAlbumMusicWrapper.MusicSheetSimpleDto> page, TenantAlbumMusicWrapper.StudentTenantAlbumMusicQuery query) {
|
|
|
+ List<TenantAlbumMusicWrapper.MusicSheetSimpleDto> musicSheets = tenantAlbumMusicMapper.selectPageSimple(page, query);
|
|
|
+ if (CollectionUtils.isEmpty(musicSheets)) {
|
|
|
+ return page.setRecords(musicSheets);
|
|
|
+ }
|
|
|
+ CbsMusicSheetWrapper.MusicSheetApplicationQuery cbsQuery = musicSheetService.getMusicSheetApplicationQuery(SourceTypeEnum.TENANT);
|
|
|
+ List<Long> cbsMusicSheetIds = musicSheets.stream().map(e -> Long.parseLong(e.getCbsMusicSheetId())).collect(Collectors.toList());
|
|
|
+ cbsQuery.setMusicSheetIds(cbsMusicSheetIds);
|
|
|
+ cbsQuery.setRows(cbsMusicSheetIds.size());
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetApplicationSimple> applications = musicSheetService.queryCbsMusicSheetApplicationSimple(cbsQuery);
|
|
|
+ if(CollectionUtils.isNotEmpty(applications)){
|
|
|
+ Map<Long, CbsMusicSheetWrapper.MusicSheetApplicationSimple> musicSheetApplicationMap = applications
|
|
|
+ .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplicationSimple::getId, Function.identity()));
|
|
|
+ for (TenantAlbumMusicWrapper.MusicSheetSimpleDto record : musicSheets) {
|
|
|
+ CbsMusicSheetWrapper.MusicSheetApplicationSimple simple = musicSheetApplicationMap.get(Long.parseLong(record.getCbsMusicSheetId()));
|
|
|
+ record.setAudioFileUrl(simple.getAudioFileUrl());
|
|
|
+ record.setName(simple.getName());
|
|
|
+ record.setTitleImg(simple.getTitleImg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return page.setRecords(musicSheets);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
* @param tenantAlbumMusic TenantAlbumMusicWrapper.TenantAlbumMusic
|
|
@@ -477,8 +499,105 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
|
|
|
throw new BizException("课件不存在");
|
|
|
}
|
|
|
LessonCoursewareDetailWrapper.LessonCoursewareDetail lessonCoursewareDetail = JSON.parseObject(JSON.toJSONString(cbsLessonCoursewareDetail), LessonCoursewareDetailWrapper.LessonCoursewareDetail.class);
|
|
|
+ // 过滤调未应用到项目的去练习曲目
|
|
|
+ this.filterLessonCourseDetail(lessonCoursewareDetail);
|
|
|
+ return lessonCoursewareDetail;
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail filterLessonCourseDetail(CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail lessonCoursewareDetail) {
|
|
|
+ // 过滤调未应用到项目的去练习曲目
|
|
|
+ List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList = lessonCoursewareDetail.getKnowledgePointList();
|
|
|
+ List<CbsMaterialRefWrapper.AddMaterialRef> addMaterialRefs = getCbsMaterialRefList(knowledgePointList);
|
|
|
+ List<CbsLessonCoursewareDetailWrapper.MaterialSmall> musicMaterialSmalls = getCbsMaterialSmalls(knowledgePointList);
|
|
|
+ if (CollectionUtils.isNotEmpty(musicMaterialSmalls)) {
|
|
|
+ List<Long> cbsMaterialMusicIds = musicMaterialSmalls.stream().map(CbsLessonCoursewareDetailWrapper.MaterialSmall::getContent)
|
|
|
+ .filter(StringUtils::isNotBlank).map(Long::parseLong).collect(Collectors.toList());
|
|
|
+ Map<Long, Long> idMap = musicSheetService.lambdaQuery()
|
|
|
+ .in(MusicSheet::getCbsMusicSheetId, cbsMaterialMusicIds)
|
|
|
+ .eq(MusicSheet::getTenantDelFlag, false)
|
|
|
+ .eq(MusicSheet::getTenantState, 1)
|
|
|
+ .list()
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(MusicSheet::getCbsMusicSheetId, MusicSheet::getId,(o1,o2)->o1));
|
|
|
|
|
|
+ // 过滤掉没有对应的曲目
|
|
|
+ filterCbsMusicMaterialList(knowledgePointList,new ArrayList<>(idMap.keySet()));
|
|
|
+ for (CbsLessonCoursewareDetailWrapper.MaterialSmall musicMaterialSmall : musicMaterialSmalls) {
|
|
|
+ musicMaterialSmall.setContent(idMap.getOrDefault(Long.parseLong(musicMaterialSmall.getContent()),-1L).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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::getTenantDelFlag, false)
|
|
|
+ .eq(MusicSheet::getTenantState, 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));
|
|
|
+ addMaterialRef.setResourceIdStr(idMap.getOrDefault(resourceId,-1L).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 过滤掉没有对应的曲目
|
|
|
+ filterCbsMaterialRefList(knowledgePointList,new ArrayList<>(idMap.values()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return lessonCoursewareDetail;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<CbsLessonCoursewareDetailWrapper.MaterialSmall> getCbsMaterialSmalls(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList) {
|
|
|
+ List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialRefList = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(knowledgePointList)) {
|
|
|
+ for (CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall : knowledgePointList) {
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(knowledgePointSmall.getChildren())) {
|
|
|
+ materialRefList.addAll(getCbsMaterialSmalls(knowledgePointSmall.getChildren()));
|
|
|
+ }
|
|
|
+ List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialList = knowledgePointSmall.getMaterialList();
|
|
|
+ if (CollectionUtils.isNotEmpty(materialList)) {
|
|
|
+ for (CbsLessonCoursewareDetailWrapper.MaterialSmall materialSmall : materialList) {
|
|
|
+ if (materialSmall.getType() == EMaterialType.SONG) {
|
|
|
+ materialRefList.add(materialSmall);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return materialRefList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<CbsMaterialRefWrapper.AddMaterialRef> getCbsMaterialRefList(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(getCbsMaterialRefList(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;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public LessonCoursewareDetailWrapper.LessonCoursewareDetail filterLessonCourseDetail(LessonCoursewareDetailWrapper.LessonCoursewareDetail lessonCoursewareDetail) {
|
|
|
// 过滤调未应用到项目的去练习曲目
|
|
|
List<LessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList = lessonCoursewareDetail.getKnowledgePointList();
|
|
|
List<LessonCoursewareDetailWrapper.AddMaterialRef> addMaterialRefs = getMaterialRefList(knowledgePointList);
|
|
@@ -526,6 +645,39 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
|
|
|
return lessonCoursewareDetail;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean filterAndUpdateKnowledgePointList(CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail courseScheduleCoursewareDetail) {
|
|
|
+ List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList = courseScheduleCoursewareDetail.getKnowledgePointList();
|
|
|
+ if (CollectionUtils.isEmpty(knowledgePointList)) {
|
|
|
+ return false; // 如果 knowledgePointList 为空,直接返回 false,后续会删除该 courseScheduleCoursewareDetail
|
|
|
+ }
|
|
|
+
|
|
|
+ // 过滤 KnowledgePointSmall
|
|
|
+ knowledgePointList.removeIf(knowledgePointSmall -> !filterKnowledgePoint(knowledgePointSmall));
|
|
|
+ courseScheduleCoursewareDetail.setKnowledgePointList(knowledgePointList);
|
|
|
+
|
|
|
+ // 如果过滤后的 knowledgePointList 为空,返回 false
|
|
|
+ return CollectionUtils.isNotEmpty(knowledgePointList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean filterKnowledgePoint(CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall) {
|
|
|
+ // 过滤 materialList
|
|
|
+// if (CollectionUtils.isNotEmpty(knowledgePointSmall.getMaterialList())) {
|
|
|
+// filterAndUpdateMaterialList(knowledgePointSmall.getMaterialList(), search);
|
|
|
+// }
|
|
|
+ // 过滤子知识点 children
|
|
|
+ if (CollectionUtils.isNotEmpty(knowledgePointSmall.getChildren())) {
|
|
|
+ knowledgePointSmall.getChildren().removeIf(child -> !filterKnowledgePoint(child));
|
|
|
+ }
|
|
|
+ // 保留当前的条件:materialList 不为空 或者 children 不为空,**否则删除当前节点**
|
|
|
+ return CollectionUtils.isNotEmpty(knowledgePointSmall.getMaterialList()) ||
|
|
|
+ CollectionUtils.isNotEmpty(knowledgePointSmall.getChildren());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void filterAndUpdateMaterialList(List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialList, String search) {
|
|
|
+ materialList.removeIf(materialSmall -> !materialSmall.getName().contains(search));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 关联课程类型
|
|
|
*
|
|
@@ -631,6 +783,22 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void filterCbsMusicMaterialList(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList, List<Long> cbsMusicSheetIds) {
|
|
|
+ if (CollectionUtils.isNotEmpty(knowledgePointList)) {
|
|
|
+ for (CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall : knowledgePointList) {
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(knowledgePointSmall.getChildren())) {
|
|
|
+ filterCbsMusicMaterialList(knowledgePointSmall.getChildren(),cbsMusicSheetIds);
|
|
|
+ }
|
|
|
+ List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialList = knowledgePointSmall.getMaterialList();
|
|
|
+ if (CollectionUtils.isNotEmpty(materialList)) {
|
|
|
+ materialList.removeIf(next -> (EMaterialType.SONG.equals(next.getType()) && !cbsMusicSheetIds.contains(Long.parseLong(next.getContent()))));
|
|
|
+ knowledgePointSmall.setMaterialList(materialList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void filterMusicMaterialList(List<LessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList, List<Long> cbsMusicSheetIds) {
|
|
|
if (CollectionUtils.isNotEmpty(knowledgePointList)) {
|
|
|
for (LessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall : knowledgePointList) {
|
|
@@ -668,6 +836,27 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
|
|
|
return materialRefList;
|
|
|
}
|
|
|
|
|
|
+ private void filterCbsMaterialRefList(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList,List<Long> cbsMusicSheetIds) {
|
|
|
+ if (CollectionUtils.isNotEmpty(knowledgePointList)) {
|
|
|
+ for (CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall : knowledgePointList) {
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(knowledgePointSmall.getChildren())) {
|
|
|
+ filterCbsMaterialRefList(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 void filterMaterialRefList(List<LessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList,List<Long> cbsMusicSheetIds) {
|
|
|
if (CollectionUtils.isNotEmpty(knowledgePointList)) {
|
|
|
for (LessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall : knowledgePointList) {
|