|
@@ -1,77 +1,74 @@
|
|
|
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.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.SysMusicScoreChangeLog;
|
|
|
-import com.ym.mec.biz.service.OrganizationService;
|
|
|
-import com.ym.mec.biz.service.UploadFileService;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
+import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.entity.UploadReturnBean;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
|
+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.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
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.ym.mec.biz.dal.page.SysExamSongQueryInfo;
|
|
|
-import com.ym.mec.biz.service.SysMusicScoreCategoriesService;
|
|
|
-import com.ym.mec.biz.service.SysMusicScoreService;
|
|
|
-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 javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+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;
|
|
|
|
|
|
@Service
|
|
|
public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicScore> implements SysMusicScoreService {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysMusicScoreDao sysMusicScoreDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
|
|
|
- @Autowired
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
+ private SysUserService sysUserService;
|
|
|
+ @Resource
|
|
|
private SysMusicScoreCategoriesDao sysMusicScoreCategoriesDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SubjectDao subjectDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysMusicScoreCategoriesService sysMusicScoreCategoriesService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysMusicScoreChangeLogDao sysMusicScoreChangeLogDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private IdGeneratorService idGeneratorService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private UploadFileService uploadFileService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private OrganizationService organizationService;
|
|
|
+ @Resource
|
|
|
+ private MusicFeignClientService musicFeignClientService;
|
|
|
+
|
|
|
+ @Value("${openfeign-client.app-id:1745637981387108354}")
|
|
|
+ public Long applicationId;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, SysMusicScore> getDAO() {
|
|
@@ -79,6 +76,11 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public SysMusicScoreDao getDao() {
|
|
|
+ return sysMusicScoreDao;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateMusicScore(MusicScoreDto musicScoreDto) {
|
|
|
SysMusicScore sysMusicScore = musicScoreDto.getSysMusicScore();
|
|
@@ -118,12 +120,8 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
@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());
|
|
|
+ sysMusicScore.setCreateUserId(sysUserService.getUserId());
|
|
|
sysMusicScoreDao.insert(sysMusicScore);
|
|
|
List<SysMusicScoreAccompaniment> sysMusicScoreAccompaniments = musicScoreDto.getSysMusicScoreAccompaniments();
|
|
|
if (sysMusicScoreAccompaniments != null && sysMusicScoreAccompaniments.size() > 0) {
|
|
@@ -153,6 +151,10 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
if (sysMusicScore == null) {
|
|
|
throw new BizException("曲目不存在");
|
|
|
}
|
|
|
+ Integer userId = sysUserService.getUserId();
|
|
|
+ if (!Objects.equals(sysMusicScore.getCreateUserId(), userId)) {
|
|
|
+ throw new BizException("无权限删除");
|
|
|
+ }
|
|
|
sysMusicScoreDao.delete(id);
|
|
|
sysMusicScoreAccompanimentDao.deleteBySongId(id);
|
|
|
Integer categoriesId = sysMusicScore.getMusicScoreCategoriesId();
|
|
@@ -190,32 +192,36 @@ 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());
|
|
|
-
|
|
|
- SysMusicScoreCategories sysMusicScoreCategories = sysMusicScoreCategoriesService.get(categoriesId);
|
|
|
-
|
|
|
- if(sysMusicScoreCategories == null){
|
|
|
- throw new BizException("分类找不到");
|
|
|
+ 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("获取曲目信息失败");
|
|
|
}
|
|
|
- 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());
|
|
|
+ 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) {
|
|
@@ -227,19 +233,60 @@ 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) {
|
|
|
//封装查询参数
|
|
|
- dealMusicScoreParam(queryInfo);
|
|
|
+ queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
|
|
|
+ this.initCategoryIds(queryInfo);
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
|
|
@@ -252,7 +299,8 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
|
@Override
|
|
|
public PageInfo<SysMusicScore> queryMusicScorePage(SysExamSongQueryInfo queryInfo) {
|
|
|
//封装查询参数
|
|
|
- dealMusicScoreParam(queryInfo);
|
|
|
+ queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
|
|
|
+ this.initCategoryIds(queryInfo);
|
|
|
|
|
|
PageInfo<SysMusicScore> sysMusicScorePageInfo = queryPage(queryInfo);
|
|
|
List<SysMusicScore> rows = sysMusicScorePageInfo.getRows();
|
|
@@ -261,19 +309,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,12 +324,20 @@ 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 PageInfo<SysMusicScore> queryMusicScorePageInfo(SysExamSongQueryInfo queryInfo) {
|
|
|
+ this.initCategoryIds(queryInfo);
|
|
|
+ if(CollectionUtils.isEmpty(queryInfo.getCategoriesIdList())){
|
|
|
+ return new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ }
|
|
|
+ PageInfo<SysMusicScore> pageInfo = this.queryPage(queryInfo);
|
|
|
+ List<SysMusicScore> rows = pageInfo.getRows();
|
|
|
+ dealMusicScoreData(rows);
|
|
|
+ return pageInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|