homepage.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. package com.cnd3b.restcontroller.publicmethod.homepage;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.cnd3b.common.Controller;
  5. import com.cnd3b.common.data.Row;
  6. import com.cnd3b.common.data.Rows;
  7. import com.cnd3b.common.data.RowsMap;
  8. import com.cnd3b.common.data.SQLFactory;
  9. public class homepage extends Controller {
  10. public homepage(JSONObject content) {
  11. super(content);
  12. }
  13. /**
  14. * 统计数据展示
  15. *
  16. * @return
  17. */
  18. public String getStatisticalData() {
  19. this.siteid = content.getString("siteid");
  20. SQLFactory sqlFactory = new SQLFactory(this, "统计数据展示");
  21. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  22. return getSucReturnObject().setData(rows).saveToDataPool(10).toString();
  23. }
  24. /**
  25. * 供需分类选择查询
  26. *
  27. * @return
  28. */
  29. public String query_typeselectList() {
  30. this.siteid = content.getString("siteid");
  31. Rows rows = dbConnect.runSqlQuery("select ttypedetailid,fvalue as ftype from ttypedetail where ftype = '供需分类' and siteid ='" + siteid + "' and fisused=1 order by sequence");
  32. RowsMap map = getAttachmentUrl("ttypedetail", rows.toArrayList("ttypedetailid"));
  33. for (Row row : rows) {
  34. row.put("attinfos", map.get(row.getString("ttypedetailid")));
  35. }
  36. return getSucReturnObject().setData(rows).toString();
  37. }
  38. /**
  39. * 供需列表查询
  40. *
  41. * @return
  42. */
  43. public String query_supplyanddemandList() {
  44. this.siteid = content.getString("siteid");
  45. /**
  46. *排序条件设置
  47. */
  48. String[] sortfield = {"t1.tsupplyanddemandid desc"};
  49. String sort = getSort(sortfield, "t1.tsupplyanddemandid desc");
  50. /**
  51. * 过滤条件设置
  52. */
  53. StringBuffer where = new StringBuffer(" 1=1 ");
  54. if (content.containsKey("where")) {
  55. JSONObject whereObject = content.getJSONObject("where");
  56. if (whereObject.containsKey("ftype") && !"".equals(whereObject.getString("ftype"))) {
  57. where.append(" and t1.ftype ='").append(whereObject.getString("ftype")).append("' ");
  58. }
  59. }
  60. SQLFactory sqlFactory = new SQLFactory(this, "供需列表查询", pageSize, pageNumber, sort);
  61. sqlFactory.addParameter("siteid", siteid);
  62. sqlFactory.addParameter_SQL("where", where);
  63. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  64. RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid"));
  65. for (Row row : rows) {
  66. //附件信息
  67. row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
  68. }
  69. return getSucReturnObject().setDataByPaging(rows).saveToDataPool().toString();
  70. }
  71. /**
  72. * 供需详情查询
  73. *
  74. * @return
  75. */
  76. public String query_supplyanddemandMain() {
  77. this.siteid = content.getString("siteid");
  78. long tsupplyanddemandid = content.getLong("tsupplyanddemandid");
  79. long tagentsid = content.getLong("tagentsid");
  80. SQLFactory sqlFactory = new SQLFactory(this, "供需详情查询");
  81. sqlFactory.addParameter("siteid", siteid);
  82. sqlFactory.addParameter("tagentsid", tagentsid);
  83. sqlFactory.addParameter("tsupplyanddemandid", tsupplyanddemandid);
  84. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  85. RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid"));
  86. for (Row row : rows) {
  87. //附件信息
  88. row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
  89. }
  90. return getSucReturnObject().setData(rows).toString();
  91. }
  92. /**
  93. * 热门商户
  94. *
  95. * @return
  96. */
  97. public String agentList() {
  98. this.siteid = content.getString("siteid");
  99. SQLFactory agentlistSql = new SQLFactory(this, "优质商户", pageSize, pageNumber, "t1.tagentsid");
  100. agentlistSql.addParameter("saleprodclass", content.getString("saleprodclass"));
  101. Rows rows = agentlistSql.runSqlQuery();
  102. RowsMap map = getAttachmentUrl("tagents", rows.toArrayList("tagentsid"));
  103. for (Row row : rows) {
  104. row.put("attinfos", map.get(row.getString("tagentsid")));
  105. }
  106. return getSucReturnObject().setData(rows).saveToDataPool(10).toString();
  107. }
  108. /**
  109. * 热门商户详情查询
  110. *
  111. * @return
  112. */
  113. public String agentsMain() {
  114. this.siteid = content.getString("siteid");
  115. SQLFactory sql = new SQLFactory(this, "优质商户详情", pageSize, pageNumber, "t1.tagents_productid");
  116. sql.addParameter("tagentsid", content.getString("tagentsid"));
  117. sql.addParameter("saleprodclass", content.getString("saleprodclass"));
  118. Rows rows = dbConnect.runSqlQuery(sql.getSQL());
  119. for (Row row : rows) {
  120. row.put("saleprodclass", JSONArray.parseArray(row.getString("saleprodclass")));
  121. row.put("attinfos", getAttachmentUrl("tagents", content.getString("tagentsid")));
  122. }
  123. return getSucReturnObject().setData(rows).toString();
  124. }
  125. /**
  126. * 热门商品
  127. *
  128. * @return
  129. */
  130. public String prodList() {
  131. this.siteid = content.getString("siteid");
  132. SQLFactory agentlistSql = new SQLFactory(this, "优质商品");
  133. Rows rows = agentlistSql.runSqlQuery();
  134. RowsMap map = getAttachmentUrl("tagents_product", rows.toArrayList("tagents_productid"));
  135. for (Row row : rows) {
  136. row.put("attinfos", map.get(row.getString("tagents_productid")));
  137. }
  138. return getSucReturnObject().setData(rows).saveToDataPool(10).toString();
  139. }
  140. }