package com.cnd3b.restcontroller.publicmethod.homepage; import com.alibaba.fastjson.JSONArray; 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.RowsMap; import com.cnd3b.common.data.SQLFactory; import p2.pao.PaoRemote; import p2.pao.PaoSetRemote; import p2.util.P2Exception; public class homepage extends Controller { public homepage(JSONObject content) { super(content); } /** * 统计数据展示 * * @return */ public String getStatisticalData() { SQLFactory sqlFactory = new SQLFactory(this, "统计数据展示"); sqlFactory.addParameter("siteid", siteid); Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL()); return getSucReturnObject().setData(rows).saveToDataPool(10).toString(); } /** * 供需分类选择查询 * * @return */ public String query_typeselectList() { Rows rows = dbConnect.runSqlQuery("select ttypedetailid,fvalue as ftype from ttypedetail where ftype = '供需分类' and siteid ='" + siteid + "' and fisused=1 order by sequence"); RowsMap map = getAttachmentUrl("ttypedetail", rows.toArrayList("ttypedetailid")); for (Row row : rows) { row.put("attinfos", map.get(row.getString("ttypedetailid"))); } return getSucReturnObject().setData(rows).toString(); } /** * 供需列表查询 * * @return */ public String query_supplyanddemandList() { /** *排序条件设置 */ String[] sortfield = {"t1.tsupplyanddemandid desc"}; String sort = getSort(sortfield, "t1.tsupplyanddemandid desc"); /** * 过滤条件设置 */ StringBuffer where = new StringBuffer(" 1=1 "); if (content.containsKey("where")) { JSONObject whereObject = content.getJSONObject("where"); if (whereObject.containsKey("ftype") && !"".equals(whereObject.getString("ftype"))) { where.append(" and t1.ftype ='").append(whereObject.getString("ftype")).append("' "); } } SQLFactory sqlFactory = new SQLFactory(this, "供需列表查询", pageSize, pageNumber, sort); sqlFactory.addParameter("siteid", siteid); sqlFactory.addParameter_SQL("where", where); Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL()); RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid")); for (Row row : rows) { //附件信息 row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid"))); row.put("headportraiturl", getHeadPic(row.getLong("tenterprise_userid"))); } return getSucReturnObject().setDataByPaging(rows).saveToDataPool().toString(); } /** * 供需详情查询 * * @return */ public String query_supplyanddemandMain() { long tsupplyanddemandid = content.getLongValue("tsupplyanddemandid"); long tagentsid = content.getLongValue("tagentsid"); SQLFactory sqlFactory = new SQLFactory(this, "供需详情查询"); sqlFactory.addParameter("siteid", siteid); sqlFactory.addParameter("tagentsid", tagentsid); sqlFactory.addParameter("tsupplyanddemandid", tsupplyanddemandid); Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL()); RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid")); for (Row row : rows) { //附件信息 row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid"))); row.put("headportraiturl", getHeadPic(row.getLong("tenterprise_userid"))); } return getSucReturnObject().setData(rows).toString(); } /** * 热门商户 * * @return */ public String agentList() { SQLFactory agentlistSql = null; if (content.containsKey("saleprodclass") && !"".equals(content.getString("saleprodclass"))) { String saleprodclass = content.getString("saleprodclass"); agentlistSql = new SQLFactory(this, "优质商户", pageSize, pageNumber, "t1.tagentsid"); agentlistSql.addParameter("saleprodclass", saleprodclass); agentlistSql.addParameter("siteid", siteid); } else { agentlistSql = new SQLFactory(this, "优质商户_全部", pageSize, pageNumber, "t1.tagentsid"); agentlistSql.addParameter("siteid", siteid); } Rows rows = agentlistSql.runSqlQuery(); RowsMap map = getAttachmentUrl("tagents", rows.toArrayList("tagentsid")); for (Row row : rows) { row.put("attinfos", map.get(row.getString("tagentsid"))); row.put("saleprodclass", JSONArray.parseArray(row.getString("saleprodclass"))); } return getSucReturnObject().setData(rows).saveToDataPool(10).toString(); } /** * 热门商户详情查询 * * @return */ public String agentsMain() { SQLFactory sql = new SQLFactory(this, "优质商户详情"); sql.addParameter("tagentsid", content.getString("tagentsid")); sql.addParameter("saleprodclass", content.getString("saleprodclass")); sql.addParameter("siteid", siteid); Rows rows = dbConnect.runSqlQuery(sql.getSQL()); for (Row row : rows) { row.put("saleprodclass", JSONArray.parseArray(row.getString("saleprodclass"))); row.put("attinfos", getAttachmentUrl("tagents", content.getString("tagentsid"))); } return getSucReturnObject().setData(rows).toString(); } /** * 热门商品 * * @return */ public String prodList() { long tagentsid = content.getLongValue("tagentsid"); SQLFactory prodlistSql = new SQLFactory(this, "优质商品", pageSize, pageNumber, "t1.tagents_productid"); prodlistSql.addParameter("siteid", siteid); prodlistSql.addParameter("tagentsid", tagentsid); //prodlistSql.addParameter("saleprodclass", content.getString("saleprodclass")); Rows rows = prodlistSql.runSqlQuery(); RowsMap map = getAttachmentUrl("tagents_product", rows.toArrayList("tagents_productid")); for (Row row : rows) { row.put("attinfos", map.get(row.getString("tagents_productid"))); } return getSucReturnObject().setDataByPaging(rows).saveToDataPool(10).toString(); } /** * 展会活动信息 * * @return */ public String activityMsg() { SQLFactory sql = new SQLFactory(this, "活动信息展示"); Rows rows = sql.runSqlQuery(); return getSucReturnObject().setData(rows).toString(); } /** * 获取管理端发布的最新通告 */ public String getNewestNoticeList() { SQLFactory sql = new SQLFactory(this, "最新管理端发布的通告", pageSize, pageNumber, "t1.createdate DESC"); Rows rows = sql.runSqlQuery(); for (Row row : rows) { row.put("attinfos", getAttachmentUrl("tnotice", row.getString("tnoticeid"))); } return getSucReturnObject().setDataByPaging(rows).preloading(1).toString(); } /** * 通告主界面查询 * * @return */ public String query_noticeMain() { String tnoticeid = content.getString("tnoticeid"); SQLFactory noticehead = new SQLFactory(this, "通告主界面查询"); noticehead.addParameter("siteid", siteid); noticehead.addParameter("tnoticeid", tnoticeid); Rows rows = dbConnect.runSqlQuery(noticehead.getSQL()); Rows attinfosRows = getAttachmentUrl("tnotice", tnoticeid); rows.get(0).put("attinfos", attinfosRows); rows.get(0).put("headportraiturl", getHeadPic(rows.get(0).getLong("tenterprise_userid"))); return getSucReturnObject().setData(rows).toString(); } /** * 新增招商管理表单 * * @return * @throws P2Exception */ public String insertBusiness() throws P2Exception { String province = content.getString("province"); String city = content.getString("city"); String county = content.getString("county"); String address = content.getString("address"); String fname = content.getString("fname"); String fphone = content.getString("fphone"); String fnote = content.getString("fnote"); PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tbusiness"); PaoRemote paoRemote = paoSetRemote.addAtEnd(); paoRemote.setValue("province", province, 11L); paoRemote.setValue("city", city, 11L); paoRemote.setValue("county", county, 11L); paoRemote.setValue("address", address, 11L); paoRemote.setValue("fname", fname, 11L); paoRemote.setValue("fphone", fphone, 11L); paoRemote.setValue("fnote", fnote, 11L); paoRemote.setValue("tbusinessid", paoRemote.getUniqueIDValue(), 11L); paoSetRemote.save(); return getSucReturnObject().toString(); } /** * 获取热门商户列表(关注) * * @return */ public String getHotAgentsList() { SQLFactory agentlistSql = null; if (content.containsKey("ftype") && !"".equals(content.getString("ftype"))) { String ftype = content.getString("ftype"); agentlistSql = new SQLFactory(this, "热门商户列表", pageSize, pageNumber, "t1.frownum"); agentlistSql.addParameter("ftype", ftype); agentlistSql.addParameter("siteid", siteid); } else { agentlistSql = new SQLFactory(this, "热门商户列表_全部", pageSize, pageNumber, "t1.ftype,t1.frownum"); agentlistSql.addParameter("siteid", siteid); } Rows rows = dbConnect.runSqlQuery(agentlistSql.getSQL()); RowsMap map = getAttachmentUrl("texcellentagents", rows.toArrayList("texcellentagentsid")); for (Row row : rows) { row.put("attinfos", map.get(row.getString("texcellentagentsid"))); } return getSucReturnObject().setData(rows).saveToDataPool(10).toString(); } /** * 获取热门商品列表(关注榜) * * @return */ public String getHotProductsList() { String ftype = content.getString("ftype"); if (ftype == null) { ftype = ""; } SQLFactory prodlistSql = new SQLFactory(this, "新品列表", pageSize, pageNumber, "t1.ftype,t1.frownum"); if (prodlistSql == null) { return getErrReturnObject().setErrMsg("prodlistSql is null").toString(); } prodlistSql.addParameter("siteid", siteid); prodlistSql.addParameter("ftype", "%" + ftype + "%"); Rows rows = dbConnect.runSqlQuery(prodlistSql.getSQL()); for (Row row : rows) { row.put("attinfos", getAttachmentUrl("texcellenproducts", row.getString("texcellenproductid"))); } return getSucReturnObject().setDataByPaging(rows).toString(); } /** * 门户搜索 * * @return */ public String searchPortalInfo() { JSONObject resultObject = new JSONObject(); String keyStr = content.getString("keyStr"); if (keyStr == null || keyStr.equals("")) { return getErrReturnObject().setErrMsg("搜索关键词不能为空").toString(); } String ftype = content.getString("ftype"); if (ftype == null) { ftype = ""; } //查询直播 if (ftype.equals("1") || ftype.equals("")) { SQLFactory sqlFactory_tlive = new SQLFactory(this, "搜索_直播"); sqlFactory_tlive.addParameter("siteid", siteid); sqlFactory_tlive.addParameter("keyStr", "%" + keyStr + "%"); Rows row_tlive = dbConnect.runSqlQuery(sqlFactory_tlive.getSQL()); resultObject.put("tlive", row_tlive); } else { resultObject.put("tlive", new Rows()); } //查询供需 if (ftype.equals("2") || ftype.equals("")) { SQLFactory sqlFactory_tsupplyanddemand = new SQLFactory(this, "搜索_供需"); sqlFactory_tsupplyanddemand.addParameter("siteid", siteid); sqlFactory_tsupplyanddemand.addParameter("keyStr", "%" + keyStr + "%"); Rows row_tsupplyanddemand = dbConnect.runSqlQuery(sqlFactory_tsupplyanddemand.getSQL()); //附件 RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", row_tsupplyanddemand.toArrayList("tsupplyanddemandid")); for (Row row : row_tsupplyanddemand) { //附件信息 row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid"))); row.put("headportraiturl", getHeadPic(row.getLong("tenterprise_userid"))); } resultObject.put("tsupplyanddemand", row_tsupplyanddemand); } else { resultObject.put("tsupplyanddemand", new Rows()); } //查询通告 if (ftype.equals("3") || ftype.equals("")) { SQLFactory sqlFactory_tnotice = new SQLFactory(this, "搜索_通告"); sqlFactory_tnotice.addParameter("siteid", siteid); sqlFactory_tnotice.addParameter("keyStr", "%" + keyStr + "%"); Rows row_notice = dbConnect.runSqlQuery(sqlFactory_tnotice.getSQL()); //附件信息 RowsMap attinfoRowsMap = getAttachmentUrl("tnotice", row_notice.toArrayList("tnoticeid")); for (Row row : row_notice) { row.put("attinfos", attinfoRowsMap.get(row.getString("tnoticeid"))); row.put("headportraiturl", getHeadPic(row.getLong("tenterprise_userid"))); } resultObject.put("TNOTICE", row_notice); } else { resultObject.put("TNOTICE", new Rows()); } return getSucReturnObject().setData(resultObject).toString(); } }