|
@@ -2,7 +2,6 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -32,6 +31,7 @@ import com.ym.mec.common.page.PageUtil;
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
import com.ym.mec.im.ImFeignService;
|
|
import com.ym.mec.im.ImFeignService;
|
|
|
|
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
import com.ym.mec.util.excel.POIUtil;
|
|
import com.ym.mec.util.excel.POIUtil;
|
|
@@ -291,6 +291,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
obj.setCreatedBy(getSysUser().getId());
|
|
obj.setCreatedBy(getSysUser().getId());
|
|
obj.setCreatedTime(now);
|
|
obj.setCreatedTime(now);
|
|
this.save(obj);
|
|
this.save(obj);
|
|
|
|
+ //推送老师端-直播已经创建
|
|
|
|
+ sendRoomLiveState(sysUser, obj, MessageTypeEnum.JIGUANG_LIVE_CREATED);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -504,11 +506,28 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
* 关闭房间-融云
|
|
* 关闭房间-融云
|
|
* 获取所有直播间缓存数据并写入数据库后并清理缓存
|
|
* 获取所有直播间缓存数据并写入数据库后并清理缓存
|
|
*
|
|
*
|
|
|
|
+ * @param roomUid 直播间Uid
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void roomDestroy(String roomUid) {
|
|
|
|
+ ImLiveBroadcastRoom room = this.getOne(Wrappers.<ImLiveBroadcastRoom>lambdaQuery()
|
|
|
|
+ .eq(ImLiveBroadcastRoom::getRoomUid, roomUid));
|
|
|
|
+ opsRoomDestroy(room);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 关闭房间-融云
|
|
|
|
+ * 获取所有直播间缓存数据并写入数据库后并清理缓存
|
|
|
|
+ *
|
|
* @param id 直播房间表id
|
|
* @param id 直播房间表id
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void roomDestroy(Integer id) {
|
|
public void roomDestroy(Integer id) {
|
|
ImLiveBroadcastRoom room = this.getById(id);
|
|
ImLiveBroadcastRoom room = this.getById(id);
|
|
|
|
+ opsRoomDestroy(room);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void opsRoomDestroy(ImLiveBroadcastRoom room) {
|
|
if (Objects.isNull(room)) {
|
|
if (Objects.isNull(room)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1073,6 +1092,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
imFeignService.createLiveRoom(room.getRoomUid(), room.getRoomTitle());
|
|
imFeignService.createLiveRoom(room.getRoomUid(), room.getRoomTitle());
|
|
//推送预约直播间消息
|
|
//推送预约直播间消息
|
|
imLiveRoomReservationService.push(room);
|
|
imLiveRoomReservationService.push(room);
|
|
|
|
+ //推送直播开始消息
|
|
|
|
+ sendRoomLiveState(sysUser, room, MessageTypeEnum.JIGUANG_LIVE_STARTED);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(">>>>>>>>>> createLiveRoom error roomUid:{} msg:{}", room.getRoomUid(), e.getMessage());
|
|
log.error(">>>>>>>>>> createLiveRoom error roomUid:{} msg:{}", room.getRoomUid(), e.getMessage());
|
|
}
|
|
}
|
|
@@ -1089,9 +1110,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
speakerInfo.setTenantId(sysUser.getTenantId());
|
|
speakerInfo.setTenantId(sysUser.getTenantId());
|
|
speakerInfo.setTotalLiveTime(0);
|
|
speakerInfo.setTotalLiveTime(0);
|
|
|
|
|
|
- //查询房间信息是否允许录像
|
|
|
|
- ImLiveBroadcastRoom one = this.getOne(new QueryWrapper<ImLiveBroadcastRoom>().eq("room_uid_", room.getRoomUid()));
|
|
|
|
- boolean video = getRoomConfig(one.getRoomConfig())
|
|
|
|
|
|
+ //获取是否允许录像
|
|
|
|
+ boolean video = getRoomConfig(room.getRoomConfig())
|
|
.filter(c -> Objects.nonNull(c.getWhether_video()))
|
|
.filter(c -> Objects.nonNull(c.getWhether_video()))
|
|
.map(c -> c.getWhether_video() == 0)
|
|
.map(c -> c.getWhether_video() == 0)
|
|
.orElse(false);
|
|
.orElse(false);
|
|
@@ -1102,6 +1122,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
//不可以录制视频
|
|
//不可以录制视频
|
|
speakerInfo.setWhetherVideo(1);
|
|
speakerInfo.setWhetherVideo(1);
|
|
}
|
|
}
|
|
|
|
+ speakerInfo.setOs(room.getOs());
|
|
//写入主讲人信息
|
|
//写入主讲人信息
|
|
getRoomSpeakerInfoCache(room.getRoomUid(), room.getSpeakerId().toString()).set(speakerInfo);
|
|
getRoomSpeakerInfoCache(room.getRoomUid(), room.getSpeakerId().toString()).set(speakerInfo);
|
|
|
|
|
|
@@ -1120,6 +1141,49 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
.map(c -> JSON.parseObject(c, ImLiveBroadcastRoomDto.RoomConfig.class));
|
|
.map(c -> JSON.parseObject(c, ImLiveBroadcastRoomDto.RoomConfig.class));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 推送老师端-直播已经创建/开始的消息
|
|
|
|
+ *
|
|
|
|
+ * @param user 用户信息
|
|
|
|
+ * @param room 房间信息
|
|
|
|
+ * @param en 直播列表地址
|
|
|
|
+ * <P> /#/liveRoomList?t=0 未开始
|
|
|
|
+ * <P>/#/liveRoomList 直播中
|
|
|
|
+ */
|
|
|
|
+ private void sendRoomLiveState(SysUser user, ImLiveBroadcastRoom room, MessageTypeEnum en) {
|
|
|
|
+ String teacherBaseUrl = sysConfigDao.findConfigValue(SysConfigService.TEACHER_BASE_URL);
|
|
|
|
+ if (StringUtils.isBlank(teacherBaseUrl)) {
|
|
|
|
+ log.error("sendRoomState error: teacherBaseUrl is null");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Map<Integer, String> pushMap = new HashMap<>();
|
|
|
|
+ pushMap.put(user.getId(), user.getId().toString());
|
|
|
|
+ String memo;
|
|
|
|
+ Object[] objs;
|
|
|
|
+ try {
|
|
|
|
+ String liveDateStr = DateUtil.format(room.getLiveStartTime(), "yyyy年MM月dd日 HH点mm分");
|
|
|
|
+ //创建直播间
|
|
|
|
+ if (en.equals(MessageTypeEnum.JIGUANG_LIVE_CREATED)) {
|
|
|
|
+ //创建直播间-发送消息-跳到未开始页面
|
|
|
|
+ memo = teacherBaseUrl + "/#/liveRoomList?t=0";
|
|
|
|
+ SysUser createUser = getSysUser(room.getCreatedBy());
|
|
|
|
+ objs = new Object[]{createUser.getUsername(), liveDateStr, room.getLiveRemark()};
|
|
|
|
+ } else if (en.equals(MessageTypeEnum.JIGUANG_LIVE_STARTED)) {
|
|
|
|
+ //直播开始-发送消息-跳到直播中页面
|
|
|
|
+ memo = teacherBaseUrl + "/#/liveRoomList";
|
|
|
|
+ objs = new Object[]{liveDateStr, room.getRoomTitle()};
|
|
|
|
+ } else {
|
|
|
|
+ log.error("sendRoomState error: MessageTypeEnum error " + en);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //发送消息
|
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, en, pushMap,
|
|
|
|
+ null, 0, memo, "TEACHER", objs);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("sendRoomState error ", e.getCause());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void getRoomData(ImLiveBroadcastRoomVo roomVo) {
|
|
private void getRoomData(ImLiveBroadcastRoomVo roomVo) {
|
|
//点赞数
|
|
//点赞数
|
|
Object like = redissonClient.getBucket(LIVE_ROOM_LIKE.replace(ROOM_UID, roomVo.getRoomUid())).get();
|
|
Object like = redissonClient.getBucket(LIVE_ROOM_LIKE.replace(ROOM_UID, roomVo.getRoomUid())).get();
|
|
@@ -1158,21 +1222,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
.orElseThrow(() -> new BizException("用户不存在."));
|
|
.orElseThrow(() -> new BizException("用户不存在."));
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private ImLiveRoomPurviewService imLiveRoomPurviewService;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 测试
|
|
* 测试
|
|
*/
|
|
*/
|
|
public Map<String, Object> test(String roomUid) {
|
|
public Map<String, Object> test(String roomUid) {
|
|
-// Map<String, Object> map = new HashMap<>();
|
|
|
|
-// TenantContextHolder.setTenantId(1);
|
|
|
|
-// map.put("roomUid", roomUid);
|
|
|
|
-// map.put("groupIds", "22053019304300001,1141,1");
|
|
|
|
-// map.put("subjectIds", "2,5,4");
|
|
|
|
-// PageInfo<SysUserDto> sysUserDtoPageInfo = imLiveRoomPurviewService.selectRoomPurviewStudent(map);
|
|
|
|
-// System.out.println(sysUserDtoPageInfo);
|
|
|
|
|
|
+ return test(roomUid, null);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ public Map<String, Object> test(String roomUid, String userFlag) {
|
|
//test
|
|
//test
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
//校验房间心跳是否过期没续租
|
|
//校验房间心跳是否过期没续租
|
|
@@ -1211,12 +1268,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
if (CollectionUtils.isNotEmpty(totalUserInfo)) {
|
|
if (CollectionUtils.isNotEmpty(totalUserInfo)) {
|
|
if (CollectionUtils.isNotEmpty(inRoomUserInfo)) {
|
|
if (CollectionUtils.isNotEmpty(inRoomUserInfo)) {
|
|
look = inRoomUserInfo.size();
|
|
look = inRoomUserInfo.size();
|
|
-// result.put("正在观看的人员信息", inRoomUserInfo);
|
|
|
|
|
|
+ Optional.ofNullable(userFlag)
|
|
|
|
+ .ifPresent(a -> result.put("正在观看的人员信息", inRoomUserInfo));
|
|
} else {
|
|
} else {
|
|
result.put("正在观看的人员信息", "没有正在观看的人员数据");
|
|
result.put("正在观看的人员信息", "没有正在观看的人员数据");
|
|
}
|
|
}
|
|
totalLook = totalUserInfo.size();
|
|
totalLook = totalUserInfo.size();
|
|
-// result.put("总人员数据", totalUserInfo);
|
|
|
|
|
|
+ Optional.ofNullable(userFlag)
|
|
|
|
+ .ifPresent(a -> result.put("总人员数据", totalUserInfo));
|
|
} else {
|
|
} else {
|
|
result.put("总人员数据", "没有人员数据");
|
|
result.put("总人员数据", "没有人员数据");
|
|
}
|
|
}
|
|
@@ -1537,6 +1596,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
private Integer whetherVideo;
|
|
private Integer whetherVideo;
|
|
//机构
|
|
//机构
|
|
private Integer tenantId;
|
|
private Integer tenantId;
|
|
|
|
+ //播出端- pc网页端 移动端mobile
|
|
|
|
+ private String os = "pc";
|
|
|
|
|
|
public Integer getSpeakerId() {
|
|
public Integer getSpeakerId() {
|
|
return speakerId;
|
|
return speakerId;
|
|
@@ -1639,6 +1700,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
public void setEndLiveTime(Date endLiveTime) {
|
|
public void setEndLiveTime(Date endLiveTime) {
|
|
this.endLiveTime = endLiveTime;
|
|
this.endLiveTime = endLiveTime;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public String getOs() {
|
|
|
|
+ return os;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setOs(String os) {
|
|
|
|
+ this.os = os;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|