实时数据:新增观众、礼物列表

修复直播状态无法判断
This commit is contained in:
Yutousama 2022-04-11 21:36:04 +08:00
parent 7d8ed357cb
commit f164172bcf
6 changed files with 105 additions and 14 deletions

View File

@ -65,6 +65,24 @@
</div>
</div>
</div>
<div class="layui-col-md-offset2"></div>
<div class="layui-col-md12">
<div class="layui-card" style="width: 100%;height: 400px">
<div class="layui-card-header">观众列表</div>
<div class="layui-card-body">
<table id="users" lay-filter="listTools"></table>
</div>
</div>
</div>
<div class="layui-col-md-offset2"></div>
<div class="layui-col-md12">
<div class="layui-card" style="width: 100%;height: 400px">
<div class="layui-card-header">礼物列表</div>
<div class="layui-card-body">
<table id="gifts" lay-filter="listTools"></table>
</div>
</div>
</div>
</div>
</div>
</div>
@ -103,6 +121,10 @@
}
}
/*$.get("/realTimeData/data.do",{roomid:json.data[i].roomid},function (json) {
})*/
element.tabChange('upInfo', id);
form.render()
})
@ -114,7 +136,8 @@
if(priceChart!=null){
priceChart.destroy()
}
$.post("/realTimeData/get/query.do", {"roomid": this.getAttribute('lay-id')}, function (json) {
let roomid=this.getAttribute('lay-id');
$.post("/realTimeData/get/query.do", {"roomid": roomid}, function (json) {
console.log(json)
if (json.code !== 0) {
$('#popular').text(0);
@ -123,6 +146,30 @@
layer.close(index);
return;
}
table.render({
elem: '#gifts'
,height: 312
,url: '/realTimeData/data.do?rid='+roomid+'&model=1' //数据接口
,page: true //开启分页
,cols: [[ //表头
{field: 'uid', title: '观众id', width:110, sort: true, fixed: 'left'}
,{field: 'msg', title: '内容', width:400, sort: true}
,{field: 'size', title: '数量', width:100}
,{field: 'money', title: '金瓜子', width: 100}
,{field: 'time', title: '时间', width: 200, sort: true}
]]
});
table.render({
elem: '#users'
,height: 312
,url: '/realTimeData/data.do?rid='+roomid+"&model=2" //数据接口
,page: true //开启分页
,cols: [[ //表头
{field: 'uid', title: '观众id', width:110, sort: true, fixed: 'left'}
,{field: 'msg', title: '内容', width:400, sort: true}
,{field: 'time', title: '时间', width: 200, sort: true}
]]
});
let gifts = json.data.gift;
let prices = json.data.price;
let priceSize = 0;

View File

@ -6,6 +6,7 @@ import com.yutou.bilibili.BiliBili.Datas.LiveData;
import com.yutou.bilibili.BiliBili.Services.IBiliBiliLiveService;
import com.yutou.bilibili.Tools.AppTools;
import com.yutou.bilibili.Tools.ExcelUtils;
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveData;
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfo;
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
import org.springframework.core.io.FileSystemResource;

View File

@ -8,6 +8,7 @@ import com.yutou.bilibili.BiliBili.LiveUtils;
import com.yutou.bilibili.BiliBili.Services.IBiliBiliLiveService;
import com.yutou.bilibili.Tools.AppTools;
import com.yutou.bilibili.Tools.Log;
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveData;
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfo;
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
import org.springframework.stereotype.Controller;
@ -62,8 +63,9 @@ public class RealTimeDataController {
Map<String, Integer> map = service.queryGiftSize(roomid,startTime,endTime);
for (String key : map.keySet()) {
JSONObject item = new JSONObject();
if(key==null||key.equals("null"))
if(key==null|| "null".equals(key)) {
continue;
}
item.put("giftName",key);
item.put("size",map.get(key));
giftArray.add(item);
@ -74,4 +76,45 @@ public class RealTimeDataController {
json.put("code",0);
return json;
}
@ResponseBody
@RequestMapping("data.do")
public JSONObject queryRoomData(int rid,int model){
Date startTime = AppTools.getToDayStartTime();
Date endTime=AppTools.getToDayNowTime();
List<BilibiliLiveData> giftList = service.queryLiveData(rid, startTime, endTime, new String[]{
LiveData.SEND_GIFT
, LiveData.COMBO_SEND
, LiveData.GUARD_BUY
});
List<BilibiliLiveData> userList = service.queryLiveData(rid, startTime, endTime, new String[]{
LiveData.INTERACT_WORD
, LiveData.ENTRY_EFFECT
});
JSONObject json=new JSONObject();
JSONArray retData=new JSONArray();
if(model==1) {
for (BilibiliLiveData data : giftList) {
JSONObject item = new JSONObject();
item.put("uid", data.getUid());
item.put("msg", data.getMsg());
json.put("size", data.getGiftindex());
json.put("money", data.getPrice());
item.put("time", AppTools.getToDayTimeToString(data.getSubtime()));
retData.add(item);
}
}else if(model==2) {
for (BilibiliLiveData data : userList) {
JSONObject item = new JSONObject();
item.put("uid", data.getUid());
item.put("msg", data.getMsg());
item.put("time", AppTools.getToDayTimeToString(data.getSubtime()));
retData.add(item);
}
}
json.put("code",0);
json.put("count",retData.size());
json.put("data",retData);
json.put("msg","");
return json;
}
}

View File

@ -295,7 +295,6 @@ public class Live implements ApplicationContextAware {
byte[] bytes = new byte[data.length - 16];
System.arraycopy(data, 16, bytes, 0, data.length - 16);
if (data.length > 32) {
List<String> list = LiveUtils.getMsgList(LiveUtils.dec(bytes), new ArrayList<>(), true);
String tmp = "";
@ -516,7 +515,15 @@ public class Live implements ApplicationContextAware {
}
});
break;
case "PREPARING"://
case "PREPARING"://直播结束
upData.setLive(0);
break;
case "WATCHED_CHANGE"://人气值
try {
Live.this.info.setPopular(Integer.getInteger(json.getJSONObject("data").getString("text_small")));
}catch (Exception ignored){
}
break;
case "SUPER_CHAT_MESSAGE_JPN":
case "NOTICE_MSG":
case "HOT_RANK_CHANGED"://榜单更新等无用信息

View File

@ -380,15 +380,7 @@ public class LiveUtils {
}
public static boolean isLivePlayer(int roomId) {
/* if (liveStateMap.containsKey(roomId)) {
return liveStateMap.get(roomId);
}
reloadLiveState(roomId);
return false;*/
if (!Live.lives.containsKey(roomId)) {
return false;
}
return Live.lives.get(roomId).geData().getLive() == 1;
return getLiveState(roomId);
}
private static void checkLiveSave(int roomId) {

View File

@ -27,8 +27,9 @@ public class BilibiliLiveInfo implements Serializable {
private static final long serialVersionUID = 1L;
public Integer getRoomid() {
if(roomid==null)
if(roomid==null) {
roomid=0;
}
return roomid;
}