|
@@ -5,8 +5,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.additional.update.impl.LambdaUpdateChainWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.dayaedu.cbs.common.enums.music.EMusicSourceType;
|
|
|
+import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
|
|
|
import com.dayaedu.cbs.openfeign.service.CbsMusicSheetService;
|
|
|
import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetApplicationExtendWrapper;
|
|
|
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
|
|
|
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectApiWrapper;
|
|
|
+import com.microsvc.toolkit.common.response.paging.PageInfo;
|
|
|
+import com.microsvc.toolkit.common.response.template.R;
|
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.MusicAlbumDao;
|
|
@@ -60,6 +66,7 @@ import com.yonge.cooleshow.biz.dal.enums.*;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.album.PurchaseRecordTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.UserTenantAlbumRecordMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.cbs.CbsMusicScoreService;
|
|
|
import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.*;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.res.OrderCreateRes;
|
|
@@ -85,6 +92,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
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;
|
|
|
|
|
@@ -201,6 +209,9 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
|
|
|
@Autowired
|
|
|
private TenantAlbumService tenantAlbumService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CbsMusicScoreService cbsMusicScoreService;
|
|
|
+
|
|
|
public MusicSheetDao getDao() {
|
|
|
return musicSheetDao;
|
|
|
}
|
|
@@ -393,12 +404,97 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
|
|
|
return musicSheetShareVo;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public MusicSheetDetailVo detail(Long id, SysUser sysUser, ClientEnum userType) {
|
|
|
- MusicSheetDetailVo detail = baseMapper.detail(id);
|
|
|
- if (detail == null) {
|
|
|
+ public MusicSheetDetailVo getCbsDetail(Long id) {
|
|
|
+ MusicSheet musicSheet = this.baseMapper.get(id);
|
|
|
+ if (musicSheet == null || musicSheet.getDelFlag()) {
|
|
|
+ throw new BizException("未找到曲目信息");
|
|
|
+ }
|
|
|
+ if(musicSheet.getCbsMusicSheetId() == null){
|
|
|
+ throw new BizException("曲目信息未同步");
|
|
|
+ }
|
|
|
+ R<CbsMusicSheetWrapper.MusicSheet> musicSheetR = cbsMusicScoreService.musicSheetDetail(musicSheet.getCbsMusicSheetId());
|
|
|
+ if(musicSheetR.getCode() != 200){
|
|
|
+ throw new BizException("获取曲目信息失败");
|
|
|
+ }
|
|
|
+ CbsMusicSheetWrapper.MusicSheet musicSheet1 = musicSheetR.getData();
|
|
|
+ if (musicSheet1 == null) {
|
|
|
+ throw new BizException("未找到曲目信息");
|
|
|
+ }
|
|
|
+ MusicSheetDetailVo detailVo = JSON.parseObject(JSON.toJSONString(musicSheet), MusicSheetDetailVo.class);
|
|
|
+ this.initMusicSheetDetailVo(detailVo,musicSheet);
|
|
|
+ return detailVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initMusicSheetDetailVo(MusicSheetDetailVo detailVo,MusicSheet musicSheet) {
|
|
|
+ R<CbsMusicSheetWrapper.MusicSheet> musicSheetR = cbsMusicScoreService.musicSheetDetail(musicSheet.getCbsMusicSheetId());
|
|
|
+ if(musicSheetR.getCode() != 200){
|
|
|
+ throw new BizException("获取曲目信息失败");
|
|
|
+ }
|
|
|
+ CbsMusicSheetWrapper.MusicSheet musicSheet1 = musicSheetR.getData();
|
|
|
+ if (musicSheet1 == null) {
|
|
|
throw new BizException("未找到曲目信息");
|
|
|
}
|
|
|
+ CbsMusicSheetWrapper.MusicSheetExtend musicSheetExtend = musicSheet1.getMusicSheetExtend();
|
|
|
+ if (musicSheetExtend != null && musicSheetExtend.getUserId() != null) {
|
|
|
+ detailVo.setUserName(musicSheetExtend.getUserName());
|
|
|
+ detailVo.setUserId(musicSheetExtend.getUserId());
|
|
|
+ //获取用户头像
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(musicSheetExtend.getUserId());
|
|
|
+ if (sysUser != null) {
|
|
|
+ detailVo.setUserAvatar(sysUser.getAvatar());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(musicSheet1.getSubjectIds())){
|
|
|
+ CbsSubjectApiWrapper.SubjectQuery subjectQuery = new CbsSubjectApiWrapper.SubjectQuery();
|
|
|
+ subjectQuery.setCbsSubjectIds(Arrays.stream(musicSheet1.getSubjectIds().split(",")).map(Long::parseLong).collect(Collectors.toList()));
|
|
|
+ List<CbsSubjectApiWrapper.Subject> subjects = subjectService.getDao().queryCbsList(subjectQuery);
|
|
|
+ if(CollectionUtils.isNotEmpty(subjects)){
|
|
|
+ detailVo.setSubjectNames(subjects.stream().map(CbsSubjectApiWrapper.Subject::getSubjectName).collect(Collectors.joining(",")));
|
|
|
+ detailVo.setCode(subjects.stream().map(CbsSubjectApiWrapper.Subject::getCode).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detailVo.setId(musicSheet.getId());
|
|
|
+ detailVo.setCbsMusicSheetId(musicSheet1.getId());
|
|
|
+ detailVo.setAudioType(AudioTypeEnum.valueOf(musicSheet1.getPlayMode().getCode()));
|
|
|
+ detailVo.setCanEvaluate(musicSheet1.getIsEvaluated() ? YesOrNoEnum.YES : YesOrNoEnum.NO);
|
|
|
+ detailVo.setShowFingering(musicSheet1.getIsShowFingering() ? YesOrNoEnum.YES : YesOrNoEnum.NO);
|
|
|
+ detailVo.setMusicTag(musicSheet1.getMusicTag());
|
|
|
+ detailVo.setMusicTagNames(musicSheet1.getMusicTagNames());
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetAccompaniment> accompanimentList = musicSheet1.getMusicSheetAccompanimentList();
|
|
|
+ if (CollectionUtils.isNotEmpty(accompanimentList)) {
|
|
|
+ detailVo.setAudioFileUrl(accompanimentList.get(0).getAudioFileUrl());
|
|
|
+ }
|
|
|
+ detailVo.setXmlFileUrl(musicSheet1.getXmlFileUrl());
|
|
|
+ detailVo.setMidiUrl(musicSheet1.getMidiFileUrl());
|
|
|
+ detailVo.setAuditVersion(musicSheet1.getAppAuditFlag() ? YesOrNoEnum.YES : YesOrNoEnum.NO);
|
|
|
+ detailVo.setHasBeat((musicSheet1.getIsPlayBeat() && !musicSheet1.getIsUseSystemBeat()) ? YesOrNoEnum.YES : YesOrNoEnum.NO);
|
|
|
+ detailVo.setExtConfigJson(musicSheet1.getExtConfigJson());
|
|
|
+ detailVo.setMusicJSON(musicSheet1.getMusicJson());
|
|
|
+ detailVo.setMusicJianSvg(musicSheet1.getMusicJianSvg());
|
|
|
+ detailVo.setMusicFirstSvg(musicSheet1.getMusicFirstSvg());
|
|
|
+ detailVo.setFirstTone(musicSheet1.getMusicFirstImg());
|
|
|
+ detailVo.setFixedTone(musicSheet1.getMusicJianImg());
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetSound> soundList = musicSheet1.getMusicSheetSoundList();
|
|
|
+ if (CollectionUtils.isNotEmpty(soundList)) {
|
|
|
+ List<MusicSheetAccompaniment> background = new ArrayList<>();
|
|
|
+ for (CbsMusicSheetWrapper.MusicSheetSound sound : soundList) {
|
|
|
+ MusicSheetAccompaniment accompaniment = new MusicSheetAccompaniment();
|
|
|
+ accompaniment.setMusicSheetId(musicSheet.getId());
|
|
|
+ accompaniment.setAudioFileUrl(sound.getAudioFileUrl());
|
|
|
+ accompaniment.setSortNumber(sound.getSortNumber());
|
|
|
+ accompaniment.setTrack(sound.getTrack());
|
|
|
+ background.add(accompaniment);
|
|
|
+ }
|
|
|
+ //按照sortNumber排序
|
|
|
+ background.sort(Comparator.comparing(MusicSheetAccompaniment::getSortNumber));
|
|
|
+ detailVo.setBackground(background);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public MusicSheetDetailVo detail(Long id, SysUser sysUser, ClientEnum userType) {
|
|
|
+ MusicSheetDetailVo detail = this.getCbsDetail(id);
|
|
|
|
|
|
// 设置收藏人数
|
|
|
detail.setFavoriteCount(detail.getFavoriteCount() + detail.getVirtualNumber());
|
|
@@ -553,14 +649,79 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initMusicSheetVo(MusicSheetVo record,CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication,Map<Long, CbsSubjectApiWrapper.Subject> subjectMap){
|
|
|
+ if(StringUtils.isNotEmpty(musicSheetApplication.getSubjectIds())){
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (String s : musicSheetApplication.getSubjectIds().split(",")) {
|
|
|
+ CbsSubjectApiWrapper.Subject subject = subjectMap.get(Long.parseLong(s));
|
|
|
+ if(subject != null){
|
|
|
+ if (sb.length() > 0) {
|
|
|
+ sb.append(",");
|
|
|
+ }
|
|
|
+ sb.append(subject.getSubjectName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setSubjectNames(sb.toString());
|
|
|
+ }
|
|
|
+ record.setCbsMusicSheetId(musicSheetApplication.getId());
|
|
|
+ record.setAudioType(AudioTypeEnum.valueOf(musicSheetApplication.getPlayMode().getCode()));
|
|
|
+ record.setCanEvaluate(musicSheetApplication.getIsEvaluated() ? YesOrNoEnum.YES : YesOrNoEnum.NO);
|
|
|
+ record.setShowFingering(musicSheetApplication.getIsShowFingering() ? YesOrNoEnum.YES : YesOrNoEnum.NO);
|
|
|
+ record.setMusicTag(musicSheetApplication.getMusicTagIds());
|
|
|
+ record.setMusicTagNames(musicSheetApplication.getMusicTagNames());
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetAccompaniment> accompanimentList = musicSheetApplication.getMusicSheetAccompanimentList();
|
|
|
+ if (CollectionUtils.isNotEmpty(accompanimentList)) {
|
|
|
+ record.setAudioFileUrl(accompanimentList.get(0).getAudioFileUrl());
|
|
|
+ }
|
|
|
+ record.setXmlFileUrl(musicSheetApplication.getXmlFileUrl());
|
|
|
+ record.setMidiUrl(musicSheetApplication.getMidiFileUrl());
|
|
|
+ record.setAuditVersion(musicSheetApplication.getAppAuditFlag() ? YesOrNoEnum.YES : YesOrNoEnum.NO);
|
|
|
+ record.setHasBeat((musicSheetApplication.getIsPlayBeat() && !musicSheetApplication.getIsUseSystemBeat()) ? YesOrNoEnum.YES : YesOrNoEnum.NO);
|
|
|
+ record.setExtConfigJson(musicSheetApplication.getExtConfigJson());
|
|
|
+ record.setMusicJSON(musicSheetApplication.getMusicJson());
|
|
|
+ record.setMusicJianSvg(musicSheetApplication.getMusicJianSvg());
|
|
|
+ record.setMusicFirstSvg(musicSheetApplication.getMusicFirstSvg());
|
|
|
+ record.setFirstTone(musicSheetApplication.getMusicFirstImg());
|
|
|
+ record.setFixedTone(musicSheetApplication.getMusicJianImg());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ public void initMusicSheetVos(List<MusicSheetVo> 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<PageInfo<CbsMusicSheetWrapper.MusicSheetApplication>> pageInfoR = cbsMusicScoreService.selectPage(query);
|
|
|
+ if(pageInfoR.getCode() != 200){
|
|
|
+ throw new BizException("获取曲目信息失败");
|
|
|
+ }
|
|
|
+ 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()));
|
|
|
+ CbsSubjectApiWrapper.SubjectQuery subjectQuery = new CbsSubjectApiWrapper.SubjectQuery();
|
|
|
+ subjectQuery.setCbsSubjectIds(records.stream().map(MusicSheetVo::getMusicSubject).filter(StringUtils::isNotEmpty).map(Long::parseLong).distinct().collect(Collectors.toList()));
|
|
|
+ List<CbsSubjectApiWrapper.Subject> subjects = subjectService.getDao().queryCbsList(subjectQuery);
|
|
|
+ Map<Long, CbsSubjectApiWrapper.Subject> subjectMap = subjects.stream().collect(Collectors.toMap(CbsSubjectApiWrapper.Subject::getSubjectId, Function.identity()));
|
|
|
+ for (MusicSheetVo record : records) {
|
|
|
+ CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = musicSheetApplicationMap.get(record.getCbsMusicSheetId());
|
|
|
+ if(musicSheetApplication != null){
|
|
|
+ this.initMusicSheetVo(record,musicSheetApplication,subjectMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public IPage<MusicSheetVo> selectStudentPage(IPage<MusicSheetVo> page, StudentMusicSheetSearch query, ClientEnum clientType) {
|
|
|
List<MusicSheetVo> records = baseMapper.selectStudentMusicPage(page, query, clientType);
|
|
|
-
|
|
|
+ //设置内容平台曲目信息
|
|
|
+ this.initMusicSheetVos(records);
|
|
|
if (CollectionUtils.isNotEmpty(records)) {
|
|
|
|
|
|
// 统计单曲归属专辑数
|
|
@@ -696,6 +857,8 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
|
|
|
query.setDelFlag(null);
|
|
|
|
|
|
List<MusicSheetVo> records = baseMapper.selectMyMusicPage(page, query);
|
|
|
+ //设置内容平台曲目信息
|
|
|
+ this.initMusicSheetVos(records);
|
|
|
|
|
|
// 统计曲目专辑数
|
|
|
if (CollectionUtils.isNotEmpty(records)) {
|
|
@@ -713,6 +876,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
|
|
|
List<MusicSheetVo> records = baseMapper.selectFavoriteMusicPage(page, query, clientType);
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(records)) {
|
|
|
+ this.initMusicSheetVos(records);
|
|
|
|
|
|
// 更新曲目专辑数量
|
|
|
musicSheetService.updateMusicAlbumNumInfo(records);
|
|
@@ -735,7 +899,10 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
|
|
|
// 设置学生端收藏联系
|
|
|
query.setClientType(ClientEnum.STUDENT);
|
|
|
// 构建分页信息
|
|
|
- page.setRecords(baseMapper.selectPracticeMusicPage(query, practiceMusicIdList));
|
|
|
+ List<MusicSheetVo> musicSheetVos = baseMapper.selectPracticeMusicPage(query, practiceMusicIdList);
|
|
|
+ //设置内容平台曲目信息
|
|
|
+ this.initMusicSheetVos(musicSheetVos);
|
|
|
+ page.setRecords(musicSheetVos);
|
|
|
page.setPages(practiceMusicIdPage.getPages());
|
|
|
page.setCurrent(practiceMusicIdPage.getCurrent());
|
|
|
page.setSize(practiceMusicIdPage.getSize());
|