live.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package com.cnd3b.restcontroller.publicmethod.live;
  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.RowsMap;
  7. import com.cnd3b.common.data.SQLFactory;
  8. import org.apache.ibatis.jdbc.SQL;
  9. public class live extends Controller {
  10. public live(JSONObject content) {
  11. super(content);
  12. }
  13. /**
  14. * 获取当前直播商户数
  15. *
  16. * @return
  17. */
  18. public String getLiveChannelData() {
  19. String tactivityid = content.getString("tactivityid");
  20. JSONObject resultObject = new JSONObject();
  21. //参展商
  22. SQLFactory agentcountSql = new SQLFactory(this, "活动直播间总数查询");
  23. agentcountSql.addParameter("tactivityid", tactivityid);
  24. Rows agentCountRows = agentcountSql.runSqlQuery();
  25. resultObject.put("fagentcount", agentCountRows.isEmpty() ? 0 : agentCountRows.get(0).getInteger("fcount"));
  26. //观众总人数
  27. SQLFactory custcountSql = new SQLFactory(this, "活动直播间观众总数查询");
  28. custcountSql.addParameter("tactivityid", tactivityid);
  29. Rows totalcustCountrows = custcountSql.runSqlQuery();
  30. resultObject.put("ftotalcustcount", totalcustCountrows.isEmpty() ? 0 : totalcustCountrows.get(0).getInteger("fcount"));
  31. SQLFactory livecustcount = new SQLFactory(this, "当前线上观众人数查询");
  32. livecustcount.addParameter("tactivityid", tactivityid);
  33. Rows liverows = dbConnect.runSqlQuery(livecustcount.getSQL());
  34. //正在直播数
  35. resultObject.put("flivecount", liverows.size());
  36. //当前在线观众人数
  37. resultObject.put("fcustcount", liverows.isEmpty() ? 0 : liverows.sum("fcount"));
  38. //直播列表
  39. resultObject.put("tlivelist", liverows);
  40. return getSucReturnObject().setData(resultObject).toString();
  41. }
  42. /**
  43. * 热门展商
  44. *
  45. * @return
  46. */
  47. public String agentList() {
  48. String tactivityid = content.getString("tactivityid");
  49. SQLFactory agentlistSql = new SQLFactory(this, "热门展商");
  50. agentlistSql.addParameter("tactivityid", tactivityid);
  51. Rows rows = agentlistSql.runSqlQuery();
  52. RowsMap map = getAttachmentUrl("tactivity_agentmsg", rows.toArrayList("tactivity_agentmsgid"));
  53. for (Row row : rows) {
  54. row.put("attinfos", map.get(row.getString("tactivity_agentmsgid")));
  55. }
  56. return getSucReturnObject().setData(rows).saveToDataPool(10).toString();
  57. }
  58. /**
  59. * 热门展品
  60. *
  61. * @return
  62. */
  63. public String prodList() {
  64. String tactivityid = content.getString("tactivityid");
  65. SQLFactory agentlistSql = new SQLFactory(this, "热门展品");
  66. agentlistSql.addParameter("tactivityid", tactivityid);
  67. Rows rows = agentlistSql.runSqlQuery();
  68. RowsMap map = getAttachmentUrl("tactivity_agentmsg", rows.toArrayList("tactivity_agentmsgid"));
  69. for (Row row : rows) {
  70. row.put("attinfos", map.get(row.getString("tactivity_agentmsgid")));
  71. }
  72. return getSucReturnObject().setData(rows).saveToDataPool(10).toString();
  73. }
  74. }