eganwu 1 год назад
Родитель
Сommit
ea4a748ac6

+ 4 - 12
src/custom/restcontroller/saletool/notice/SQL/通告列表查询.sql

@@ -1,22 +1,14 @@
 SELECT
     t1.sat_noticeid,
     t1.title,
-    t1.sat_notice_classid,
-    t2.classname,
-    t1.createby,
-    t1.createdate,
-    t1.changeby,
-    t1.changedate,
-	t1.summary,
-    t1.begdate,
-    t1.enddate,
-	t1.checkdate,
+    t1.checkdate,
     t1.status,
-     t1.isontop,
-    t1.readcount
+    t2.classname,
+    (CASE WHEN  (t3.confirmed is null) THEN 2 ELSE t3.confirmed END) confirmed
 FROM
     sat_notice t1
         LEFT JOIN sat_notice_class t2 ON t1.sat_notice_classid = t2.sat_notice_classid
+        left join sat_notice_read t3 on t3.siteid = t1.siteid AND t3.sat_noticeid = t1.sat_noticeid and t3.createuserid =$userid$
 where $where$ and t1.status='发布' and t1.siteid=$siteid$ AND t1.sat_noticeid IN
 (
 SELECT sat_noticeid FROM sat_notice_auth WHERE

+ 41 - 30
src/custom/restcontroller/saletool/notice/notice.java

@@ -26,7 +26,6 @@ public class notice extends Controller {
     }
 
     @API(title = "通告列表", apiversion = R.ID20221111090904.v1.class)
-    @CACHEING
     public String queryNoticeList() throws YosException {
         String where = " 1=1 ";
         if (content.containsKey("where")) {
@@ -38,10 +37,17 @@ 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.getLongValue("isread") == 0) {
+                    where = where + " and t3.confirmed =0";
+                }
+                //已知
+                if (whereObject.getLongValue("isread") == 1) {
+                    where = where + " and t3.confirmed =1";
+                }
+                //未读
+                if (whereObject.getLongValue("isread") == 2) {
+                    where = where + " and t3.confirmed is null";
                 }
             }
         }
@@ -59,11 +65,14 @@ public class notice extends Controller {
         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<>());
+        userid = 23797;
+        ArrayList<Long> roleids = dbConnect.runSqlQuery("SELECT roleid from sys_userrole WHERE userid=" + userid + " and siteid='" + siteid + "' ").toArrayList("roleid", new ArrayList<>());
         if (roleids.size() == 0) {
             roleids.add(-1L);
         }
+        if (pageSorting.equals("''")) {
+            pageSorting = "t1.checkdate desc";
+        }
 
         SQLFactory sqlFactory = new SQLFactory(this, "通告列表查询", pageSize, pageNumber, pageSorting);
         sqlFactory.addParameter_SQL("where", where);
@@ -77,33 +86,35 @@ public class notice extends Controller {
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
 
 
-        ArrayList<Long> ids = rows.toArrayList("sat_noticeid", new ArrayList<Long>());
-        // 封面cover
-        RowsMap coverRowsMap = getAttachmentUrl("sat_notice", ids, "cover");
-        // 附件
-        RowsMap RowsMap = getAttachmentUrl("sat_notice", ids);
+//        ArrayList<Long> ids = rows.toArrayList("sat_noticeid", new ArrayList<Long>());
+//        // 封面cover
+//        RowsMap coverRowsMap = getAttachmentUrl("sat_notice", ids, "cover");
+//        // 附件
+//        RowsMap RowsMap = getAttachmentUrl("sat_notice", ids);
         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);
+//            Rows Rows = RowsMap.get(row.getString("sat_noticeid"));
+//            if (Rows.isEmpty()) {
+//                row.put("attinfos", new Rows());
+//            } else {
+//                row.put("attinfos", Rows);
+//            }
+//            Rows coverRows = coverRowsMap.get(row.getString("sat_noticeid"));
+//            if (coverRows.isEmpty()) {
+//                row.put("cover", "");
+//            } else {
+//                row.put("cover", coverRows.get(0).getString("url"));
+//            }
+            if (row.getLong("confirmed") == 0) {
+                row.putIfAbsent("readstatus", "已读");
+            }
+            if (row.getLong("confirmed") == 1) {
+                row.putIfAbsent("readstatus", "已知");
             }
-            Rows coverRows = coverRowsMap.get(row.getString("sat_noticeid"));
-            if (coverRows.isEmpty()) {
-                row.put("cover", "");
-            } else {
-                row.put("cover", coverRows.get(0).getString("url"));
+            if (row.getLong("confirmed") == 2) {
+                row.putIfAbsent("readstatus", "未读");
             }
         }
-//        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", rows.getTotalRows());
 

+ 1 - 1
src/custom/restcontroller/webmanage/saletool/notice/SQL/通告详情查询.sql

@@ -5,5 +5,5 @@ SELECT
 FROM
     sat_notice t1
         LEFT JOIN sat_notice_class t2 ON t1.sat_notice_classid = t2.sat_notice_classid
-        left join sat_notice_read t3 on t3.siteid = t1.siteid AND t3.sat_noticeid = t1.sat_noticeid and t3.createuserid =1
+        left join sat_notice_read t3 on t3.siteid = t1.siteid AND t3.sat_noticeid = t1.sat_noticeid and t3.createuserid =$userid$
  where t1.sat_noticeid = $sat_noticeid$