homepage.java 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. import p2.pao.PaoRemote;
  10. import p2.pao.PaoSetRemote;
  11. import p2.util.P2Exception;
  12. public class homepage extends Controller {
  13. public homepage(JSONObject content) {
  14. super(content);
  15. }
  16. /**
  17. * 统计数据展示
  18. *
  19. * @return
  20. */
  21. public String getStatisticalData() {
  22. SQLFactory sqlFactory = new SQLFactory(this, "统计数据展示");
  23. sqlFactory.addParameter("siteid", siteid);
  24. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  25. return getSucReturnObject().setData(rows).saveToDataPool(10).toString();
  26. }
  27. /**
  28. * 供需分类选择查询
  29. *
  30. * @return
  31. */
  32. public String query_typeselectList() {
  33. Rows rows = dbConnect.runSqlQuery("select ttypedetailid,fvalue as ftype from ttypedetail where ftype = '供需分类' and siteid ='" + siteid + "' and fisused=1 order by sequence");
  34. RowsMap map = getAttachmentUrl("ttypedetail", rows.toArrayList("ttypedetailid"));
  35. for (Row row : rows) {
  36. row.put("attinfos", map.get(row.getString("ttypedetailid")));
  37. }
  38. return getSucReturnObject().setData(rows).toString();
  39. }
  40. /**
  41. * 供需列表查询
  42. *
  43. * @return
  44. */
  45. public String query_supplyanddemandList() {
  46. /**
  47. *排序条件设置
  48. */
  49. String[] sortfield = {"t1.tsupplyanddemandid desc"};
  50. String sort = getSort(sortfield, "t1.tsupplyanddemandid desc");
  51. /**
  52. * 过滤条件设置
  53. */
  54. StringBuffer where = new StringBuffer(" 1=1 ");
  55. if (content.containsKey("where")) {
  56. JSONObject whereObject = content.getJSONObject("where");
  57. if (whereObject.containsKey("ftype") && !"".equals(whereObject.getString("ftype"))) {
  58. where.append(" and t1.ftype ='").append(whereObject.getString("ftype")).append("' ");
  59. }
  60. }
  61. SQLFactory sqlFactory = new SQLFactory(this, "供需列表查询", pageSize, pageNumber, sort);
  62. sqlFactory.addParameter("siteid", siteid);
  63. sqlFactory.addParameter_SQL("where", where);
  64. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  65. RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid"));
  66. for (Row row : rows) {
  67. //附件信息
  68. row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
  69. row.put("headportraiturl", getHeadPic(row.getLong("tenterprise_userid")));
  70. }
  71. return getSucReturnObject().setDataByPaging(rows).saveToDataPool().toString();
  72. }
  73. /**
  74. * 供需详情查询
  75. *
  76. * @return
  77. */
  78. public String query_supplyanddemandMain() {
  79. long tsupplyanddemandid = content.getLong("tsupplyanddemandid");
  80. long tagentsid = content.getLong("tagentsid");
  81. SQLFactory sqlFactory = new SQLFactory(this, "供需详情查询");
  82. sqlFactory.addParameter("siteid", siteid);
  83. sqlFactory.addParameter("tagentsid", tagentsid);
  84. sqlFactory.addParameter("tsupplyanddemandid", tsupplyanddemandid);
  85. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  86. RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid"));
  87. for (Row row : rows) {
  88. //附件信息
  89. row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
  90. row.put("headportraiturl", getHeadPic(row.getLong("tenterprise_userid")));
  91. }
  92. return getSucReturnObject().setData(rows).toString();
  93. }
  94. /**
  95. * 热门商户
  96. *
  97. * @return
  98. */
  99. public String agentList() {
  100. SQLFactory agentlistSql = null;
  101. if (content.containsKey("saleprodclass") && !"".equals(content.getString("saleprodclass"))) {
  102. String saleprodclass = content.getString("saleprodclass");
  103. agentlistSql = new SQLFactory(this, "优质商户", pageSize, pageNumber, "t1.tagentsid");
  104. agentlistSql.addParameter("saleprodclass", saleprodclass);
  105. agentlistSql.addParameter("siteid", siteid);
  106. } else {
  107. agentlistSql = new SQLFactory(this, "优质商户_全部", pageSize, pageNumber, "t1.tagentsid");
  108. agentlistSql.addParameter("siteid", siteid);
  109. }
  110. Rows rows = agentlistSql.runSqlQuery();
  111. RowsMap map = getAttachmentUrl("tagents", rows.toArrayList("tagentsid"));
  112. for (Row row : rows) {
  113. row.put("attinfos", map.get(row.getString("tagentsid")));
  114. row.put("saleprodclass", JSONArray.parseArray(row.getString("saleprodclass")));
  115. }
  116. return getSucReturnObject().setData(rows).saveToDataPool(10).toString();
  117. }
  118. /**
  119. * 热门商户详情查询
  120. *
  121. * @return
  122. */
  123. public String agentsMain() {
  124. SQLFactory sql = new SQLFactory(this, "优质商户详情");
  125. sql.addParameter("tagentsid", content.getString("tagentsid"));
  126. sql.addParameter("saleprodclass", content.getString("saleprodclass"));
  127. sql.addParameter("siteid", siteid);
  128. Rows rows = dbConnect.runSqlQuery(sql.getSQL());
  129. for (Row row : rows) {
  130. row.put("saleprodclass", JSONArray.parseArray(row.getString("saleprodclass")));
  131. row.put("attinfos", getAttachmentUrl("tagents", content.getString("tagentsid")));
  132. }
  133. return getSucReturnObject().setData(rows).toString();
  134. }
  135. /**
  136. * 热门商品
  137. *
  138. * @return
  139. */
  140. public String prodList() {
  141. long tagentsid = content.getLongValue("tagentsid");
  142. SQLFactory prodlistSql = new SQLFactory(this, "优质商品", pageSize, pageNumber, "t1.tagents_productid");
  143. prodlistSql.addParameter("siteid", siteid);
  144. prodlistSql.addParameter("tagentsid", tagentsid);
  145. //prodlistSql.addParameter("saleprodclass", content.getString("saleprodclass"));
  146. Rows rows = prodlistSql.runSqlQuery();
  147. RowsMap map = getAttachmentUrl("tagents_product", rows.toArrayList("tagents_productid"));
  148. for (Row row : rows) {
  149. row.put("attinfos", map.get(row.getString("tagents_productid")));
  150. }
  151. return getSucReturnObject().setDataByPaging(rows).saveToDataPool(10).toString();
  152. }
  153. /**
  154. * 展会活动信息
  155. *
  156. * @return
  157. */
  158. public String activityMsg() {
  159. SQLFactory sql = new SQLFactory(this, "活动信息展示");
  160. Rows rows = sql.runSqlQuery();
  161. return getSucReturnObject().setData(rows).toString();
  162. }
  163. /**
  164. * 获取管理端发布的最新通告
  165. */
  166. public String getNewestNoticeList() {
  167. SQLFactory sql = new SQLFactory(this, "最新管理端发布的通告",pageSize,pageNumber,"t1.createdate DESC");
  168. Rows rows = sql.runSqlQuery();
  169. for (Row row : rows) {
  170. row.put("attinfos", getAttachmentUrl("tnotice", row.getString("tnoticeid")));
  171. }
  172. return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
  173. }
  174. /**
  175. * 通告主界面查询
  176. *
  177. * @return
  178. */
  179. public String query_noticeMain() {
  180. String tnoticeid = content.getString("tnoticeid");
  181. SQLFactory noticehead = new SQLFactory(this, "通告主界面查询");
  182. noticehead.addParameter("siteid", siteid);
  183. noticehead.addParameter("tnoticeid", tnoticeid);
  184. Rows rows = dbConnect.runSqlQuery(noticehead.getSQL());
  185. Rows attinfosRows = getAttachmentUrl("tnotice", tnoticeid);
  186. rows.get(0).put("attinfos", attinfosRows);
  187. rows.get(0).put("headportraiturl", getHeadPic(rows.get(0).getLong("tenterprise_userid")));
  188. return getSucReturnObject().setData(rows).toString();
  189. }
  190. /**
  191. * 新增招商管理表单
  192. * @return
  193. * @throws P2Exception
  194. */
  195. public String insertBusiness() throws P2Exception {
  196. String province = content.getString("province");
  197. String city = content.getString("city");
  198. String county = content.getString("county");
  199. String address = content.getString("address");
  200. String fname = content.getString("fname");
  201. String fphone = content.getString("fphone");
  202. String fnote = content.getString("fnote");
  203. PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tbusiness");
  204. PaoRemote paoRemote = paoSetRemote.addAtEnd();
  205. paoRemote.setValue("province",province,11L);
  206. paoRemote.setValue("city",city,11L);
  207. paoRemote.setValue("county",county,11L);
  208. paoRemote.setValue("address",address,11L);
  209. paoRemote.setValue("fname",fname,11L);
  210. paoRemote.setValue("fphone",fphone,11L);
  211. paoRemote.setValue("fnote",fnote,11L);
  212. paoRemote.setValue("tbusinessid",paoRemote.getUniqueIDValue(),11L);
  213. paoSetRemote.save();
  214. return getSucReturnObject().toString();
  215. }
  216. /**
  217. * 获取热门商户列表(关注)
  218. *
  219. * @return
  220. */
  221. public String getHotAgentsList() {
  222. SQLFactory agentlistSql = null;
  223. if (content.containsKey("ftype") && !"".equals(content.getString("ftype"))) {
  224. String ftype = content.getString("ftype");
  225. agentlistSql = new SQLFactory(this, "热门商户列表", pageSize, pageNumber, "t1.frownum");
  226. agentlistSql.addParameter("ftype", ftype);
  227. agentlistSql.addParameter("siteid", siteid);
  228. } else {
  229. agentlistSql = new SQLFactory(this, "热门商户列表_全部", pageSize, pageNumber, "t1.ftype,t1.frownum");
  230. agentlistSql.addParameter("siteid", siteid);
  231. }
  232. System.err.println(agentlistSql.getSQL());
  233. Rows rows = dbConnect.runSqlQuery(agentlistSql.getSQL());
  234. RowsMap map = getAttachmentUrl("texcellentagents", rows.toArrayList("texcellentagentsid"));
  235. for (Row row : rows) {
  236. row.put("attinfos", map.get(row.getString("texcellentagentsid")));
  237. }
  238. return getSucReturnObject().setData(rows).saveToDataPool(10).toString();
  239. }
  240. }