|
@@ -3,6 +3,7 @@ package com.ym.service.Impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.microsvc.toolkit.middleware.rtc.RTCRoomPluginContext;
|
|
@@ -113,9 +114,11 @@ public class RoomServiceImpl implements RoomService {
|
|
|
@Autowired
|
|
|
private SysExamSongDao sysExamSongDao;
|
|
|
@Autowired
|
|
|
+ private SysMusicScoreService sysMusicScoreService;
|
|
|
+ @Autowired
|
|
|
private CourseScheduleStudentMusicScoreDao courseScheduleStudentMusicScoreDao;
|
|
|
@Autowired
|
|
|
- private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
|
|
|
+ private SysMusicScoreAccompanimentService sysMusicScoreAccompanimentService;
|
|
|
@Autowired
|
|
|
private SysTenantConfigService sysTenantConfigService;
|
|
|
@Autowired
|
|
@@ -564,7 +567,8 @@ public class RoomServiceImpl implements RoomService {
|
|
|
.setGroupId(roomId);
|
|
|
}
|
|
|
|
|
|
- List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores = courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(null, courseId, null, null, null);
|
|
|
+ List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores =
|
|
|
+ courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(null, courseId, null, null, null);
|
|
|
Room room = roomDao.findByRid(roomId);
|
|
|
String display = "";
|
|
|
if (roleEnum == RoleTeacher || roleEnum == RoleEnum.RoleAssistant) {
|
|
@@ -595,8 +599,10 @@ public class RoomServiceImpl implements RoomService {
|
|
|
}
|
|
|
}
|
|
|
//已下载的伴奏列表
|
|
|
- if (scheduleStudentMusicScores != null && scheduleStudentMusicScores.size() > 0) {
|
|
|
- List<CourseScheduleStudentMusicScore> musicScores = scheduleStudentMusicScores.stream().filter(e -> e.getUserId().equals(sysUser.getId())).collect(Collectors.toList());
|
|
|
+ this.initCourseScheduleStudentMusicScore(scheduleStudentMusicScores);
|
|
|
+ if (CollectionUtils.isNotEmpty(scheduleStudentMusicScores)) {
|
|
|
+ List<CourseScheduleStudentMusicScore> musicScores = scheduleStudentMusicScores.stream()
|
|
|
+ .filter(e -> e.getUserId().equals(sysUser.getId())).collect(Collectors.toList());
|
|
|
String toJSONString = JSON.toJSONString(musicScores, SerializerFeature.DisableCircularReferenceDetect);
|
|
|
List<CourseScheduleStudentMusicScore> lists = JSON.parseArray(toJSONString, CourseScheduleStudentMusicScore.class);
|
|
|
userResult.setScheduleStudentMusicScores(lists);
|
|
@@ -636,17 +642,8 @@ public class RoomServiceImpl implements RoomService {
|
|
|
Set<String> userIds = roomMemberList.stream().map(RoomMember::getUid).collect(Collectors.toSet());
|
|
|
Map<Integer, String> midiMap = MapUtil.convertMybatisMap(courseScheduleStudentPaymentDao.queryMidiByUserIdsAndCourseId(userIds, courseId.toString()));
|
|
|
Map<Integer, String> examSongMap = MapUtil.convertMybatisMap(courseScheduleStudentPaymentDao.queryExamSongByUserIdsAndCourseId(userIds, courseId.toString()));
|
|
|
+ this.initCourseScheduleStudentMusicScore(scheduleStudentMusicScores);
|
|
|
roomResult.setMembers(roomMemberList, midiMap, examSongMap, scheduleStudentMusicScores);
|
|
|
-
|
|
|
- // 全员静音状态开启
|
|
|
- /*if (muteAll && TencentCloudRTCPlugin.PLUGIN_NAME.equals(courseSchedule.getServiceProvider())) {
|
|
|
- for (RoomResult.MemberResult item : roomResult.getMembers()) {
|
|
|
- // 重置学生用户当前静音状态
|
|
|
- if (RoleStudent.getValue() == item.getRole()) {
|
|
|
- item.setMicrophone(false);
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
}
|
|
|
roomResult.setWhiteboards(whiteboardDao.findByRid(roomId));
|
|
|
if (room != null) {
|
|
@@ -668,6 +665,27 @@ public class RoomServiceImpl implements RoomService {
|
|
|
businessLogger.info("join room: roomId = {}, userId = {}, userName={}, role = {}", roomId, userId, userName, roleEnum);
|
|
|
}
|
|
|
|
|
|
+ private void initCourseScheduleStudentMusicScore(List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores) {
|
|
|
+ if(CollectionUtils.isEmpty(scheduleStudentMusicScores)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> musicSheetSoundIds = scheduleStudentMusicScores.stream().map(e->Long.parseLong(e.getMusicScoreAccompanimentId())).distinct().collect(Collectors.toList());
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetAccApplication> sheetApplications = this.getSheetApplications(musicSheetSoundIds);
|
|
|
+ Map<Long, CbsMusicSheetWrapper.MusicSheetAccApplication> sheetApplicationMap = sheetApplications.stream()
|
|
|
+ .collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetAccApplication::getMusicSheetSoundId, Function.identity()));
|
|
|
+ for (CourseScheduleStudentMusicScore studentMusicScore : scheduleStudentMusicScores) {
|
|
|
+ CbsMusicSheetWrapper.MusicSheetAccApplication sheetApplication =
|
|
|
+ sheetApplicationMap.get(Long.parseLong(studentMusicScore.getMusicScoreAccompanimentId()));
|
|
|
+ if(sheetApplication == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ studentMusicScore.setMusicScoreName(sheetApplication.getName());
|
|
|
+ studentMusicScore.setMp3Url(sheetApplication.getMp3Url());
|
|
|
+ studentMusicScore.setUrl(sheetApplication.getUrl());
|
|
|
+ courseScheduleStudentMusicScoreDao.update(studentMusicScore);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void joinImGroup(String roomId, Integer actualTeacherId, CourseSchedule courseSchedule) throws Exception {
|
|
|
|
|
|
String joinImGroupKey = "joinImGroup:" + roomId;
|
|
@@ -1722,7 +1740,7 @@ public class RoomServiceImpl implements RoomService {
|
|
|
.enable(enable)
|
|
|
.targetId(userId)
|
|
|
.targetName(Optional.ofNullable(data.getUserName()).orElse(authUser.getUsername()))
|
|
|
- .songId(Optional.ofNullable(data.getMusicScoreAccompanimentId()).map(String::valueOf).orElse(null))
|
|
|
+ .songId(data.getMusicScoreAccompanimentId())
|
|
|
.songVolume(data.getSoundVolume())
|
|
|
.sendUserInfo(RTCRoomMessage.MessageUser.builder()
|
|
|
.sendUserId(data.getSendUserId())
|
|
@@ -1731,18 +1749,6 @@ public class RoomServiceImpl implements RoomService {
|
|
|
.build())
|
|
|
.build();
|
|
|
|
|
|
- // 消息内容
|
|
|
- /*RTCRoomMessage.MessageContent messageContent = RTCRoomMessage.MessageContent
|
|
|
- .builder()
|
|
|
- .type(typeEnum.ordinal())
|
|
|
- .enable(enable)
|
|
|
- .sendUserInfo(RTCRoomMessage.MessageUser.builder()
|
|
|
- .sendUserId(userId)
|
|
|
- .sendUserName(authUser.getUsername())
|
|
|
- .avatarUrl(authUser.getAvatar())
|
|
|
- .build())
|
|
|
- .build();*/
|
|
|
-
|
|
|
// 腾讯云消息推送
|
|
|
RTCRoomMessage message = RTCRoomMessage.builder()
|
|
|
.objectName(RTCRoomMessage.CONTROL_DEVICE_NOTIFY_MESSAGE)
|
|
@@ -2231,6 +2237,7 @@ public class RoomServiceImpl implements RoomService {
|
|
|
Set<String> userIds = roomMemberList.stream().map(RoomMember::getUid).collect(Collectors.toSet());
|
|
|
Map<Integer, String> midiMap = MapUtil.convertMybatisMap(courseScheduleStudentPaymentDao.queryMidiByUserIdsAndCourseId(userIds, roomId.substring(1)));
|
|
|
Map<Integer, String> examSongMap = MapUtil.convertMybatisMap(courseScheduleStudentPaymentDao.queryExamSongByUserIdsAndCourseId(userIds, roomId.substring(1)));
|
|
|
+ this.initCourseScheduleStudentMusicScore(scheduleStudentMusicScores);
|
|
|
roomResult.setMembers(roomMemberList, midiMap, examSongMap, scheduleStudentMusicScores);
|
|
|
|
|
|
// 全员静音开启状态
|
|
@@ -2710,6 +2717,28 @@ public class RoomServiceImpl implements RoomService {
|
|
|
courseScheduleStudentPaymentDao.adjustPlayMidi(Long.parseLong(roomId.substring(1)), playMidiMessageData.getUserId(), content);
|
|
|
}
|
|
|
|
|
|
+ private CbsMusicSheetWrapper.MusicSheetAccApplication getSheetApplication(String musicSheetSoundId){
|
|
|
+ CbsMusicSheetWrapper.MusicSheetApplicationQuery query = sysMusicScoreService.getMusicSheetApplicationQuery();
|
|
|
+ query.setRows(1);
|
|
|
+ query.setMusicSheetSoundId(Long.parseLong(musicSheetSoundId));
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetAccApplication> applications = sysMusicScoreService.queryCbsMusicSheetSoundApplication(query).getRows();
|
|
|
+ if (CollectionUtils.isEmpty(applications)) {
|
|
|
+ throw new BizException("曲目信息不存在");
|
|
|
+ }
|
|
|
+ return applications.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<CbsMusicSheetWrapper.MusicSheetAccApplication> getSheetApplications(List<Long> musicSheetSoundIds){
|
|
|
+ CbsMusicSheetWrapper.MusicSheetApplicationQuery query = sysMusicScoreService.getMusicSheetApplicationQuery();
|
|
|
+ query.setRows(musicSheetSoundIds.size());
|
|
|
+ query.setMusicSheetSoundIds(musicSheetSoundIds);
|
|
|
+ List<CbsMusicSheetWrapper.MusicSheetAccApplication> applications = sysMusicScoreService.queryCbsMusicSheetSoundApplication(query).getRows();
|
|
|
+ if (CollectionUtils.isEmpty(applications)) {
|
|
|
+ throw new BizException("曲目信息不存在");
|
|
|
+ }
|
|
|
+ return applications;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void pushDownloadMusicScoreMsg(MusicScoreData musicScoreData) throws Exception {
|
|
@@ -2719,28 +2748,31 @@ public class RoomServiceImpl implements RoomService {
|
|
|
List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores =
|
|
|
courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(musicScoreData.getMusicScoreAccompanimentId(),
|
|
|
courseScheduleId, null, null, 0);
|
|
|
- SysMusicScoreAccompaniment accompaniment = sysMusicScoreAccompanimentDao.get(musicScoreData.getMusicScoreAccompanimentId());
|
|
|
+ //获取曲目信息
|
|
|
+ CbsMusicSheetWrapper.MusicSheetAccApplication sheetApplication = this.getSheetApplication(musicScoreData.getMusicScoreAccompanimentId());
|
|
|
if (scheduleStudentMusicScores.size() == 0) {
|
|
|
//第一次下载,生成数据
|
|
|
List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseSchedule(courseScheduleId);
|
|
|
Set<Integer> studentIds = courseScheduleStudentPayments.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
|
|
|
studentIds.forEach(e -> {
|
|
|
CourseScheduleStudentMusicScore musicScore = new CourseScheduleStudentMusicScore();
|
|
|
- musicScore.setMusicScoreAccompanimentId(accompaniment.getId());
|
|
|
- musicScore.setSpeed(accompaniment.getSpeed());
|
|
|
+ musicScore.setMusicScoreAccompanimentId(musicScoreData.getMusicScoreAccompanimentId());
|
|
|
+ musicScore.setSpeed(sheetApplication.getPlaySpeed());
|
|
|
musicScore.setCourseScheduleId(courseScheduleId);
|
|
|
musicScore.setUserId(e);
|
|
|
scheduleStudentMusicScores.add(musicScore);
|
|
|
});
|
|
|
CourseScheduleStudentMusicScore musicScore = new CourseScheduleStudentMusicScore();
|
|
|
- musicScore.setMusicScoreAccompanimentId(accompaniment.getId());
|
|
|
- musicScore.setSpeed(accompaniment.getSpeed());
|
|
|
+ musicScore.setMusicScoreAccompanimentId(musicScoreData.getMusicScoreAccompanimentId());
|
|
|
+ musicScore.setSpeed(sheetApplication.getPlaySpeed());
|
|
|
musicScore.setCourseScheduleId(courseScheduleId);
|
|
|
musicScore.setUserId(authUser.getId());
|
|
|
musicScore.setUserType(1);
|
|
|
scheduleStudentMusicScores.add(musicScore);
|
|
|
courseScheduleStudentMusicScoreDao.batchInsert(scheduleStudentMusicScores);
|
|
|
}
|
|
|
+ SysMusicScoreAccompaniment accompaniment = sysMusicScoreAccompanimentService.initSysMusicScoreAccompaniment(sheetApplication);
|
|
|
+ accompaniment.setId(musicScoreData.getMusicScoreAccompanimentId());
|
|
|
MusicScoreMessage musicScoreMessage = JSON.parseObject(JSON.toJSONString(accompaniment), MusicScoreMessage.class);
|
|
|
// 发送消息
|
|
|
String serviceProvider = getRoomServiceProvider(musicScoreData.getRoomId());
|
|
@@ -2819,17 +2851,20 @@ public class RoomServiceImpl implements RoomService {
|
|
|
Integer studentId = authUser.getId();
|
|
|
String roomId = musicScoreData.getRoomId();
|
|
|
Long scheduleId = Long.parseLong(roomId.substring(1));
|
|
|
- Integer accompanimentId = musicScoreData.getMusicScoreAccompanimentId();
|
|
|
+ String accompanimentId = musicScoreData.getMusicScoreAccompanimentId();
|
|
|
List<CourseScheduleStudentMusicScore> studentMusicScores = courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(accompanimentId, scheduleId, studentId, null, null);
|
|
|
if (accompanimentId != null) {
|
|
|
- SysMusicScoreAccompaniment accompaniment = sysMusicScoreAccompanimentDao.get(accompanimentId);
|
|
|
- if (accompaniment == null) {
|
|
|
- throw new BizException("曲目信息不存在");
|
|
|
- }
|
|
|
//修改下载状态
|
|
|
- if (studentMusicScores == null || studentMusicScores.size() == 0) {
|
|
|
+ if (CollectionUtils.isEmpty(studentMusicScores)) {
|
|
|
throw new BizException("学员不存在此下载曲目");
|
|
|
}
|
|
|
+ CbsMusicSheetWrapper.MusicSheetAccApplication sheetApplication = this.getSheetApplication(accompanimentId);
|
|
|
+ for (CourseScheduleStudentMusicScore studentMusicScore : studentMusicScores) {
|
|
|
+ studentMusicScore.setMusicScoreName(sheetApplication.getName());
|
|
|
+ studentMusicScore.setMp3Url(sheetApplication.getMp3Url());
|
|
|
+ studentMusicScore.setUrl(sheetApplication.getUrl());
|
|
|
+ courseScheduleStudentMusicScoreDao.update(studentMusicScore);
|
|
|
+ }
|
|
|
CourseScheduleStudentMusicScore studentMusicScore = studentMusicScores.get(0);
|
|
|
studentMusicScore.setDownStatus(musicScoreData.getStatus());
|
|
|
courseScheduleStudentMusicScoreDao.update(studentMusicScore);
|