| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- 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.Map;
- import java.util.concurrent.ConcurrentHashMap;
- 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);
- 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);
- 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();
- }
- }
|