| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561 |
- package restcontroller.webmanage.saletool.notice;
- import beans.remind.Remind;
- import beans.user.User;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import common.Controller;
- import common.YosException;
- import common.annotation.API;
- import common.annotation.CACHEING;
- import common.annotation.CACHEING_CLEAN;
- import common.annotation.cm;
- import common.data.Row;
- import common.data.Rows;
- import common.data.RowsMap;
- import common.data.SQLFactory;
- import restcontroller.R;
- import java.util.ArrayList;
- import java.util.List;
- @API(title = "通告")
- public class notice extends Controller {
- public notice(JSONObject content) throws YosException {
- super(content);
- }
- @API(title = "通告新增修改", apiversion = R.ID20221101094803.v1.class)
- @CACHEING_CLEAN(cms = {@cm(clazz = notice.class, method = {"queryNoticeList"})})
- public String insertormodify_notice() throws YosException {
- long sat_noticeid = content.getLong("sat_noticeid");
- ArrayList<String> sqllist = new ArrayList<>();
- String title = content.getString("title");
- Long sat_notice_classid = content.getLong("sat_notice_classid");
- String summary = content.getString("summary");
- String content1 = content.getString("content", true);
- boolean issecret = content.getBoolean("issecret");
- boolean isontop = content.getBoolean("isontop");
- String begdate = content.getStringValue("begdate");
- String enddate = content.getStringValue("enddate");
- if (sat_noticeid <= 0 || dbConnect
- .runSqlQuery("select sat_noticeid from sat_notice where sat_noticeid=" + sat_noticeid).isEmpty()) {
- sat_noticeid = createTableID("sat_notice");
- SQLFactory sqlFactory = new SQLFactory(this, "通告新增");
- sqlFactory.addParameter("sat_noticeid", sat_noticeid);
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("createdepid", departmentid);
- sqlFactory.addParameter("createuserid", userid);
- sqlFactory.addParameter("createby", username);
- sqlFactory.addParameter("authuserid", userid);
- sqlFactory.addParameter("authdepid", departmentid);
- sqlFactory.addParameter("changeby", username);
- sqlFactory.addParameter("changeuserid", userid);
- sqlFactory.addParameter("title", title);
- sqlFactory.addParameter("sat_notice_classid", sat_notice_classid);
- sqlFactory.addParameter("summary", summary);
- sqlFactory.addParameter("content", content1);
- sqlFactory.addParameter("issecret", issecret);
- sqlFactory.addParameter("isontop", isontop);
- sqlFactory.addParameter("begdate", begdate.equals("") ? "null" : begdate);
- sqlFactory.addParameter("enddate", enddate.equals("") ? "null" : enddate);
- content.put("sat_noticeid", sat_noticeid);
- sqllist.add(sqlFactory.getSQL());
- if (isontop) {
- sqllist.add("update sat_notice set isontop=0 where isontop=1 and sat_noticeid !=" + sat_noticeid);
- }
- } else {
- Rows rowscount = dbConnect.runSqlQuery("select status from sat_notice where sat_noticeid=" + sat_noticeid);
- if (rowscount.isEmpty()) {
- return getErrReturnObject().setErrMsg("此通告不存在").toString();
- } else {
- if (!rowscount.get(0).getString("status").equals("新建")) {
- return getErrReturnObject().setErrMsg("非新建状态的通告无法更新").toString();
- }
- }
- SQLFactory sqlFactory = new SQLFactory(this, "通告更新");
- sqlFactory.addParameter("sat_noticeid", sat_noticeid);
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("createdepid", departmentid);
- sqlFactory.addParameter("authuserid", userid);
- sqlFactory.addParameter("authdepid", departmentid);
- sqlFactory.addParameter("changeby", username);
- sqlFactory.addParameter("changeuserid", userid);
- sqlFactory.addParameter("title", title);
- sqlFactory.addParameter("isontop", isontop);
- sqlFactory.addParameter("sat_notice_classid", sat_notice_classid);
- sqlFactory.addParameter("summary", summary);
- sqlFactory.addParameter("content", content1);
- sqlFactory.addParameter("issecret", issecret);
- sqlFactory.addParameter("begdate", begdate.equals("") ? "null" : begdate);
- sqlFactory.addParameter("enddate", enddate.equals("") ? "null" : enddate);
- sqllist.add(sqlFactory.getSQL());
- if (isontop) {
- sqllist.add("update sat_notice set isontop=0 where isontop=1 and sat_noticeid !=" + sat_noticeid);
- }
- }
- dbConnect.runSqlUpdate(sqllist);
- return queryNoticeMain();
- }
- @API(title = "通告列表", apiversion = R.ID20221101094903.v1.class)
- @CACHEING
- public String queryNoticeList() throws YosException {
- /*
- 排序条件设置
- */
- String sort = "t1.createdate desc";
- /*
- 过滤条件设置
- */
- String where = " 1=1 ";
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where = where + " and t1.title like'%" + whereObject.getString("condition") + "%'";
- }
- if (whereObject.containsKey("sat_notice_classid") && !"".equals(whereObject.getString("sat_notice_classid"))) {
- where = where + " and t2.sat_notice_classid = " + whereObject.getString("sat_notice_classid");
- }
- if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
- where = where + " and t1.status ='" + whereObject.getString("status") + "' ";
- }
- if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
- where = where + " and t1.checkdate >='" + whereObject.getString("begindate") + "'";
- }
- if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
- where = where + " and t1.checkdate <='" + whereObject.getString("enddate") + "'";
- }
- }
- SQLFactory sqlFactory = new SQLFactory(this, "通告列表查询", pageSize, pageNumber, pageSorting);
- sqlFactory.addParameter_SQL("where", where);
- sqlFactory.addParameter("siteid", siteid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
- ArrayList<Long> ids = rows.toArrayList("sat_noticeid", new ArrayList<Long>());
- // 附件
- RowsMap RowsMap = getAttachmentUrl("sat_notice", ids);
- // 封面cover
- RowsMap coverRowsMap = getAttachmentUrl("sat_notice", ids, "cover");
- for (Row row : rows) {
- Rows Rows = RowsMap.get(row.getString("sat_noticeid"));
- if (Rows.isEmpty()) {
- row.put("attinfos", new Rows());
- } else {
- row.put("attinfos", Rows);
- }
- // row.put("attinfos", attRowsMap.getOrDefault(row.getString("sat_coursewareid"), new Rows()));
- }
- for (Row row : rows) {
- Rows coverRows = coverRowsMap.get(row.getString("sat_noticeid"));
- if (coverRows.isEmpty()) {
- row.put("cover", "");
- } else {
- row.put("cover", coverRows.get(0).getString("url"));
- }
- }
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "通告详情", apiversion = R.ID20221101095003.v1.class)
- public String queryNoticeMain() throws YosException {
- Long sat_noticeid = content.getLong("sat_noticeid");
- // 新增记录
- addReadRecord(sat_noticeid);
- SQLFactory sqlFactory = new SQLFactory(this, "通告详情查询");
- sqlFactory.addParameter("sat_noticeid", sat_noticeid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
- ArrayList<Long> ids = rows.toArrayList("sat_noticeid", new ArrayList<Long>());
- // 附件
- RowsMap attRowsMap = getAttachmentUrl("sat_notice", ids, "default");
- // 封面cover
- RowsMap coverRowsMap = getAttachmentUrl("sat_notice", ids, "cover");
- for (Row row : rows) {
- Rows coverRows = coverRowsMap.get(row.getString("sat_noticeid"));
- if (coverRows.isEmpty()) {
- row.put("cover", "");
- } else {
- row.put("cover", coverRows.get(0).getString("url"));
- }
- row.put("attinfos", attRowsMap.getOrDefault(row.getString("sat_noticeid"), new Rows()));
- }
- return getSucReturnObject().setData(rows.size() > 0 ? rows.get(0) : new Row()).toString();
- }
- @API(title = "删除", apiversion = R.ID20221101095103.v1.class)
- @CACHEING_CLEAN(cms = {@cm(clazz = notice.class, method = {"queryNoticeList"})})
- public String delete() throws YosException {
- JSONArray sat_noticeids = content.getJSONArray("sat_noticeids");
- StringBuffer err = new StringBuffer();
- for (Object o : sat_noticeids) {
- long sat_noticeid = Long.parseLong(o.toString());
- Rows rowscount = dbConnect.runSqlQuery("select title,status from sat_notice where sat_noticeid=" + sat_noticeid);
- if (rowscount.isEmpty()) {
- err.append(rowscount.get(0).getString("title")).append("--").append("此通告不存在,无法删除;");
- continue;
- } else if (!rowscount.get(0).getString("status").equals("新建")) {
- err.append(rowscount.get(0).getString("title")).append("--").append("非新建状态的通告无法删除;");
- continue;
- }
- ArrayList<String> list = new ArrayList<>();
- String deletesql = "delete from sat_notice where sat_noticeid=" + sat_noticeid;
- list.add(deletesql);
- dbConnect.runSqlUpdate(list);
- }
- if (err.length() == 0)
- return getSucReturnObject().toString();
- else
- return getSucReturnObject().setData(err).toString();
- }
- /**
- * 通告发布
- *
- * @return
- */
- @API(title = "发布", apiversion = R.ID20221101095203.v1.class)
- @CACHEING_CLEAN(apiversions = {R.ID20221111090904.v1.class, R.ID20221101094903.v1.class})
- public String release() throws YosException {
- JSONArray sat_noticeids = content.getJSONArray("sat_noticeids");
- String[] s = {"sat_noticeids"};
- for (String s1 : s) {
- if (!content.containsKey(s1))
- return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
- }
- List<String> list = sat_noticeids.toJavaList(String.class);
- String[] stringArray = list.toArray(new String[0]);
- SQLFactory sqlFactoryquery = new SQLFactory(this, "通告状态查询");
- sqlFactoryquery.addParameter("siteid", siteid);
- sqlFactoryquery.addParameter_in("sat_noticeids", stringArray);
- Rows rows = dbConnect.runSqlQuery(sqlFactoryquery);
- for (Row row : rows) {
- if (row.getString("status").equals("发布")) {
- return getErrReturnObject().setErrMsg("【" + row.getString("title") + "】通告已发布,无法再次发布").toString();
- }
- }
- SQLFactory sqlFactoryupdate = new SQLFactory(this, "通告发布");
- sqlFactoryupdate.addParameter("siteid", siteid);
- sqlFactoryupdate.addParameter_in("sat_noticeids", stringArray);
- sqlFactoryupdate.addParameter("checkby", username);
- dbConnect.runSqlUpdate(sqlFactoryupdate);
- //发送消息
- for (String id : stringArray) {
- //sendMsg(Long.parseLong(id));
- }
- return getSucReturnObject().toString();
- }
- /**
- * 发送消息:新课程发布,商学院发布范围内的经销商/人员
- *
- * @param id
- * @throws YosException
- */
- public void sendMsg(Long id) throws YosException {
- SQLFactory sqlFactory = new SQLFactory(this, "查询范围内的账号");
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("sat_noticeid", id);
- Rows useridRows = dbConnect.runSqlQuery(sqlFactory.getSQL());
- if (useridRows.isNotEmpty()) {
- for (Row row : useridRows) {
- Long tempUserid = row.getLong("userid");
- if (tempUserid != 0) {
- Remind remind = new Remind(this);
- remind.setType("应用");
- remind.setTitle("新通告发布");
- remind.setContent("您有新的通告,请查看!");
- remind.setTouserid(tempUserid);
- remind.sendByDialogMsg().createSys_message();
- remind.setToemail(User.getUserMailAddress(this, tempUserid));
- remind.sendByMail();
- }
- }
- }
- }
- /**
- * 通告下架
- *
- * @return
- */
- @API(title = "下架", apiversion = R.ID20221101095303.v1.class)
- @CACHEING_CLEAN(apiversions = {R.ID20221111090904.v1.class, R.ID20221101094903.v1.class})
- public String undercarriage() throws YosException {
- JSONArray sat_noticeids = content.getJSONArray("sat_noticeids");
- String[] s = {"sat_noticeids"};
- for (String s1 : s) {
- if (!content.containsKey(s1))
- return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
- }
- List<String> list = sat_noticeids.toJavaList(String.class);
- String[] stringArray = list.toArray(new String[0]);
- SQLFactory sqlFactoryquery = new SQLFactory(this, "通告状态查询");
- sqlFactoryquery.addParameter("siteid", siteid);
- sqlFactoryquery.addParameter_in("sat_noticeids", stringArray);
- Rows rows = dbConnect.runSqlQuery(sqlFactoryquery);
- for (Row row : rows) {
- if (row.getString("status").equals("新建")) {
- return getErrReturnObject().setErrMsg("【" + row.getString("title") + "】通告已下架,无法再次下架").toString();
- }
- }
- SQLFactory sqlFactoryupdate = new SQLFactory(this, "通告下架");
- sqlFactoryupdate.addParameter("siteid", siteid);
- sqlFactoryupdate.addParameter_in("sat_noticeids", stringArray);
- dbConnect.runSqlUpdate(sqlFactoryupdate);
- //发送消息
- for (String id : stringArray) {
- if (rows.isNotEmpty()) {
- sendOffMsg(Long.parseLong(id), rows.get(0).getString("title"));
- }
- }
- return getSucReturnObject().toString();
- }
- /**
- * 发送消息:新课程发布,商学院发布范围内的经销商/人员
- *
- * @param id
- * @throws YosException
- */
- public void sendOffMsg(Long id, String title) throws YosException {
- SQLFactory sqlFactory = new SQLFactory(this, "查询范围内的账号");
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("sat_noticeid", id);
- Rows useridRows = dbConnect.runSqlQuery(sqlFactory.getSQL());
- if (useridRows.isNotEmpty()) {
- for (Row row : useridRows) {
- Long tempUserid = row.getLong("userid");
- if (tempUserid != 0) {
- Remind remind = new Remind(this);
- remind.setType("应用");
- remind.setTitle("通告取消");
- remind.setContent("通告【" + title + "】已取消发布,请查看!");
- remind.setTouserid(tempUserid);
- remind.sendByDialogMsg().createSys_message();
- remind.setToemail(User.getUserMailAddress(this, tempUserid));
- remind.sendByMail();
- }
- }
- }
- }
- /**
- * 通告置顶
- *
- * @return
- */
- @API(title = "置顶", apiversion = R.ID20221101095403.v1.class)
- @CACHEING_CLEAN(cms = {@cm(clazz = notice.class, method = {"queryNoticeList"})})
- public String topping() throws YosException {
- String[] s = {"sat_noticeid"};
- for (String s1 : s) {
- if (!content.containsKey(s1))
- return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
- }
- String sqlName = "SELECT COUNT(*) count FROM sat_notice WHERE sat_noticeid = '"
- + content.getIntValue("sat_noticeid") + "' and isontop=1";
- Rows rowsName = dbConnect.runSqlQuery(sqlName);
- if (rowsName.get(0).getLong("count") > 0) {
- return getErrReturnObject().setErrMsg("此通告已置顶,无须再次置顶").toString();
- }
- dbConnect.runSqlUpdate("update sat_notice set isontop=0 where isontop=1 ");
- dbConnect.runSqlUpdate(
- "update sat_notice set isontop=1 where sat_noticeid=" + content.getIntValue("sat_noticeid"));
- return getSucReturnObject().toString();
- }
- /**
- * 通告取消置顶
- *
- * @return
- */
- @API(title = "取消置顶", apiversion = R.ID20221101095503.v1.class)
- @CACHEING_CLEAN(cms = {@cm(clazz = notice.class, method = {"queryNoticeList"})})
- public String cancelTopping() throws YosException {
- String[] s = {"sat_noticeid"};
- for (String s1 : s) {
- if (!content.containsKey(s1))
- return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
- }
- String sqlName = "SELECT COUNT(*) count FROM sat_notice WHERE sat_noticeid = '"
- + content.getIntValue("sat_noticeid") + "' and isontop=0";
- Rows rowsName = dbConnect.runSqlQuery(sqlName);
- if (rowsName.get(0).getLong("count") > 0) {
- return getErrReturnObject().setErrMsg("此通告已取消置顶,无须再次取消").toString();
- }
- dbConnect.runSqlUpdate(
- "update sat_notice set isontop=0 where sat_noticeid=" + content.getIntValue("sat_noticeid"));
- return getSucReturnObject().toString();
- }
- /**
- * 更新阅读记录(通告留言和打分)
- *
- * @return
- */
- @API(title = "更新阅读记录", apiversion = R.ID20221101095603.v1.class)
- public String updateReadRecord() throws YosException {
- Long sat_noticeid = content.getLong("sat_noticeid");
- int score = content.getInteger("score");
- String leavemessage = content.getString("leavemessage");
- Rows rows = dbConnect.runSqlQuery("select sat_notice_readid FROM sat_notice_read WHERE siteid = '" + siteid
- + "' AND sat_noticeid = '" + sat_noticeid + "' AND createuserid = '" + userid + "'");
- if (rows.isEmpty()) {
- return getErrReturnObject().setErrMsg("阅读记录不存在,无法更新").toString();
- }
- SQLFactory sqlFactory = new SQLFactory(this, "阅读记录更新");
- sqlFactory.addParameter("leavemessage", leavemessage);
- sqlFactory.addParameter("score", score);
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("sat_noticeid", sat_noticeid);
- sqlFactory.addParameter("userid", userid);
- dbConnect.runSqlUpdate(sqlFactory);
- return getSucReturnObject().toString();
- }
- /**
- * 查询阅读记录(通告留言和打分)
- *
- * @return
- */
- @API(title = "查询阅读记录", apiversion = R.ID20221101095703.v1.class)
- public String queryReadRecord() throws YosException {
- Long sat_noticeid = content.getLong("sat_noticeid");
- String where = " 1=1 ";
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where = where + " and (t1.leavemessage like'%" + whereObject.getString("condition")
- + "%' or t3.position like '%" + whereObject.getString("condition") + "%' or t1.createby like '%" + whereObject.getString("condition") + "%')";
- }
- if (whereObject.containsKey("score") && !"".equals(whereObject.getString("score"))) {
- where = where + " and t1.score ='" + whereObject.getString("score") + "' ";
- }
- if (whereObject.containsKey("usertype") && !"".equals(whereObject.getString("usertype"))) {
- where = where + " and t2.usertype ='" + whereObject.getString("usertype") + "' ";
- }
- if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
- where = where + " and t1.createdate >='" + whereObject.getString("begindate") + "'";
- }
- if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
- where = where + " and t1.createdate <='" + whereObject.getString("enddate") + "'";
- }
- }
- Rows rows = dbConnect
- .runSqlQuery("select t2.usertype,t3.position,t1.createdate,t1.createby,t1.leavemessage,t1.score,(SELECT count(*) FROM sat_notice_read WHERE siteid ='" + siteid + "' AND sat_noticeid = '" + sat_noticeid + "' and score>0) evaluatecount FROM sat_notice_read t1\n" +
- " left join sys_usersite t2 on t1.createuserid=t2.userid and t1.siteid=t2.siteid\n" +
- " left join sys_enterprise_hr t3 on t1.createuserid=t3.userid and t1.siteid=t3.siteid\n" +
- " WHERE " + where + " and t1.siteid = '" + siteid + "' AND t1.sat_noticeid ='" + sat_noticeid + "' and !(isnull(t1.leavemessage) and t1.score=0)");
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "更新下载附件记录")
- public String updateDownloadRecord() throws YosException {
- Long sat_noticeid = content.getLong("sat_noticeid");
- dbConnect.runSqlUpdate("UPDATE sat_notice_read SET isdownloadfile=1 WHERE siteid = '" + siteid
- + "' AND sat_noticeid = '" + sat_noticeid + "' AND createuserid = '" + userid + "'");
- return getSucReturnObject().toString();
- }
- @API(title = "通告阅读记录评分分析")
- public String scoreAnalysis() throws YosException {
- Long sat_noticeid = content.getLong("sat_noticeid");
- SQLFactory sqlFactory = new SQLFactory(this, "通告评分状况分析");
- sqlFactory.addParameter("sat_noticeid", sat_noticeid);
- sqlFactory.addParameter("siteid", siteid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
- return getSucReturnObject().setData(rows).toString();
- }
- /**
- * 通告阅读记录下载分析
- *
- * @return
- */
- @API(title = "通告阅读记录下载分析")
- public String fileDownloadAnalysis() throws YosException {
- Long sat_noticeid = content.getLong("sat_noticeid");
- SQLFactory sqlFactory = new SQLFactory(this, "通告附件下载状况分析");
- sqlFactory.addParameter("sat_noticeid", sat_noticeid);
- sqlFactory.addParameter("siteid", siteid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
- SQLFactory sqlFactory1 = new SQLFactory(this, "通告总人数统计查询");
- sqlFactory1.addParameter("sat_noticeid", sat_noticeid);
- sqlFactory1.addParameter("siteid", siteid);
- Rows rows1 = dbConnect.runSqlQuery(sqlFactory1);
- Rows rowscount = new Rows();
- Row row = new Row();
- row.put("sumcount", rows1.get(0).getLong("sumnum"));
- row.put("downloadcount", rows.get(0).getLong("downloadcount"));
- row.put("undownloadcount", rows1.get(0).getLong("sumnum") - rows.get(0).getLong("downloadcount"));
- rowscount.add(row);
- return getSucReturnObject().setData(rowscount).toString();
- }
- @API(title = "同板块间通告评分对比")
- public String scoreContrast() throws YosException {
- String where = " 1=1 ";
- int sat_notice_classid = content.getIntValue("sat_notice_classid");
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
- where = where + " and t1.checkdate >='" + whereObject.getString("begindate") + "'";
- }
- if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
- where = where + " and t1.checkdate <='" + whereObject.getString("enddate") + "'";
- }
- }
- SQLFactory sqlFactory = new SQLFactory(this, "同板块间通告评分对比");
- sqlFactory.addParameter_SQL("where", where);
- sqlFactory.addParameter("sat_notice_classid", sat_notice_classid);
- sqlFactory.addParameter("siteid", siteid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
- return getSucReturnObject().setData(rows).toString();
- }
- // 添加阅读记录
- public void addReadRecord(Long sat_noticeid) throws YosException {
- // 新增浏览次数
- dbConnect.runSqlUpdate("UPDATE sat_notice SET readcount=readcount+1 WHERE sat_noticeid='" + sat_noticeid + "'");
- // 查询当前用户的阅读记录是否存在
- String sql = "SELECT sat_notice_readid FROM sat_notice_read WHERE siteid = '" + siteid
- + "' AND sat_noticeid = '" + sat_noticeid + "' AND createuserid = '" + userid + "'";
- Rows rows = dbConnect.runSqlQuery(sql);
- if (rows.isEmpty()) {
- SQLFactory sqlFactory = new SQLFactory(this, "阅读记录新增");
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("sat_notice_readid", createTableID("sat_notice_read"));
- sqlFactory.addParameter("createby", username);
- sqlFactory.addParameter("changeby", username);
- sqlFactory.addParameter("sat_noticeid", sat_noticeid);
- sqlFactory.addParameter("createuserid", userid);
- sqlFactory.addParameter("hrid", hrid);
- sqlFactory.addParameter("sa_agentsid", userInfo.getAgentsId());
- dbConnect.runSqlUpdate(sqlFactory);
- } else {
- SQLFactory sqlFactory = new SQLFactory(this, "阅读记录次数更新");
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("sat_noticeid", sat_noticeid);
- sqlFactory.addParameter("userid", userid);
- sqlFactory.addParameter("hrid", hrid);
- sqlFactory.addParameter("sa_agentsid", userInfo.getAgentsId());
- dbConnect.runSqlUpdate(sqlFactory);
- }
- }
- }
|