|
|
@@ -1,5 +1,7 @@
|
|
|
package restcontroller.saletool.notice;
|
|
|
|
|
|
+import beans.department.Department;
|
|
|
+import beans.salearea.SaleArea;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import common.Controller;
|
|
|
import common.YosException;
|
|
|
@@ -24,13 +26,6 @@ public class notice extends Controller {
|
|
|
@API(title = "通告列表", apiversion = R.ID20221111090904.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");
|
|
|
@@ -41,24 +36,45 @@ public class notice extends Controller {
|
|
|
where = where + " and t1.sat_notice_classid = " + whereObject.getString("sat_notice_classid");
|
|
|
}
|
|
|
if (whereObject.containsKey("isread") && !"".equals(whereObject.getString("isread"))) {
|
|
|
- if(whereObject.getBooleanValue("isread")){
|
|
|
- where = where + " and (CASE WHEN (SELECT COUNT(*) FROM sat_notice_read WHERE siteid = t1.siteid AND sat_noticeid = t1.sat_noticeid and createuserid ="+userid+")>0 THEN '已读' ELSE '未读' END)='已读'";
|
|
|
- }else{
|
|
|
- where = where + " and (CASE WHEN (SELECT COUNT(*) FROM sat_notice_read WHERE siteid = t1.siteid AND sat_noticeid = t1.sat_noticeid and createuserid ="+userid+")>0 THEN '已读' ELSE '未读' END)='未读'";
|
|
|
+ if (whereObject.getBooleanValue("isread")) {
|
|
|
+ where = where + " and (CASE WHEN (SELECT COUNT(*) FROM sat_notice_read WHERE siteid = t1.siteid AND sat_noticeid = t1.sat_noticeid and createuserid =" + userid + ")>0 THEN '已读' ELSE '未读' END)='已读'";
|
|
|
+ } else {
|
|
|
+ where = where + " and (CASE WHEN (SELECT COUNT(*) FROM sat_notice_read WHERE siteid = t1.siteid AND sat_noticeid = t1.sat_noticeid and createuserid =" + userid + ")>0 THEN '已读' ELSE '未读' END)='未读'";
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ ArrayList<Long> departmentids = new ArrayList<>();
|
|
|
+ departmentids.addAll(Department.getSubDepartmentIds(this, departmentid));
|
|
|
+ departmentids.add(departmentid);
|
|
|
+ if (departmentids.size() == 0) {
|
|
|
+ departmentids.add(-1l);
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<Long> sa_saleareaids = new ArrayList<>();
|
|
|
+ sa_saleareaids.addAll(SaleArea.getSubSaleAreaIds(this, userInfo.getSaleAreaIds()));
|
|
|
+ sa_saleareaids.addAll(userInfo.getSaleAreaIds());
|
|
|
+ if (sa_saleareaids.size() == 0) {
|
|
|
+ sa_saleareaids.add(-1l);
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<Long> roleids = dbConnect.runSqlQuery("SELECT roleid from sys_userrole WHERE userid=23797 and siteid='" + siteid + "' ").toArrayList("roleid", new ArrayList<>());
|
|
|
+ if (roleids.size() == 0) {
|
|
|
+ roleids.add(-1L);
|
|
|
+ }
|
|
|
+
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "通告列表查询", pageSize, pageNumber, pageSorting);
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter_in("departmentid", departmentid);
|
|
|
+ sqlFactory.addParameter_in("departmentid", departmentids);
|
|
|
sqlFactory.addParameter_in("hrid", hrid);
|
|
|
sqlFactory.addParameter_in("userid", userid);
|
|
|
- sqlFactory.addParameter_in("sa_agentsid", userInfo.getAgentID());
|
|
|
- sqlFactory.addParameter_in("sa_saleareaid", userInfo.getSaleAreaIds());
|
|
|
+ sqlFactory.addParameter_in("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.addParameter_in("sa_saleareaid", sa_saleareaids);
|
|
|
+ sqlFactory.addParameter_in("roleid", roleids);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
|
|
|
+
|
|
|
ArrayList<Long> ids = rows.toArrayList("sat_noticeid", new ArrayList<Long>());
|
|
|
// 封面cover
|
|
|
RowsMap coverRowsMap = getAttachmentUrl("sat_notice", ids, "cover");
|
|
|
@@ -71,8 +87,6 @@ public class notice extends Controller {
|
|
|
} else {
|
|
|
row.put("attinfos", Rows);
|
|
|
}
|
|
|
- }
|
|
|
- for (Row row : rows) {
|
|
|
Rows coverRows = coverRowsMap.get(row.getString("sat_noticeid"));
|
|
|
if (coverRows.isEmpty()) {
|
|
|
row.put("cover", "");
|
|
|
@@ -80,16 +94,16 @@ public class notice extends Controller {
|
|
|
row.put("cover", coverRows.get(0).getString("url"));
|
|
|
}
|
|
|
}
|
|
|
- SQLFactory sqlFactorycount = new SQLFactory(this, "通告列表总数量查询");
|
|
|
- sqlFactorycount.addParameter("siteid", siteid);
|
|
|
- sqlFactorycount.addParameter_in("departmentid", departmentid);
|
|
|
- sqlFactorycount.addParameter_in("userid", userid);
|
|
|
- sqlFactorycount.addParameter_in("hrid", hrid);
|
|
|
- sqlFactorycount.addParameter_in("sa_agentsid", userInfo.getAgentID());
|
|
|
- sqlFactorycount.addParameter_in("sa_saleareaid", userInfo.getSaleAreaIds());
|
|
|
- Row readrow = dbConnect.runSqlQuery(0, sqlFactorycount);
|
|
|
+// SQLFactory sqlFactorycount = new SQLFactory(this, "通告列表总数量查询");
|
|
|
+// sqlFactorycount.addParameter("siteid", siteid);
|
|
|
+// sqlFactorycount.addParameter_in("departmentid", departmentid);
|
|
|
+// sqlFactorycount.addParameter_in("userid", userid);
|
|
|
+// sqlFactorycount.addParameter_in("hrid", hrid);
|
|
|
+// sqlFactorycount.addParameter_in("sa_agentsid", userInfo.getAgentID());
|
|
|
+// sqlFactorycount.addParameter_in("sa_saleareaid", userInfo.getSaleAreaIds());
|
|
|
+// Row readrow = dbConnect.runSqlQuery(0, sqlFactorycount);
|
|
|
JSONObject object = new JSONObject();
|
|
|
- object.put("readNum", readrow.getLong("num"));
|
|
|
+ object.put("readNum", rows.getTotalRows());
|
|
|
|
|
|
|
|
|
return getSucReturnObject().setData(rows).setTips(object).toString();
|
|
|
@@ -160,7 +174,7 @@ public class notice extends Controller {
|
|
|
sqlFactory.addParameter("sat_noticeid", sat_noticeid);
|
|
|
sqlFactory.addParameter("userid", userid);
|
|
|
sqlFactory.addParameter("hrid", hrid);
|
|
|
- sqlFactory.addParameter("sa_agentsid", userInfo.getAgentID());
|
|
|
+ sqlFactory.addParameter("sa_agentsid", userInfo.getAgentID());
|
|
|
dbConnect.runSqlUpdate(sqlFactory);
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
@@ -191,7 +205,7 @@ public class notice extends Controller {
|
|
|
sqlFactory.addParameter("sat_noticeid", sat_noticeid);
|
|
|
sqlFactory.addParameter("createuserid", userid);
|
|
|
sqlFactory.addParameter("hrid", hrid);
|
|
|
- sqlFactory.addParameter("sa_agentsid", userInfo.getAgentID());
|
|
|
+ sqlFactory.addParameter("sa_agentsid", userInfo.getAgentID());
|
|
|
dbConnect.runSqlUpdate(sqlFactory);
|
|
|
} else {
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "阅读记录次数更新");
|
|
|
@@ -199,7 +213,7 @@ public class notice extends Controller {
|
|
|
sqlFactory.addParameter("sat_noticeid", sat_noticeid);
|
|
|
sqlFactory.addParameter("userid", userid);
|
|
|
sqlFactory.addParameter("hrid", hrid);
|
|
|
- sqlFactory.addParameter("sa_agentsid", userInfo.getAgentID());
|
|
|
+ sqlFactory.addParameter("sa_agentsid", userInfo.getAgentID());
|
|
|
dbConnect.runSqlUpdate(sqlFactory);
|
|
|
}
|
|
|
|