|  | @@ -1126,7 +1126,90 @@ public class RoomServiceImpl implements RoomService {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -	private void updateDisplay(String roomId, String senderId, String display, Integer isIncludeSender) throws ApiException, Exception {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public boolean statusSync(String roomId,String userId) throws Exception {
 | 
	
		
			
				|  |  | +        List<RoomMember> byRidAndUid = roomMemberDao.findByRidAndUid(roomId, userId);
 | 
	
		
			
				|  |  | +        if(byRidAndUid.size() > 0){
 | 
	
		
			
				|  |  | +            SysUser sysUser = sysUserFeignService.queryUserById(Integer.parseInt(userId));
 | 
	
		
			
				|  |  | +            Teacher teacher = teacherDao.get(sysUser.getId());
 | 
	
		
			
				|  |  | +            if(teacher != null){
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    teacherAttendanceService.addTeacherAttendanceRecord(Integer.parseInt(roomId.substring(4)),sysUser.getId(), SignStatusEnum.SIGN_OUT,true);
 | 
	
		
			
				|  |  | +                }catch (Exception e){
 | 
	
		
			
				|  |  | +                    e.printStackTrace();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<Room> roomList = roomDao.findByRid(roomId);
 | 
	
		
			
				|  |  | +            if (roomList.size() == 0) {
 | 
	
		
			
				|  |  | +                log.error("room : {} not exist ", roomId);
 | 
	
		
			
				|  |  | +                throw new ApiException(ErrorEnum.ERR_ROOM_NOT_EXIST);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            List<RoomMember> roomMemberList = roomMemberDao.findByRidAndUid(roomId, userId);
 | 
	
		
			
				|  |  | +            if (roomMemberList.size() == 0) {
 | 
	
		
			
				|  |  | +                log.error("{} not exist in room: {}", userId, roomId);
 | 
	
		
			
				|  |  | +                throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            int userRole = roomMemberList.get(0).getRole();
 | 
	
		
			
				|  |  | +            log.info("leaveRoom: roomId={}, role={}", roomId, RoleEnum.getEnumByValue(userRole));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (userRole == RoleEnum.RoleTeacher.getValue() || userRole == RoleEnum.RoleAssistant.getValue()) {
 | 
	
		
			
				|  |  | +                if (isUserDisplay(roomList.get(0), userId)) {
 | 
	
		
			
				|  |  | +                    updateDisplay(roomId, userId, "", 0);
 | 
	
		
			
				|  |  | +                    log.info("clear display cause speaker leave: roomId={}", roomId);
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    log.info("don't update current display: room={}, role={}", roomList.get(0), RoleEnum.getEnumByValue(userRole));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                log.info("don't update current display: room={}, userRole={}", roomList.get(0), RoleEnum.getEnumByValue(userRole));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (roomMemberDao.countByRid(roomId) == 1) {
 | 
	
		
			
				|  |  | +                IMApiResultInfo apiResultInfo = null;
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    apiResultInfo = imHelper.dismiss(userId, roomId);
 | 
	
		
			
				|  |  | +                    if (apiResultInfo.getCode() == 200) {
 | 
	
		
			
				|  |  | +                        roomMemberDao.deleteUserByRidAndUid(roomId, userId);
 | 
	
		
			
				|  |  | +                        roomDao.deleteByRid(roomId);
 | 
	
		
			
				|  |  | +                        deleteWhiteboardByUser(roomId, userId);
 | 
	
		
			
				|  |  | +                        log.info("dismiss the room: {}", roomId);
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        log.error("{} exit {} room error: {}", userId, roomId, apiResultInfo.getErrorMessage());
 | 
	
		
			
				|  |  | +                        throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR, apiResultInfo.getErrorMessage());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } catch (Exception e) {
 | 
	
		
			
				|  |  | +                    log.error("{} exit {} room error: {}", userId, roomId, e.getMessage());
 | 
	
		
			
				|  |  | +                    throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR, e.getMessage());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                IMApiResultInfo apiResultInfo = null;
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    apiResultInfo = imHelper.quit(new String[]{userId}, roomId);
 | 
	
		
			
				|  |  | +                    if (apiResultInfo.isSuccess()) {
 | 
	
		
			
				|  |  | +                        roomMemberDao.deleteUserByRidAndUid(roomId, userId);
 | 
	
		
			
				|  |  | +                        MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Leave, userId, userRole);
 | 
	
		
			
				|  |  | +                        msg.setUserName(sysUser.getUsername());
 | 
	
		
			
				|  |  | +                        imHelper.publishMessage(userId, roomId, msg);
 | 
	
		
			
				|  |  | +                        imHelper.quit(new String[]{userId}, roomId);
 | 
	
		
			
				|  |  | +                        log.info("quit group: roomId={}", roomId);
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR, apiResultInfo.getErrorMessage());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } catch (Exception e) {
 | 
	
		
			
				|  |  | +                    log.error("leave room error: roomId={}, {}", roomId, e.getMessage());
 | 
	
		
			
				|  |  | +                    throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            userDao.deleteByUid(userId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return true;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void updateDisplay(String roomId, String senderId, String display, Integer isIncludeSender) throws ApiException, Exception {
 | 
	
		
			
				|  |  |          roomDao.updateDisplayByRid(roomId, display);
 | 
	
		
			
				|  |  |          DisplayMessage displayMessage = new DisplayMessage(display);
 | 
	
		
			
				|  |  |          imHelper.publishMessage(senderId, roomId, displayMessage, isIncludeSender);
 |