浏览代码

网络教室伴奏

zouxuan 4 年之前
父节点
当前提交
1c58a2398d

+ 24 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentMusicScoreDao.java

@@ -10,8 +10,6 @@ public interface CourseScheduleStudentMusicScoreDao extends BaseDAO<Integer, Cou
 
     int updateByMusicScore(CourseScheduleStudentMusicScore courseScheduleStudentMusicScore);
 
-    List<CourseScheduleStudentMusicScore> findByCourseId(Long courseId);
-
     List<CourseScheduleStudentMusicScore> queryByScoreIdAndCourseId(@Param("musicScoreAccompanimentId") Integer musicScoreAccompanimentId,
                                                                     @Param("courseId") Long courseId,
                                                                     @Param("userId") Integer userId,
@@ -20,4 +18,28 @@ public interface CourseScheduleStudentMusicScoreDao extends BaseDAO<Integer, Cou
 
     int batchInsert(@Param("scheduleStudentMusicScores") List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores);
 
+    /**
+     * 关闭所有伴奏的播放
+     * @param scheduleId
+     * @param userId
+     */
+    void closePlayStatus(@Param("scheduleId") long scheduleId, @Param("userId") int userId, @Param("musicScoreAccompanimentId") Integer musicScoreAccompanimentId);
+
+    /**
+     * 开启原音播放
+     * @param scheduleId
+     * @param userId
+     * @param musicScoreAccompanimentId
+     * @return
+     */
+    int openPlayStatus(@Param("scheduleId") long scheduleId, @Param("userId") int userId, @Param("musicScoreAccompanimentId") Integer musicScoreAccompanimentId);
+
+    /**
+     * 开启伴奏播放
+     * @param scheduleId
+     * @param userId
+     * @param musicScoreAccompanimentId
+     * @return
+     */
+    int openAccompanimentPlayStatus(@Param("scheduleId") long scheduleId, @Param("userId") int userId, @Param("musicScoreAccompanimentId") Integer musicScoreAccompanimentId);
 }

+ 15 - 0
mec-biz/src/main/resources/config/mybatis/courseScheduleStudentMusicScoreMapper.xml

@@ -72,6 +72,21 @@
             AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
         </if>
     </update>
+    <update id="closePlayStatus">
+        UPDATE course_schedule_student_music_score SET play_status_ = 0,accompaniment_play_status_ = 0,update_time_ = NOW()
+        WHERE course_schedule_id_ = #{scheduleId} AND user_id_ = #{userId}
+        <if test="musicScoreAccompanimentId">
+            AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
+        </if>
+    </update>
+    <update id="openPlayStatus">
+        UPDATE course_schedule_student_music_score SET play_status_ = 1,update_time_ = NOW()
+        WHERE course_schedule_id_ = #{scheduleId} AND user_id_ = #{userId} AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
+    </update>
+    <update id="openAccompanimentPlayStatus">
+        UPDATE course_schedule_student_music_score SET accompaniment_play_status_ = 1,update_time_ = NOW()
+        WHERE course_schedule_id_ = #{scheduleId} AND user_id_ = #{userId} AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
+    </update>
 
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">

+ 12 - 40
mec-im/src/main/java/com/ym/controller/RoomController.java

@@ -163,66 +163,38 @@ public class RoomController{
         return new BaseResponse<>(result);
     }
 
+    @ApiOperation(value = "学员麦克风、摄像头等开关控制")
     @RequestMapping(value = "/device/control", method = RequestMethod.POST)
     public Object controlDevice(@RequestBody ReqDeviceControlData data)
             throws Exception {
-        boolean result;
-        if (data.getCameraOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.Camera, data.getCameraOn());
-        } else if (data.getMicrophoneOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.Microphone, data.getMicrophoneOn());
-        } else if (data.getMusicModeOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.MusicMode, data.getMusicModeOn());
-        } else if (data.getHandUpOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.HandUp, data.getHandUpOn());
-        }else if (data.getExamSongOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.ExamSong, data.getExamSongOn());
-        }else if (data.getExamSongOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.MusicScore, data.getMusicScoreOn());
-        } else {
-            throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
-        }
-        return new BaseResponse<>(result);
+        return new BaseResponse<>(roomService.controlDevice(data));
     }
 
+    @ApiOperation(value = "学员麦克风、摄像头等开关批量控制")
+    @RequestMapping(value = "/device/batchControl", method = RequestMethod.POST)
+    public Object batchControlDevice(@RequestBody ReqDeviceControlData data)throws Exception {
+        log.info("batchControl: {}",JSONObject.toJSON(data));
+        return new BaseResponse<>(roomService.batchControlDevice(data));
+    }
+
+    @ApiOperation(value = "学员伴奏下载状态回调")
     @RequestMapping(value = "adjustExamSong", method = RequestMethod.POST)
     public Object adjustExamSong(@RequestBody ExamSongData examSongData) throws Exception {
         roomService.adjustExamSong(examSongData.getRoomId(),examSongData.getStatus(),examSongData.getExamSongId());
         return new BaseResponse<>();
     }
 
-    @ApiOperation(value = "学员下载状态回调")
+    @ApiOperation(value = "学员伴奏下载状态回调")
     @RequestMapping(value = "adjustMusicScore", method = RequestMethod.POST)
     public Object adjustMusicScore(@RequestBody MusicScoreData musicScoreData) throws Exception {
         roomService.adjustMusicScore(musicScoreData);
         return new BaseResponse<>();
     }
 
-    @RequestMapping(value = "/device/batchControl", method = RequestMethod.POST)
-    public Object batchControlDevice(@RequestBody ReqDeviceControlData data)throws Exception {
-        log.info("batchControl: {}",JSONObject.toJSON(data));
-        boolean result = roomService.batchControlDevice(data);
-        return new BaseResponse<>(result);
-    }
-
     @RequestMapping(value = "/device/sync", method = RequestMethod.POST)
     public Object syncDeviceState(@RequestBody ReqDeviceControlData data)
             throws Exception {
-        boolean result;
-        if (data.getCameraOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.Camera, data.getCameraOn());
-        } else if (data.getMicrophoneOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.Microphone, data.getMicrophoneOn());
-        } else if (data.getMusicModeOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.MusicMode, data.getMusicModeOn());
-        }  else if (data.getHandUpOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.HandUp, data.getHandUpOn());
-        }  else if (data.getExamSongOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.ExamSong, data.getExamSongOn());
-        } else {
-            throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
-        }
-        return new BaseResponse<>(result);
+        return new BaseResponse<>(roomService.syncDeviceState(data));
     }
 
     @RequestMapping(value = "/whiteboard/turn-page", method = RequestMethod.POST)

+ 1 - 0
mec-im/src/main/java/com/ym/pojo/DeviceTypeEnum.java

@@ -7,4 +7,5 @@ public enum DeviceTypeEnum {
     HandUp,
     ExamSong,
     MusicScore,
+    MusicScoreAccompaniment,
 }

+ 4 - 0
mec-im/src/main/java/com/ym/pojo/ReqDeviceControlData.java

@@ -9,7 +9,11 @@ public class ReqDeviceControlData {
 	private Boolean musicModeOn;
 	private Boolean handUpOn;
 	private Boolean examSongOn;
+	//原音播放状态
 	private Boolean musicScoreOn;
+	//伴奏播放状态
+	private Boolean accompanimentOn;
+
 	private String roomId;
 	private String userId;
 	private String ticket;

+ 89 - 119
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -801,7 +801,9 @@ public class RoomServiceImpl implements RoomService {
         return true;
     }
 
-    public Boolean controlDevice1(ReqDeviceControlData data) throws Exception {
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean controlDevice(ReqDeviceControlData data) throws Exception {
         String roomId = data.getRoomId();
         String userId = data.getUserId();
         DeviceTypeEnum typeEnum;
@@ -824,12 +826,12 @@ public class RoomServiceImpl implements RoomService {
         }else if (data.getMusicScoreOn() != null) {
             typeEnum = DeviceTypeEnum.MusicScore;
             enable = data.getMusicScoreOn();
+        }else if (data.getAccompanimentOn() != null) {
+            typeEnum = DeviceTypeEnum.MusicScoreAccompaniment;
+            enable = data.getAccompanimentOn();
         } else {
             throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
         }
-        CheckUtils.checkArgument(roomId != null, "roomId must't be null");
-        CheckUtils.checkArgument(userId != null, "userId must't be null");
-        CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
         SysUser authUser = sysUserFeignService.queryUserInfo();
         log.info("controlDevice: userId={}, typeEnum={}, onOff={}", userId, typeEnum, enable);
 
@@ -850,89 +852,21 @@ public class RoomServiceImpl implements RoomService {
                 imHelper.publishMessage(authUser.getId().toString(), roomId, deviceResourceMessage, 1);
             }else if(typeEnum.equals(DeviceTypeEnum.MusicScore)){
                 long scheduleId = Long.parseLong(roomId.substring(1));
-                List<CourseScheduleStudentMusicScore> studentMusicScores = courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(data.getMusicScoreAccompanimentId(), scheduleId,Integer.parseInt(userId),null,null);
-                if(studentMusicScores == null || studentMusicScores.size() == 0){
-                    throw new BizException("学员不存在此下载曲目");
-                }
-                CourseScheduleStudentMusicScore studentMusicScore = studentMusicScores.get(0);
-                studentMusicScore.setPlayStatus(1);
-                courseScheduleStudentMusicScoreDao.update(studentMusicScore);
-            }else {
-                String ticket = IdentifierUtils.uuid();
-                ControlDeviceTaskInfo taskInfo = new ControlDeviceTaskInfo();
-                taskInfo.setRoomId(roomId);
-                taskInfo.setTypeEnum(typeEnum);
-                taskInfo.setOnOff(true);
-                taskInfo.setApplyUserId(authUser.getId().toString());
-                taskInfo.setTargetUserId(userId);
-                taskInfo.setTicket(ticket);
-                scheduleManager.addTask(taskInfo);
-                ControlDeviceNotifyMessage msg = new ControlDeviceNotifyMessage(ActionEnum.Invite.ordinal());
-                msg.setTicket(ticket);
-                msg.setType(taskInfo.getTypeEnum().ordinal());
-                msg.setOpUserId(authUser.getId().toString());
-                msg.setOpUserName(authUser.getUsername());
-                imHelper.publishMessage(authUser.getId().toString(), userId, roomId, msg);
-            }
-        } else {
-            if (typeEnum.equals(DeviceTypeEnum.Camera)) {
-                roomMemberDao.updateCameraByRidAndUid(roomId, userId, false);
-            } else if (typeEnum.equals(DeviceTypeEnum.Microphone)){
-                roomMemberDao.updateMicByRidAndUid(roomId, userId, false);
-            } else if (typeEnum.equals(DeviceTypeEnum.HandUp)){
-                roomMemberDao.updateHandByRidAndUid(roomId, userId, false);
-            } else if (typeEnum.equals(DeviceTypeEnum.ExamSong)){
-                long scheduleId = Long.parseLong(roomId.substring(1));
-                ExamSongDownloadData msg;
-                String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(scheduleId, Integer.parseInt(userId));
-                if(StringUtils.isEmpty(examJson)){
-                    throw new BizException("学员伴奏信息异常");
-                }else {
-                    msg = JSON.parseObject(examJson, ExamSongDownloadData.class);
-                    msg.setEnable(enable);
-                }
-                courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,Integer.parseInt(userId),JSON.toJSONString(msg));
-            }else {
-                roomMemberDao.updateMusicByRidAndUid(roomId, userId, false);
-            }
-            DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(typeEnum.ordinal(), false);
-            deviceResourceMessage.setUserId(userId);
-            UserInfo userInfo = userDao.findByUid(userId);
-            if (userInfo != null) {
-                deviceResourceMessage.setUserName(userInfo.getName());
-            }
-            imHelper.publishMessage(authUser.getId().toString(), roomId, deviceResourceMessage, 1);
-        }
-        return true;
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Boolean controlDevice(String roomId, String userId, DeviceTypeEnum typeEnum, boolean enable) throws Exception {
-        CheckUtils.checkArgument(roomId != null, "roomId must't be null");
-        CheckUtils.checkArgument(userId != null, "userId must't be null");
-        CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
-        SysUser authUser = sysUserFeignService.queryUserInfo();
-        log.info("controlDevice: userId={}, typeEnum={}, onOff={}", userId, typeEnum, enable);
-
-        if (enable) {
-            if (typeEnum.equals(DeviceTypeEnum.ExamSong)){
-                long scheduleId = Long.parseLong(roomId.substring(1));
-                ExamSongDownloadData msg;
-                String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(scheduleId, Integer.parseInt(userId));
-                if(StringUtils.isEmpty(examJson)){
-                    throw new BizException("学员伴奏信息异常");
-                }else {
-                    msg = JSON.parseObject(examJson, ExamSongDownloadData.class);
-                    msg.setEnable(enable);
-                }
-                courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,Integer.parseInt(userId),JSON.toJSONString(msg));
+                //关闭所有曲目播放
+                courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,Integer.parseInt(userId),null);
+                //原音
+                courseScheduleStudentMusicScoreDao.openPlayStatus(scheduleId,authUser.getId(),data.getMusicScoreAccompanimentId());
                 DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(typeEnum.ordinal(), enable);
                 deviceResourceMessage.setUserId(userId);
                 imHelper.publishMessage(authUser.getId().toString(), roomId, deviceResourceMessage, 1);
-            }else if(typeEnum.equals(DeviceTypeEnum.MusicScore)){
+            }else if(typeEnum.equals(DeviceTypeEnum.MusicScoreAccompaniment)){
                 long scheduleId = Long.parseLong(roomId.substring(1));
-
+                //关闭所有曲目播放
+                courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,Integer.parseInt(userId),null);
+                courseScheduleStudentMusicScoreDao.openAccompanimentPlayStatus(scheduleId,authUser.getId(),data.getMusicScoreAccompanimentId());
+                DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(typeEnum.ordinal(), enable);
+                deviceResourceMessage.setUserId(userId);
+                imHelper.publishMessage(authUser.getId().toString(), roomId, deviceResourceMessage, 1);
             }else {
                 String ticket = IdentifierUtils.uuid();
                 ControlDeviceTaskInfo taskInfo = new ControlDeviceTaskInfo();
@@ -968,6 +902,14 @@ public class RoomServiceImpl implements RoomService {
                     msg.setEnable(enable);
                 }
                 courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,Integer.parseInt(userId),JSON.toJSONString(msg));
+            }else if(typeEnum.equals(DeviceTypeEnum.MusicScore)){
+                long scheduleId = Long.parseLong(roomId.substring(1));
+                //关闭所有曲目播放
+                courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,Integer.parseInt(userId),null);
+            }else if(typeEnum.equals(DeviceTypeEnum.MusicScoreAccompaniment)){
+                long scheduleId = Long.parseLong(roomId.substring(1));
+                //关闭所有曲目播放
+                courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,Integer.parseInt(userId),null);
             }else {
                 roomMemberDao.updateMusicByRidAndUid(roomId, userId, false);
             }
@@ -998,34 +940,26 @@ public class RoomServiceImpl implements RoomService {
         if(roomMembers.size() == 0){
             return false;
         }
-        boolean result = true;
-        if (data.getCameraOn() != null) {
-            for (RoomMember e:roomMembers) {
-                controlDevice(data.getRoomId(), e.getUid(), DeviceTypeEnum.Camera, data.getCameraOn());
-            }
-        } else if (data.getMicrophoneOn() != null) {
-            for (RoomMember e:roomMembers) {
-                controlDevice(data.getRoomId(), e.getUid(), DeviceTypeEnum.Microphone, data.getMicrophoneOn());
-            }
-        } else if (data.getMusicModeOn() != null) {
-            for (RoomMember e:roomMembers) {
-                controlDevice(data.getRoomId(), e.getUid(), DeviceTypeEnum.MusicMode, data.getMusicModeOn());
-            }
-        } else if (data.getExamSongOn() != null) {
+        if (data.getExamSongOn() != null) {
             if(StringUtils.isNotEmpty(data.getUserId())){
                 for (RoomMember e:roomMembers) {
-                    controlDevice(data.getRoomId(), e.getUid(), DeviceTypeEnum.ExamSong, data.getExamSongOn());
+                    data.setUserId(e.getUid());
+                    controlDevice(data);
                 }
             }else {
                 List<BasicUserDto> students = courseScheduleStudentPaymentDao.findStudents(Long.parseLong(data.getRoomId().substring(1)));
                 for (BasicUserDto e:students) {
-                    controlDevice(data.getRoomId(), e.getUserId().toString(), DeviceTypeEnum.ExamSong, data.getExamSongOn());
+                    data.setUserId(e.getUserId().toString());
+                    controlDevice(data);
                 }
             }
         } else {
-            throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
+            for (RoomMember e:roomMembers) {
+                data.setUserId(e.getUid());
+                controlDevice(data);
+            }
         }
-        return result;
+        return true;
     }
 
     @Override
@@ -1053,14 +987,12 @@ public class RoomServiceImpl implements RoomService {
             courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
         }else if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.MusicScore)) {
             long scheduleId = Long.parseLong(roomId.substring(1));
-            //学员伴奏播放状态修改为播放
-            List<CourseScheduleStudentMusicScore> studentMusicScores = courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(data.getMusicScoreAccompanimentId(), scheduleId, authUser.getId(), null, null);
-            if(studentMusicScores == null || studentMusicScores.size() == 0){
-                throw new BizException("学员伴奏信息异常");
-            }
-            CourseScheduleStudentMusicScore studentMusicScore = studentMusicScores.get(0);
-            studentMusicScore.setPlayStatus(1);
-            courseScheduleStudentMusicScoreDao.update(studentMusicScore);
+            courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,authUser.getId(),null);
+            courseScheduleStudentMusicScoreDao.openPlayStatus(scheduleId,authUser.getId(), data.getMusicScoreAccompanimentId());
+        }else if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.MusicScoreAccompaniment)) {
+            long scheduleId = Long.parseLong(roomId.substring(1));
+            courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,authUser.getId(),null);
+            courseScheduleStudentMusicScoreDao.openAccompanimentPlayStatus(scheduleId,authUser.getId(), data.getMusicScoreAccompanimentId());
         } else {
             roomMemberDao.updateMicByRidAndUid(roomId, userId, taskInfo.isOnOff());
         }
@@ -1095,20 +1027,46 @@ public class RoomServiceImpl implements RoomService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean syncDeviceState(String roomId, DeviceTypeEnum type, boolean enable) throws Exception {
-        CheckUtils.checkArgument(roomId != null, "roomId must't be null");
-        CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
+    public Boolean syncDeviceState(ReqDeviceControlData data) throws Exception {
+        String roomId = data.getRoomId();
+        DeviceTypeEnum type;
+        boolean enable;
+        if (data.getCameraOn() != null) {
+            type = DeviceTypeEnum.Camera;
+            enable = data.getCameraOn();
+        } else if (data.getMicrophoneOn() != null) {
+            type = DeviceTypeEnum.Camera;
+            enable = data.getCameraOn();
+        } else if (data.getMusicModeOn() != null) {
+            type = DeviceTypeEnum.MusicMode;
+            enable = data.getMusicModeOn();
+        }  else if (data.getHandUpOn() != null) {
+            type = DeviceTypeEnum.HandUp;
+            enable = data.getHandUpOn();
+        }  else if (data.getExamSongOn() != null) {
+            type = DeviceTypeEnum.ExamSong;
+            enable = data.getExamSongOn();
+            //原音
+        }  else if (data.getMusicScoreOn() != null) {
+            type = DeviceTypeEnum.MusicScore;
+            enable = data.getMusicScoreOn();
+            //伴奏
+        }  else if (data.getAccompanimentOn() != null) {
+            type = DeviceTypeEnum.MusicScoreAccompaniment;
+            enable = data.getAccompanimentOn();
+        } else {
+            throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
+        }
         SysUser authUser = sysUserFeignService.queryUserInfo();
         String userId = authUser.getId().toString();
 
-        int result;
         DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(type.ordinal(), enable);
         if (type.equals(DeviceTypeEnum.Camera)) {
-            result = roomMemberDao.updateCameraByRidAndUid(roomId, userId, enable);
+            roomMemberDao.updateCameraByRidAndUid(roomId, userId, enable);
         } else if (type.equals(DeviceTypeEnum.Microphone)){
-            result = roomMemberDao.updateMicByRidAndUid(roomId, userId, enable);
+            roomMemberDao.updateMicByRidAndUid(roomId, userId, enable);
         } else if (type.equals(DeviceTypeEnum.HandUp)){
-            result = roomMemberDao.updateHandByRidAndUid(roomId, userId, enable);
+            roomMemberDao.updateHandByRidAndUid(roomId, userId, enable);
         } else if (type.equals(DeviceTypeEnum.ExamSong)){
             long scheduleId = Long.parseLong(roomId.substring(1));
             ExamSongDownloadData msg;
@@ -1119,13 +1077,25 @@ public class RoomServiceImpl implements RoomService {
                 msg = JSON.parseObject(examJson, ExamSongDownloadData.class);
                 msg.setEnable(enable);
             }
-            result = courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
+            courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
+        } else if (type.equals(DeviceTypeEnum.MusicScore)){
+            long scheduleId = Long.parseLong(roomId.substring(1));
+            courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,authUser.getId(),null);
+            if(enable){
+                courseScheduleStudentMusicScoreDao.openPlayStatus(scheduleId,authUser.getId(),data.getMusicScoreAccompanimentId());
+            }
+        } else if (type.equals(DeviceTypeEnum.MusicScoreAccompaniment)){
+            long scheduleId = Long.parseLong(roomId.substring(1));
+            courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,authUser.getId(),null);
+            if(enable){
+                courseScheduleStudentMusicScoreDao.openAccompanimentPlayStatus(scheduleId,authUser.getId(),data.getMusicScoreAccompanimentId());
+            }
         }else {
-            result = roomMemberDao.updateMusicByRidAndUid(roomId, userId, enable);
+            roomMemberDao.updateMusicByRidAndUid(roomId, userId, enable);
         }
         deviceResourceMessage.setUserId(userId);
         imHelper.publishMessage(userId, roomId, deviceResourceMessage, 1);
-        log.info("syncDeviceState : {}, {}, result = {}", roomId, enable, result);
+        log.info("syncDeviceState : {}, {}, result = {}", roomId, enable);
         return true;
     }
 

+ 2 - 2
mec-im/src/main/java/com/ym/service/RoomService.java

@@ -35,7 +35,7 @@ public interface RoomService {
 
     Boolean turnWhiteBoardPage(String roomId, String whiteBoardId, int page) throws Exception;
 
-    Boolean controlDevice(String roomId, String userId, DeviceTypeEnum type, boolean enable) throws Exception;
+    Boolean controlDevice(ReqDeviceControlData data) throws Exception;
 
     Boolean batchControlDevice(ReqDeviceControlData data) throws Exception;
 
@@ -58,7 +58,7 @@ public interface RoomService {
     Boolean approveUpgradeRole(String roomId, String ticket) throws Exception;
     Boolean rejectUpgradeRole(String roomId, String ticket) throws Exception;
 
-    Boolean syncDeviceState(String roomId, DeviceTypeEnum type, boolean enable) throws Exception;
+    Boolean syncDeviceState(ReqDeviceControlData data) throws Exception;
 
     Boolean changeRole(String roomId, String userId, int role) throws Exception;