Переглянути джерело

1.任务#2568 管理端在线用户(实时)列表查询接口
2.任务#2569 管理端在线商户(实时)列表查询接口
3.任务#2570 管理端当前开播商户数、直播观众数、供需信息数统计接口

wzg 4 роки тому
батько
коміт
4cde856c5e

+ 3 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/data/SQL/供需信息数.sql

@@ -0,0 +1,3 @@
+SELECT count(0) fcount
+FROM tsupplyanddemand
+WHERE fstatus != 'н¨'

+ 10 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/data/SQL/在线商户实时.sql

@@ -0,0 +1,10 @@
+select *
+from (SELECT DISTINCT t2.tagentsid,
+                      t2.ftype,
+                      t2.fagentname,
+                      t2.saleprodclass
+      FROM tenterprise_users AS t1
+               LEFT JOIN tagents AS t2 ON t1.tagentsid = t2.tagentsid
+      WHERE t1.tenterprise_userid IN $tenterprise_userid$
+  AND t2.ftype != '¸öÈË'
+     ) as t1

+ 5 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/data/SQL/在线用户实时.sql

@@ -0,0 +1,5 @@
+SELECT t1.tenterprise_userid, t1.frole, t1.fname, t1.fsex, t1.fphonenumber, t2.ftype, t2.fagentname
+FROM tenterprise_users as t1
+         LEFT JOIN tagents as t2
+                   ON t1.tagentsid = t2.tagentsid
+WHERE t1.tenterprise_userid IN $tenterprise_userid$

+ 1 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/data/SQL/开播商户数.sql

@@ -0,0 +1 @@
+select count(0)fcount from tlive where livestatus='live'

+ 10 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/data/SQL/直播观众数.sql

@@ -0,0 +1,10 @@
+select sum(count) as fcustcount
+from (
+         select ROW_NUMBER() over(partition by t1.channelid order by t1.time desc)as num,
+                t1.count
+         from tlive_usercount t1
+                  inner join tlive t2 on t1.channelid = t2.channelid --and t2.livestatus='live'
+     ) t
+where t.num = 1
+
+

+ 80 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/data/analysis.java

@@ -2,9 +2,89 @@ package com.cnd3b.restcontroller.enterprise.data;
 
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
+import com.cnd3b.common.data.Row;
+import com.cnd3b.common.data.Rows;
+import com.cnd3b.common.data.SQLFactory;
+import com.cnd3b.common.parameter.parameter;
+import com.cnd3b.common.websocket.WebClientSocket;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static com.cnd3b.common.parameter.parameter.parameter_init;
+import static com.cnd3b.common.parameter.parameter.websocketClients;
 
 public class analysis extends Controller {
     public analysis(JSONObject content) {
         super(content);
     }
+
+
+    /**
+     * 获取在线用户(实时),用户表:tenterprise_users,商户表:tagents
+     *
+     * @return
+     */
+    public String getOnLineUserList() {
+        Map<Long, ConcurrentHashMap<String, WebClientSocket>> websocketClients = parameter.websocketClients;
+        ArrayList<String> userList = new ArrayList<>();
+        for (Map.Entry<Long, ConcurrentHashMap<String, WebClientSocket>> m : websocketClients.entrySet()) {
+            userList.add(String.valueOf(m.getKey()));
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "在线用户实时", pageSize, pageNumber, "t1.tenterprise_userid");
+        sqlFactory.addParameter_in("tenterprise_userid", userList);
+//        System.err.println(sqlFactory.getSQL());
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        for (Row row : rows) {
+            row.put("loginindate", getDateTime_Str(getLoginDate(row.getLong("tenterprise_userid"))));
+        }
+        return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
+    }
+
+    /**
+     * 获取在线商户(商户)
+     *
+     * @return
+     */
+    public String getOnLineMerchantList() {
+        ArrayList<String> userList = new ArrayList<>();
+        for (Map.Entry<Long, ConcurrentHashMap<String, WebClientSocket>> m : parameter.websocketClients.entrySet()) {
+            userList.add(String.valueOf(m.getKey()));
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "在线商户实时", pageSize, pageNumber, "t1.tagentsid");
+        sqlFactory.addParameter_in("tenterprise_userid", userList);
+//        System.err.println(sqlFactory.getSQL());
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
+    }
+
+    /**
+     * 获取开播商户数,直播观众数,供需信息数
+     *
+     * @return
+     */
+    public String getLiveInfoCount() {
+
+        JSONObject resultObject = new JSONObject();
+
+        //开播商户数
+        SQLFactory countKaiBoSql = new SQLFactory(this, "开播商户数");
+        Rows countRowsKaiBo = countKaiBoSql.runSqlQuery();
+        resultObject.put("countAgent", countRowsKaiBo.isEmpty() ? 0 : countRowsKaiBo.get(0).getInteger("fcount"));
+
+        //直播观众数
+        SQLFactory countLiveSql = new SQLFactory(this, "直播观众数");
+        Rows countRowsLive = countLiveSql.runSqlQuery();
+        resultObject.put("countUser", countRowsLive.isEmpty() ? 0 : countRowsLive.get(0).getInteger("fcount"));
+
+        //供需信息数
+        SQLFactory countGXSql = new SQLFactory(this, "供需信息数");
+        Rows countRowsGX = countGXSql.runSqlQuery();
+        resultObject.put("countGX", countRowsGX.isEmpty() ? 0 : countRowsGX.get(0).getInteger("fcount"));
+
+        return getSucReturnObject().setData(resultObject).toString();
+    }
+
 }