|
@@ -687,10 +687,8 @@ public class RoomServiceImpl implements RoomService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String createWhiteBoard(String roomId) throws Exception {
|
|
|
CheckUtils.checkArgument(roomId != null, "roomId must't be null");
|
|
|
-// CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
|
|
|
SysUser authUser = sysUserFeignService.queryUserInfo();
|
|
|
String userId = authUser.getId().toString();
|
|
|
-// CheckUtils.checkArgument(roomMemberDao.existsByRidAndUid(roomId, userId), "room member not exist");
|
|
|
|
|
|
log.info("createWhiteBoard: roomId = {}", roomId);
|
|
|
|
|
@@ -803,6 +801,111 @@ public class RoomServiceImpl implements RoomService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ public Boolean controlDevice1(ReqDeviceControlData data) throws Exception {
|
|
|
+ String roomId = data.getRoomId();
|
|
|
+ String userId = data.getUserId();
|
|
|
+ DeviceTypeEnum typeEnum;
|
|
|
+ boolean enable;
|
|
|
+ if (data.getCameraOn() != null) {
|
|
|
+ typeEnum = DeviceTypeEnum.Camera;
|
|
|
+ enable = data.getCameraOn();
|
|
|
+ } else if (data.getMicrophoneOn() != null) {
|
|
|
+ typeEnum = DeviceTypeEnum.Microphone;
|
|
|
+ enable = data.getMicrophoneOn();
|
|
|
+ } else if (data.getMusicModeOn() != null) {
|
|
|
+ typeEnum = DeviceTypeEnum.MusicMode;
|
|
|
+ enable = data.getMusicModeOn();
|
|
|
+ } else if (data.getHandUpOn() != null) {
|
|
|
+ typeEnum = DeviceTypeEnum.HandUp;
|
|
|
+ enable = data.getHandUpOn();
|
|
|
+ }else if (data.getExamSongOn() != null) {
|
|
|
+ typeEnum = DeviceTypeEnum.ExamSong;
|
|
|
+ enable = data.getExamSongOn();
|
|
|
+ }else if (data.getMusicScoreOn() != null) {
|
|
|
+ typeEnum = DeviceTypeEnum.MusicScore;
|
|
|
+ enable = data.getMusicScoreOn();
|
|
|
+ } 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);
|
|
|
+
|
|
|
+ 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));
|
|
|
+ DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(typeEnum.ordinal(), enable);
|
|
|
+ deviceResourceMessage.setUserId(userId);
|
|
|
+ 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 {
|