Преглед изворни кода

商户直播通过系统消息提醒其合作商户

沈静伟 пре 4 година
родитељ
комит
161945bbb9

+ 18 - 5
src/dsb/com/cnd3b/service/GetPolyvAnalysisBigData.java

@@ -19,20 +19,33 @@ import java.util.HashMap;
 public class GetPolyvAnalysisBigData extends BaseClass implements Runnable {
     @Override
     public void run() {
-        try {
-            if (new SQLiteJDBC().checkServicesUsed("GetPolyvAnalysisBigData", false)) {
-                System.err.println("start:getLiveData");
+
+        if (new SQLiteJDBC().checkServicesUsed("GetPolyvAnalysisBigData", false)) {
+            try {
                 getLiveData();//频道统计信息,占用资源少
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            try {
                 System.err.println("start:getLiveviewLog");
                 getLiveviewLog();//观众信息,占用资源大
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            try {
                 System.err.println("start:getLiveMessageList");
                 getLiveMessageList();//观众留言、占用资源较大
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            try {
                 System.err.println("start:getSessionStats");
                 getSessionStats();//场次统计信息,占用资源少
+            } catch (Exception e) {
+                e.printStackTrace();
             }
-        } catch (Exception e) {
-            e.printStackTrace();
         }
+
     }
 
     /**

+ 36 - 28
src/dsb/com/cnd3b/service/GetPolyvAnalysisData.java

@@ -20,13 +20,17 @@ import java.util.HashMap;
 public class GetPolyvAnalysisData extends BaseClass implements Runnable {
     @Override
     public void run() {
-        try {
-            if (new SQLiteJDBC().checkServicesUsed("GetPolyvAnalysisData", false)) {
+        if (new SQLiteJDBC().checkServicesUsed("GetPolyvAnalysisData", false)) {
+            try {
                 getLiveStatusAndCoverImageUrl();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            try {
                 getLiveUserCount();
+            } catch (Exception e) {
+                e.printStackTrace();
             }
-        } catch (Exception e) {
-            e.printStackTrace();
         }
     }
 
@@ -63,33 +67,37 @@ public class GetPolyvAnalysisData extends BaseClass implements Runnable {
      * 创建开播提醒消息
      */
     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);
+        try {
+            //如果从未直播状态变为直播状态,则创建系统消息提醒其合作商
+            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);
+                        }
                     }
                 }
             }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
     }