zouxuan 4 years ago
parent
commit
0f1914bd83
1 changed files with 28 additions and 15 deletions
  1. 28 15
      mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

+ 28 - 15
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -765,21 +765,34 @@ public class RoomServiceImpl implements RoomService {
         log.info("controlDevice: userId={}, typeEnum={}, onOff={}", userId, typeEnum, enable);
 
         if (enable) {
-            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);
+            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 {
+                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);