eganwu hace 1 año
padre
commit
85d4dc3bf7

+ 45 - 0
src/custom/restcontroller/R.java

@@ -5442,6 +5442,51 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID20240312111102 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240312133602 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240312142702 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240312145602 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240312151602 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240312161602 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240312162402 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240312163202 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240312163702 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 0 - 6
src/custom/restcontroller/webmanage/saletool/notice/SQL/通告新增.sql

@@ -1,6 +0,0 @@
-INSERT INTO sat_notice(sat_noticeid,siteid, createdepid, createuserid, createby, createdate, authuserid,
-                           authdepid,changeuserid, changeby, changedate, title, readcount,summary,content,
-                           sat_notice_classid, status, issecret, isontop,begdate,enddate)
-VALUES ($sat_noticeid$, $siteid$, $createdepid$, $createuserid$, $createby$, CURRENT_TIME, $authuserid$,
-        $authdepid$,
-        $changeuserid$, $changeby$, CURRENT_TIME, $title$, 0,$summary$,$content$, $sat_notice_classid$, '新建', $issecret$, $isontop$,$begdate$,$enddate$)

+ 0 - 21
src/custom/restcontroller/webmanage/saletool/notice/SQL/通告更新.sql

@@ -1,21 +0,0 @@
-UPDATE sat_notice
-SET siteid=$siteid$,
-    createdepid = $createdepid$,
-    authuserid = $authuserid$,
-    authdepid = $authdepid$,
-    changedate = CURRENT_TIME,
-    changeuserid = $changeuserid$,
-    changeby = $changeby$,
-    title = $title$,
-    summary = $summary$,
-    content = $content$,
-    issecret = $issecret$,
-    isontop = $isontop$,
-    begdate = $begdate$,
-    enddate = $enddate$,
-    sat_notice_classid = $sat_notice_classid$
-WHERE sat_noticeid = $sat_noticeid$ 
-
-
-
-

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

@@ -15,6 +15,7 @@ SELECT
     t1.status,
     t1.isontop,
     t1.readcount,
+    t1.publishdate,
 		(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) readstatus,
     (SELECT COUNT(*) FROM sat_notice_read WHERE  siteid = t1.siteid AND sat_noticeid = t1.sat_noticeid) readpersoncount,
     (SELECT count(*) FROM sys_attachment_links WHERE   siteid = t1.siteid AND ownerid = t1.sat_noticeid AND ownertable = 'sat_notice' ) attachmentcount

+ 83 - 126
src/custom/restcontroller/webmanage/saletool/notice/notice.java

@@ -10,10 +10,7 @@ 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 common.data.*;
 import restcontroller.R;
 
 import java.util.ArrayList;
@@ -21,6 +18,10 @@ import java.util.List;
 
 @API(title = "通告")
 public class notice extends Controller {
+
+    //表名
+    String sat_notice = "sat_notice";
+
     public notice(JSONObject content) throws YosException {
         super(content);
     }
@@ -29,72 +30,32 @@ public class notice extends Controller {
     @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);
+
+        if (sat_noticeid <= 0 || dbConnect.runSqlQuery("select sat_noticeid from sat_notice where sat_noticeid=" + sat_noticeid).isEmpty()) {
+            sat_noticeid = createTableID(sat_notice);
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, sat_notice);
+            insertSQL.setSiteid(siteid);
+            insertSQL.setUniqueid(sat_noticeid);
+            insertSQL.setValue("title", content.getString("title"));
+            insertSQL.setValue("status", content.getString("status"));
+            insertSQL.setValue("publishdate", content.getStringValueForDate("publishdate", "yyyy-MM-dd", "null"));
+            insertSQL.setValue("sat_notice_classid", content.getLongValue("sat_notice_classid"));
+            insertSQL.setValue("content", content.getString("content", true));
+            insertSQL.insert();
             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);
-            }
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, sat_notice);
+            updateSQL.setSiteid(siteid);
+            updateSQL.setUniqueid(sat_noticeid);
+            updateSQL.setValue("title", content.getString("title"));
+            updateSQL.setValue("status", content.getString("status"));
+            updateSQL.setValue("publishdate", content.getStringValueForDate("publishdate", "yyyy-MM-dd", "null"));
+            updateSQL.setValue("sat_notice_classid", content.getLongValue("sat_notice_classid"));
+            updateSQL.setValue("content", content.getString("content", true));
+            updateSQL.update();
+
+
         }
-        dbConnect.runSqlUpdate(sqllist);
         return queryNoticeMain();
     }
 
@@ -120,21 +81,22 @@ public class notice extends Controller {
             if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
                 where = where + " and t1.status ='" + whereObject.getString("status") + "' ";
             }
+            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") + "'";
             }
-            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)>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)>0 THEN '已读' ELSE '未读' END)='未读'";
-                }
-
-
-            }
+//            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)>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)>0 THEN '已读' ELSE '未读' END)='未读'";
+//                }
+//            }
 
         }
         SQLFactory sqlFactory = new SQLFactory(this, "通告列表查询", pageSize, pageNumber, pageSorting);
@@ -155,10 +117,6 @@ public class notice extends Controller {
             } 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", "");
@@ -166,6 +124,7 @@ public class notice extends Controller {
                 row.put("cover", coverRows.get(0).getString("url"));
             }
         }
+
         return getSucReturnObject().setData(rows).toString();
     }
 
@@ -179,12 +138,24 @@ public class notice extends Controller {
         sqlFactory.addParameter("userid", userid);
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
 
-        ArrayList<Long> ids = rows.toArrayList("sat_noticeid", new ArrayList<Long>());
+        ArrayList<Long> ids = rows.toArrayList("sat_noticeid", new ArrayList<>());
         // 附件
         RowsMap attRowsMap = getAttachmentUrl("sat_notice", ids, "default");
         // 封面cover
         RowsMap coverRowsMap = getAttachmentUrl("sat_notice", ids, "cover");
-        for (Row row : rows) {
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_notice_auth",
+                "roleid");
+        querySQL.addJoinTable(JOINTYPE.inner, "sys_role", "t2", "t1.roleid=t2.roleid and t1.siteid=t2.siteid",
+                "rolename");
+        querySQL.setTableAlias("t1");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t1.sat_noticeid", sat_noticeid);
+        Rows roleRows = querySQL.query();
+
+        Row row = new Row();
+        if (rows.isNotEmpty()) {
+            row = rows.get(0);
             Rows coverRows = coverRowsMap.get(row.getString("sat_noticeid"));
             if (coverRows.isEmpty()) {
                 row.put("cover", "");
@@ -192,9 +163,13 @@ public class notice extends Controller {
                 row.put("cover", coverRows.get(0).getString("url"));
             }
             row.put("attinfos", attRowsMap.getOrDefault(row.getString("sat_noticeid"), new Rows()));
+            row.putIfAbsent("publishdate", "");
+
+            row.put("role", roleRows);
         }
 
-        return getSucReturnObject().setData(rows.size() > 0 ? rows.get(0) : new Row()).toString();
+
+        return getSucReturnObject().setData(row).toString();
     }
 
     @API(title = "删除", apiversion = R.ID20221101095103.v1.class)
@@ -220,10 +195,8 @@ public class notice extends Controller {
             list.add(deletesql);
             dbConnect.runSqlUpdate(list);
         }
-        if (err.length() == 0)
-            return getSucReturnObject().toString();
-        else
-            return getSucReturnObject().setData(err).toString();
+        if (err.length() == 0) return getSucReturnObject().toString();
+        else return getSucReturnObject().setData(err).toString();
     }
 
     /**
@@ -237,8 +210,7 @@ public class notice extends Controller {
         JSONArray sat_noticeids = content.getJSONArray("sat_noticeids");
         String[] s = {"sat_noticeids"};
         for (String s1 : s) {
-            if (!content.containsKey(s1))
-                return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
+            if (!content.containsKey(s1)) return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
         }
         List<String> list = sat_noticeids.toJavaList(String.class);
         String[] stringArray = list.toArray(new String[0]);
@@ -258,9 +230,9 @@ public class notice extends Controller {
         sqlFactoryupdate.addParameter("checkby", username);
         dbConnect.runSqlUpdate(sqlFactoryupdate);
         //发送消息
-        for (String id : stringArray) {
-            //sendMsg(Long.parseLong(id));
-        }
+//        for (String id : stringArray) {
+//            //sendMsg(Long.parseLong(id));
+//        }
         return getSucReturnObject().toString();
     }
 
@@ -304,8 +276,7 @@ public class notice extends Controller {
         JSONArray sat_noticeids = content.getJSONArray("sat_noticeids");
         String[] s = {"sat_noticeids"};
         for (String s1 : s) {
-            if (!content.containsKey(s1))
-                return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
+            if (!content.containsKey(s1)) return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
         }
         List<String> list = sat_noticeids.toJavaList(String.class);
         String[] stringArray = list.toArray(new String[0]);
@@ -324,11 +295,11 @@ public class notice extends Controller {
         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"));
-            }
-        }
+//        for (String id : stringArray) {
+//            if (rows.isNotEmpty()) {
+//                //sendOffMsg(Long.parseLong(id), rows.get(0).getString("title"));
+//            }
+//        }
         return getSucReturnObject().toString();
     }
 
@@ -371,18 +342,15 @@ public class notice extends Controller {
     public String topping() throws YosException {
         String[] s = {"sat_noticeid"};
         for (String s1 : s) {
-            if (!content.containsKey(s1))
-                return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
+            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";
+        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"));
+        dbConnect.runSqlUpdate("update sat_notice set isontop=1 where sat_noticeid=" + content.getIntValue("sat_noticeid"));
 
         return getSucReturnObject().toString();
     }
@@ -397,17 +365,14 @@ public class notice extends Controller {
     public String cancelTopping() throws YosException {
         String[] s = {"sat_noticeid"};
         for (String s1 : s) {
-            if (!content.containsKey(s1))
-                return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
+            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";
+        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"));
+        dbConnect.runSqlUpdate("update sat_notice set isontop=0 where sat_noticeid=" + content.getIntValue("sat_noticeid"));
         return getSucReturnObject().toString();
     }
 
@@ -421,8 +386,7 @@ public class notice extends Controller {
         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 + "'");
+        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();
         }
@@ -449,8 +413,7 @@ public class notice extends Controller {
         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") + "%')";
+                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") + "' ";
@@ -466,19 +429,14 @@ public class notice extends Controller {
             }
         }
 
-        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)");
+        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 + "'");
+        dbConnect.runSqlUpdate("UPDATE sat_notice_read SET isdownloadfile=1 WHERE siteid = '" + siteid + "' AND sat_noticeid = '" + sat_noticeid + "' AND createuserid = '" + userid + "'");
         return getSucReturnObject().toString();
     }
 
@@ -546,8 +504,7 @@ public class notice extends Controller {
         // 新增浏览次数
         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 + "'";
+        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, "阅读记录新增");
@@ -558,7 +515,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, "阅读记录次数更新");
@@ -566,7 +523,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);
         }
     }

+ 292 - 2
src/custom/restcontroller/webmanage/saletool/notice/noticeauth.java

@@ -9,8 +9,7 @@ import beans.data.BatchDeleteErr;
 import common.Controller;
 import common.YosException;
 import common.annotation.API;
-import common.data.Rows;
-import common.data.SQLFactory;
+import common.data.*;
 import restcontroller.R;
 
 import java.util.ArrayList;
@@ -235,5 +234,296 @@ public class noticeauth extends Controller {
         return sqlFactory.getSQL();
     }
 
+    @API(title = "通告权限新增", apiversion = R.ID20240312111102.v1.class)
+    public String add() throws YosException {
+        Long sat_noticeid = content.getLongValue("sat_noticeid");
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+        if (content.containsKey("sys_enterpriseids")) {
+            JSONArray sys_enterpriseids = content.getJSONArray("sys_enterpriseids");
+            for (Object obj : sys_enterpriseids) {
+                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_notice_auth");
+                insertSQL.setUniqueid(createTableID("sat_notice_auth"));
+                insertSQL.setSiteid(siteid);
+                insertSQL.setValue("sat_noticeid", sat_noticeid);
+                insertSQL.setValue("sys_enterpriseid", obj);
+                insertSQL.setWhere("not exists(select 1 from  sat_notice_auth where sys_enterpriseid=" + obj + " and sat_noticeid=" + sat_noticeid + " and siteid='" + siteid + "' )");
+                sqlList.add(insertSQL.getSQL());
+            }
+        }
+
+        if (content.containsKey("departmentids")) {
+            JSONArray departmentids = content.getJSONArray("departmentids");
+            for (Object obj : departmentids) {
+                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_notice_auth");
+                insertSQL.setUniqueid(createTableID("sat_notice_auth"));
+                insertSQL.setSiteid(siteid);
+                insertSQL.setValue("sat_noticeid", sat_noticeid);
+                insertSQL.setValue("departmentid", obj);
+                insertSQL.setWhere("not exists(select 1 from  sat_notice_auth where departmentid=" + obj + " and sat_noticeid=" + sat_noticeid + " and siteid='" + siteid + "' )");
+                sqlList.add(insertSQL.getSQL());
+            }
+        }
+
+        if (content.containsKey("hrids")) {
+            JSONArray hrids = content.getJSONArray("hrids");
+            for (Object obj : hrids) {
+                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_notice_auth");
+                insertSQL.setUniqueid(createTableID("sat_notice_auth"));
+                insertSQL.setSiteid(siteid);
+                insertSQL.setValue("sat_noticeid", sat_noticeid);
+                insertSQL.setValue("hrid", obj);
+                insertSQL.setWhere("not exists(select 1 from  sat_notice_auth where hrid=" + obj + " and sat_noticeid=" + sat_noticeid + " and siteid='" + siteid + "' )");
+                sqlList.add(insertSQL.getSQL());
+            }
+        }
+
+        if (content.containsKey("sa_saleareaids")) {
+            JSONArray sa_saleareaids = content.getJSONArray("sa_saleareaids");
+            for (Object obj : sa_saleareaids) {
+                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_notice_auth");
+                insertSQL.setUniqueid(createTableID("sat_notice_auth"));
+                insertSQL.setSiteid(siteid);
+                insertSQL.setValue("sat_noticeid", sat_noticeid);
+                insertSQL.setValue("sa_saleareaid", obj);
+                insertSQL.setWhere("not exists(select 1 from  sat_notice_auth where sa_saleareaid=" + obj + " and sat_noticeid=" + sat_noticeid + " and siteid='" + siteid + "' )");
+                sqlList.add(insertSQL.getSQL());
+            }
+        }
+
+        if (sqlList.size() > 0) {
+            dbConnect.runSqlUpdate(sqlList);
+        }
+
+
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "通告角色权限新增", apiversion = R.ID20240312133602.v1.class)
+    public String addrole() throws YosException {
+        Long sat_noticeid = content.getLongValue("sat_noticeid");
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+
+        JSONArray roleids = content.getJSONArray("roleids");
+        for (Object obj : roleids) {
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_notice_auth");
+            insertSQL.setUniqueid(createTableID("sat_notice_auth"));
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("sat_noticeid", sat_noticeid);
+            insertSQL.setValue("roleid", obj);
+            insertSQL.setValue("roleid", obj);
+            insertSQL.setWhere("not exists(select 1 from  sat_notice_auth where roleid=" + obj + " and sat_noticeid=" + sat_noticeid + " and siteid='" + siteid + "' )");
+            sqlList.add(insertSQL.getSQL());
+        }
+
+        if (sqlList.size() > 0) {
+            dbConnect.runSqlUpdate(sqlList);
+        }
+
+        DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_notice_auth");
+        deleteSQL.setSiteid(siteid);
+        deleteSQL.setWhere("sat_noticeid", sat_noticeid);
+        deleteSQL.setWhere("roleid not in " + roleids.toString().replace("[", "(").replace("]", ")") + "");
+        deleteSQL.delete();
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "通告角色权限删除", apiversion = R.ID20240312142702.v1.class)
+    public String deleteQuanXian() throws YosException {
+        Long sat_noticeid = content.getLongValue("sat_noticeid");
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+        if (content.containsKey("sys_enterpriseids")) {
+            JSONArray sys_enterpriseids = content.getJSONArray("sys_enterpriseids");
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_notice_auth");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setWhere("sat_noticeid", sat_noticeid);
+            deleteSQL.setWhere("sys_enterpriseid ", sys_enterpriseids.toArray());
+            sqlList.add(deleteSQL.getSQL());
+        }
+
+        if (content.containsKey("departmentids")) {
+            JSONArray departmentids = content.getJSONArray("departmentids");
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_notice_auth");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setWhere("sat_noticeid", sat_noticeid);
+            deleteSQL.setWhere("departmentid ", departmentids);
+            sqlList.add(deleteSQL.getSQL());
+        }
+
+        if (content.containsKey("hrids")) {
+            JSONArray hrids = content.getJSONArray("hrids");
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_notice_auth");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setWhere("sat_noticeid", sat_noticeid);
+            deleteSQL.setWhere("hrid ", hrids);
+            sqlList.add(deleteSQL.getSQL());
+        }
+
+        if (content.containsKey("sa_saleareaids")) {
+            JSONArray sa_saleareaids = content.getJSONArray("sa_saleareaids");
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_notice_auth");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setWhere("sat_noticeid", sat_noticeid);
+            deleteSQL.setWhere("sa_saleareaid ", sa_saleareaids);
+            sqlList.add(deleteSQL.getSQL());
+        }
+
+        if (sqlList.size() > 0) {
+            dbConnect.runSqlUpdate(sqlList);
+        }
+
+
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "选择成员", apiversion = R.ID20240312145602.v1.class)
+    public String chooseHr() throws YosException {
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.hrcode like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.depname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.position like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+
+        }
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_hr",
+                "hrid", "hrcode", "name", "phonenumber", "position");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t2", "t1.siteid=t2.siteid and t1.departmentid=t2.departmentid",
+                "depname");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere(where.toString());
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "选择合作伙伴", apiversion = R.ID20240312151602.v1.class)
+    public String chooseEnterprise() throws YosException {
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.type like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.address like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t4.erpagentnum like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+
+        }
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents",
+                "agentnum", "sys_enterpriseid", "type");
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+        querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
+                "enterprisename", "address");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t4", "t1.sys_enterpriseid = t4.ownerid and ownertable = 'sys_enterprise' and t1.siteid = t4.siteid",
+                "erpagentnum");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_tradefield", "t5", "t1.sys_enterpriseid = t5.sys_enterpriseid and t1.siteid = t5.siteid");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_salearea", "t6", "t5.sa_saleareaid=t6.sa_saleareaid and t5.siteid=t6.siteid",
+                "areaname");
+        querySQL.addQueryFields("pcc", "CONCAT(t2.province,t2.city,t2.county)");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere(where.toString());
+
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "部门列表",apiversion = R.ID20240312162402.v1.class)
+    public String depList() throws YosException {
+
+        Long sat_noticeid = content.getLongValue("sat_noticeid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_department",
+                "departmentid", "depname", "depno");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t2", "t2.departmentid=t1.parentid and t2.siteid=t1.siteid");
+        querySQL.addJoinTable(JOINTYPE.left, "sat_notice_auth", "t3", "t1.siteid=t3.siteid and t1.departmentid=t3.departmentid");
+        querySQL.addQueryFields("parentdepname","t2.depname");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t3.sat_noticeid",sat_noticeid);
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+
+        Rows rows = querySQL.query();
+
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "人员列表",apiversion = R.ID20240312161602.v1.class)
+    public String hrList() throws YosException {
+        Long sat_noticeid = content.getLongValue("sat_noticeid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_hr",
+                "hrid", "hrcode", "name",  "position");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t2", "t1.siteid=t2.siteid and t1.departmentid=t2.departmentid",
+                "depname");
+        querySQL.addJoinTable(JOINTYPE.left, "sat_notice_auth", "t3", "t1.siteid=t3.siteid and t1.hrid=t3.hrid");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t3.sat_noticeid",sat_noticeid);
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "区域列表",apiversion = R.ID20240312163202.v1.class)
+    public String areaList() throws YosException {
+
+        Long sat_noticeid = content.getLongValue("sat_noticeid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_salearea",
+                "areaname", "sa_saleareaid");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_salearea", "t2", "t2.sa_saleareaid=t1.parentid and t2.siteid=t1.siteid");
+        querySQL.addJoinTable(JOINTYPE.left, "sat_notice_auth", "t3", "t1.siteid=t3.siteid and t1.sa_saleareaid=t3.sa_saleareaid");
+        querySQL.addQueryFields("parentareaname","t2.areaname");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t3.sat_noticeid",sat_noticeid);
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+
+        Rows rows = querySQL.query();
+
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "合作伙伴列表",apiversion = R.ID20240312163702.v1.class)
+    public String enterpriseList() throws YosException {
+        Long sat_noticeid = content.getLongValue("sat_noticeid");
+
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents",
+                "agentnum", "sys_enterpriseid", "type");
+
+        querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
+                "enterprisename");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_tradefield", "t5", "t1.sys_enterpriseid = t5.sys_enterpriseid and t1.siteid = t5.siteid");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_salearea", "t6", "t5.sa_saleareaid=t6.sa_saleareaid and t5.siteid=t6.siteid",
+                "areaname");
+        querySQL.addJoinTable(JOINTYPE.left, "sat_notice_auth", "t3", "t1.siteid=t3.siteid and t1.sys_enterpriseid=t3.sys_enterpriseid");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t3.sat_noticeid",sat_noticeid);
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
 
 }