Pārlūkot izejas kodu

管乐迷曲目来源内容平台

zouxuan 1 gadu atpakaļ
vecāks
revīzija
fc0a406601

+ 5 - 257
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysMusicScoreAccompaniment.java

@@ -2,11 +2,13 @@ package com.ym.mec.biz.dal.entity;
 
 import com.ym.mec.biz.dal.entity.SysMusicScore.PlayMode;
 import com.ym.mec.biz.dal.enums.ClientTypeEnum;
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
  * 对应数据库表(sys_music_score_accompaniment):
  */
+@Data
 public class SysMusicScoreAccompaniment {
 
 	/**  */
@@ -14,6 +16,8 @@ public class SysMusicScoreAccompaniment {
 	
 	/**  */
 	private Integer examSongId;
+	/**  */
+	private Long cbsMusicSheetId;
 	
 	/**  */
 	private Integer subjectId;
@@ -31,7 +35,7 @@ public class SysMusicScoreAccompaniment {
 	private Integer delFlag;
 	
 	/** 速度 */
-	private Integer speed;
+	private String speed;
 	
 	/**  */
 	private String xmlUrl;
@@ -91,262 +95,6 @@ public class SysMusicScoreAccompaniment {
 	
 	private String extStyleConfigJson;
 
-	public String getExtConfigJson() {
-		return extConfigJson;
-	}
-
-	public void setExtConfigJson(String extConfigJson) {
-		this.extConfigJson = extConfigJson;
-	}
-
-	public String getExtStyleConfigJson() {
-		return extStyleConfigJson;
-	}
-
-	public void setExtStyleConfigJson(String extStyleConfigJson) {
-		this.extStyleConfigJson = extStyleConfigJson;
-	}
-
-	public String getMetronomeUrl() {
-		return metronomeUrl;
-	}
-
-	public void setMetronomeUrl(String metronomeUrl) {
-		this.metronomeUrl = metronomeUrl;
-	}
-
-	public String getMidiUrl() {
-		return midiUrl;
-	}
-
-	public void setMidiUrl(String midiUrl) {
-		this.midiUrl = midiUrl;
-	}
-
-	public String getRankIds() {
-		return rankIds;
-	}
-
-	public void setRankIds(String rankIds) {
-		this.rankIds = rankIds;
-	}
-
-	public ClientTypeEnum getClientType() {
-		return clientType;
-	}
-
-	public void setClientType(ClientTypeEnum clientType) {
-		this.clientType = clientType;
-	}
-
-	public Boolean getIsShowFingering() {
-		return isShowFingering;
-	}
-
-	public void setIsShowFingering(Boolean showFingering) {
-		isShowFingering = showFingering;
-	}
-
-	public String getMemo() {
-		return memo;
-	}
-
-	public void setMemo(String memo) {
-		this.memo = memo;
-	}
-
-	public Integer getCategoriesId() {
-		return categoriesId;
-	}
-
-	public void setCategoriesId(Integer categoriesId) {
-		this.categoriesId = categoriesId;
-	}
-
-	public Integer getParentCategoriesId() {
-		return parentCategoriesId;
-	}
-
-	public void setParentCategoriesId(Integer parentCategoriesId) {
-		this.parentCategoriesId = parentCategoriesId;
-	}
-
-	public String getCategoriesName() {
-		return categoriesName;
-	}
-
-	public void setCategoriesName(String categoriesName) {
-		this.categoriesName = categoriesName;
-	}
-
-	public String getSubjectName() {
-		return subjectName;
-	}
-
-	public void setSubjectName(String subjectName) {
-		this.subjectName = subjectName;
-	}
-
-	public String getExamSongName() {
-		return examSongName;
-	}
-
-	public void setExamSongName(String examSongName) {
-		this.examSongName = examSongName;
-	}
-
-	public String getType() {
-		return type;
-	}
-
-	public void setType(String type) {
-		this.type = type;
-	}
-
-	public String getUrl() {
-		return url;
-	}
-
-	public void setUrl(String url) {
-		this.url = url;
-	}
-
-	public void setId(Integer id){
-		this.id = id;
-	}
-	
-	public Integer getId(){
-		return this.id;
-	}
-			
-	public void setExamSongId(Integer examSongId){
-		this.examSongId = examSongId;
-	}
-	
-	public Integer getExamSongId(){
-		return this.examSongId;
-	}
-			
-	public void setSubjectId(Integer subjectId){
-		this.subjectId = subjectId;
-	}
-	
-	public Integer getSubjectId(){
-		return this.subjectId;
-	}
-			
-	public void setMp3Url(String mp3Url){
-		this.mp3Url = mp3Url;
-	}
-	
-	public String getMp3Url(){
-		return this.mp3Url;
-	}
-			
-	public void setDelFlag(Integer delFlag){
-		this.delFlag = delFlag;
-	}
-	
-	public Integer getDelFlag(){
-		return this.delFlag;
-	}
-			
-	public void setSpeed(Integer speed){
-		this.speed = speed;
-	}
-	
-	public Integer getSpeed(){
-		return this.speed;
-	}
-			
-	public void setXmlUrl(String xmlUrl){
-		this.xmlUrl = xmlUrl;
-	}
-	
-	public String getXmlUrl(){
-		return this.xmlUrl;
-	}
-			
-	public void setCreateTime(java.util.Date createTime){
-		this.createTime = createTime;
-	}
-	
-	public java.util.Date getCreateTime(){
-		return this.createTime;
-	}
-			
-	public void setUpdateTime(java.util.Date updateTime){
-		this.updateTime = updateTime;
-	}
-	
-	public java.util.Date getUpdateTime(){
-		return this.updateTime;
-	}
-			
-	public Boolean getIsOpenMetronome() {
-		return isOpenMetronome;
-	}
-
-	public void setIsOpenMetronome(Boolean isOpenMetronome) {
-		this.isOpenMetronome = isOpenMetronome;
-	}
-
-	public String getRenderFrom() {
-		return renderFrom;
-	}
-
-	public void setRenderFrom(String renderFrom) {
-		this.renderFrom = renderFrom;
-	}
-
-	public boolean isEnableEvaluation() {
-		return enableEvaluation;
-	}
-
-	public void setEnableEvaluation(boolean enableEvaluation) {
-		this.enableEvaluation = enableEvaluation;
-	}
-
-	public String getMetronomeMp3Url() {
-		return metronomeMp3Url;
-	}
-
-	public void setMetronomeMp3Url(String metronomeMp3Url) {
-		this.metronomeMp3Url = metronomeMp3Url;
-	}
-
-	public String getMuseScoreUrl() {
-		return museScoreUrl;
-	}
-
-	public void setMuseScoreUrl(String museScoreUrl) {
-		this.museScoreUrl = museScoreUrl;
-	}
-
-	public String getMuseScoreMemo() {
-		return museScoreMemo;
-	}
-
-	public void setMuseScoreMemo(String museScoreMemo) {
-		this.museScoreMemo = museScoreMemo;
-	}
-
-	public PlayMode getPlayMode() {
-		return playMode;
-	}
-
-	public void setPlayMode(PlayMode playMode) {
-		this.playMode = playMode;
-	}
-
-	public String getTrack() {
-		return track;
-	}
-
-	public void setTrack(String track) {
-		this.track = track;
-	}
-
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysMusicScoreService.java

@@ -4,6 +4,7 @@ package com.ym.mec.biz.service;
 import java.util.List;
 import java.util.Map;
 
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
 import com.ym.mec.biz.dal.dao.SysMusicScoreDao;
 import com.ym.mec.biz.dal.dto.MusicScoreDto;
 import com.ym.mec.biz.dal.entity.SysMusicScore;
@@ -21,6 +22,8 @@ public interface SysMusicScoreService extends BaseService<Integer, SysMusicScore
 
     void del(Integer id);
 
+    List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(List<Long> cbsMusicSheetIds);
+
     List<SysMusicScore> queryMusicScoreAll(SysExamSongQueryInfo queryInfo);
 
     PageInfo<SysMusicScore> queryMusicScorePage(SysExamSongQueryInfo queryInfo);

+ 57 - 37
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreAccompanimentServiceImpl.java

@@ -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;
@@ -72,47 +74,65 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
 	}
 
 	public void initAccompaniment(List<SysMusicScoreAccompaniment> accompaniments){
-		/*List<Subject> subjects = subjectDao.queryCbsList(null);
+		if(CollectionUtils.isEmpty(accompaniments)){
+			return;
+		}
+		List<SysMusicScoreAccompaniment> records = accompaniments.stream().filter(e -> e.getCbsMusicSheetId() != null).collect(Collectors.toList());
+		if(CollectionUtils.isEmpty(records)){
+			return;
+		}
+		List<Long> cbsMusicSheetIds = records.stream().map(SysMusicScoreAccompaniment::getCbsMusicSheetId).collect(Collectors.toList());
+		List<CbsMusicSheetWrapper.MusicSheetApplication> applications = sysMusicScoreService.queryCbsMusicSheetApplication(cbsMusicSheetIds);
+		if (CollectionUtils.isEmpty(applications)) {
+			return;
+		}
+		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 record : records) {
+			CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = applicationMap.get(record.getCbsMusicSheetId());
+			if (musicSheetApplication == null) {
+				throw new BizException("曲目信息不存在,曲目ID:" + record.getCbsMusicSheetId());
+			}
+			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.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());
+			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.setUrl(accompanimentList.get(0).getAudioFileUrl());
+			}
+			List<CbsMusicSheetWrapper.MusicSheetSound> soundList = musicSheetApplication.getMusicSheetSoundList();
+			if (CollectionUtils.isNotEmpty(soundList)) {
+				record.setMp3Url(soundList.get(0).getAudioFileUrl());
+//				record.setAccompanimentUrl(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());
 		}
-		record.setXmlUrl(musicSheetApplication.getXmlFileUrl());
-		record.setMidiUrl(musicSheetApplication.getMidiFileUrl());
-		record.setOrder(musicSheetApplication.getSortNo());
-		record.setEnableEvaluation(musicSheetApplication.getIsEvaluated());
-		record.setIsOpenMetronome(musicSheetApplication.getIsUseSystemBeat() && musicSheetApplication.getIsPlayBeat());*/
 	}
 
 	@Override

+ 24 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreServiceImpl.java

@@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetApplicationExtendClientWrapper;
 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;
@@ -193,24 +190,33 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
         }
     }
 
+    @Override
+    public List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(List<Long> cbsMusicSheetIds){
+        CbsMusicSheetWrapper.MusicSheetApplicationQuery query = new CbsMusicSheetWrapper.MusicSheetApplicationQuery();
+        query.setMusicSheetIds(cbsMusicSheetIds);
+        query.setDetailFlag(true);
+        query.setDelFlag(true);
+        query.setPage(1);
+        query.setRows(cbsMusicSheetIds.size());
+        query.setApplicationId(applicationId);
+        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())){
+            return pageInfo.getRows();
+        }
+        return new ArrayList<>();
+    }
+
     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);
-            query.setDelFlag(true);
-            query.setPage(1);
-            query.setRows(cbsMusicSheetIds.size());
-            query.setApplicationId(applicationId);
-            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()
+            List<CbsMusicSheetWrapper.MusicSheetApplication> applications = this.queryCbsMusicSheetApplication(cbsMusicSheetIds);
+            if(CollectionUtils.isNotEmpty(applications)){
+                Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMap = applications
                         .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, Function.identity()));
                 List<Subject> subjects = subjectDao.queryCbsList(null);
                 Map<Long, Subject> subjectMap = subjects.stream().collect(Collectors.toMap(Subject::getCbsSubjectId, Function.identity()));

+ 5 - 3
mec-biz/src/main/resources/config/mybatis/SysMusicScoreAccompanimentMapper.xml

@@ -50,7 +50,7 @@
 	<select id="get" resultMap="SysMusicScoreAccompaniment" >
 		SELECT sesa.id_,sesa.exam_song_id_,sesa.subject_id_,CASE WHEN sesa.metronome_mp3_url_ IS NULL OR sesa.metronome_mp3_url_ = '' THEN sesa.mp3_url_ ELSE sesa.metronome_mp3_url_ END url_,sesa.speed_,
 		sesa.xml_url_,sesa.is_show_fingering_,sesa.is_open_metronome_,sesa.memo_,sesa.track_,
-		ses.name_,ses.type_,ses.url_ mp3_url_,sesc.name_ categories_name_,sesc.id_ categories_id_,ses.client_type_,ses.metronome_url_,ses.midi_url_
+		ses.name_,ses.type_,ses.url_ mp3_url_,sesc.name_ categories_name_,sesc.id_ categories_id_,ses.client_type_,ses.metronome_url_,ses.midi_url_,ses.cbs_music_sheet_id_
 		FROM sys_music_score ses
 		LEFT JOIN sys_music_score_accompaniment sesa ON ses.id_ = sesa.exam_song_id_
 		LEFT JOIN sys_music_score_categories sesc ON sesc.id_ = ses.music_score_categories_id_
@@ -147,7 +147,8 @@
 		SELECT
 		    sesa.*,ses.name_,ses.type_,ses.url_,
 		       s.name_ subject_name_,sesc.name_ categories_name_,sesc.id_ categories_id_,sesc.parent_id_ parent_categories_id_,ses.client_type_,
-		ses.rank_ids_,ses.render_from_,ses.enable_evaluation_,ses.metronome_url_,ses.midi_url_,ses.play_mode_,ses.render_from_,ses.ext_config_json_,ses.ext_style_config_json_
+		ses.rank_ids_,ses.render_from_,ses.enable_evaluation_,ses.metronome_url_,ses.midi_url_,ses.play_mode_,ses.render_from_,
+		ses.ext_config_json_,ses.ext_style_config_json_,ses.cbs_music_sheet_id_
 		FROM sys_music_score ses
 		LEFT JOIN sys_music_score_accompaniment sesa ON ses.id_ = sesa.exam_song_id_
 		LEFT JOIN sys_music_score_categories sesc ON sesc.id_ = ses.music_score_categories_id_
@@ -183,7 +184,8 @@
 	</select>
 	<select id="queryAccPage" resultMap="SysMusicScoreAccompaniment">
 		SELECT sesa.*,ses.name_,ses.type_,ses.url_,s.name_ subject_name_,sesc.name_ categories_name_,sesc.id_ categories_id_,sesc.parent_id_ parent_categories_id_,ses.client_type_,
-		ses.enable_evaluation_,ses.metronome_url_,ses.midi_url_,ses.play_mode_,ses.render_from_,ses.ext_config_json_,ses.ext_style_config_json_,ses.rank_ids_
+		ses.enable_evaluation_,ses.metronome_url_,ses.midi_url_,ses.play_mode_,ses.render_from_,ses.ext_config_json_,
+		ses.ext_style_config_json_,ses.rank_ids_,ses.cbs_music_sheet_id_
 		FROM sys_music_score ses
 		LEFT JOIN sys_music_score_accompaniment sesa ON ses.id_ = sesa.exam_song_id_
 		LEFT JOIN sys_music_score_categories sesc ON sesc.id_ = ses.music_score_categories_id_