analysis.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package com.cnd3b.restcontroller.enterprise.data;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.cnd3b.common.Controller;
  4. import com.cnd3b.common.data.Row;
  5. import com.cnd3b.common.data.Rows;
  6. import com.cnd3b.common.data.SQLFactory;
  7. import com.cnd3b.common.parameter.parameter;
  8. import com.cnd3b.common.websocket.WebClientSocket;
  9. import java.util.ArrayList;
  10. import java.util.Map;
  11. import java.util.concurrent.ConcurrentHashMap;
  12. public class analysis extends Controller {
  13. public analysis(JSONObject content) {
  14. super(content);
  15. }
  16. /**
  17. * 获取在线用户(实时),用户表:tenterprise_users,商户表:tagents
  18. *
  19. * @return
  20. */
  21. public String getOnLineUserList() {
  22. Map<Long, ConcurrentHashMap<String, WebClientSocket>> websocketClients = parameter.websocketClients;
  23. ArrayList<String> userList = new ArrayList<>();
  24. for (Map.Entry<Long, ConcurrentHashMap<String, WebClientSocket>> m : websocketClients.entrySet()) {
  25. userList.add(String.valueOf(m.getKey()));
  26. }
  27. SQLFactory sqlFactory = new SQLFactory(this, "在线用户实时", pageSize, pageNumber, "t1.tenterprise_userid");
  28. sqlFactory.addParameter_in("tenterprise_userid", userList);
  29. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  30. for (Row row : rows) {
  31. row.put("loginindate", getDateTime_Str(getLoginDate(row.getLong("tenterprise_userid"))));
  32. }
  33. return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
  34. }
  35. /**
  36. * 获取在线商户(商户)
  37. *
  38. * @return
  39. */
  40. public String getOnLineMerchantList() {
  41. ArrayList<String> userList = new ArrayList<>();
  42. for (Map.Entry<Long, ConcurrentHashMap<String, WebClientSocket>> m : parameter.websocketClients.entrySet()) {
  43. userList.add(String.valueOf(m.getKey()));
  44. }
  45. SQLFactory sqlFactory = new SQLFactory(this, "在线商户实时", pageSize, pageNumber, "t1.tagentsid");
  46. sqlFactory.addParameter_in("tenterprise_userid", userList);
  47. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  48. return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
  49. }
  50. /**
  51. * 获取开播商户数,直播观众数,供需信息数
  52. *
  53. * @return
  54. */
  55. public String getLiveInfoCount() {
  56. JSONObject resultObject = new JSONObject();
  57. //开播商户数
  58. SQLFactory countKaiBoSql = new SQLFactory(this, "开播商户数");
  59. Rows countRowsKaiBo = countKaiBoSql.runSqlQuery();
  60. resultObject.put("countAgent", countRowsKaiBo.isEmpty() ? 0 : countRowsKaiBo.get(0).getInteger("fcount"));
  61. //直播观众数
  62. SQLFactory countLiveSql = new SQLFactory(this, "直播观众数");
  63. Rows countRowsLive = countLiveSql.runSqlQuery();
  64. resultObject.put("countUser", countRowsLive.isEmpty() ? 0 : countRowsLive.get(0).getInteger("fcount"));
  65. //供需信息数
  66. SQLFactory countGXSql = new SQLFactory(this, "供需信息数");
  67. Rows countRowsGX = countGXSql.runSqlQuery();
  68. resultObject.put("countGX", countRowsGX.isEmpty() ? 0 : countRowsGX.get(0).getInteger("fcount"));
  69. return getSucReturnObject().setData(resultObject).toString();
  70. }
  71. }