|
|
@@ -11,6 +11,7 @@ import java.util.stream.Collectors;
|
|
|
import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
|
|
|
import com.ym.mec.biz.dal.dao.SubjectDao;
|
|
|
import com.ym.mec.biz.dal.entity.SysMusicScore;
|
|
|
+import com.ym.mec.biz.service.SysMusicScoreService;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -41,7 +42,8 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
|
|
|
private SubjectDao subjectDao;
|
|
|
@Resource
|
|
|
private SysMusicScoreCategoriesService sysMusicScoreCategoriesService;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private SysMusicScoreService sysMusicScoreService;
|
|
|
@Override
|
|
|
public BaseDAO<Integer, SysMusicScoreAccompaniment> getDAO() {
|
|
|
return sysMusicScoreAccompanimentDao;
|
|
|
@@ -66,53 +68,79 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
|
|
|
public List<SysMusicScoreAccompaniment> queryAll(SysExamSongQueryInfo queryInfo) {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
- List<SysMusicScoreAccompaniment> accompaniments = sysMusicScoreAccompanimentDao.queryPage(params);
|
|
|
-
|
|
|
- return accompaniments;
|
|
|
+ return this.initAccompaniment(sysMusicScoreAccompanimentDao.queryPage(params));
|
|
|
}
|
|
|
|
|
|
- public void initAccompaniment(List<SysMusicScoreAccompaniment> accompaniments){
|
|
|
- /*List<Subject> subjects = subjectDao.queryCbsList(null);
|
|
|
+ public List<SysMusicScoreAccompaniment> initAccompaniment(List<SysMusicScoreAccompaniment> accompaniments){
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ List<Long> cbsMusicSheetIds = accompaniments.stream().filter(e->e.getCbsMusicSheetId() != null)
|
|
|
+ .map(SysMusicScoreAccompaniment::getCbsMusicSheetId).collect(Collectors.toList());
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetApplication> applications = sysMusicScoreService.queryCbsMusicSheetApplication(cbsMusicSheetIds);
|
|
|
+ if (CollectionUtils.isEmpty(applications)) {
|
|
|
+ throw new BizException("获取曲目信息失败");
|
|
|
+ }
|
|
|
+ List<Subject> subjects = subjectDao.queryCbsList(null);
|
|
|
Map<Long, Subject> subjectMap = subjects.stream().collect(Collectors.toMap(Subject::getCbsSubjectId, Function.identity()));
|
|
|
- if(StringUtils.isNotEmpty(musicSheetApplication.getSubjectIds())){
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- for (String s : musicSheetApplication.getSubjectIds().split(",")) {
|
|
|
- Subject subject = subjectMap.get(Long.parseLong(s));
|
|
|
- if(subject != null){
|
|
|
- if (sb.length() > 0) {
|
|
|
- sb.append(",");
|
|
|
+ Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> applicationMap = applications.stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, 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());
|
|
|
+ }
|
|
|
+ List<SysMusicScoreAccompaniment> childAccompaniments = new ArrayList<>();
|
|
|
+ for (int i = 0; i < musicSheetApplication.getMusicSheetSoundList().size(); i++) {
|
|
|
+ SysMusicScoreAccompaniment record = new SysMusicScoreAccompaniment();
|
|
|
+ if(StringUtils.isNotEmpty(musicSheetApplication.getSubjectIds())){
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (String s : musicSheetApplication.getSubjectIds().split(",")) {
|
|
|
+ Subject subject = subjectMap.get(Long.parseLong(s));
|
|
|
+ if(subject != null){
|
|
|
+ if (sb.length() > 0) {
|
|
|
+ sb.append(",");
|
|
|
+ }
|
|
|
+ sb.append(subject.getName());
|
|
|
+ }
|
|
|
}
|
|
|
- sb.append(subject.getName());
|
|
|
+ record.setSubjectName(sb.toString());
|
|
|
+ }
|
|
|
+ record.setCbsMusicSheetId(musicSheetApplication.getId());
|
|
|
+ record.setPlayMode(SysMusicScore.PlayMode.valueOf(musicSheetApplication.getPlayMode().getCode()));
|
|
|
+ record.setExtConfigJson(musicSheetApplication.getExtConfigJson());
|
|
|
+ record.setExtStyleConfigJson(musicSheetApplication.getExtStyleConfigJson());
|
|
|
+ if(musicSheetApplication.getMusicSheetCategoryId() != null){
|
|
|
+ record.setCategoriesId(musicSheetApplication.getMusicSheetCategoryId().intValue());
|
|
|
+ }
|
|
|
+ record.setExamSongName(musicSheetApplication.getName());
|
|
|
+ record.setCategoriesName(musicSheetApplication.getMusicSheetCategoryName());
|
|
|
+ record.setSpeed(musicSheetApplication.getPlaySpeed());
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetAccompaniment> accompanimentList = musicSheetApplication.getMusicSheetAccompanimentList();
|
|
|
+ if (CollectionUtils.isNotEmpty(accompanimentList)) {
|
|
|
+ record.setMetronomeUrl(accompanimentList.get(0).getAudioFileUrl());
|
|
|
}
|
|
|
+ record.setMp3Url(musicSheetApplication.getMusicSheetSoundList().get(i).getAudioFileUrl());
|
|
|
+ record.setXmlUrl(musicSheetApplication.getXmlFileUrl());
|
|
|
+ record.setMidiUrl(musicSheetApplication.getMidiFileUrl());
|
|
|
+ record.setEnableEvaluation(musicSheetApplication.getIsEvaluated());
|
|
|
+ record.setIsOpenMetronome(musicSheetApplication.getIsUseSystemBeat() && musicSheetApplication.getIsPlayBeat());
|
|
|
+ childAccompaniments.add(record);
|
|
|
}
|
|
|
- record.setSubjectName(sb.toString());
|
|
|
- }
|
|
|
- record.setCbsMusicSheetId(musicSheetApplication.getId());
|
|
|
- record.setPlayMode(SysMusicScore.PlayMode.valueOf(musicSheetApplication.getPlayMode().getCode()));
|
|
|
- record.setExtConfigJson(musicSheetApplication.getExtConfigJson());
|
|
|
- record.setExtStyleConfigJson(musicSheetApplication.getExtStyleConfigJson());
|
|
|
- if(musicSheetApplication.getMusicSheetCategoryId() != null){
|
|
|
- record.setMusicScoreCategoriesId(musicSheetApplication.getMusicSheetCategoryId().intValue());
|
|
|
- record.setCategoriesId(musicSheetApplication.getMusicSheetCategoryId().intValue());
|
|
|
- }
|
|
|
- record.setName(musicSheetApplication.getName());
|
|
|
- record.setCategoriesName(musicSheetApplication.getMusicSheetCategoryName());
|
|
|
- record.setSpeed(musicSheetApplication.getPlaySpeed());
|
|
|
- List<CbsMusicSheetWrapper.MusicSheetAccompaniment> accompanimentList = musicSheetApplication.getMusicSheetAccompanimentList();
|
|
|
- if (CollectionUtils.isNotEmpty(accompanimentList)) {
|
|
|
- record.setMetronomeUrl(accompanimentList.get(0).getAudioFileUrl());
|
|
|
- record.setUrl(accompanimentList.get(0).getAudioFileUrl());
|
|
|
- }
|
|
|
- List<CbsMusicSheetWrapper.MusicSheetSound> soundList = musicSheetApplication.getMusicSheetSoundList();
|
|
|
- if (CollectionUtils.isNotEmpty(soundList)) {
|
|
|
- record.setAccompanimentMetronomeUrl(soundList.get(0).getAudioFileUrl());
|
|
|
- record.setAccompanimentUrl(soundList.get(0).getAudioFileUrl());
|
|
|
+ result.addAll(childAccompaniments);
|
|
|
}
|
|
|
- record.setXmlUrl(musicSheetApplication.getXmlFileUrl());
|
|
|
- record.setMidiUrl(musicSheetApplication.getMidiFileUrl());
|
|
|
- record.setOrder(musicSheetApplication.getSortNo());
|
|
|
- record.setEnableEvaluation(musicSheetApplication.getIsEvaluated());
|
|
|
- record.setIsOpenMetronome(musicSheetApplication.getIsUseSystemBeat() && musicSheetApplication.getIsPlayBeat());*/
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -145,7 +173,7 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return sysMusicScoreAccompaniments;
|
|
|
+ return this.initAccompaniment(sysMusicScoreAccompaniments);
|
|
|
}
|
|
|
|
|
|
@Override
|