f632e7d7c25d8a86b1f6718f467bfef0d3c09058..ee2316e2cb7afde1c54f5e4216a1b0d1e055749e
5 天以前 xinyb
CRM邮箱配置调整
ee2316 对比 | 目录
5 天以前 xinyb
CRM邮件文件夹和标签
aad276 对比 | 目录
9个文件已修改
248 ■■■■■ 已修改文件
src/com/yc/crm/mail/action/MailAccount.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/action/MailController.java 123 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/action/MailFolder.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/action/MailTag.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/entity/MailModuleBelowEntity.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/entity/T482102Entity.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailAccountImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailIfc.java 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailImpl.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/action/MailAccount.java
@@ -321,7 +321,7 @@
    public AllBackMsg deleteAccount(@RequestParam(defaultValue = "0") Integer accountId, HttpServletRequest request, HttpServletResponse response) {
        AllBackMsg msg = new AllBackMsg();
        try {
            if (accountId == 0) {
            if (accountId.equals(0)) {
                msg.setFail("邮箱编号ID获取不到");
                return msg;
            }
src/com/yc/crm/mail/action/MailController.java
@@ -82,6 +82,7 @@
        }
        return msg;
    }
    /**
     * 左边结构下层
     *
@@ -99,7 +100,7 @@
            }
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            List<MailModuleBelowEntity> list =emailIfc.getMailModuleBelowList(userCode);
            List<MailModuleBelowEntity> list = emailIfc.getMailModuleBelowList(userCode);
            msg.setSuccess("执行成功", list);
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
@@ -134,14 +135,16 @@
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            List<t482101HList> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead, userCode, page, limit);
            Map<String, Object> map = new HashMap<>();
            map.put("page", page);
            map.put("limit", limit);
            if (t482101HEntityList.size() > 0) {
                Map<String,Object> map=new HashMap<>();
                map.put("page",page);
                map.put("limit",limit);
                map.put("total",emailIfc.getMailTotal(mail,mailType,isNoRead,userCode));
                map.put("list",t482101HEntityList);
                msg.setSuccess("执行完成", map);
                map.put("total", emailIfc.getMailTotal(mail, mailType, isNoRead, null, userCode));
                map.put("list", t482101HEntityList);
            } else {
                map.put("list", new ArrayList<>());
            }
            msg.setSuccess("执行完成", map);
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
@@ -175,14 +178,16 @@
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            List<t482101HList> t482101HEntityList = emailIfc.getHandleMailList(mail, userCode, page, limit);
            Map<String, Object> map = new HashMap<>();
            map.put("page", page);
            map.put("limit", limit);
            if (t482101HEntityList.size() > 0) {
                Map<String,Object> map=new HashMap<>();
                map.put("page",page);
                map.put("limit",limit);
                map.put("total",emailIfc.getMailTotal(mail,3,false,userCode));
                map.put("list",t482101HEntityList);
                msg.setSuccess("执行完成", map);
                map.put("total", emailIfc.getMailTotal(mail, 3, false, null, userCode));
                map.put("list", t482101HEntityList);
            } else {
                map.put("list", new ArrayList<>());
            }
            msg.setSuccess("执行完成", map);
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
@@ -530,6 +535,98 @@
    }
    /**
     * 移动邮件分类
     *
     * @param request
     * @param response
     * @return
     */
    @PostMapping("/updateMailType.do")
    public AllBackMsg updateMailType(@RequestBody Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) throws Exception {
        AllBackMsg msg = new AllBackMsg();
        try {
            HttpSession session = request.getSession();
            String userCode = (String) session.getAttribute(SessionKey.USERCODE);//当前登录用户
            if (StringUtils.isBlank(userCode)) {//获取不到当前用户直接结束
                msg.setFail("获取不到用户信息");
                return msg;
            }
            if (map.get("docCode") == null) {
                msg.setFail("获取不到移动邮件编号docCode");
                return msg;
            }
            String docCode = (String) map.get("docCode");
            Integer folderId = map.get("folderId") == null ? 0 : (Integer) map.get("folderId");
            List<String> tagArray = (List<String>) map.get("tagId");
            if (folderId.equals(0) && (tagArray == null || tagArray.size() == 0)) {
                msg.setFail("移动邮件分类不能为空");
                return msg;
            }
            String tagId = "";
            if (tagArray != null && tagArray.size() > 0) {
                tagId = StringUtils.join(tagArray, ",");
            }
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            emailIfc.updateMailType(docCode, folderId, tagId);
            msg.setOk("移动成功");
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
            SpObserver.setDBtoInstance();
        }
        return msg;
    }
    /**
     * 加载不同目录里的邮件
     *
     * @param request
     * @param response
     * @return
     */
    @GetMapping("/classificationMail.do")
    public AllBackMsg classificationMail(@RequestParam(defaultValue = "-1") Integer id, String type, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "20") Integer limit,
                                         HttpServletRequest request, HttpServletResponse response) throws Exception {
        AllBackMsg msg = new AllBackMsg();
        try {
            HttpSession session = request.getSession();
            String userCode = (String) session.getAttribute(SessionKey.USERCODE);//当前登录用户
            if (StringUtils.isBlank(userCode)) {//获取不到当前用户直接结束
                msg.setFail("获取不到用户信息");
                return msg;
            }
            if (id == null || id.equals(-1)) {
                msg.setFail("获取不到文件Id");
                return msg;
            }
            if (StringUtils.isBlank(type)) {
                msg.setFail("获取不到文件类型");
                return msg;
            }
            type = type + "_" + id;//组装下
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            List<t482101HList> t482101 = emailIfc.getFolderMailList(type, userCode, page, limit);
            Map<String, Object> map = new HashMap<>();
            map.put("page", page);
            map.put("limit", limit);
            if (t482101.size() > 0) {
                map.put("total", emailIfc.getMailTotal(null, 6, false, type, userCode));
                map.put("list", t482101);
            } else {
                map.put("list", new ArrayList<>());
            }
            msg.setSuccess("执行完成", map);
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
            SpObserver.setDBtoInstance();
        }
        return msg;
    }
    /**
     * 待处理邮件
     *
     * @param request
src/com/yc/crm/mail/action/MailFolder.java
@@ -237,6 +237,8 @@
                    if (fo.size() > 0) {
                        for (T482107Entity y : fo) {
                            MailModuleBelowEntity folder1 = new MailModuleBelowEntity();
                            folder1.setId(y.getFolderId());
                            folder1.setType("folder");
                            folder1.setKey(y.getRowId());
                            folder1.setParentKey(y.getParentRowId());
                            folder1.setName(y.getFolderName());
src/com/yc/crm/mail/action/MailTag.java
@@ -181,15 +181,19 @@
        List<MailModuleBelowEntity> tagList = new ArrayList<>();
        MailModuleBelowEntity tag1 = new MailModuleBelowEntity();
        tag1.setKey("systemTag");
        tag1.setType("tag");
        tag1.setName("系统标签");
        MailModuleBelowEntity tag2 = new MailModuleBelowEntity();
        tag2.setKey("customTag");
        tag2.setType("tag");
        tag2.setName("自定义标签");
        try {
            List<MailModuleBelowEntity> system = new ArrayList<>();
            List<MailModuleBelowEntity> custom = new ArrayList<>();
            for (T482115Entity t : T482115) {
                MailModuleBelowEntity tag = new MailModuleBelowEntity();
                tag.setId(t.getTagId());
                tag.setType("tag");
                tag.setName(t.getTagName());
                if (t.isSystemFlag()) {
                    tag.setKey("systemTag" + t.getTagId());
src/com/yc/crm/mail/entity/MailModuleBelowEntity.java
@@ -14,9 +14,11 @@
 */
@Data
public class MailModuleBelowEntity {
    private Integer id = 0;//唯一值
    private String key;//key
    private String parentKey;//父key
    private String name;//名称
    private String type;//类型
    private Integer number = 0;//数量
    private Object list;//下节点
@@ -25,13 +27,16 @@
        MailModuleBelowEntity a = new MailModuleBelowEntity();
        a.setKey("moduleBelowA");
        a.setName("文件夹");
        a.setType("folder");
        list1.add(a);
        MailModuleBelowEntity b = new MailModuleBelowEntity();
        b.setKey("moduleBelowB");
        b.setName("标签邮件");
        b.setType("tag");
        list1.add(b);
        MailModuleBelowEntity c = new MailModuleBelowEntity();
        c.setKey("moduleBelowC");
        c.setType("other");
        c.setName("显示更多");
        list1.add(c);
        return list1;
src/com/yc/crm/mail/entity/T482102Entity.java
@@ -24,6 +24,7 @@
    private boolean proxyFlag;//是否启用代理
    private String mailDomain;
    private Integer mailType = 0;//邮箱类型
    private Integer mailStatusCode=0;//邮箱状态码
    private String mailStatus = "正常";//邮箱状态
    private String keywordList;
    private String siteUrl;
src/com/yc/crm/mail/service/MailAccountImpl.java
@@ -146,8 +146,8 @@
            sql += "select companyId,companyName,email,password,alias_email as aliasEmail,userCode,userName,accountId,receive_server_user_name as receiveServerUserName," +
                    "isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,isnull(mailType,0) as mailType,mailStatus,keywordList,siteUrl,receiveProtocol," +
                    "receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost,smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost," +
                    "isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion " +
                    "from t482102 " +
                    "isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion, " +
                    "(case when isnull(mailStatus,'')='正常' then 0 else -1 end) as mailStatusCode from t482102 " +
                    "where userCode=" + GridUtils.prossSqlParm(userCode);
            sql += " order by accountId";
            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482102Entity.class));
src/com/yc/crm/mail/service/MailIfc.java
@@ -80,14 +80,23 @@
     * @param isRead   是否已读
     * @return
     */
    List<t482101HList> getReceivingMailList(String email, Integer mailType, boolean isNoRead, String userCode,Integer page,Integer limit);
    List<t482101HList> getReceivingMailList(String email, Integer mailType, boolean isNoRead, String userCode, Integer page, Integer limit);
    /**
     * 获取待处理邮件列表
     *
     * @param email
     * @return
     */
    List<t482101HList> getHandleMailList(String email,String userCode,Integer page,Integer limit);
    List<t482101HList> getHandleMailList(String email, String userCode, Integer page, Integer limit);
    /**
     * 获取文件夹邮件列表
     *
     * @param email
     * @return
     */
    List<t482101HList> getFolderMailList(String type, String userCode, Integer page, Integer limit) throws Exception;
    /**
     * 获取用户的全部邮件
@@ -125,7 +134,18 @@
     *
     * @param docCode
     */
    abstract void updateRead(String docCode,boolean status);
    abstract void updateRead(String docCode, boolean status);
    /**
     * 更新移动邮件位置
     *
     * @param userCode
     * @param docCode
     * @param folderId
     * @param tagId
     * @return
     */
    abstract void updateMailType(String docCode, Integer folderId, String tagId);
    /**
     * 绑定账号的邮箱模块
@@ -136,12 +156,23 @@
    abstract List<MailModuleEntity> getMailModuleList(String userCode);
    abstract List<MailModuleBelowEntity> getMailModuleBelowList(String userCode);
    /**
     * 待处理邮件
     *
     * @param handleTime
     * @param docCode
     */
    abstract void updateMailHandle(String handleTime,String docCode);
    abstract void updateMailHandle(String handleTime, String docCode);
    abstract Integer getMailTotal(String email, Integer mailType, boolean isNoRead,String userCode);
    /**
     * 查总数
     * @param email
     * @param mailType
     * @param isNoRead
     * @param id
     * @param userCode
     * @return
     */
    abstract Integer getMailTotal(String email, Integer mailType, boolean isNoRead, String id, String userCode);
}
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;