| | |
| | | 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 |
| | |
| | | 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 { |
| | |
| | | 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; |
| | | } |
| | |
| | | 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 { |
| | |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | String userCode = (String) session.getAttribute(SessionKey.USERCODE); |
| | | if(StringUtils.isBlank(userCode)){ |
| | | if (StringUtils.isBlank(userCode)) { |
| | | msg.setFail("登录用户已过期,请检查"); |
| | | return msg; |
| | | } |
| | |
| | | List<T482102Entity> t482102Entities = mailAccountIfc.getAccount(userCode, mail); |
| | | if (t482102Entities.size() > 0) { |
| | | msg.setSuccess("执行成功", t482102Entities.get(0)); |
| | | }else{ |
| | | } else { |
| | | msg.setFail("未找到配置信息,0条数据"); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | 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; |
| | | } |
| | | } |
| | |
| | | |
| | | 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; |
| | |
| | | } |
| | | 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); |
| | | } |
| | |
| | | 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 { |
New file |
| | |
| | | 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; |
| | | } |
| | | } |
New file |
| | |
| | | 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; |
| | | |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | |
| | | 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) { |
| | |
| | | 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; |
| | | |
| | |
| | | * @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; |
| | |
| | | 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) { |
| | |
| | | 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) { |
| | |
| | | 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; |
| | |
| | | |
| | | 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; |
| | |
| | | * @param isRead 是否已读 |
| | | * @return |
| | | */ |
| | | List<t482101HEntity> getReceivingMailList(String email,Integer mailType,boolean isNoRead); |
| | | List<t482101HList> getReceivingMailList(String email, Integer mailType, boolean isNoRead); |
| | | |
| | | |
| | | /** |
| | |
| | | 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; |
| | |
| | | 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)," |
| | |
| | | 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); |
| | |
| | | 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)," |
| | |
| | | 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 '' ,'',''"; |
| | |
| | | "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; |
| | | } |
| | |
| | | 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; |
| | | } |
| | |
| | | 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; |
| | | } |
| | |
| | | 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; |
| | | } |
| | |
| | | } |
| | | |
| | | @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; |
| | | } |
| | |
| | | "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; |
| | | } |
| | |
| | | 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; |
| | | } |
| | |
| | | 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) { |
| | |
| | | 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; |
| | |
| | | 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) { |
New file |
| | |
| | | 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); |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |