|
@@ -13,10 +13,7 @@ import com.ym.dao.WhiteboardDao;
|
|
|
import com.ym.job.ScheduleManager;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentDao;
|
|
|
-import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
-import com.ym.mec.biz.dal.dao.TeacherDao;
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
|
import com.ym.mec.biz.dal.entity.StudentAttendance;
|
|
|
import com.ym.mec.biz.dal.entity.Teacher;
|
|
@@ -30,6 +27,7 @@ import com.ym.mec.biz.service.TeacherAttendanceService;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.im.IMHelper;
|
|
|
import com.ym.mec.im.message.*;
|
|
|
+import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.pojo.*;
|
|
|
import com.ym.service.MessageService;
|
|
@@ -41,7 +39,6 @@ import com.ym.utils.IdentifierUtils;
|
|
|
import com.ym.whiteboard.WhiteBoardHelper;
|
|
|
import io.rong.models.message.GroupMessage;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang.StringEscapeUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -49,9 +46,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by super_zou on 2019/11/28.
|
|
@@ -72,6 +68,9 @@ public class RoomServiceImpl implements RoomService {
|
|
|
private RoomMemberDao roomMemberDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private WhiteBoardHelper whiteBoardHelper;
|
|
|
|
|
|
@Autowired
|
|
@@ -171,6 +170,8 @@ public class RoomServiceImpl implements RoomService {
|
|
|
roomResult.setSurplusTime(DateUtil.secondsBetween(new Date(),DateUtil.stringToDate(classDate + " " + endClassTime,DateUtil.EXPANDED_DATE_TIME_FORMAT)));
|
|
|
RoomResult.MemberResult userResult = new RoomResult.MemberResult();
|
|
|
List<RoomMember> memberList = roomMemberDao.findByRidAndUid(roomId, userId);
|
|
|
+ String midi = courseScheduleStudentPaymentDao.getMidiByCourseIdAndUserId(roomId.substring(1),userId);
|
|
|
+ userResult.setPlayMidiJson(JSONObject.parseObject(midi,CustomMessage.class));
|
|
|
if (memberList.isEmpty()) {
|
|
|
int count = roomMemberDao.countByRidAndExcludeRole(roomId, RoleEnum.RoleAudience.getValue());
|
|
|
if (!isAudience && count == roomProperties.getMaxCount()) {
|
|
@@ -197,8 +198,6 @@ public class RoomServiceImpl implements RoomService {
|
|
|
// roomMemberDao.updateCameraByRidAndUid(roomId, userId, !isDisableCamera);
|
|
|
userResult.setCamera(roomMember.isCamera());
|
|
|
userResult.setJoinTime(roomMember.getJoinDt());
|
|
|
- userResult.setPlayMidiJson(StringEscapeUtils.unescapeJavaScript(roomMember.getPlayMidiJson()));
|
|
|
-
|
|
|
log.info("user exist in the room: roomId={} , userId={}, use the last role={}", roomId, userId, roleEnum);
|
|
|
}
|
|
|
|
|
@@ -239,8 +238,11 @@ public class RoomServiceImpl implements RoomService {
|
|
|
roomResult.setRoomId(roomId);
|
|
|
|
|
|
List<RoomMember> roomMemberList = roomMemberDao.findByRid(roomId);
|
|
|
- roomResult.setMembers(roomMemberList);
|
|
|
-
|
|
|
+ if(roomMemberList != null && roomMemberList.size() > 0){
|
|
|
+ Set<String> userIds = roomMemberList.stream().map(e -> e.getUid()).collect(Collectors.toSet());
|
|
|
+ Map<Integer,String> midiMap = MapUtil.convertMybatisMap(courseScheduleStudentPaymentDao.queryMidiByUserIdsAndCourseId(userIds,roomId.substring(1)));
|
|
|
+ roomResult.setMembers(roomMemberList,midiMap);
|
|
|
+ }
|
|
|
List<Whiteboard> whiteboardList = whiteboardDao.findByRid(roomId);
|
|
|
roomResult.setWhiteboards(whiteboardList);
|
|
|
log.info("join success: roomId = {}, userId = {}, userName={}, role = {}", roomId, userId, userName, roleEnum);
|
|
@@ -897,11 +899,15 @@ public class RoomServiceImpl implements RoomService {
|
|
|
@Override
|
|
|
public List<RoomResult.MemberResult> getMembers(String roomId) throws ApiException, Exception {
|
|
|
CheckUtils.checkArgument(roomId != null, "roomId must't be null");
|
|
|
-
|
|
|
List<RoomMember> roomMemberList = roomMemberDao.findByRid(roomId);
|
|
|
- RoomResult roomResult = new RoomResult();
|
|
|
- roomResult.setMembers(roomMemberList);
|
|
|
- return roomResult.getMembers();
|
|
|
+ if(roomMemberList != null && roomMemberList.size() > 0){
|
|
|
+ RoomResult roomResult = new RoomResult();
|
|
|
+ Set<String> userIds = roomMemberList.stream().map(e -> e.getUid()).collect(Collectors.toSet());
|
|
|
+ Map<Integer,String> midiMap = MapUtil.convertMybatisMap(courseScheduleStudentPaymentDao.queryMidiByUserIdsAndCourseId(userIds,roomId.substring(1)));
|
|
|
+ roomResult.setMembers(roomMemberList,midiMap);
|
|
|
+ return roomResult.getMembers();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1390,19 +1396,29 @@ public class RoomServiceImpl implements RoomService {
|
|
|
}
|
|
|
// roomService.sendImPlayMidiMessage(playMidiMessageData);
|
|
|
GroupMessage groupMessage = new GroupMessage();
|
|
|
- CustomMessage customMessage = JSONObject.parseObject(playMidiMessageData.getContent(),CustomMessage.class);
|
|
|
+ String content = playMidiMessageData.getContent();
|
|
|
+ String roomId = playMidiMessageData.getRoomId();
|
|
|
+ CustomMessage customMessage = JSONObject.parseObject(content,CustomMessage.class);
|
|
|
groupMessage.setContent(customMessage);
|
|
|
- groupMessage.setTargetId(playMidiMessageData.getRoomId().split(","));
|
|
|
+ groupMessage.setTargetId(roomId.split(","));
|
|
|
groupMessage.setSenderId(sysUser.getId().toString());
|
|
|
groupMessage.setObjectName("DY:PlayMidiMessage");
|
|
|
messageService.groupSend(groupMessage);
|
|
|
//记录节拍器消息
|
|
|
String userId = playMidiMessageData.getUserId();
|
|
|
- if(StringUtils.isEmpty(userId)){
|
|
|
- roomMemberDao.updatePlayMidiJsonByRidAndRole(playMidiMessageData.getRoomId(),RoleEnum.RoleStudent.getValue(), playMidiMessageData.getContent());
|
|
|
+// long courseId = Long.parseLong(roomId.substring(1));
|
|
|
+ courseScheduleStudentPaymentDao.adjustPlayMidi(Long.parseLong(roomId.substring(1)),userId,content);
|
|
|
+ /*if(StringUtils.isEmpty(userId)){
|
|
|
+ //批量操作节拍器状态
|
|
|
+ courseScheduleStudentPaymentDao.openPlayMidi(courseId,userId,content);
|
|
|
+ roomMemberDao.updatePlayMidiJsonByRidAndRole(roomId,RoleEnum.RoleStudent.getValue(), content);
|
|
|
}else {
|
|
|
- roomMemberDao.updatePlayMidiJsonByRidAndUid(playMidiMessageData.getRoomId(),userId,playMidiMessageData.getContent());
|
|
|
- }
|
|
|
+ //关闭某个学员
|
|
|
+ if(!customMessage.getEnable()){
|
|
|
+ roomMemberDao.updatePlayMidiJsonByRidAndRole(playMidiMessageData.getRoomId(),RoleEnum.RoleTeacher.getValue(), null);
|
|
|
+ }
|
|
|
+ roomMemberDao.updatePlayMidiJsonByRidAndUid(playMidiMessageData.getRoomId(),userId,content);
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
/*@Override
|