xinyb
2024-09-04 4284431e6755e854a7de7afb2ef09e461d3e72eb
CRM邮件功能优化
5个文件已添加
8个文件已修改
512 ■■■■■ 已修改文件
src/com/yc/crm/mail/action/MailAccount.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/action/MailController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/action/MailTag.java 167 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/entity/T482115Entity.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/entity/t482101HList.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailBlackListImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailFolderImpl.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailIfc.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailImpl.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailQuickTextImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailSignatureImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailTagIfc.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailTagImpl.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/action/MailAccount.java
@@ -12,10 +12,14 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.mail.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
 * @BelongsProject: eCoWorksV3
@@ -62,7 +66,13 @@
            DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
            SpObserver.setDBtoInstance("_" + dataSource.getDbId());
            mailAccountIfc.addEmailAccount(account);//添加新的邮箱配置
            msg.setOk("已保存");
            Map<String, Object> map = new HashMap<>();
            map.put("companyId", companyId);
            map.put("companyName", companyName);
            map.put("userCode", userCode);
            map.put("userName", userName);
            map.put("email", account.getEmail());
            msg.setSuccess("已保存", map);
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
@@ -83,13 +93,14 @@
    public AllBackMsg updateAccount(@RequestBody T482102Entity account, HttpServletRequest request, HttpServletResponse response) {
        AllBackMsg msg = new AllBackMsg();
        try {
            if(account.getAccountId()==0){
            if (account.getAccountId() == 0) {
                msg.setFail("获取不到邮箱配置ID,请检查");
                return msg;
            }
            HttpSession session = request.getSession();
            String userCode = (String) session.getAttribute(SessionKey.USERCODE);
            if(StringUtils.isBlank(userCode)){
            String userName = (String) session.getAttribute(SessionKey.USER_NAME);
            if (StringUtils.isBlank(userCode)) {
                msg.setFail("登录用户已过期,请检查");
                return msg;
            }
@@ -97,7 +108,11 @@
            DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
            SpObserver.setDBtoInstance("_" + dataSource.getDbId());
            mailAccountIfc.updateEmailAccount(account);
            msg.setOk("已更新");
            Map<String, Object> map = new HashMap<>();
            map.put("userCode", userCode);
            map.put("userName", userName);
            map.put("email", account.getEmail());
            msg.setSuccess("已更新", map);
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
@@ -124,7 +139,7 @@
            }
            HttpSession session = request.getSession();
            String userCode = (String) session.getAttribute(SessionKey.USERCODE);
            if(StringUtils.isBlank(userCode)){
            if (StringUtils.isBlank(userCode)) {
                msg.setFail("登录用户已过期,请检查");
                return msg;
            }
@@ -161,7 +176,7 @@
            List<T482102Entity> t482102Entities = mailAccountIfc.getAccount(userCode, mail);
            if (t482102Entities.size() > 0) {
                msg.setSuccess("执行成功", t482102Entities.get(0));
            }else{
            } else {
                msg.setFail("未找到配置信息,0条数据");
            }
        } catch (Exception e) {
@@ -171,4 +186,72 @@
        }
        return msg;
    }
    /**
     * 检测绑定是否有效
     *
     * @param email
     * @param request
     * @param response
     * @return
     */
    @GetMapping("/isEmailValid.do")
    public AllBackMsg isEmailValid(String email, HttpServletRequest request, HttpServletResponse response) {
        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 (StringUtils.isBlank(email)) {
                msg.setFail("检测绑定邮箱不能为空");
                return msg;
            }
            DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
            SpObserver.setDBtoInstance("_" + dataSource.getDbId());
            //根据当前用户查询绑定的邮箱信息
            T482102Entity emailEntity = mailAccountIfc.getAccountInfo(userCode, email);//返回邮箱的账号信息
            if (emailEntity == null || StringUtils.isBlank(emailEntity.getEmail())) {
                msg.setFail("找不到邮箱:" + email + "配置信息请完善。");
                return msg;
            }
            Properties props = new Properties();
            props.put("mail.smtp.host", emailEntity.getSmtpHost()); // 替换为你的SMTP服务器
            props.put("mail.smtp.port", emailEntity.getSmtpPort()); // 或者你使用的端口
            props.put("mail.smtp.auth", "true");
            props.put("mail.smtp.starttls.enable", "true");
            if (emailEntity.getSmtpHost().contains("163")) {//163邮箱设置
                props.put("mail.smtp.ssl.enable", "true");
            }
            Session mailSession = Session.getInstance(props, new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(emailEntity.getEmail(), emailEntity.getPassword());
                }
            });
//            Store store = mailSession.getTransport("imaps"); // 使用IMAP协议
//            store.connect();
//            Session mailSession = Session.getInstance(props, null);
//            mailSession.setDebug(false);
//
            Transport transport = mailSession.getTransport();
            transport.connect();
            transport.close();
//            transport.connect(emailEntity.getSmtpHost(),emailEntity.getEmail(), emailEntity.getPassword());
//            transport.sendMessage(new MimeMessage(mailSession), new Address[]{new InternetAddress(emailEntity.getEmail())});
//            transport.close();
            msg.setOk("有效邮箱");
        } catch (MessagingException e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
            SpObserver.setDBtoInstance();
        }
        return msg;
    }
}
src/com/yc/crm/mail/action/MailController.java
@@ -2,6 +2,7 @@
import com.yc.crm.mail.entity.T482102Entity;
import com.yc.crm.mail.entity.t482101HEntity;
import com.yc.crm.mail.entity.t482101HList;
import com.yc.crm.mail.service.MailAccountIfc;
import com.yc.crm.mail.service.MailIfc;
import com.yc.crm.mail.util.AllBackMsg;
@@ -59,7 +60,7 @@
            }
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            List<t482101HEntity> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead);
            List<t482101HList> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead);
            if (t482101HEntityList.size() > 0) {
                msg.setSuccess("执行完成", t482101HEntityList);
            }
@@ -176,7 +177,6 @@
            Map<String, Object> map = new HashMap<>();
            map.put("docCode", t482101H.getDocCode());
            msg.setSuccess("执行成功", map);
//            msg.setOk("执行成功");
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
src/com/yc/crm/mail/action/MailTag.java
New file
@@ -0,0 +1,167 @@
package com.yc.crm.mail.action;
import com.yc.crm.mail.entity.T482115Entity;
import com.yc.crm.mail.service.MailTagIfc;
import com.yc.crm.mail.util.AllBackMsg;
import com.yc.entity.DataSourceEntity;
import com.yc.multiData.MultiDataSource;
import com.yc.multiData.SpObserver;
import com.yc.utils.SessionKey;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;
/**
 * @BelongsProject: eCoWorksV3
 * @BelongsPackage: com.yc.crm.mail.action
 * @author: xinyb
 * @CreateTime: 2024-09-04  15:22
 * @Description:标签
 */
@CrossOrigin
@RestController
@RequestMapping("/crm/mail/tag")
public class MailTag {
    @Autowired
    MailTagIfc mailTagIfc;
    /**
     * 添加标签
     *
     * @param signature
     * @param request
     * @param response
     * @return
     */
    @PostMapping("/addTag.do")
    public AllBackMsg addTag(@RequestBody T482115Entity tag, HttpServletRequest request, HttpServletResponse response) {
        AllBackMsg msg = new AllBackMsg();
        try {
            HttpSession session = request.getSession();
            String companyId = (String) session.getAttribute(SessionKey.COMPANY_ID);
            String companyName = (String) session.getAttribute(SessionKey.COMPANY_NAME);
            String userCode = (String) session.getAttribute(SessionKey.USERCODE);
            String userName = (String) session.getAttribute(SessionKey.USER_NAME);
            tag.setCompanyId(companyId);
            tag.setCompanyName(companyName);
            tag.setUserCode(userCode);
            tag.setUserName(userName);
            DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
            SpObserver.setDBtoInstance("_" + dataSource.getDbId());
            //保存
            mailTagIfc.saveTag(tag);
            msg.setOk("已保存");
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
            SpObserver.setDBtoInstance();
        }
        return msg;
    }
    /**
     * 修改标签
     *
     * @param signature
     * @param request
     * @param response
     * @return
     */
    @PostMapping("/updateTag.do")
    public AllBackMsg updateTag(@RequestBody T482115Entity tag, HttpServletRequest request, HttpServletResponse response) {
        AllBackMsg msg = new AllBackMsg();
        try {
            if (tag.getTagId() == null) {
                msg.setFail("缺少SignId值,请检查");
                return msg;
            }
            HttpSession session = request.getSession();
            String userCode = (String) session.getAttribute(SessionKey.USERCODE);
            if (StringUtils.isBlank(userCode)) {
                msg.setFail("登录用户已过期,请检查");
                return msg;
            }
            tag.setUserCode(userCode);
            DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
            SpObserver.setDBtoInstance("_" + dataSource.getDbId());
            mailTagIfc.updateTag(tag);
            msg.setOk("已更新");
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
            SpObserver.setDBtoInstance();
        }
        return msg;
    }
    /**
     * 删除标签
     *
     * @param signId
     * @param request
     * @param response
     * @return
     */
    @PostMapping("/deleteTag.do")
    public AllBackMsg deleteTag(@RequestParam(defaultValue = "0") Integer tagId, HttpServletRequest request, HttpServletResponse response) {
        AllBackMsg msg = new AllBackMsg();
        try {
            if (tagId == 0) {
                msg.setFail("签名ID获取不到");
                return msg;
            }
            HttpSession session = request.getSession();
            String userCode = (String) session.getAttribute(SessionKey.USERCODE);
            if (StringUtils.isBlank(userCode)) {
                msg.setFail("登录用户已过期,请检查");
                return msg;
            }
            DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
            SpObserver.setDBtoInstance("_" + dataSource.getDbId());
            Integer cont = mailTagIfc.deleteTag(userCode, tagId);
            if (cont > 0) {
                msg.setOk("已删除");
            }
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
            SpObserver.setDBtoInstance();
        }
        return msg;
    }
    /**
     * 标签查询
     * @param search   搜索
     * @param request
     * @param response
     * @return
     */
    @GetMapping("/getTagList.do")
    public AllBackMsg getTagList(String search, HttpServletRequest request, HttpServletResponse response) {
        AllBackMsg msg = new AllBackMsg();
        try {
            HttpSession session = request.getSession();
            String userCode = (String) session.getAttribute(SessionKey.USERCODE);
            if (StringUtils.isBlank(userCode)) {
                msg.setFail("登录用户已过期,请检查");
                return msg;
            }
            DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
            SpObserver.setDBtoInstance("_" + dataSource.getDbId());
            List<T482115Entity> list = mailTagIfc.getTagList(userCode, search);
            msg.setSuccess("执行成功", list);
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
            SpObserver.setDBtoInstance();
        }
        return msg;
    }
}
src/com/yc/crm/mail/entity/T482115Entity.java
New file
@@ -0,0 +1,29 @@
package com.yc.crm.mail.entity;
import lombok.Data;
/**
 * @BelongsProject: eCoWorksV3
 * @BelongsPackage: com.yc.crm.mail.entity
 * @author: xinyb
 * @CreateTime: 2024-09-04  15:17
 * @Description:标签
 */
@Data
public class T482115Entity {
    private String companyId;
    private String companyName;
    private Integer tagId;// [primary key]
    private String tagName;
    private String userCode;
    private String userName;
    private Integer sortId;
    private String createTime;
    private String updateTime;
    private String tagDesc;// [note:'标签备注']
    private boolean systemFlag;// [note:'是否为系统标签']
    private String tagColor;
    private Integer tagType = 0;//[note:'标签类型 0:邮件 1:其他(线索,客户,商机)']
    private Integer DocVersion;
}
src/com/yc/crm/mail/entity/t482101HList.java
New file
@@ -0,0 +1,30 @@
package com.yc.crm.mail.entity;
import lombok.Data;
/**
 * @BelongsProject: eCoWorksV3
 * @BelongsPackage: com.yc.crm.mail.entity
 * @author: xinyb
 * @CreateTime: 2024-09-04  11:27
 * @Description:
 */
@Data
public class t482101HList {
    private String companyId;
    private String companyName;
    private Integer classType = 0;// [note: '1:客户2:同事3:通讯录0:其他']
    private String docCode;// [primary key ]
    private Integer mailType;// [note: '0:草稿箱1:收件箱2:发件箱']
    private String sender;// [note:'发送人']
    private Integer folderId = 0;// [note:'文件夹id']
    private Integer deleteFlag = 0; //[note:'是否已删除']
    private Integer readFlag = 0;// [note:'是否已读']
    private String subject;// [note:'主题']
    private String userCode;
    private String userName;
    private String createTime;
    private String updateTime;
    private String receiveTime;// [note:'回复时间']
    private String plainText;
}
src/com/yc/crm/mail/service/MailBlackListImpl.java
@@ -49,7 +49,7 @@
    public Integer deleteBlackList(String userCode,Integer blackId) {
        String sql = "set nocount on \n";
        try {
            sql += "delete t482106 where black_id=" + blackId + " and userCode=" + userCode + "\n";
            sql += "delete t482106 where black_id=" + blackId + " and userCode='" + userCode + "'\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
src/com/yc/crm/mail/service/MailFolderImpl.java
@@ -5,6 +5,7 @@
import com.yc.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -15,16 +16,17 @@
 * @CreateTime: 2024-08-23  09:27
 * @Description:
 */
@Service
public class MailFolderImpl extends BaseService implements MailFolderIfc {
    @Override
    public void saveFolder(T482107Entity folder) {
        String sql = "set nocount on\n";
        try {
            sql += "insert into t482107(companyId,companyName,folderName,userCode,userName,content,sortId,createTime,updateTime) " +
            sql += "insert into t482107(companyId,companyName,folder_name,userCode,userName,sort_id,create_time,update_time,rowId,treeControl,parentRowId) " +
                    "values (" + GridUtils.prossSqlParm(folder.getCompanyId()) + "," + GridUtils.prossSqlParm(folder.getCompanyName()) + "," +
                    GridUtils.prossSqlParm(folder.getFolderName()) + "," + GridUtils.prossSqlParm(folder.getUserCode()) + "," +
                    GridUtils.prossSqlParm(folder.getUserName()) + "," + GridUtils.prossSqlParm(folder.getTreeControl()) + "," +
                    folder.getSortId() + ",getdate(),getdate())";
                    GridUtils.prossSqlParm(folder.getUserName()) + "," + folder.getSortId() + ",getdate(),getdate()," +
                    GridUtils.prossSqlParm(folder.getRowId()) + "," + GridUtils.prossSqlParm(folder.getTreeControl()) + "," + GridUtils.prossSqlParm(folder.getParentRowId()) + ")";
            jdbcTemplate.update(sql);
        } catch (Exception e) {
            throw e;
@@ -35,9 +37,10 @@
    public Integer updateFolder(T482107Entity folder) {
        String sql = "set nocount on\n";
        try {
            sql += "update t482107 set folderName=" + GridUtils.prossSqlParm(folder.getFolderName()) + ",treeControl=" + GridUtils.prossSqlParm(folder.getTreeControl()) +
                    ",sortId=" + folder.getSortId() + ",updateTime=getdate() " +
                    "where folderId=" + folder.getFolderId() + " and userCode=" + GridUtils.prossSqlParm(folder.getUserCode()) + "\n";
            sql += "update t482107 set folder_name=" + GridUtils.prossSqlParm(folder.getFolderName()) +
                    ",sort_id=" + folder.getSortId() + ",update_time=getdate() " + ",rowId=" + GridUtils.prossSqlParm(folder.getRowId()) +
                    ",treeControl=" + GridUtils.prossSqlParm(folder.getTreeControl()) + ",parentRowId=" + GridUtils.prossSqlParm(folder.getParentRowId()) +
                    "where folder_id=" + folder.getFolderId() + " and userCode=" + GridUtils.prossSqlParm(folder.getUserCode()) + "\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
@@ -49,7 +52,7 @@
    public Integer deleteFolder(String userCode, Integer folderId) {
        String sql = "set nocount on\n";
        try {
            sql += "delete t482107 where userCode='" + userCode + "' and folderId=" + folderId + "\n";
            sql += "delete t482107 where userCode='" + userCode + "' and folder_id=" + folderId + "\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
@@ -61,12 +64,12 @@
    public List<T482107Entity> getMailFolder(String userCode, String search) {
        String sql = "set nocount on\n";
        try {
            sql += "select companyId,companyName,folderName,userCode,userName,content,sortId,createTime,updateTime " +
            sql += "select companyId,companyName,folder_id,folder_name,userCode,userName,sort_id,create_time,update_time,rowId,treeControl,parentRowId " +
                    "from t482107 where userCode=" + GridUtils.prossSqlParm(userCode);
            if (StringUtils.isNotBlank(search)) {
                sql += " and content like '%" + search + "%'";
                sql += " and folder_name like '%" + search + "%'";
            }
            sql += " order by folderId \n";
            sql += " order by folder_id \n";
            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482107Entity.class));
        } catch (Exception e) {
            throw e;
src/com/yc/crm/mail/service/MailIfc.java
@@ -2,6 +2,7 @@
import com.yc.crm.mail.entity.T482102Entity;
import com.yc.crm.mail.entity.t482101HEntity;
import com.yc.crm.mail.entity.t482101HList;
import com.yc.entity.attachment.AttachmentEntity;
import javax.mail.MessagingException;
@@ -77,7 +78,7 @@
     * @param isRead 是否已读
     * @return
     */
    List<t482101HEntity> getReceivingMailList(String email,Integer mailType,boolean isNoRead);
    List<t482101HList> getReceivingMailList(String email, Integer mailType, boolean isNoRead);
    /**
src/com/yc/crm/mail/service/MailImpl.java
@@ -5,6 +5,7 @@
import com.yc.action.grid.GridUtils;
import com.yc.crm.mail.entity.T482102Entity;
import com.yc.crm.mail.entity.t482101HEntity;
import com.yc.crm.mail.entity.t482101HList;
import com.yc.entity.AttachmentConfig;
import com.yc.entity.DataSourceEntity;
import com.yc.entity.attachment.AttachmentEntity;
@@ -59,7 +60,7 @@
                sql += "declare @docCode varchar(50) \n";
                sql += "exec sp_newdoccode 482101," + GridUtils.prossSqlParm(m.getUserCode()) + ",@docCode output \n";
                sql += "insert into t482101H(companyId,companyName,formId,docCode,docdate,PeriodID,postCode,postname,mailType,sender,receiver," +
                        "cc,bcc,subject,userCode,userName,content,file_unid,messageId,read_flag,delete_flag,create_time,update_time,receive_time," +
                        "cc,bcc,subject,userCode,userName,content,plain_text,file_unid,messageId,read_flag,delete_flag,create_time,update_time,receive_time," +
                        "attach_flag) values ";
                sql += "(" + GridUtils.prossSqlParm(m.getCompanyId()) + "," + GridUtils.prossSqlParm(m.getCompanyName()) + ",482101," +
                        "@docCode,convert(varchar(10),getdate(),120),convert(varchar(7),getdate(),120),"
@@ -68,7 +69,7 @@
                        GridUtils.prossSqlParm(StringUtils.join(m.getReceiver(), ",")) + "," + GridUtils.prossSqlParm(StringUtils.join(m.getCc(), ",")) + "," +
                        GridUtils.prossSqlParm(StringUtils.join(m.getBcc(), ",")) + "," +
                        GridUtils.prossSqlParm(m.getSubject()) + "," + GridUtils.prossSqlParm(m.getUserCode()) + "," + GridUtils.prossSqlParm(m.getUserName()) + "," +
                        GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getFileUNID()) + "," + GridUtils.prossSqlParm(m.getMessageId()) + "," +
                        GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getPlainText()) + "," + GridUtils.prossSqlParm(m.getFileUNID()) + "," + GridUtils.prossSqlParm(m.getMessageId()) + "," +
                        m.getReadFlag() + "," + m.getDeleteFlag() + ",getdate(),getdate()," + GridUtils.prossSqlParm(m.getReceiveTime()) + "," + m.getAttachFlag() + ") \n";
                sql += "select @docCode as docCode";
                String docCode = jdbcTemplate.queryForObject(sql, String.class);
@@ -92,7 +93,7 @@
            for (t482101HEntity m : mail) {//遍历内容
                sql += "exec sp_newdoccode 482101," + GridUtils.prossSqlParm(m.getUserCode()) + ",@docCode output \n";
                sql += "insert into t482101H(companyId,companyName,formId,docCode,docdate,PeriodID,postCode,postname,mailType,sender,receiver," +
                        "cc,bcc,subject,userCode,userName,content,file_unid,messageId,read_flag,delete_flag,create_time,update_time,receive_time," +
                        "cc,bcc,subject,userCode,userName,content,plain_text,file_unid,messageId,read_flag,delete_flag,create_time,update_time,receive_time," +
                        "attach_flag) values ";
                sql += "(" + GridUtils.prossSqlParm(m.getCompanyId()) + "," + GridUtils.prossSqlParm(m.getCompanyName()) + ",482101," +
                        "@docCode,convert(varchar(10),getdate(),120),convert(varchar(7),getdate(),120),"
@@ -101,7 +102,7 @@
                        GridUtils.prossSqlParm(StringUtils.join(m.getReceiver(), ",")) + "," + GridUtils.prossSqlParm(StringUtils.join(m.getCc(), ",")) + "," +
                        GridUtils.prossSqlParm(StringUtils.join(m.getBcc(), ",")) + "," +
                        GridUtils.prossSqlParm(m.getSubject()) + "," + GridUtils.prossSqlParm(m.getUserCode()) + "," + GridUtils.prossSqlParm(m.getUserName()) + "," +
                        GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getFileUNID()) + "," + GridUtils.prossSqlParm(m.getMessageId()) + "," +
                        GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getPlainText()) + "," + GridUtils.prossSqlParm(m.getFileUNID()) + "," + GridUtils.prossSqlParm(m.getMessageId()) + "," +
                        m.getReadFlag() + "," + m.getDeleteFlag() + ",getdate(),getdate()," + GridUtils.prossSqlParm(m.getReceiveTime()) + "," +
                        m.getAttachFlag() + ") \n";
//                sql +="exec postt482101V3 '' ,'',''";
@@ -120,9 +121,9 @@
                    "cc=" + GridUtils.prossSqlParm(StringUtils.join(mail.getCc(), ",")) + ",bcc=" + GridUtils.prossSqlParm(StringUtils.join(mail.getBcc(), ",")) + ",subject=" + GridUtils.prossSqlParm(mail.getSubject()) + "," +
                    "content=" + GridUtils.prossSqlParm(mail.getContent()) + ",file_unid=" + GridUtils.prossSqlParm(mail.getFileUNID()) + ",mailType=" + mail.getMailType() + "," +
                    "update_time=getdate() \n";
            sql += " where docCode=" + GridUtils.prossSqlParm(mail.getDocCode());
            sql += "select select @@ROWCOUNT";
            return jdbcTemplate.update(sql, Integer.class);
            sql += " where docCode=" + GridUtils.prossSqlParm(mail.getDocCode())+"\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
@@ -136,7 +137,7 @@
            sql += "update t482101H deleteFlag=1 where userCode =" + GridUtils.prossSqlParm(userCode) +
                    " and docCode in (select list from GetInStr(@docCode))\n";//标记删除
            sql += "select select @@ROWCOUNT";
            return jdbcTemplate.update(sql, Integer.class);
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
@@ -150,7 +151,7 @@
            sql += "delete t482101H where userCode =" + GridUtils.prossSqlParm(userCode) +
                    " and docCode in (select list from GetInStr(@docCode))\n";//标记删除
            sql += "select select @@ROWCOUNT";
            return jdbcTemplate.update(sql, Integer.class);
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
@@ -163,7 +164,7 @@
            sql += "declare @messageId varchar(200) ='" + messageId + "' \n";
            sql += "delete t482101H where messageId in (select list from GetInStr(@messageId))\n";//删除
            sql += "select select @@ROWCOUNT";
            return jdbcTemplate.update(sql, Integer.class);
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
@@ -183,17 +184,18 @@
    }
    @Override
    public List<t482101HEntity> getReceivingMailList(String email, Integer mailType, boolean isNoRead) {
    public List<t482101HList> getReceivingMailList(String email, Integer mailType, boolean isNoRead) {
        String sql = "set nocount on\n";
        try {
            sql += "select DocCode,sender,receiver,subject,content,file_unid as fileUNID,receive_time " +
                    "from t482101H ";
            sql += "select companyId,companyName,mailType,DocCode,sender,receiver,subject,plain_text," +
                    "receive_time,update_time,create_time,sender,userCode,userName,folder_id,delete_Flag, " +
                    "read_Flag from t482101H ";
            if (isNoRead) {//未读执行
                sql += "where receiver ='" + email + "' and  isnull(readFlag,0)= 0";
            } else {//已读
                sql += "where receiver ='" + email + "' and  mailType=" + mailType;
            }
            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(t482101HEntity.class));
            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(t482101HList.class));
        } catch (Exception e) {
            throw e;
        }
@@ -359,7 +361,7 @@
                    "updateTime=getdate() \n";
            sql += " where docCode=" + GridUtils.prossSqlParm(mail.getDocCode());
            sql += "select select @@ROWCOUNT";
            return jdbcTemplate.update(sql, Integer.class);
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
@@ -373,7 +375,7 @@
            sql += "delete t482101H where userCode =" + GridUtils.prossSqlParm(userCode) +
                    " and docCode in (select list from GetInStr(@docCode)) \n";
            sql += "select select @@ROWCOUNT";
            return jdbcTemplate.update(sql, Integer.class);
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
src/com/yc/crm/mail/service/MailQuickTextImpl.java
@@ -51,7 +51,7 @@
    public Integer deleteQuickText(String userCode, Integer textId) {
        String sql = "set nocount on\n";
        try {
            sql += "delete t482108 where userCode='" + userCode + "' and textId=" + textId + "\n";
            sql += "delete t482108 where userCode='" + userCode + "' and text_id=" + textId + "\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
@@ -63,12 +63,12 @@
    public List<T482108Entity> getMailQuickText(String userCode,String search) {
        String sql = "set nocount on\n";
        try {
            sql += "select companyId,companyName,textId,textName,userCode,userName,content,sortId,createTime,updateTime" +
                    "from t482108 where userCode=" + GridUtils.prossSqlParm(userCode);
            sql += "select companyId,companyName,text_id,text_name,userCode,userName,content,sort_id,create_time,update_time " +
                    " from t482108 where userCode=" + GridUtils.prossSqlParm(userCode);
            if (StringUtils.isNotBlank(search)) {
                sql += " and TextName like '%" + search+"%'";
                sql += " and Text_name like '%" + search+"%'";
            }
            sql += " order by textId" + "\n";
            sql += " order by text_id" + "\n";
            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482108Entity.class));
        } catch (Exception e) {
            throw e;
src/com/yc/crm/mail/service/MailSignatureImpl.java
@@ -50,7 +50,7 @@
    public Integer deleteSignature(String userCode,Integer sigId) {
        String sql = "set nocount on\n";
        try {
            sql += "delete t482109  where sign_id=" + sigId+ " and userCode=" + userCode + "\n";
            sql += "delete t482109  where sign_id=" + sigId+ " and userCode='" + userCode + "'\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
src/com/yc/crm/mail/service/MailTagIfc.java
New file
@@ -0,0 +1,35 @@
package com.yc.crm.mail.service;
import com.yc.crm.mail.entity.T482115Entity;
import java.util.List;
public interface MailTagIfc {
    /**
     * 保存个人签名
     * @param quickText
     */
    void saveTag(T482115Entity tag);
    /**
     * 修改个人签名
     * @param quickText
     * @return
     */
    Integer updateTag(T482115Entity tag);
    /**
     * 删除个人签名
     * @param userCode
     * @param textId
     * @return
     */
    Integer deleteTag(String userCode,Integer tagId);
    /**
     * 查询个人签名
     * @param name
     * @return
     */
    List<T482115Entity> getTagList(String userCode, String search);
}
src/com/yc/crm/mail/service/MailTagImpl.java
New file
@@ -0,0 +1,78 @@
package com.yc.crm.mail.service;
import com.yc.action.grid.GridUtils;
import com.yc.crm.mail.entity.T482115Entity;
import com.yc.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * @BelongsProject: eCoWorksV3
 * @BelongsPackage: com.yc.crm.mail.service
 * @author: xinyb
 * @CreateTime: 2024-09-04  15:28
 * @Description:
 */
@Service
public class MailTagImpl extends BaseService implements MailTagIfc {
    @Override
    public void saveTag(T482115Entity tag) {
        String sql = "set nocount on\n";
        try {
            sql += "insert into t482115(companyId,companyName,tag_name,userCode,userName,sort_id,create_time,update_time,tag_desc,system_flag,tag_color,tag_type) " +
                    "values(" + GridUtils.prossSqlParm(tag.getCompanyId()) + "," + GridUtils.prossSqlParm(tag.getCompanyName()) + "," +
                    GridUtils.prossSqlParm(tag.getTagName()) + "," + GridUtils.prossSqlParm(tag.getUserCode()) + "," + GridUtils.prossSqlParm(tag.getUserName()) + "," +
                    tag.getSortId() + ",getdate(),getdate()," + GridUtils.prossSqlParm(tag.getTagDesc()) + ",'" + tag.isSystemFlag() + "'," +
                    GridUtils.prossSqlParm(tag.getTagColor()) + "," + tag.getTagType() + ")";
            jdbcTemplate.update(sql);
        } catch (Exception e) {
            throw e;
        }
    }
    @Override
    public Integer updateTag(T482115Entity tag) {
        String sql = "set nocount on\n";
        try {
            sql += "update t482115 set tag_name=" + GridUtils.prossSqlParm(tag.getTagName()) + ",sort_id=" + tag.getSortId() + "," +
                    "update_time=getdate(),tag_desc=" + GridUtils.prossSqlParm(tag.getTagDesc()) + ",system_flag='" + tag.isSystemFlag() + "'," +
                    "tag_color=" + GridUtils.prossSqlParm(tag.getTagColor()) + ",tag_type=" + tag.getTagType() +
                    " where tag_id=" + tag.getTagId() + " and userCode=" + GridUtils.prossSqlParm(tag.getUserCode()) + "\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
    }
    @Override
    public Integer deleteTag(String userCode, Integer tagId) {
        String sql = "set nocount on\n";
        try {
            sql += "delete t482115  where tag_id=" + tagId + " and userCode='" + userCode + "'\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
    }
    @Override
    public List<T482115Entity> getTagList(String userCode, String search) {
        String sql = "set nocount on\n";
        try {
            sql += "select companyId,companyName,tag_id,tag_name,userCode,userName,sort_id,create_time,update_time,tag_desc,system_flag,tag_color,tag_type " +
                    "from t482115 where userCode=" + GridUtils.prossSqlParm(userCode);
            if (StringUtils.isNotBlank(search)) {
                sql += " and tag_name like '%" + search + "%'";
            }
            sql += " order by tag_id \n";
            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482115Entity.class));
        } catch (Exception e) {
            throw e;
        }
    }
}