|
@@ -2,18 +2,17 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
|
|
|
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
|
|
|
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectApiWrapper;
|
|
|
+import com.microsvc.toolkit.common.response.template.R;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.MusicScoreDto;
|
|
|
import com.ym.mec.biz.dal.dto.SysMusicScoreMetronomeTranscod;
|
|
|
import com.ym.mec.biz.dal.dto.SysMusicScoreTranscod;
|
|
|
-import com.ym.mec.biz.dal.entity.SysMusicScore;
|
|
|
-import com.ym.mec.biz.dal.entity.SysMusicScoreAccompaniment;
|
|
|
-import com.ym.mec.biz.dal.entity.SysMusicScoreCategories;
|
|
|
-import com.ym.mec.biz.dal.entity.SysMusicScoreChangeLog;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
|
|
|
import com.ym.mec.biz.service.OrganizationService;
|
|
|
import com.ym.mec.biz.service.SysMusicScoreCategoriesService;
|
|
@@ -28,7 +27,9 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.file.FileUtil;
|
|
|
import com.ym.mec.util.shell.ScriptUtil;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -38,6 +39,7 @@ import java.io.FileInputStream;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ym.mec.biz.dal.enums.ClientTypeEnum.SMART_PRACTICE;
|
|
@@ -68,12 +70,20 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
@Resource
|
|
|
private MusicFeignClientService musicFeignClientService;
|
|
|
|
|
|
+ @Value("${openfeign-client.app-id:1745637981387108354}")
|
|
|
+ public Long applicationId;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Integer, SysMusicScore> getDAO() {
|
|
|
return sysMusicScoreDao;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public SysMusicScoreDao getDao() {
|
|
|
+ return sysMusicScoreDao;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateMusicScore(MusicScoreDto musicScoreDto) {
|
|
|
SysMusicScore sysMusicScore = musicScoreDto.getSysMusicScore();
|
|
@@ -204,13 +214,36 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void dealMusicScoreData(List<SysMusicScore> rows){
|
|
|
- if (rows != null && rows.size() > 0) {
|
|
|
- Set<Integer> categoriesIds = rows.stream().map(e -> e.getMusicScoreCategoriesId()).collect(Collectors.toSet());
|
|
|
+ private void dealMusicScoreData(List<SysMusicScore> records){
|
|
|
+ if (CollectionUtils.isNotEmpty(records)) {
|
|
|
+ List<Long> cbsMusicSheetIds = records.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList());
|
|
|
+ CbsMusicSheetWrapper.MusicSheetApplicationQuery query = new CbsMusicSheetWrapper.MusicSheetApplicationQuery();
|
|
|
+ query.setMusicSheetIds(cbsMusicSheetIds);
|
|
|
+ query.setDetailFlag(true);
|
|
|
+ R<com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicSheetWrapper.MusicSheetApplication>> pageInfoR =
|
|
|
+ musicFeignClientService.musicSheetPageByApplication(query);
|
|
|
+ if(pageInfoR.getCode() != 200){
|
|
|
+ throw new BizException("获取曲目信息失败");
|
|
|
+ }
|
|
|
+ com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicSheetWrapper.MusicSheetApplication> pageInfo = pageInfoR.getData();
|
|
|
+ if(pageInfo != null && CollectionUtils.isNotEmpty(pageInfo.getRows())){
|
|
|
+ Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMap = pageInfo.getRows()
|
|
|
+ .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, Function.identity()));
|
|
|
+ List<Subject> subjects = subjectDao.queryCbsList(records.stream().map(SysMusicScore::getSubjectIds)
|
|
|
+ .filter(StringUtils::isNotEmpty).map(Long::parseLong).distinct().collect(Collectors.toList()));
|
|
|
+ Map<Integer, Subject> subjectMap = subjects.stream().collect(Collectors.toMap(Subject::getId, Function.identity()));
|
|
|
+ for (SysMusicScore record : records) {
|
|
|
+ CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = musicSheetApplicationMap.get(record.getCbsMusicSheetId());
|
|
|
+ if(musicSheetApplication != null){
|
|
|
+ this.initMusicSheetVo(record,musicSheetApplication,subjectMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Set<Integer> categoriesIds = records.stream().map(e -> e.getMusicScoreCategoriesId()).collect(Collectors.toSet());
|
|
|
//获取分部列表
|
|
|
Map<Integer, String> organMap = MapUtil.convertMybatisMap(sysMusicScoreCategoriesDao.queryOrganByIds(categoriesIds));
|
|
|
//获取声部列表
|
|
|
- Set<Integer> subjectIds = rows.stream().map(e -> e.getSubjectId()).collect(Collectors.toSet());
|
|
|
+ /*Set<Integer> subjectIds = rows.stream().map(e -> e.getSubjectId()).collect(Collectors.toSet());
|
|
|
subjectIds.removeAll(Collections.singleton(null));
|
|
|
Map<Long, String> subjectMap = new HashMap();
|
|
|
if (subjectIds.size() > 0) {
|
|
@@ -222,15 +255,55 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
if(null != categoriesId){
|
|
|
map.put(categoriesId, getParentTreeName(categoriesId));
|
|
|
}
|
|
|
- }
|
|
|
- for (SysMusicScore row : rows) {
|
|
|
- row.setCategoriesName(map.get(row.getMusicScoreCategoriesId()));
|
|
|
+ }*/
|
|
|
+ for (SysMusicScore row : records) {
|
|
|
+// row.setCategoriesName(map.get(row.getMusicScoreCategoriesId()));
|
|
|
row.setOrganName(organMap.get(row.getMusicScoreCategoriesId()));
|
|
|
- row.setSubjectName(subjectMap.get(row.getSubjectId()));
|
|
|
+// row.setSubjectName(subjectMap.get(row.getSubjectId()));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void initMusicSheetVo(SysMusicScore record,CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication,Map<Integer, Subject> subjectMap){
|
|
|
+ if(StringUtils.isNotEmpty(musicSheetApplication.getSubjectIds())){
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (String s : musicSheetApplication.getSubjectIds().split(",")) {
|
|
|
+ Subject subject = subjectMap.get(Integer.parseInt(s));
|
|
|
+ if(subject != null){
|
|
|
+ if (sb.length() > 0) {
|
|
|
+ sb.append(",");
|
|
|
+ }
|
|
|
+ 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.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());
|
|
|
+ }
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetSound> soundList = musicSheetApplication.getMusicSheetSoundList();
|
|
|
+ if (CollectionUtils.isNotEmpty(soundList)) {
|
|
|
+ record.setAccompanimentMetronomeUrl(soundList.get(0).getAudioFileUrl());
|
|
|
+ }
|
|
|
+ record.setXmlUrl(musicSheetApplication.getXmlFileUrl());
|
|
|
+ record.setMidiUrl(musicSheetApplication.getMidiFileUrl());
|
|
|
+ record.setOrder(musicSheetApplication.getSortNo());
|
|
|
+ record.setEnableEvaluation(musicSheetApplication.getIsEvaluated());
|
|
|
+ record.setIsOpenMetronome(musicSheetApplication.getIsUseSystemBeat() && musicSheetApplication.getIsPlayBeat());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<SysMusicScore> queryMusicScoreAll(SysExamSongQueryInfo queryInfo) {
|
|
|
//封装查询参数
|
|
@@ -256,17 +329,6 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
return sysMusicScorePageInfo;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public PageInfo<SysMusicScore> queryCbsPage(SysExamSongQueryInfo queryInfo) {
|
|
|
- //封装查询参数
|
|
|
- dealMusicScoreParam(queryInfo);
|
|
|
-
|
|
|
- PageInfo<SysMusicScore> sysMusicScorePageInfo = queryPage(queryInfo);
|
|
|
- List<SysMusicScore> rows = sysMusicScorePageInfo.getRows();
|
|
|
- //处理查询结果
|
|
|
- dealMusicScoreData(rows);
|
|
|
- return sysMusicScorePageInfo;
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<SysMusicScore> queryMusicScorePageInfo(SysExamSongQueryInfo queryInfo) {
|