eganwu 2 лет назад
Родитель
Сommit
6089b93a27

+ 9 - 1
src/custom/restcontroller/R.java

@@ -5674,9 +5674,17 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20231108160203 {
+        public static class v1 {
+        }
+    }
 
+    public static class ID20240320152902 {
+        public static class v1 {
+        }
+    }
 
-    public static class ID20231108160203 {
+    public static class ID20240320153302 {
         public static class v1 {
         }
     }

+ 71 - 23
src/custom/restcontroller/saletool/notice/notice.java

@@ -1,17 +1,19 @@
 package restcontroller.saletool.notice;
 
+import beans.attachment.Attachment;
 import beans.department.Department;
+import beans.parameter.Parameter;
+import beans.remind.Remind;
 import beans.salearea.SaleArea;
 import com.alibaba.fastjson.JSONObject;
 import common.Controller;
 import common.YosException;
 import common.annotation.API;
 import common.annotation.CACHEING;
-import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
+import common.data.*;
 import restcontroller.R;
+import utility.email.Email;
+import utility.email.EmailContent;
 
 import java.util.ArrayList;
 
@@ -109,30 +111,76 @@ public class notice extends Controller {
         return getSucReturnObject().setData(rows).setTips(object).toString();
     }
 
-    @API(title = "通告详情")
-    public String queryNoticeMain() throws YosException {
+
+    @API(title = "确认已知", apiversion = R.ID20240320152902.v1.class)
+    public String confirmed() throws YosException {
         Long sat_noticeid = content.getLong("sat_noticeid");
-        // 新增记录
-        addReadRecord(sat_noticeid);
-        SQLFactory sqlFactory = new SQLFactory(this, "通告详情查询");
-        sqlFactory.addParameter("sat_noticeid", sat_noticeid);
-        sqlFactory.addParameter("userid", userid);
-        Rows rows = dbConnect.runSqlQuery(sqlFactory);
 
-        // 附件
-        ArrayList<Long> ids = rows.toArrayList("sat_noticeid", new ArrayList<Long>());
-        RowsMap attRowsMap = getAttachmentUrl("sat_notice", ids);
-        for (Row row : rows) {
-            Rows Rows = attRowsMap.get(row.getString("sat_noticeid"));
-            if (Rows.isEmpty()) {
-                row.put("attinfos", new Rows());
-            } else {
-                row.put("attinfos", Rows);
-            }
+        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_notice_read");
+        updateSQL.setSiteid(siteid);
+        updateSQL.setValue("confirmed", 1);
+        updateSQL.setWhere("sat_noticeid", sat_noticeid);
+        updateSQL.setWhere("createuserid", userid);
+        updateSQL.update();
+
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "发送邮件", apiversion = R.ID20240320153302.v1.class)
+    public String sendMail() throws Exception {
+        Long sat_noticeid = content.getLong("sat_noticeid");
+        String email = content.getStringValue("email");
+
+        if (!Parameter.get(siteid, "remind_mail").equalsIgnoreCase("1")) {
+            return getErrReturnObject().setErrMsg("邮件功能未开启").toString();
+        }
+
+        Rows rows = dbConnect.runSqlQuery("SELECT * from sat_notice where sat_noticeid=" + sat_noticeid);
+        if (rows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("数据不存在").toString();
         }
-        return getSucReturnObject().setData(rows.get(0)).toString();
+
+        Rows rowsAtt = Attachment.get(this, "sat_notice", sat_noticeid);
+
+        EmailContent emailContent = new EmailContent();
+        emailContent.addText(rows.get(0).getString("content"));
+        for (Row rowAtt : rowsAtt) {
+            emailContent.addFile(rowAtt.getString("url"));
+        }
+        Remind remind = new Remind(siteid);
+        remind.setTitle(rows.get(0).getString("title"));
+        remind.setToemail(email);
+        remind.setContent(emailContent);
+        remind.sendByMail();
+
+
+        return getSucReturnObject().toString();
     }
 
+//    @API(title = "通告详情")
+//    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);
+//        sqlFactory.addParameter("userid", userid);
+//        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+//
+//        // 附件
+//        ArrayList<Long> ids = rows.toArrayList("sat_noticeid", new ArrayList<Long>());
+//        RowsMap attRowsMap = getAttachmentUrl("sat_notice", ids);
+//        for (Row row : rows) {
+//            Rows Rows = attRowsMap.get(row.getString("sat_noticeid"));
+//            if (Rows.isEmpty()) {
+//                row.put("attinfos", new Rows());
+//            } else {
+//                row.put("attinfos", Rows);
+//            }
+//        }
+//        return getSucReturnObject().setData(rows.get(0)).toString();
+//    }
+
     /**
      * 查询阅读记录(通告留言和打分)
      *

+ 1 - 11
src/custom/restcontroller/webmanage/saletool/notice/SQL/通告列表查询.sql

@@ -5,19 +5,9 @@ SELECT
     t2.classname,
     t1.createby,
     t1.createdate,
-    t1.changeby,
-    t1.changedate,
-	t1.summary,
-    t1.begdate,
-    t1.enddate,
-	t1.checkdate,
 	t1.checkby,
     t1.status,
-    t1.isontop,
-    t1.readcount,
-		(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
+    t1.readcount
 FROM
     sat_notice t1
         LEFT JOIN sat_notice_class t2 ON t1.sat_notice_classid = t2.sat_notice_classid

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

@@ -1,26 +1,9 @@
 SELECT
-    t1.sat_noticeid,
-    t1.title,
-    t1.content,
-    t1.sat_notice_classid,
+    t1.*,
     t2.classname,
-    t1.createby,
-    t1.createdate,
-    t1.changeby,
-    t1.changedate,
-	t1.summary,
-    t1.begdate,
-    t1.enddate,
-	t1.checkdate,
-    t1.status,
-    t1.isontop,
-    t1.readcount,
-    t1.publishdate,
-    t1.checkby,
-	(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
+    (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 =1
  where t1.sat_noticeid = $sat_noticeid$

+ 10 - 4
src/custom/restcontroller/webmanage/saletool/notice/notice.java

@@ -81,9 +81,6 @@ 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") + "'";
             }
@@ -165,7 +162,16 @@ public class notice extends Controller {
             row.put("attinfos", attRowsMap.getOrDefault(row.getString("sat_noticeid"), new Rows()));
             row.putIfAbsent("publishdate", "");
 
-            row.put("role", roleRows.toArrayList("roleid",new ArrayList<Long>()));
+            row.put("role", roleRows.toArrayList("roleid", new ArrayList<Long>()));
+            if (row.getLong("confirmed") == 0) {
+                row.putIfAbsent("readstatus", "已读");
+            }
+            if (row.getLong("confirmed") == 1) {
+                row.putIfAbsent("readstatus", "已知");
+            }
+            if (row.getLong("confirmed") == 2) {
+                row.putIfAbsent("readstatus", "未读");
+            }
         }