xinyb
2024-09-20 0c7568c19ebdb540d5cca242eb9e95231d1a0dd7
CRM邮箱配置
5个文件已修改
61 ■■■■ 已修改文件
src/com/yc/crm/mail/action/MailController.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/entity/T482102Entity.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailIfc.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailImpl.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailServiceImpl.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/action/MailController.java
@@ -109,7 +109,12 @@
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            List<t482101HList> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead, userCode, page, limit);
            if (t482101HEntityList.size() > 0) {
                msg.setSuccess("执行完成", t482101HEntityList);
                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);
            }
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
@@ -145,7 +150,12 @@
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            List<t482101HList> t482101HEntityList = emailIfc.getHandleMailList(mail, userCode, page, limit);
            if (t482101HEntityList.size() > 0) {
                msg.setSuccess("执行完成", t482101HEntityList);
                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);
            }
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
src/com/yc/crm/mail/entity/T482102Entity.java
@@ -27,7 +27,7 @@
    private String mailStatus = "正常";//邮箱状态
    private String keywordList;
    private String siteUrl;
    private String receiveProtocol = "imap";//收件协议类型
    private String receiveProtocol = "imaps";//收件协议类型
    private String receiveEmail;//收件邮箱
    private String receivePassword;//收件邮箱密码
    private boolean receiveSSL = true;
src/com/yc/crm/mail/service/MailIfc.java
@@ -140,4 +140,6 @@
     * @param docCode
     */
    abstract void updateMailHandle(String handleTime,String docCode);
    abstract Integer getMailTotal(String email, Integer mailType, boolean isNoRead,String userCode);
}
src/com/yc/crm/mail/service/MailImpl.java
@@ -405,4 +405,29 @@
            throw e;
        }
    }
    @Override
    public Integer getMailTotal(String email, Integer mailType, boolean isNoRead, String userCode) {
        String sql = "set nocount on\n";
        try {
            sql += "select count(*) from t482101H ";
            sql += " where userCode=" + GridUtils.prossSqlParm(userCode);
            if (mailType < 3) {
                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() ";
                } else if (mailType == 2) {
                    sql += " and sender =" + GridUtils.prossSqlParm(email);
                }
            }
            if (isNoRead) {//0表示未读,1表示已读
                sql += " and isnull(read_flag,0) = 0";
            }
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            return 0;
        }
    }
}
src/com/yc/crm/mail/service/MailServiceImpl.java
@@ -288,7 +288,11 @@
            Date nowTime = new Date();
            for (int i = 0; i < messages.length; i++) {
                m = messages[i];
                LocalDate sendDate = m.getSentDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
                Date time = m.getReceivedDate();
                if (time == null) {
                    continue;
                }
                LocalDate sendDate = time.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
                if ((sendDate.isAfter(startTime) || sendDate.isEqual(startTime)) &&
                        (sendDate.isBefore(endTime) || sendDate.isEqual(endTime))) {//时间段获取邮件
                    t482101HEntity mail = new t482101HEntity();
@@ -417,7 +421,10 @@
                BodyPart bodyPart = mimeMultipart.getBodyPart(i);
                if (bodyPart.isMimeType("image/*")) {//图片
                    MailFileEntity.MailBodyPart p = new MailFileEntity.MailBodyPart();
                    String fileName = MimeUtility.decodeText(bodyPart.getFileName());
                    String fileName = "xxx.jpg";
                    if (StringUtils.isNotBlank(bodyPart.getFileName())) {
                        fileName = MimeUtility.decodeText(bodyPart.getFileName());
                    }
                    p.setFileName(fileName);//有些邮件没有扩展名
                    String cId = ((IMAPBodyPart) bodyPart).getContentID();//获取cId
                    if (StringUtils.isNotBlank(cId)) {//在有扩展名时候
@@ -426,7 +433,7 @@
                            p.setFileName(cId);//有些邮件没有扩展名
                        }
                    }
                    if (StringUtils.isBlank(p.getFileType()) && StringUtils.isNotBlank(fileName)) {
                    if (StringUtils.isBlank(p.getFileType())) {
                        if (fileName.lastIndexOf(".") != -1) {
                            p.setFileType(fileName.substring(fileName.lastIndexOf(".") + 1));
                        }
@@ -445,7 +452,10 @@
                    part.add(p);
                } else if (Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition())) {//附件
                    MailFileEntity.MailBodyPart p = new MailFileEntity.MailBodyPart();
                    String fileName = MimeUtility.decodeText(bodyPart.getFileName());
                    String fileName = "";
                    if (StringUtils.isNotBlank(bodyPart.getFileName())) {
                        fileName = MimeUtility.decodeText(bodyPart.getFileName());
                    }
                    p.setFileName(fileName);
                    if (StringUtils.isNotBlank(fileName)) {
                        p.setFileType(fileName.substring(fileName.lastIndexOf(".") + 1));