|
|
@@ -2,9 +2,13 @@ package com.cnd3b.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.cnd3b.common.BaseClass;
|
|
|
+import com.cnd3b.common.data.Rows;
|
|
|
+import com.cnd3b.common.data.RowsMap;
|
|
|
import com.cnd3b.common.data.SQLFactory;
|
|
|
import com.cnd3b.common.data.db.DBConnect;
|
|
|
import com.cnd3b.common.data.db.SQLiteJDBC;
|
|
|
+import com.cnd3b.common.parameter.parameter;
|
|
|
+import com.cnd3b.common.websocket.WebClientSocket;
|
|
|
import com.cnd3b.utility.polyv.Polyv;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
@@ -31,7 +35,9 @@ public class GetPolyvAnalysisData extends BaseClass implements Runnable {
|
|
|
*/
|
|
|
public void getLiveStatusAndCoverImageUrl() {
|
|
|
DBConnect dbConnect = new DBConnect();
|
|
|
- String[] channelids = dbConnect.runSqlQuery("select channelid from tlive").toArray("channelid");
|
|
|
+ Rows channelRows = dbConnect.runSqlQuery("select channelid,livestatus,tagentsid,steid from tlive");
|
|
|
+ String[] channelids = channelRows.toArray("channelid");
|
|
|
+ RowsMap map = channelRows.toRowsMap("channelid");
|
|
|
Polyv polyv = new Polyv();
|
|
|
HashMap<String, String> livestatusMap = polyv.getLiveStatuses(channelids);
|
|
|
ArrayList<String> sqllist = new ArrayList<>();
|
|
|
@@ -39,6 +45,11 @@ public class GetPolyvAnalysisData extends BaseClass implements Runnable {
|
|
|
String livestatus = livestatusMap.get(channelid);
|
|
|
if (livestatus.equalsIgnoreCase("live")) {
|
|
|
sqllist.add("update tlive set livestatus='" + livestatus + "',lastlivedate='" + getDate_Str() + "' ,channelcoverimageurl='" + polyv.getChannelImage(channelid, livestatus) + "' where channelid='" + channelid + "'");
|
|
|
+ if (!livestatus.equals(map.get(channelid).get(0).getString("livestatus"))) {
|
|
|
+ long tagentsid = map.get(channelid).get(0).getLong("tagentsid");
|
|
|
+ String siteid = map.get(channelid).get(0).getString("siteid");
|
|
|
+ createLiveMessage(siteid, tagentsid);
|
|
|
+ }
|
|
|
} else if (livestatus.equalsIgnoreCase("waiting")) {
|
|
|
sqllist.add("update tlive set livestatus='" + livestatus + "',channelcoverimageurl='" + polyv.getChannelImage(channelid, livestatus) + "' where channelid='" + channelid + "'");
|
|
|
} else {
|
|
|
@@ -48,6 +59,41 @@ public class GetPolyvAnalysisData extends BaseClass implements Runnable {
|
|
|
dbConnect.runSqlUpdate(sqllist);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建开播提醒消息
|
|
|
+ */
|
|
|
+ private void createLiveMessage(String siteid, long tagentsid) {
|
|
|
+ //如果从未直播状态变为直播状态,则创建系统消息提醒其合作商
|
|
|
+ DBConnect dbConnect = new DBConnect();
|
|
|
+ Rows agentRows = dbConnect.runSqlQuery("select * from tagents where siteid='" + siteid + "' and tagentsid='" + tagentsid + "'");
|
|
|
+ if (!agentRows.isEmpty()) {
|
|
|
+ String fbrand = agentRows.get(0).getString("fbrand");
|
|
|
+ Rows useridRows = dbConnect.runSqlQuery("select distinct t2.tenterprise_userid from tagents_cooperation t1 inner join tenterprise_users t2 on t1.siteid=t2.siteid and t1.tagentsid=t2.tagentsid where t1.tagentsid='" + tagentsid + "'");//获取其所有合作商的账号列表
|
|
|
+ ArrayList<String> userids = useridRows.toArrayList("tenterprise_userid");
|
|
|
+ SQLFactory factory = new SQLFactory(this, "系统消息插入");
|
|
|
+ factory.addParameter("siteid", siteid);
|
|
|
+ factory.addParameter("ftype", "商户");
|
|
|
+ factory.addParameter("ftitle", "开播提醒");
|
|
|
+ factory.addParameter("fmessage", "合作商户" + fbrand + "正在直播!");
|
|
|
+ factory.addParameter_in("tenterprise_userid", userids);
|
|
|
+ factory.addParameter("objectid", "null");
|
|
|
+ factory.addParameter("objectname", "null");
|
|
|
+ dbConnect.runSqlUpdate(factory.getSQL());
|
|
|
+ for (String id : userids) {
|
|
|
+ long userid = Long.parseLong(id);
|
|
|
+ if (parameter.websocketClients.containsKey(userid)) {
|
|
|
+ JSONObject methodobject = new JSONObject();
|
|
|
+ methodobject.put("type", "remind");//提醒
|
|
|
+ methodobject.put("text", "合作商户" + fbrand + "正在直播!");
|
|
|
+ for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
|
|
|
+ webClientSocket.sendSystemMessage(methodobject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取频道实时在线人数
|
|
|
*/
|