From f164172bcf64df22fb561d9feccd5ed5af330b5d Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Mon, 11 Apr 2022 21:36:04 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=95=B0=E6=8D=AE=EF=BC=9A?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=82=E4=BC=97=E3=80=81=E7=A4=BC=E7=89=A9?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=20=E4=BF=AE=E5=A4=8D=E7=9B=B4=E6=92=AD?=
=?UTF-8?q?=E7=8A=B6=E6=80=81=E6=97=A0=E6=B3=95=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Web/html/body/bilibili/realTimeData.html | 49 ++++++++++++++++++-
.../Controllers/OverviewController.java | 1 +
.../Controllers/RealTimeDataController.java | 45 ++++++++++++++++-
.../com/yutou/bilibili/BiliBili/Live.java | 11 ++++-
.../yutou/bilibili/BiliBili/LiveUtils.java | 10 +---
.../Bili/mybatis/model/BilibiliLiveInfo.java | 3 +-
6 files changed, 105 insertions(+), 14 deletions(-)
diff --git a/Web/html/body/bilibili/realTimeData.html b/Web/html/body/bilibili/realTimeData.html
index 6b2093a..37aaa1d 100644
--- a/Web/html/body/bilibili/realTimeData.html
+++ b/Web/html/body/bilibili/realTimeData.html
@@ -65,6 +65,24 @@
+
+
+
+
@@ -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;
diff --git a/src/main/java/com/yutou/bilibili/BiliBili/Controllers/OverviewController.java b/src/main/java/com/yutou/bilibili/BiliBili/Controllers/OverviewController.java
index 39dc890..694a6b3 100644
--- a/src/main/java/com/yutou/bilibili/BiliBili/Controllers/OverviewController.java
+++ b/src/main/java/com/yutou/bilibili/BiliBili/Controllers/OverviewController.java
@@ -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;
diff --git a/src/main/java/com/yutou/bilibili/BiliBili/Controllers/RealTimeDataController.java b/src/main/java/com/yutou/bilibili/BiliBili/Controllers/RealTimeDataController.java
index 3218103..bcf69d0 100644
--- a/src/main/java/com/yutou/bilibili/BiliBili/Controllers/RealTimeDataController.java
+++ b/src/main/java/com/yutou/bilibili/BiliBili/Controllers/RealTimeDataController.java
@@ -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 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 giftList = service.queryLiveData(rid, startTime, endTime, new String[]{
+ LiveData.SEND_GIFT
+ , LiveData.COMBO_SEND
+ , LiveData.GUARD_BUY
+ });
+ List 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;
+ }
}
diff --git a/src/main/java/com/yutou/bilibili/BiliBili/Live.java b/src/main/java/com/yutou/bilibili/BiliBili/Live.java
index fbcf8b0..79a6bd7 100644
--- a/src/main/java/com/yutou/bilibili/BiliBili/Live.java
+++ b/src/main/java/com/yutou/bilibili/BiliBili/Live.java
@@ -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 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"://榜单更新等无用信息
diff --git a/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java b/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java
index 73b33de..79bf9c8 100644
--- a/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java
+++ b/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java
@@ -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) {
diff --git a/src/main/java/com/yutou/bilibili/mybatis/Bili/mybatis/model/BilibiliLiveInfo.java b/src/main/java/com/yutou/bilibili/mybatis/Bili/mybatis/model/BilibiliLiveInfo.java
index a4baff8..b456cf1 100644
--- a/src/main/java/com/yutou/bilibili/mybatis/Bili/mybatis/model/BilibiliLiveInfo.java
+++ b/src/main/java/com/yutou/bilibili/mybatis/Bili/mybatis/model/BilibiliLiveInfo.java
@@ -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;
}