Browse Source

分类排序

zouxuan 7 months ago
parent
commit
77747475c4

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysMusicScoreAccompanimentService.java

@@ -20,6 +20,8 @@ public interface SysMusicScoreAccompanimentService extends BaseService<String, S
 
     List<SysMusicScoreAccompaniment> queryAccPage(SysExamSongQueryInfo queryInfo);
 
+    List<SysMusicScoreAccompaniment> queryAccPage(Map<String, Object> params,List<CbsMusicSheetWrapper.MusicSheetApplication> applications);
+
     List<SysMusicScoreAccompaniment> queryAccPage(Map<String, Object> params);
 
     List<Subject> querySubjectIds(Integer categoriesId);

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

@@ -83,10 +83,11 @@ public class CbsMusicScoreCategoriesServiceImpl implements CbsMusicScoreCategori
 		categoryIds = categoryIds.endsWith(",") ? categoryIds.substring(0, categoryIds.length() - 1) : categoryIds;
 		List<SysMusicScoreCategories> categoryList = this.queryByIds(categoryIds);
 		if(CollectionUtils.isNotEmpty(categoryList)){
-			List<Integer> collect = categoryList.stream().map(SysMusicScoreCategories::getParentId).distinct().collect(Collectors.toList());
+			String collect = categoryList.stream().map(SysMusicScoreCategories::getParentId).distinct().map(Object::toString).collect(Collectors.joining(","));
+			List<SysMusicScoreCategories> sysMusicScoreCategories = this.queryByIds(collect);
 			List<SysMusicScoreCategories> rows = new ArrayList<SysMusicScoreCategories>();
-			for (Integer i : collect) {
-				rows.add(this.getChildTreeById(i.longValue()));
+			for (SysMusicScoreCategories musicScoreCategories : sysMusicScoreCategories) {
+				rows.add(this.getChildTree(musicScoreCategories));
 			}
 			return rows;
 		}

+ 81 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreAccompanimentServiceImpl.java

@@ -49,6 +49,82 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Strin
 		return this.initAccompaniment(sysMusicScoreAccompanimentDao.queryPage(params));
 	}
 
+	public List<SysMusicScoreAccompaniment> initAccompaniment(List<SysMusicScoreAccompaniment> accompaniments,List<CbsMusicSheetWrapper.MusicSheetApplication> applications){
+		List<SysMusicScoreAccompaniment> result = new ArrayList<>();
+		if(CollectionUtils.isEmpty(accompaniments)){
+			return result;
+		}
+		long count = accompaniments.stream().filter(e -> e.getCbsMusicSheetId() != null).count();
+		if(count == 0){
+			return result;
+		}
+		Map<String, CbsMusicSheetWrapper.MusicSheetApplication> applicationMap = applications.stream().collect(Collectors.toMap(e->e.getId().toString(), Function.identity()));
+		for (SysMusicScoreAccompaniment accompaniment : accompaniments) {
+			if(accompaniment.getCbsMusicSheetId() == null){
+				result.add(accompaniment);
+				continue;
+			}
+			CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = applicationMap.get(accompaniment.getCbsMusicSheetId());
+			if (musicSheetApplication == null) {
+				throw new BizException("曲目信息不存在,曲目ID:" + accompaniment.getCbsMusicSheetId());
+			}
+			if(CollectionUtils.isEmpty(musicSheetApplication.getMusicSheetSoundList())){
+				throw new BizException("曲目原音信息不存在,曲目ID:" + accompaniment.getCbsMusicSheetId());
+			}
+			if (accompaniment.getIsOpenMetronome() ==null || accompaniment.getIsOpenMetronome()) {
+				if (StringUtils.isNotBlank(accompaniment.getUrl())) {
+					accompaniment.setMetronomeUrl(accompaniment.getUrl());
+				}
+			}
+			List<SysMusicScoreAccompaniment> childAccompaniments = new ArrayList<>();
+			for (int i = 0; i < musicSheetApplication.getMusicSheetSoundList().size(); i++) {
+				SysMusicScoreAccompaniment record = new SysMusicScoreAccompaniment();
+				record.setIsConvertibleScore(musicSheetApplication.getIsConvertibleScore());
+				if(musicSheetApplication.getScoreType() != null){
+					record.setScoreType(musicSheetApplication.getScoreType().getCode());
+				}
+				record.setId(accompaniment.getExamSongId().toString());
+				record.setType(accompaniment.getType());
+				record.setRankIds("FREE".equals(musicSheetApplication.getPaymentType()) ? null : "1");
+				record.setClientType(accompaniment.getClientType());
+				record.setExamSongId(accompaniment.getExamSongId());
+				record.setCbsMusicSheetId(musicSheetApplication.getId().toString());
+				record.setPlayMode(SysMusicScore.PlayMode.valueOf(musicSheetApplication.getPlayMode().getCode()));
+				record.setExtConfigJson(musicSheetApplication.getExtConfigJson());
+//				record.setSubjectId(accompaniment.getSubjectId());
+				record.setExtStyleConfigJson(musicSheetApplication.getExtStyleConfigJson());
+				if(musicSheetApplication.getMusicSheetCategoryId() != null){
+					record.setCategoriesId(musicSheetApplication.getMusicSheetCategoryId().intValue());
+				}
+				record.setMusicSheetType(musicSheetApplication.getMusicSheetType().getCode());
+				record.setParentCategoriesId(accompaniment.getParentCategoriesId());
+				record.setExamSongName(musicSheetApplication.getName());
+				record.setCategoriesName(musicSheetApplication.getMusicSheetCategoryName());
+				record.setSpeed(musicSheetApplication.getPlaySpeed());
+				CbsMusicSheetWrapper.MusicSheetSound sound = musicSheetApplication.getMusicSheetSoundList().get(i);
+				record.setMetronomeMp3Url(sound.getAudioFileUrl());
+				record.setTrack(sound.getTrack());
+				record.setSubjectName(sound.getTrack());
+				record.setXmlUrl(musicSheetApplication.getXmlFileUrl());
+				record.setMidiUrl(musicSheetApplication.getMidiFileUrl());
+				record.setEnableEvaluation(musicSheetApplication.getIsEvaluated());
+				record.setIsOpenMetronome(musicSheetApplication.getIsUseSystemBeat());
+				List<CbsMusicSheetWrapper.MusicSheetAccompaniment> accompanimentList = musicSheetApplication.getMusicSheetAccompanimentList();
+				if (CollectionUtils.isNotEmpty(accompanimentList)) {
+					record.setMetronomeUrl(accompanimentList.get(0).getAudioFileUrl());
+					record.setUrl(accompanimentList.get(0).getAudioFileUrl());
+				}
+				record.setMetronomeMp3Url(sound.getAudioFileUrl());
+				record.setMp3Url(sound.getAudioFileUrl());
+				record.setIsShowFingering(musicSheetApplication.getIsShowFingering());
+				record.setIsScoreRender(musicSheetApplication.getIsScoreRender());
+				record.setDefaultScoreRender(musicSheetApplication.getDefaultScoreRender());
+				childAccompaniments.add(record);
+			}
+			result.addAll(childAccompaniments);
+		}
+		return result;
+	}
 	public List<SysMusicScoreAccompaniment> initAccompaniment(List<SysMusicScoreAccompaniment> accompaniments){
 		List<SysMusicScoreAccompaniment> result = new ArrayList<>();
 		if(CollectionUtils.isEmpty(accompaniments)){
@@ -273,6 +349,11 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Strin
 		return this.initAccompaniment(sysMusicScoreAccompaniments);
 	}
 
+	@Override
+	public List<SysMusicScoreAccompaniment> queryAccPage(Map<String, Object> params,List<CbsMusicSheetWrapper.MusicSheetApplication> applications) {
+		return this.initAccompaniment(sysMusicScoreAccompanimentDao.queryAccPage(params),applications);
+	}
+
 
 	@Override
 	public List<Subject> querySubjectIds(Integer categoriesId) {

+ 10 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreServiceImpl.java

@@ -160,6 +160,12 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
             List<String> cbsMusicSheetIds = records.stream().map(SysMusicScore::getCbsMusicSheetId).collect(Collectors.toList());
             List<CbsMusicSheetWrapper.MusicSheetApplication> applications = this.queryCbsMusicSheetApplication(cbsMusicSheetIds);
             if(CollectionUtils.isNotEmpty(applications)){
+                //获取原音
+                List<Integer> musicSheetIds = records.stream().map(SysMusicScore::getId).collect(Collectors.toList());
+                Map<String, Object> params = new HashMap<>();
+                params.put("musicScoreIds", musicSheetIds);
+                List<SysMusicScoreAccompaniment> accompaniments = sysMusicScoreAccompanimentService.queryAccPage(params,applications);
+
                 Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMap = applications
                         .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, Function.identity()));
 
@@ -172,6 +178,10 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
                             this.queryMusicalInstrument(Arrays.stream(instrumentIds.split(",")).map(Integer::parseInt).distinct().collect(Collectors.toList()));
                     musicalInstrumentQueryMap = musicalInstrumentQueryDtos.stream().collect(Collectors.toMap(CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto::getId, o -> o, (o1, o2) -> o1));
                 }
+                Map<Integer, List<SysMusicScoreAccompaniment>> accompanimentMap = new HashMap<>();
+                if(CollectionUtils.isNotEmpty(accompaniments)){
+                    accompanimentMap = accompaniments.stream().collect(Collectors.groupingBy(SysMusicScoreAccompaniment::getExamSongId));
+                }
                 //获取声部乐器关联
                 List<Instrument> list = instrumentService.lambdaQuery().list();
                 Map<Integer, Instrument> instrumentMap = list.stream().collect(Collectors.toMap(Instrument::getSubjectId, o -> o));
@@ -180,15 +190,6 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
                     if(musicSheetApplication != null){
                         this.initMusicSheetVo(record,musicSheetApplication,musicalInstrumentQueryMap,instrumentMap);
                     }
-                }
-            }
-            List<Integer> musicSheetIds = records.stream().map(SysMusicScore::getId).collect(Collectors.toList());
-            Map<String, Object> params = new HashMap<>();
-            params.put("musicScoreIds", musicSheetIds);
-            List<SysMusicScoreAccompaniment> accompaniments = sysMusicScoreAccompanimentService.queryAccPage(params);
-            if(CollectionUtils.isNotEmpty(accompaniments)){
-                Map<Integer, List<SysMusicScoreAccompaniment>> accompanimentMap = accompaniments.stream().collect(Collectors.groupingBy(SysMusicScoreAccompaniment::getExamSongId));
-                for (SysMusicScore record : records) {
                     List<SysMusicScoreAccompaniment> accompanimentList = accompanimentMap.get(record.getId());
                     if(CollectionUtils.isNotEmpty(accompanimentList)){
                         record.setBackground(accompanimentList);