|
@@ -1,77 +1,70 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
|
|
|
-import static com.ym.mec.biz.dal.enums.ClientTypeEnum.SMART_PRACTICE;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.net.HttpURLConnection;
|
|
|
-import java.net.URL;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
-import com.ym.mec.biz.dal.dao.*;
|
|
|
-import com.ym.mec.biz.dal.dto.SysMusicScoreMetronomeTranscod;
|
|
|
-import com.ym.mec.biz.dal.dto.SysMusicScoreTranscod;
|
|
|
-import com.ym.mec.biz.dal.entity.SysMusicScoreChangeLog;
|
|
|
-import com.ym.mec.biz.service.OrganizationService;
|
|
|
-import com.ym.mec.biz.service.UploadFileService;
|
|
|
-import com.ym.mec.common.entity.UploadReturnBean;
|
|
|
-import com.ym.mec.common.service.IdGeneratorService;
|
|
|
-import com.ym.mec.util.file.FileUtil;
|
|
|
-import com.ym.mec.util.shell.ScriptUtil;
|
|
|
-
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
-import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
-import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.biz.dal.dto.MusicScoreDto;
|
|
|
-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.beust.jcommander.internal.Lists;
|
|
|
+import com.dayaedu.cbs.common.enums.EClientType;
|
|
|
+import com.dayaedu.cbs.common.enums.music.EAudioType;
|
|
|
+import com.dayaedu.cbs.common.enums.music.EMusicAvailableType;
|
|
|
+import com.dayaedu.cbs.common.enums.music.EMusicPlayMode;
|
|
|
+import com.dayaedu.cbs.common.enums.music.EMusicSourceType;
|
|
|
+import com.dayaedu.cbs.common.enums.school.EMusicSheetType;
|
|
|
+import com.dayaedu.cbs.domain.wrapper.MusicSheetWrapper;
|
|
|
+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.musicInstrument.CbsMusicalInstrumentWrapper;
|
|
|
+import com.microsvc.toolkit.common.response.template.R;
|
|
|
+import com.ym.mec.biz.dal.dao.SysMusicScoreAccompanimentDao;
|
|
|
+import com.ym.mec.biz.dal.dao.SysMusicScoreCategoriesDao;
|
|
|
+import com.ym.mec.biz.dal.dao.SysMusicScoreDao;
|
|
|
+import com.ym.mec.biz.dal.dto.ReasonDto;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
|
|
|
-import com.ym.mec.biz.service.SysMusicScoreCategoriesService;
|
|
|
-import com.ym.mec.biz.service.SysMusicScoreService;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+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 javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.LinkedBlockingQueue;
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicScore> implements SysMusicScoreService {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysMusicScoreDao sysMusicScoreDao;
|
|
|
- @Autowired
|
|
|
- private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
|
|
|
- @Autowired
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysMusicScoreCategoriesDao sysMusicScoreCategoriesDao;
|
|
|
- @Autowired
|
|
|
- private SubjectDao subjectDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysMusicScoreCategoriesService sysMusicScoreCategoriesService;
|
|
|
- @Autowired
|
|
|
- private SysMusicScoreChangeLogDao sysMusicScoreChangeLogDao;
|
|
|
- @Autowired
|
|
|
- private IdGeneratorService idGeneratorService;
|
|
|
- @Autowired
|
|
|
- private UploadFileService uploadFileService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private OrganizationService organizationService;
|
|
|
+ @Resource
|
|
|
+ private SubjectService subjectService;
|
|
|
+ @Resource
|
|
|
+ private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
|
|
|
+ @Resource
|
|
|
+ private MusicFeignClientService musicFeignClientService;
|
|
|
+ @Resource
|
|
|
+ private InstrumentService instrumentService;
|
|
|
+
|
|
|
+ @Value("${openfeign-client.app-id:1745637981387108354}")
|
|
|
+ public Long applicationId;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, SysMusicScore> getDAO() {
|
|
@@ -79,98 +72,8 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void updateMusicScore(MusicScoreDto musicScoreDto) {
|
|
|
- SysMusicScore sysMusicScore = musicScoreDto.getSysMusicScore();
|
|
|
- sysMusicScoreDao.update(sysMusicScore);
|
|
|
- List<Integer> delExamSongAccompanimentIds = musicScoreDto.getDelExamSongAccompanimentIds();
|
|
|
- if (delExamSongAccompanimentIds != null && delExamSongAccompanimentIds.size() > 0) {
|
|
|
- sysMusicScoreAccompanimentDao.batchDel(delExamSongAccompanimentIds);
|
|
|
- }
|
|
|
- List<SysMusicScoreAccompaniment> sysMusicScoreAccompaniments = musicScoreDto.getSysMusicScoreAccompaniments();
|
|
|
- if (sysMusicScoreAccompaniments != null && sysMusicScoreAccompaniments.size() > 0) {
|
|
|
- List<Integer> subjectIdList = sysMusicScoreAccompaniments.stream().map(e -> e.getSubjectId()).collect(Collectors.toList());
|
|
|
- subjectIdList.removeAll(Collections.singleton(null));
|
|
|
-
|
|
|
- if (subjectIdList.size() > 0) {
|
|
|
- List<Integer> idList = sysMusicScoreAccompaniments.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
- List<Integer> subjectIds = sysMusicScoreAccompanimentDao.findSubjectByMusicScoreId(sysMusicScore.getId(), idList);
|
|
|
- int subjectSize = subjectIds.size() + subjectIdList.size();
|
|
|
- subjectIdList.addAll(subjectIds);
|
|
|
- int size = new HashSet<>(subjectIdList).size();
|
|
|
- if (size < subjectSize && !musicScoreDto.getMultitrack()) {
|
|
|
- throw new BizException("操作失败:请勿提交重复的伴奏声部");
|
|
|
- }
|
|
|
- }
|
|
|
- //获取需要修改的伴奏
|
|
|
- List<SysMusicScoreAccompaniment> updateCollect = sysMusicScoreAccompaniments.stream().filter(e -> e.getId() != null).collect(Collectors.toList());
|
|
|
- if (updateCollect.size() > 0) {
|
|
|
- sysMusicScoreAccompanimentDao.batchUpdate(updateCollect, sysMusicScore.getIsOpenMetronome());
|
|
|
- }
|
|
|
- //获取需要新增的伴奏
|
|
|
- List<SysMusicScoreAccompaniment> addCollect = sysMusicScoreAccompaniments.stream().filter(e -> e.getId() == null).collect(Collectors.toList());
|
|
|
- if (addCollect.size() > 0) {
|
|
|
- sysMusicScoreAccompanimentDao.batchInsert(addCollect, sysMusicScore.getId(), sysMusicScore.getIsOpenMetronome());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void add(MusicScoreDto musicScoreDto) {
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
- if (sysUser == null) {
|
|
|
- throw new BizException("请登录");
|
|
|
- }
|
|
|
- SysMusicScore sysMusicScore = musicScoreDto.getSysMusicScore();
|
|
|
- sysMusicScore.setCreateUserId(sysUser.getId());
|
|
|
- sysMusicScoreDao.insert(sysMusicScore);
|
|
|
- List<SysMusicScoreAccompaniment> sysMusicScoreAccompaniments = musicScoreDto.getSysMusicScoreAccompaniments();
|
|
|
- if (sysMusicScoreAccompaniments != null && sysMusicScoreAccompaniments.size() > 0) {
|
|
|
- sysMusicScoreAccompaniments.forEach(e -> {
|
|
|
- e.setIsOpenMetronome(sysMusicScore.getIsOpenMetronome());
|
|
|
- });
|
|
|
- sysMusicScoreAccompanimentDao.batchInsert(sysMusicScoreAccompaniments, sysMusicScore.getId(), sysMusicScore.getIsOpenMetronome());
|
|
|
- }
|
|
|
- Integer categoriesId = sysMusicScore.getMusicScoreCategoriesId();
|
|
|
- if (categoriesId != null && sysMusicScore.getClientType() == SMART_PRACTICE) {
|
|
|
- while (true) {
|
|
|
- SysMusicScoreCategories categories = sysMusicScoreCategoriesDao.get(categoriesId);
|
|
|
- if (categories.getParentId() == 0) {
|
|
|
- categories.setMusicScoreNum(categories.getMusicScoreNum() + 1);
|
|
|
- sysMusicScoreCategoriesDao.update(categories);
|
|
|
- return;
|
|
|
- }
|
|
|
- categoriesId = categories.getParentId();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void del(Integer id) {
|
|
|
- SysMusicScore sysMusicScore = sysMusicScoreDao.get(id);
|
|
|
- if (sysMusicScore == null) {
|
|
|
- throw new BizException("曲目不存在");
|
|
|
- }
|
|
|
- sysMusicScoreDao.delete(id);
|
|
|
- sysMusicScoreAccompanimentDao.deleteBySongId(id);
|
|
|
- Integer categoriesId = sysMusicScore.getMusicScoreCategoriesId();
|
|
|
- if (categoriesId != null && sysMusicScore.getClientType() == SMART_PRACTICE) {
|
|
|
- while (true) {
|
|
|
- SysMusicScoreCategories categories = sysMusicScoreCategoriesDao.get(categoriesId);
|
|
|
- if (categories.getParentId() == 0) {
|
|
|
- Integer musicScoreNum = categories.getMusicScoreNum() - 1;
|
|
|
- if (musicScoreNum < 0) {
|
|
|
- musicScoreNum = 0;
|
|
|
- }
|
|
|
- categories.setMusicScoreNum(musicScoreNum);
|
|
|
- sysMusicScoreCategoriesDao.update(categories);
|
|
|
- return;
|
|
|
- }
|
|
|
- categoriesId = categories.getParentId();
|
|
|
- }
|
|
|
- }
|
|
|
+ public SysMusicScoreDao getDao() {
|
|
|
+ return sysMusicScoreDao;
|
|
|
}
|
|
|
|
|
|
private String getParentTreeName(Integer categoriesId) {
|
|
@@ -190,56 +93,143 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void dealMusicScoreParam(SysExamSongQueryInfo queryInfo){
|
|
|
- queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
|
|
|
- if(queryInfo.getCategoriesId() != null){
|
|
|
- List<Integer> categoriesIdList = new ArrayList<>();
|
|
|
- Integer categoriesId = Integer.parseInt(queryInfo.getCategoriesId());
|
|
|
+ @Override
|
|
|
+ public List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(List<String> cbsMusicSheetIds){
|
|
|
+ CbsMusicSheetWrapper.MusicSheetApplicationQuery query = new CbsMusicSheetWrapper.MusicSheetApplicationQuery();
|
|
|
+ query.setMusicSheetIds(cbsMusicSheetIds.stream().map(Long::parseLong).collect(Collectors.toList()));
|
|
|
+ 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<>();
|
|
|
+ }
|
|
|
|
|
|
- SysMusicScoreCategories sysMusicScoreCategories = sysMusicScoreCategoriesService.get(categoriesId);
|
|
|
+ //获取乐器名称
|
|
|
+ @Override
|
|
|
+ public List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> queryMusicalInstrument(List<Integer> musicalInstrumentIds){
|
|
|
+ //获取乐器名称
|
|
|
+ CbsMusicalInstrumentWrapper.MusicalInstrumentQuery musicalInstrumentQuery = new CbsMusicalInstrumentWrapper.MusicalInstrumentQuery();
|
|
|
+ musicalInstrumentQuery.setIds(musicalInstrumentIds);
|
|
|
+ musicalInstrumentQuery.setPage(1);
|
|
|
+ musicalInstrumentQuery.setRows(musicalInstrumentIds.size());
|
|
|
+ R<com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto>> infoR = musicFeignClientService.musicalInstrumentPage(musicalInstrumentQuery);
|
|
|
+ if(infoR.getCode() != 200){
|
|
|
+ throw new com.microsvc.toolkit.common.webportal.exception.BizException("获取乐器信息失败,{}",infoR.getMessage());
|
|
|
+ }
|
|
|
+ return infoR.getData().getRows();
|
|
|
+ }
|
|
|
|
|
|
- if(sysMusicScoreCategories == null){
|
|
|
- throw new BizException("分类找不到");
|
|
|
+ private void dealMusicScoreData(List<SysMusicScore> records){
|
|
|
+ if (CollectionUtils.isNotEmpty(records)) {
|
|
|
+ List<String> cbsMusicSheetIds = records.stream().map(SysMusicScore::getCbsMusicSheetId).collect(Collectors.toList());
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetApplication> applications = this.queryCbsMusicSheetApplication(cbsMusicSheetIds);
|
|
|
+ if(CollectionUtils.isNotEmpty(applications)){
|
|
|
+ Set<Integer> categoriesIds = records.stream().map(SysMusicScore::getMusicScoreCategoriesId).collect(Collectors.toSet());
|
|
|
+ //获取分部列表
|
|
|
+ Map<Integer, String> organMap = MapUtil.convertMybatisMap(sysMusicScoreCategoriesDao.queryOrganByIds(categoriesIds));
|
|
|
+ Map<Integer, String> map = new HashMap<>(categoriesIds.size());
|
|
|
+ for (Integer categoriesId : categoriesIds) {
|
|
|
+ if(null != categoriesId){
|
|
|
+ map.put(categoriesId, getParentTreeName(categoriesId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMap = applications
|
|
|
+ .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, Function.identity()));
|
|
|
+
|
|
|
+ //获取乐器名称
|
|
|
+ String instrumentIds = applications.stream().map(CbsMusicSheetWrapper.MusicSheetApplication::getMusicalInstrumentIds).collect(Collectors.joining(","));
|
|
|
+ List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> musicalInstrumentQueryDtos =
|
|
|
+ this.queryMusicalInstrument(Arrays.stream(instrumentIds.split(",")).map(Integer::parseInt).distinct().collect(Collectors.toList()));
|
|
|
+ Map<Integer,CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> musicalInstrumentQueryMap = musicalInstrumentQueryDtos.stream()
|
|
|
+ .collect(Collectors.toMap(CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto::getId, o -> o, (o1, o2) -> o1));
|
|
|
+ //获取分类名称
|
|
|
+ Map<Integer, String> categoriesMap = new HashMap<>(categoriesIds.size());
|
|
|
+ for (Integer categoriesId : categoriesIds) {
|
|
|
+ if(null != categoriesId){
|
|
|
+ categoriesMap.put(categoriesId, getParentTreeName(categoriesId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (SysMusicScore record : records) {
|
|
|
+ record.setCategoriesName(map.get(record.getMusicScoreCategoriesId()));
|
|
|
+ record.setOrganName(organMap.get(record.getMusicScoreCategoriesId()));
|
|
|
+ CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = musicSheetApplicationMap.get(Long.parseLong(record.getCbsMusicSheetId()));
|
|
|
+ if(musicSheetApplication != null){
|
|
|
+ this.initMusicSheetVo(record,musicSheetApplication,musicalInstrumentQueryMap,categoriesMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- categoriesIdList.add(categoriesId);
|
|
|
- sysMusicScoreCategories = sysMusicScoreCategoriesService.getChildTree(sysMusicScoreCategories);
|
|
|
- getAllCategoryIdList(categoriesIdList, sysMusicScoreCategories.getSysMusicScoreCategoriesList());
|
|
|
-
|
|
|
- queryInfo.setCategoriesIdList(categoriesIdList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void dealMusicScoreData(List<SysMusicScore> rows){
|
|
|
- if (rows != null && rows.size() > 0) {
|
|
|
- Set<Integer> categoriesIds = rows.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());
|
|
|
- subjectIds.removeAll(Collections.singleton(null));
|
|
|
- Map<Long, String> subjectMap = new HashMap();
|
|
|
- if (subjectIds.size() > 0) {
|
|
|
- String ids = StringUtils.join(subjectIds, ",");
|
|
|
- subjectMap = MapUtil.convertMybatisMap(subjectDao.findBySubjecIds(ids));
|
|
|
- }
|
|
|
- Map<Integer, String> map = new HashMap<>(categoriesIds.size());
|
|
|
- for (Integer categoriesId : categoriesIds) {
|
|
|
- if(null != categoriesId){
|
|
|
- map.put(categoriesId, getParentTreeName(categoriesId));
|
|
|
+ public void initMusicSheetVo(SysMusicScore record,CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication
|
|
|
+ ,Map<Integer,CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> musicalInstrumentQueryMap,Map<Integer, String> categoriesMap){
|
|
|
+ record.setRankIds(StringUtils.equals("FREE",musicSheetApplication.getPaymentType()) ? "" : "1");
|
|
|
+ record.setCbsMusicSheetId(musicSheetApplication.getId().toString());
|
|
|
+ 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());
|
|
|
+ if(musicSheetApplication.getMusicSheetCategoryId() != null){
|
|
|
+ record.setCategoriesName(categoriesMap.get(musicSheetApplication.getMusicSheetCategoryId().intValue()));
|
|
|
+ }
|
|
|
+ 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.setXmlUrl(musicSheetApplication.getXmlFileUrl());
|
|
|
+ record.setMidiUrl(musicSheetApplication.getMidiFileUrl());
|
|
|
+ record.setOrder(musicSheetApplication.getSortNo());
|
|
|
+ record.setEnableEvaluation(musicSheetApplication.getIsEvaluated());
|
|
|
+ record.setIsOpenMetronome(musicSheetApplication.getIsUseSystemBeat() && musicSheetApplication.getIsPlayBeat());
|
|
|
+ if(musicSheetApplication.getMusicSheetType() == EMusicSheetType.CONCERT){
|
|
|
+ record.setSubjectName("");
|
|
|
+ }else {
|
|
|
+ if(StringUtils.isNotEmpty(musicSheetApplication.getMusicalInstrumentIds())){
|
|
|
+ String[] split = musicSheetApplication.getMusicalInstrumentIds().split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto musicalInstrumentQueryDto = musicalInstrumentQueryMap.get(Integer.parseInt(s));
|
|
|
+ if(Objects.nonNull(musicalInstrumentQueryDto)){
|
|
|
+ if(sb.length() > 0){
|
|
|
+ sb.append(",");
|
|
|
+ }
|
|
|
+ sb.append(musicalInstrumentQueryDto.getName());
|
|
|
+ }
|
|
|
+ record.setSubjectName(sb.toString());
|
|
|
}
|
|
|
}
|
|
|
- for (SysMusicScore row : rows) {
|
|
|
- row.setCategoriesName(map.get(row.getMusicScoreCategoriesId()));
|
|
|
- row.setOrganName(organMap.get(row.getMusicScoreCategoriesId()));
|
|
|
- row.setSubjectName(subjectMap.get(row.getSubjectId()));
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<SysMusicScore> queryMusicScoreAll(SysExamSongQueryInfo queryInfo) {
|
|
|
//封装查询参数
|
|
|
- dealMusicScoreParam(queryInfo);
|
|
|
+ queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
|
|
|
+ if(queryInfo.getSubjectId() != null){
|
|
|
+ queryInfo.setSubjectIds(queryInfo.getSubjectId().toString());
|
|
|
+ }
|
|
|
+ this.initCategoryIds(queryInfo);
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
|
|
@@ -252,7 +242,11 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
@Override
|
|
|
public PageInfo<SysMusicScore> queryMusicScorePage(SysExamSongQueryInfo queryInfo) {
|
|
|
//封装查询参数
|
|
|
- dealMusicScoreParam(queryInfo);
|
|
|
+ queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
|
|
|
+ if(queryInfo.getSubjectId() != null){
|
|
|
+ queryInfo.setSubjectIds(queryInfo.getSubjectId().toString());
|
|
|
+ }
|
|
|
+ this.initCategoryIds(queryInfo);
|
|
|
|
|
|
PageInfo<SysMusicScore> sysMusicScorePageInfo = queryPage(queryInfo);
|
|
|
List<SysMusicScore> rows = sysMusicScorePageInfo.getRows();
|
|
@@ -261,19 +255,14 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
return sysMusicScorePageInfo;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public PageInfo<SysMusicScore> queryMusicScorePageInfo(SysExamSongQueryInfo queryInfo) {
|
|
|
- if (queryInfo.getCategoriesId() != null) {
|
|
|
+ private void initCategoryIds(SysExamSongQueryInfo queryInfo){
|
|
|
+ if(StringUtils.isNotEmpty(queryInfo.getCategoriesId())){
|
|
|
List<Integer> categoriesIdList = new ArrayList<>();
|
|
|
- Integer categoriesId = null;
|
|
|
- if (StringUtils.isNotEmpty(queryInfo.getCategoriesId())) {
|
|
|
- categoriesId = Integer.parseInt(queryInfo.getCategoriesId());
|
|
|
- }
|
|
|
- //List<SysMusicScoreCategories> scoreCategories = sysMusicScoreCategoriesService.queryTree(musicScoreQueryInfo);
|
|
|
+ Integer categoriesId = Integer.parseInt(queryInfo.getCategoriesId());
|
|
|
|
|
|
SysMusicScoreCategories sysMusicScoreCategories = sysMusicScoreCategoriesService.get(categoriesId);
|
|
|
|
|
|
- if (sysMusicScoreCategories == null) {
|
|
|
+ if(sysMusicScoreCategories == null){
|
|
|
throw new BizException("分类找不到");
|
|
|
}
|
|
|
categoriesIdList.add(categoriesId);
|
|
@@ -281,93 +270,31 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
getAllCategoryIdList(categoriesIdList, sysMusicScoreCategories.getSysMusicScoreCategoriesList());
|
|
|
|
|
|
queryInfo.setCategoriesIdList(categoriesIdList);
|
|
|
- }else {
|
|
|
- if(queryInfo.getCategoriesId() == null){
|
|
|
- return new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
- }
|
|
|
}
|
|
|
- return this.queryPage(queryInfo);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void transcod(Integer sysMusicScoreId) {
|
|
|
- SysMusicScoreTranscod obj = sysMusicScoreDao.getTranscod(sysMusicScoreId);
|
|
|
- if (obj == null) {
|
|
|
- throw new BizException("曲目信息不存在");
|
|
|
- }
|
|
|
- List<SysMusicScoreMetronomeTranscod> metronomeTranscod = sysMusicScoreDao.getMetronomeTranscod(sysMusicScoreId);
|
|
|
- obj.setAccompanimentList(metronomeTranscod);
|
|
|
- //
|
|
|
- String old = JSONObject.toJSONString(obj);
|
|
|
- boolean flag = false;
|
|
|
- String url = doTranscod(obj.getUrl());
|
|
|
- if (StringUtils.isNotEmpty(url)) {
|
|
|
- obj.setUrl(url);
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- String metronomeUrl = doTranscod(obj.getMetronomeUrl());
|
|
|
- if (StringUtils.isNotEmpty(metronomeUrl)) {
|
|
|
- obj.setMetronomeUrl(metronomeUrl);
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- if (flag) {
|
|
|
- //更新obj
|
|
|
- SysMusicScore sysMusicScore = new SysMusicScore();
|
|
|
- sysMusicScore.setId(obj.getId());
|
|
|
- sysMusicScore.setUrl(obj.getUrl());
|
|
|
- sysMusicScore.setMetronomeUrl(obj.getMetronomeUrl());
|
|
|
- sysMusicScoreDao.update(sysMusicScore);
|
|
|
- }
|
|
|
|
|
|
- for (SysMusicScoreMetronomeTranscod o : metronomeTranscod) {
|
|
|
- Boolean subFlag = false;
|
|
|
- String mp3Url = doTranscod(o.getMp3Url());
|
|
|
- if (StringUtils.isNotEmpty(mp3Url)) {
|
|
|
- o.setMp3Url(mp3Url);
|
|
|
- flag = true;
|
|
|
- subFlag = true;
|
|
|
- }
|
|
|
- String metronomeMp3Url = doTranscod(o.getMetronomeMp3Url());
|
|
|
- if (StringUtils.isNotEmpty(metronomeMp3Url)) {
|
|
|
- o.setMetronomeMp3Url(metronomeMp3Url);
|
|
|
- flag = true;
|
|
|
- subFlag = true;
|
|
|
- }
|
|
|
- if (subFlag) {
|
|
|
- SysMusicScoreAccompaniment accompaniment = new SysMusicScoreAccompaniment();
|
|
|
- accompaniment.setExamSongId(o.getId());
|
|
|
- accompaniment.setMp3Url(o.getMp3Url());
|
|
|
- accompaniment.setMetronomeMp3Url(o.getMetronomeMp3Url());
|
|
|
- sysMusicScoreDao.updateAccompanimentBySongId(accompaniment);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public PageInfo<SysMusicScore> queryMusicScorePageInfo(SysExamSongQueryInfo queryInfo) {
|
|
|
+ this.initCategoryIds(queryInfo);
|
|
|
+ if(queryInfo.getSubjectId() != null){
|
|
|
+ queryInfo.setSubjectIds(queryInfo.getSubjectId().toString());
|
|
|
}
|
|
|
- if (!flag) {
|
|
|
- return;
|
|
|
+ if(CollectionUtils.isEmpty(queryInfo.getCategoriesIdList())){
|
|
|
+ return new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
}
|
|
|
- obj.setAccompanimentList(metronomeTranscod);
|
|
|
- String now = JSONObject.toJSONString(obj);
|
|
|
-
|
|
|
- //记录日志
|
|
|
- SysMusicScoreChangeLog log = new SysMusicScoreChangeLog();
|
|
|
- log.setSysMusicScoreId(obj.getId());
|
|
|
- log.setChangeBefore(old);
|
|
|
- log.setChangeAfter(now);
|
|
|
- sysMusicScoreChangeLogDao.insert(log);
|
|
|
+ PageInfo<SysMusicScore> pageInfo = this.queryPage(queryInfo);
|
|
|
+ List<SysMusicScore> rows = pageInfo.getRows();
|
|
|
+ dealMusicScoreData(rows);
|
|
|
+ return pageInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int updateExtStyleConfigJson(Integer id, String extStyleConfigJson) {
|
|
|
- return sysMusicScoreDao.updateExtStyleConfigJson(id, extStyleConfigJson);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public Map<Long, SysMusicScore> getMapByIds(List<Long> musicSheetIds) {
|
|
|
if (CollectionUtils.isEmpty(musicSheetIds)) {
|
|
|
return new HashMap<>();
|
|
|
}
|
|
|
-
|
|
|
List<SysMusicScore> musicScoreList = sysMusicScoreDao.findByIds(musicSheetIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
|
|
-
|
|
|
if (CollectionUtils.isEmpty(musicScoreList)) {
|
|
|
return new HashMap<>();
|
|
|
}
|
|
@@ -375,82 +302,213 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
return musicScoreList.stream().collect(Collectors.toMap(o -> o.getId().longValue(), e -> e));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 进行转码
|
|
|
- *
|
|
|
- * @param fileUrl
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String doTranscod(String fileUrl) {
|
|
|
- String transcodUrl = "";
|
|
|
- if (StringUtils.isEmpty(fileUrl)) {
|
|
|
- return transcodUrl;
|
|
|
+ @Override
|
|
|
+ public Boolean stateList(ReasonDto reasonDto) {
|
|
|
+ List<Integer> musicSheets = Arrays.stream(reasonDto.getMusicSheetIds().split(",")).map(Integer::parseInt).collect(Collectors.toList());
|
|
|
+ List<SysMusicScore> musicSheetList = sysMusicScoreDao.findByIds(musicSheets.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
|
|
+
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetApplication> rows =
|
|
|
+ this.queryCbsMusicSheetApplication(musicSheetList.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList()));
|
|
|
+ String applicationExtendIds = rows.stream().map(e -> e.getApplicationExtendId().toString()).collect(Collectors.joining(","));
|
|
|
+ CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus extendStatus = new CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus();
|
|
|
+ extendStatus.setIds(applicationExtendIds);
|
|
|
+ extendStatus.setStatus(reasonDto.getState()== YesOrNoEnum.YES);
|
|
|
+ R<JSONObject> jsonObjectR = musicFeignClientService.musicSheetApplicationExtendStatus(extendStatus);
|
|
|
+ if (jsonObjectR.getCode() != 200) {
|
|
|
+ throw new BizException("修改曲目状态失败,{}", jsonObjectR.getMessage());
|
|
|
}
|
|
|
- //文件扩展名
|
|
|
- String expand = FileUtil.getFileExpandByPath(fileUrl);
|
|
|
- //将远程文件写入本地临时文件路径
|
|
|
- String tempFileName = getTempFileName(expand);
|
|
|
- File tempFile = new File(tempFileName);
|
|
|
- //转码后文件路径
|
|
|
- String tempTranscodFileName = getTempFileName(expand);
|
|
|
- try {
|
|
|
- URL url = new URL(fileUrl);
|
|
|
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
|
- //设置超时间为3秒
|
|
|
- conn.setConnectTimeout(3 * 1000);
|
|
|
- //防止屏蔽程序抓取而返回403错误
|
|
|
- conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
|
|
-
|
|
|
- FileUtil.inputStreamToFile(conn.getInputStream(), tempFile);
|
|
|
-
|
|
|
- String script = "ffmpeg -i " + tempFileName + " -vn -c:a libmp3lame -b:a 320k -ac 2 " + tempTranscodFileName;
|
|
|
- int i = ScriptUtil.callScript(script);
|
|
|
- if (i == 0) {
|
|
|
- //转码成功
|
|
|
- FileInputStream inputStream = new FileInputStream(tempTranscodFileName);
|
|
|
- UploadReturnBean uploadReturnBean = uploadFileService.uploadFile(inputStream, expand);
|
|
|
- transcodUrl = uploadReturnBean.getUrl();
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- //删除服务器中的文件
|
|
|
- if (tempFile.exists()) {
|
|
|
- tempFile.delete();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean state(Integer id) {
|
|
|
+ SysMusicScore musicScore = sysMusicScoreDao.get(id);
|
|
|
+ if (musicScore == null) {
|
|
|
+ throw new BizException("曲目信息不存在");
|
|
|
+ }
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetApplication> rows =
|
|
|
+ this.queryCbsMusicSheetApplication(Collections.singletonList(musicScore.getCbsMusicSheetId()));
|
|
|
+ String applicationExtendIds = rows.stream().map(e -> e.getApplicationExtendId().toString()).collect(Collectors.joining(","));
|
|
|
+ CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus extendStatus = new CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus();
|
|
|
+ extendStatus.setIds(applicationExtendIds);
|
|
|
+ extendStatus.setStatus(musicScore.getShowFlag() != 1);
|
|
|
+ R<JSONObject> jsonObjectR = musicFeignClientService.musicSheetApplicationExtendStatus(extendStatus);
|
|
|
+ if (jsonObjectR.getCode() != 200) {
|
|
|
+ throw new BizException("修改曲目状态失败,{}", jsonObjectR.getMessage());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateCbs(MusicSheetWrapper.MusicSheetApplicationExtendWrapper addMusicSheetApplicationExtend) {
|
|
|
+ CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend extend =
|
|
|
+ JSONObject.parseObject(JSONObject.toJSONString(addMusicSheetApplicationExtend), CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend.class);
|
|
|
+ extend.setApplicationId(applicationId);
|
|
|
+ R<JSONObject> jsonObjectR = musicFeignClientService.musicSheetApplicationExtendUpdate(extend);
|
|
|
+ if (jsonObjectR.getCode() != 200) {
|
|
|
+ throw new BizException("修改失败,{}",jsonObjectR.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sync() {
|
|
|
+ ThreadPoolExecutor executorService = new ThreadPoolExecutor(50, 50,
|
|
|
+ 0L, TimeUnit.MILLISECONDS,
|
|
|
+ new LinkedBlockingQueue<>());
|
|
|
+ List<SysMusicScore> records = sysMusicScoreDao.selectSyncPage();
|
|
|
+ if (CollectionUtils.isEmpty(records)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (SysMusicScore record : records) {
|
|
|
+ executorService.submit(() ->
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ syncMusicSheet(record);
|
|
|
+ }catch (Exception e) {
|
|
|
+ log.error("曲目同步异常,曲目ID:{}", record.getId(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ while (!executorService.getQueue().isEmpty()) {
|
|
|
+ try {
|
|
|
+ log.info("线程池中正在执行的任务数量:{},等待数量:{}", executorService.getActiveCount(),executorService.getQueue().size());
|
|
|
+ Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error("线程等待异常", e);
|
|
|
}
|
|
|
- File tempTranscodFile = new File(tempTranscodFileName);
|
|
|
- if (tempTranscodFile.exists()) {
|
|
|
- tempTranscodFile.delete();
|
|
|
+ }
|
|
|
+ log.info("-------------------- 曲目数据同步成功! -------------------------------");
|
|
|
+ executorService.shutdown();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void syncMusicSheet(SysMusicScore record) {
|
|
|
+ List<SysMusicScoreAccompaniment> list = sysMusicScoreAccompanimentDao.findByMusicScoreId(record.getId());
|
|
|
+
|
|
|
+ CbsMusicSheetWrapper.AddMusicSheet addMusicSheet = this.musicToAddMusicSheet(record,list);
|
|
|
+
|
|
|
+ R<CbsMusicSheetWrapper.MusicSheet> musicSheetR = musicFeignClientService.musicCbsSync(addMusicSheet);
|
|
|
+ try {
|
|
|
+ CbsMusicSheetWrapper.MusicSheet musicSheet = musicSheetR.feignData();
|
|
|
+ if (musicSheet == null) {
|
|
|
+ log.error("曲目同步失败,曲目ID:{}", record.getId());
|
|
|
}
|
|
|
+ } catch (Exception e){
|
|
|
+ log.error("曲目同步失败,曲目ID:{}", record.getId(),e);
|
|
|
}
|
|
|
- return transcodUrl;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 通过网络文件路径获取临时文件路径
|
|
|
- *
|
|
|
- * @param fileUrl
|
|
|
- * @return
|
|
|
- */
|
|
|
- String tempPath = "/usr/temp";
|
|
|
-
|
|
|
- private String getTempFileName(String expand) {
|
|
|
- //没有目录则创建
|
|
|
- File file = new File(tempPath);
|
|
|
- if (!file.exists()) {
|
|
|
- file.mkdirs();
|
|
|
+ //测试环境合奏分类
|
|
|
+ private static String categoryIds = "42,43,44,45,46,91,92,93,94,95,7,11,15,180";
|
|
|
+ private static String prodCategoryIds = "42,43,44,45,46,91,92,93,94,95,185,186,7,11,15,180";
|
|
|
+
|
|
|
+ private CbsMusicSheetWrapper.AddMusicSheet musicToAddMusicSheet(SysMusicScore from, List<SysMusicScoreAccompaniment> accList) {
|
|
|
+ CbsMusicSheetWrapper.AddMusicSheet addMusicSheet = new CbsMusicSheetWrapper.AddMusicSheet();
|
|
|
+ addMusicSheet.setId(Long.parseLong(from.getCbsMusicSheetId()));
|
|
|
+ addMusicSheet.setName(from.getName());
|
|
|
+ if (StringUtils.isNotBlank(from.getSubjectIds())) {
|
|
|
+ List<Integer> subjectIds = Arrays.stream(from.getSubjectIds().split(","))
|
|
|
+ .map(Integer::parseInt).distinct().collect(Collectors.toList());
|
|
|
+ List<Subject> list = subjectService.findBySubjectByIdList(subjectIds);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ addMusicSheet.setSubjectIds(list.stream().filter(e->e.getCbsSubjectId() != null).map(o->o.getCbsSubjectId().toString()).collect(Collectors.joining(",")));
|
|
|
+ //获取关联的乐器
|
|
|
+ List<Instrument> list1 = instrumentService.lambdaQuery().in(Instrument::getSubjectId, subjectIds).list();
|
|
|
+ if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
+ addMusicSheet.setMusicalInstrumentIds(list1.stream().map(o -> o.getId().toString()).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- //.mp3
|
|
|
- String fileName = tempPath + File.separator + idGeneratorService.generatorId("tempFile");
|
|
|
- if (StringUtils.isNotEmpty(expand)) {
|
|
|
- fileName += "." + expand;
|
|
|
+ addMusicSheet.setSendAppFlag(false);
|
|
|
+ addMusicSheet.setMusicCover("https://oss.dayaedu.com/gyt/07/1690789356356.png");
|
|
|
+ addMusicSheet.setAppAuditFlag(false);
|
|
|
+ addMusicSheet.setRemark(from.getMuseScoreMemo());
|
|
|
+ addMusicSheet.setIsPlayBeat(true);
|
|
|
+ if(categoryIds.contains(from.getMusicScoreCategoriesId().toString())){
|
|
|
+ addMusicSheet.setMusicSheetType(EMusicSheetType.CONCERT);
|
|
|
+ }else {
|
|
|
+ addMusicSheet.setMusicSheetType(EMusicSheetType.SINGLE);
|
|
|
+ }
|
|
|
+ addMusicSheet.setIsEvaluated(from.isEnableEvaluation());
|
|
|
+ addMusicSheet.setIsConvertibleScore(true);
|
|
|
+ addMusicSheet.setPlaySpeed(from.getSpeed());
|
|
|
+ addMusicSheet.setPlayMode(from.getPlayMode() == SysMusicScore.PlayMode.MP3 ? EMusicPlayMode.MP3 : EMusicPlayMode.MIDI);
|
|
|
+ addMusicSheet.setMidiFileUrl(from.getMidiUrl());
|
|
|
+ addMusicSheet.setExtConfigJson(from.getExtConfigJson());
|
|
|
+ addMusicSheet.setCreateTime(from.getCreateTime());
|
|
|
+ addMusicSheet.setAudioType(EAudioType.HOMEMODE);
|
|
|
+ addMusicSheet.setAvailableType(EMusicAvailableType.ORG);
|
|
|
+ addMusicSheet.setSourceType(EMusicSourceType.PLATFORM);
|
|
|
+ addMusicSheet.setStatus(true);
|
|
|
+
|
|
|
+ String tracks = "";
|
|
|
+ // 伴奏,原音 扩展信息
|
|
|
+ if (addMusicSheet.getPlayMode() == EMusicPlayMode.MP3) {
|
|
|
+ CbsMusicSheetWrapper.MusicSheetAccompaniment musicSheetAccompaniment = new CbsMusicSheetWrapper.MusicSheetAccompaniment();
|
|
|
+ if (StringUtils.isNotBlank(musicSheetAccompaniment.getAudioFileUrl())) {
|
|
|
+ addMusicSheet.setMusicSheetAccompanimentList(Lists.newArrayList(musicSheetAccompaniment));
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(accList)) {
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetSound> musicSheetSounds = new ArrayList<>();
|
|
|
+ int i = 0;
|
|
|
+ for (SysMusicScoreAccompaniment sheetAccompaniment : accList) {
|
|
|
+ CbsMusicSheetWrapper.MusicSheetSound musicSheetSound = new CbsMusicSheetWrapper.MusicSheetSound();
|
|
|
+ if (StringUtils.isNotBlank(sheetAccompaniment.getMetronomeMp3Url())){
|
|
|
+ musicSheetSound.setAudioFileUrl(sheetAccompaniment.getMetronomeMp3Url());
|
|
|
+ } else {
|
|
|
+ musicSheetSound.setAudioFileUrl(sheetAccompaniment.getMp3Url());
|
|
|
+ }
|
|
|
+ musicSheetSound.setTrack(sheetAccompaniment.getTrack());
|
|
|
+ if (sheetAccompaniment.getSubjectId() != null) {
|
|
|
+ Subject subject = subjectService.get(sheetAccompaniment.getSubjectId());
|
|
|
+ if (Objects.nonNull(subject)) {
|
|
|
+ //获取关联的乐器
|
|
|
+ Instrument one = instrumentService.lambdaQuery().eq(Instrument::getSubjectId, subject.getId()).one();
|
|
|
+ if (Objects.nonNull(one)) {
|
|
|
+ musicSheetSound.setMusicalInstrumentId(one.getId().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ musicSheetSound.setSortNumber(i++);
|
|
|
+ if (StringUtils.isNotBlank(musicSheetSound.getAudioFileUrl())) {
|
|
|
+ //xml
|
|
|
+ addMusicSheet.setXmlFileUrl(sheetAccompaniment.getXmlUrl());
|
|
|
+ //是否显示指法
|
|
|
+ addMusicSheet.setIsShowFingering(sheetAccompaniment.getIsShowFingering());
|
|
|
+ //是否使用系统节拍器
|
|
|
+ addMusicSheet.setIsUseSystemBeat(sheetAccompaniment.getIsOpenMetronome());
|
|
|
+ musicSheetSounds.add(musicSheetSound);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tracks = musicSheetSounds.stream().map(CbsMusicSheetWrapper.MusicSheetSound::getTrack).collect(Collectors.joining(","));
|
|
|
+ addMusicSheet.setMusicSheetSoundList(musicSheetSounds);
|
|
|
+ }
|
|
|
}
|
|
|
- return fileName;
|
|
|
+ addMusicSheet.setMultiTracksSelection(tracks);
|
|
|
+
|
|
|
+ CbsMusicSheetWrapper.MusicSheetExtend musicSheetExtend = new CbsMusicSheetWrapper.MusicSheetExtend();
|
|
|
+ musicSheetExtend.setApplicationId(applicationId);
|
|
|
+ musicSheetExtend.setClientType(EClientType.BACKEND.name());
|
|
|
+ addMusicSheet.setMusicSheetExtend(musicSheetExtend);
|
|
|
+
|
|
|
+ // 应用扩展信息
|
|
|
+ CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend addMusicSheetApplicationExtend = new CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend();
|
|
|
+ addMusicSheetApplicationExtend.setApplicationId(applicationId);
|
|
|
+ addMusicSheetApplicationExtend.setStatus(addMusicSheet.getStatus());
|
|
|
+ addMusicSheetApplicationExtend.setSortNo(from.getOrder());
|
|
|
+ addMusicSheetApplicationExtend.setPaymentType(StringUtils.isNotEmpty(from.getRankIds()) ? "VIP" : "FREE");
|
|
|
+ addMusicSheetApplicationExtend.setAvailableType(EMusicAvailableType.ORG);
|
|
|
+ addMusicSheetApplicationExtend.setMusicSheetCategoryId(from.getMusicScoreCategoriesId().longValue());
|
|
|
+ addMusicSheet.setMusicCategoryId(from.getMusicScoreCategoriesId().longValue());
|
|
|
+ addMusicSheet.setAddMusicSheetApplicationExtend(Lists.newArrayList(addMusicSheetApplicationExtend));
|
|
|
+ addMusicSheet.setIsConvertibleScore(true);
|
|
|
+ return addMusicSheet;
|
|
|
}
|
|
|
|
|
|
private void getAllCategoryIdList(List<Integer> categoryIdList, List<SysMusicScoreCategories> sysMusicScoreCategoriesList) {
|
|
|
|
|
|
- if (sysMusicScoreCategoriesList != null && sysMusicScoreCategoriesList.size() > 0) {
|
|
|
+ if (CollectionUtils.isNotEmpty(sysMusicScoreCategoriesList)) {
|
|
|
for (SysMusicScoreCategories sysMusicScoreCategories : sysMusicScoreCategoriesList) {
|
|
|
categoryIdList.add(sysMusicScoreCategories.getId());
|
|
|
getAllCategoryIdList(categoryIdList, sysMusicScoreCategories.getSysMusicScoreCategoriesList());
|