|
@@ -766,21 +766,37 @@ 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));
|
|
|
+ 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();
|
|
|
+ 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);
|