From ee2316e2cb7afde1c54f5e4216a1b0d1e055749e Mon Sep 17 00:00:00 2001 From: xinyb <574600396@qq.com> Date: 星期五, 27 九月 2024 17:33:14 +0800 Subject: [PATCH] CRM邮箱配置调整 --- src/com/yc/crm/mail/service/MailImpl.java | 66 +++++++++++++++++++++++++++++++- 1 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/com/yc/crm/mail/service/MailImpl.java b/src/com/yc/crm/mail/service/MailImpl.java index d72ccf3..48a224d 100644 --- a/src/com/yc/crm/mail/service/MailImpl.java +++ b/src/com/yc/crm/mail/service/MailImpl.java @@ -259,6 +259,32 @@ } @Override + public List<t482101HList> getFolderMailList(String type, String userCode, Integer page, Integer limit) throws Exception { + String sql = "set nocount on\n"; + try { + String[] id = type.split("_"); + if (id.length != 2) { + throw new Exception("閭欢绫诲瀷Id鏍煎紡涓嶆纭�"); + } + sql += "select companyId,companyName,mailType,DocCode,senderName,sender,receiver,subject,plain_text," + + "receive_time,update_time,create_time,senderName,sender,userCode,userName,folder_id,delete_Flag, " + + "read_Flag,(case when (isnull(handle_time,'') <> '' and isnull(handle_time,'') < getdate()) then 1 else 0 end) as handle," + + "handle_time,sender_time,receiving_time from t482101H "; + sql += " where userCode=" + GridUtils.prossSqlParm(userCode) + " \n"; + if (id[0].equals("folder")) {//鏄枃浠跺す + sql += " and folder_id=" + id[1] + " \n"; + } else if (id[0].equals("tag")) {//鏄爣绛� + sql += " and tag_list like '%," + id[1] + ",%'"; + } + sql += " order by docCode asc \n"; + sql += " OFFSET (" + page + " - 1) * " + limit + " ROWS FETCH NEXT " + limit + " ROWS ONLY"; + return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(t482101HList.class)); + } catch (Exception e) { + throw e; + } + } + + @Override public List<t482101HList> getUserMailList(String userCode) { String sql = " set nocount on \n"; try { @@ -313,6 +339,28 @@ try { sql += "declare @docCode varchar(200) ='" + docCode + "' \n"; sql += "update t482101H set read_flag=" + (status ? 1 : 0) + " where docCode in (select list from GetInStr(@docCode))\n"; + sql += "select @@ROWCOUNT"; + jdbcTemplate.queryForObject(sql, Integer.class); + } catch (Exception e) { + throw e; + } + } + + @Override + public void updateMailType(String docCode, Integer folderId, String tagId) { + String sql = " set nocount on \n"; + try { + boolean bol = false; + sql += "declare @docCode varchar(200) ='" + docCode + "' \n"; + sql += "update t482101H set \n"; + if (!folderId.equals(0)) { + sql += " folder_id=" + folderId + "\n"; + bol = true; + } + if (StringUtils.isNotBlank(tagId)) { + sql += (bol ? "," : "") + " tag_list='," + tagId + ",' \n"; + } + sql += " where docCode in (select list from GetInStr(@docCode))\n"; sql += "select @@ROWCOUNT"; jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { @@ -452,7 +500,7 @@ } @Override - public Integer getMailTotal(String email, Integer mailType, boolean isNoRead, String userCode) { + public Integer getMailTotal(String email, Integer mailType, boolean isNoRead, String id, String userCode) { String sql = "set nocount on\n"; try { sql += "select count(*) from t482101H "; @@ -461,15 +509,27 @@ sql += " and mailType=" + mailType;//0锛氳崏绋跨 1锛氭敹浠剁 2锛氬彂浠剁 } if (StringUtils.isNotBlank(email)) { - if (mailType == 1 || mailType == 3) { - sql += " and receiver like '%" + email + "%' and isnull(handle_time,'') <> '' and isnull(handle_time,'') < getdate() "; + if (mailType == 1) { + sql += " and receiver like '%" + email + "%'"; } else if (mailType == 2) { sql += " and sender =" + GridUtils.prossSqlParm(email); + } else if (mailType == 3) { + sql += " and isnull(handle_time,'') <> '' and isnull(handle_time,'') < getdate() "; } } if (isNoRead) {//0琛ㄧず鏈锛�1琛ㄧず宸茶 sql += " and isnull(read_flag,0) = 0"; } + if (StringUtils.isNotBlank(id)) {//鏂囦欢澶� + String[] type = id.split("_"); + if (type.length == 2) { + if (type[0].equals("folder")) { + sql += " and folder_id=" + type[1]; + } else if (type[0].equals("tag")) { + sql += " and tag_list like '%," + type[1] + ",%'"; + } + } + } return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { return 0; -- Gitblit v1.8.0