| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- package com.cnd3b.restcontroller.customer.wechatapplet;
- 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 com.cnd3b.common.parameter.parameter;
- import com.cnd3b.utility.WebRequest;
- import com.cnd3b.utility.wechatdock.WechatDock_Enterprise;
- import org.apache.commons.codec.digest.DigestUtils;
- import p2.pao.PaoRemote;
- import p2.pao.PaoSetRemote;
- import p2.util.P2Exception;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- public class wechatapplet extends Controller {
- /**
- * 构造函数
- *
- * @param content
- */
- public wechatapplet(JSONObject content) {
- super(content);
- }
- /**
- * 获取培训学习列表
- *
- * @return
- */
- public String getCoursewareList() throws P2Exception {
- String ttypedetailid = content.getString("ttypedetailid");
- String keywords = "";
- if (content.containsKey("keywords")) {
- keywords = content.getString("keywords");
- }
- SQLFactory sqlFactory = new SQLFactory(this, "查询课件列表", pageSize, pageNumber, " t1.createdate desc");
- sqlFactory.addParameter("ttypedetailid", ttypedetailid);
- sqlFactory.addParameter("keywords", "%" + keywords + "%");
- Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
- // RowsMap rowsMap = getAttachmentUrl("tarchives_sc", rows.toArrayList("tarchives_scid"), "video");
- //查询封面
- RowsMap rowsMapCover = getAttachmentUrl("tarchives_sc", rows.toArrayList("tarchives_scid"), "cover");
- for (Row row : rows) {
- // row.put("attinfos", rowsMap.get(row.getString("tarchives_scid")));
- Rows coverRows = rowsMapCover.get(row.getString("tarchives_scid"));
- if (!coverRows.isEmpty()) {
- row.put("cover", coverRows.get(0).getString("fobsurl"));
- } else {
- row.put("cover", "");
- }
- }
- createRequestLog();
- return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
- }
- /**
- * 获取课件详情
- *
- * @return
- */
- public String getCoursewareDetail() throws P2Exception {
- String tarchives_scid = content.getString("tarchives_scid");
- //已学习人数加一
- String sql = "UPDATE tarchives_sc SET fvisitors= CASE WHEN fvisitors IS NULL THEN 1 else fvisitors + 1 END where tarchives_scid='" + tarchives_scid + "'";
- dbConnect.runSqlUpdate(sql);
- SQLFactory sqlFactory = new SQLFactory(this, "查询课件详细");
- sqlFactory.addParameter("tarchives_scid", tarchives_scid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
- RowsMap rowsMap = getAttachmentUrl("tarchives_sc", rows.toArrayList("tarchives_scid"), "video");
- //查询封面
- RowsMap rowsMapCover = getAttachmentUrl("tarchives_sc", rows.toArrayList("tarchives_scid"), "cover");
- for (Row row : rows) {
- row.put("attinfos", rowsMap.get(row.getString("tarchives_scid")));
- Rows coverRows = rowsMapCover.get(row.getString("tarchives_scid"));
- if (!coverRows.isEmpty()) {
- row.put("cover", coverRows.get(0).getString("fobsurl"));
- }
- }
- if (rows.isEmpty()) {
- return getErrReturnObject().setErrMsg("未找到当前课件").toString();
- }
- createRequestLog();
- return getSucReturnObject().setData(rows.get(0)).toString();
- }
- /**
- * 获取分类
- *
- * @return
- * @throws P2Exception
- */
- public String getTypeList() throws P2Exception {
- String fusertype = content.getString("fusertype");
- String where = "";
- //1表示业务员
- if (fusertype.equals("1")) {
- where = "t1.fissaler ='1'";
- } else {
- where = "t1.fisagent ='1'";
- }
- String fparentid = content.getString("fparentid");
- SQLFactory sqlFactory = new SQLFactory(this, "分类");
- sqlFactory.addParameter_SQL("fparentid", fparentid);
- sqlFactory.addParameter_SQL("where", where);
- String sql = sqlFactory.getSQL();
- Rows rows = dbConnect.runSqlQuery(sql);
- createRequestLog();
- return getSucReturnObject().setData(rows).toString();
- }
- /**
- * 新增日志
- */
- private void createRequestLog() {
- new Thread() {
- @Override
- public void run() {
- String sql = "SELECT*FROM tuserrequestlog WHERE fdate='" + getDate_Str() + "' AND tuserid='" + parameter.tuserid + "'";
- Rows rows = dbConnect.runSqlQuery(sql);
- if (rows.isEmpty()) {
- SQLFactory sqlFactory = new SQLFactory(this, "新增日志");
- sqlFactory.addParameter("tuserrequestlogid", createTableID("tuserrequestlog", "tuserrequestlogid"));
- sqlFactory.addParameter("siteid", parameter.defaultsiteid);
- sqlFactory.addParameter("fdate", getDate_Str());
- sqlFactory.addParameter("flastrequestdate", getDateTime_Str());
- sqlFactory.addParameter("tuserid", parameter.tuserid);
- dbConnect.runSqlUpdate(sqlFactory.getSQL());
- } else {
- String id = rows.get(0).getString("tuserrequestlogid");
- String sqlUpdate = "UPDATE tuserrequestlog SET frequesttimes=frequesttimes+1,flastrequestdate = '" + getDateTime_Str() + "' WHERE tuserrequestlogid = '" + id + "'";
- dbConnect.runSqlUpdate(sqlUpdate);
- }
- }
- }.start();
- }
- }
|