src/com/yc/crm/mail/action/MailController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/com/yc/crm/mail/service/MailIfc.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/com/yc/crm/mail/service/MailImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/com/yc/crm/mail/service/MailServiceIfc.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/com/yc/crm/mail/service/MailServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/com/yc/crm/mail/action/MailController.java
@@ -2,6 +2,7 @@ import com.yc.crm.mail.entity.*; import com.yc.crm.mail.service.MailAccountIfc; import com.yc.crm.mail.service.MailFileIfc; import com.yc.crm.mail.service.MailIfc; import com.yc.crm.mail.service.MailServiceIfc; import com.yc.crm.mail.util.AllBackMsg; @@ -47,6 +48,8 @@ MailIfc emailIfc; @Autowired MailServiceIfc mailServiceIfc; @Autowired MailFileIfc mailFileIfc; private static final Pattern EMAIL_PATTERN = Pattern.compile("^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$"); @@ -85,7 +88,8 @@ * @return */ @GetMapping("/getMailList.do") public AllBackMsg getMailList(String mail, @RequestParam(defaultValue = "1") Integer mailType, boolean isNoRead, HttpServletRequest request, HttpServletResponse response) throws Exception { public AllBackMsg getMailList(String mail, @RequestParam(defaultValue = "1") Integer mailType, @RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "20") Integer limit, boolean isNoRead, HttpServletRequest request, HttpServletResponse response) throws Exception { AllBackMsg msg = new AllBackMsg(); try { if (StringUtils.isNotBlank(mail)) { @@ -102,7 +106,7 @@ } DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息 SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源 List<t482101HList> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead, userCode); List<t482101HList> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead, userCode,page,limit); if (t482101HEntityList.size() > 0) { msg.setSuccess("执行完成", t482101HEntityList); } @@ -120,7 +124,8 @@ * @return */ @GetMapping("/getHandleMailList.do") public AllBackMsg getHandleMailList(String mail, HttpServletRequest request, HttpServletResponse response) throws Exception { public AllBackMsg getHandleMailList(String mail,@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "20") Integer limit, HttpServletRequest request, HttpServletResponse response) throws Exception { AllBackMsg msg = new AllBackMsg(); try { if (StringUtils.isNotBlank(mail)) { @@ -137,7 +142,7 @@ } DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息 SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源 List<t482101HList> t482101HEntityList = emailIfc.getHandleMailList(mail, userCode); List<t482101HList> t482101HEntityList = emailIfc.getHandleMailList(mail, userCode,page,limit); if (t482101HEntityList.size() > 0) { msg.setSuccess("执行完成", t482101HEntityList); } @@ -168,11 +173,11 @@ if (t482101HEntity != null) { if (StringUtils.isNotBlank(t482101HEntity.getAttachmentList())) {//附件的处理 //获取到附件内容 List<AttachmentEntity> attachmentEntities = emailIfc.getAttachmentEntityList(t482101HEntity.getAttachmentList()); List<AttachmentEntity> attachmentEntities = mailFileIfc.getAttachmentEntityList(t482101HEntity.getAttachmentList()); List<String> list = new ArrayList<>(); if (attachmentEntities.size() > 0) { for (AttachmentEntity a : attachmentEntities) { list.add(shoppingImageServer + "/uploads/attachment/" + dataSourceEntity.getDbId() + "/482101/" + a.getUnid() + "@p@" + a.getPhysicalFile()); list.add(shoppingImageServer + "/uploads/email/" + dataSourceEntity.getDbId() + "/482101/" + a.getUnid() + "@p@" + a.getPhysicalFile()); } t482101HEntity.setAttachmentPath(list); } src/com/yc/crm/mail/service/MailIfc.java
@@ -1,10 +1,8 @@ package com.yc.crm.mail.service; import com.yc.crm.mail.entity.MailFileEntity; import com.yc.crm.mail.entity.MailModuleEntity; import com.yc.crm.mail.entity.t482101HEntity; import com.yc.crm.mail.entity.t482101HList; import com.yc.entity.attachment.AttachmentEntity; import java.util.List; @@ -81,14 +79,14 @@ * @param isRead 是否已读 * @return */ List<t482101HList> getReceivingMailList(String email, Integer mailType, boolean isNoRead, String userCode); 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); List<t482101HList> getHandleMailList(String email,String userCode,Integer page,Integer limit); /** * 获取用户的全部邮件 @@ -112,29 +110,6 @@ * @return */ // Integer deleteMailDrafts(String userCode,String docCode); /** * 附件保存 * * @param unIdFile */ abstract void saveAttachment(List<MailFileEntity> mailFile); /** * 邮件附件的调用处理 * * @param unid * @return */ abstract List<AttachmentEntity> getAttachmentEntityList(String unIdSeq); /** * 删除附件 * * @param unId * @return */ abstract Integer deleteAttachment(List<String> unId); /** * 获取收件邮箱已经存在的MessageId集合 src/com/yc/crm/mail/service/MailImpl.java
@@ -3,7 +3,6 @@ import com.yc.action.grid.GridUtils; import com.yc.crm.mail.entity.*; import com.yc.entity.AttachmentConfig; import com.yc.entity.attachment.AttachmentEntity; import com.yc.sdk.shopping.service.imagedata.ShoppingImageDataIfc; import com.yc.sdk.weixincp.util.UploadFiles; import com.yc.service.BaseService; @@ -14,11 +13,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -210,7 +205,7 @@ } @Override public List<t482101HList> getReceivingMailList(String email, Integer mailType, boolean isNoRead, String userCode) { public List<t482101HList> getReceivingMailList(String email, Integer mailType, boolean isNoRead, String userCode, Integer page, Integer limit) { String sql = "set nocount on\n"; try { sql += "select companyId,companyName,mailType,DocCode,senderName,sender,receiver,subject,plain_text," + @@ -229,6 +224,8 @@ if (isNoRead) {//0表示未读,1表示已读 sql += " and isnull(read_flag,0) = 0"; } 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; @@ -236,7 +233,7 @@ } @Override public List<t482101HList> getHandleMailList(String email, String userCode) { public List<t482101HList> getHandleMailList(String email, String userCode, Integer page, Integer limit) { String sql = "set nocount on\n"; try { sql += "select companyId,companyName,mailType,DocCode,senderName,sender,receiver,subject,plain_text," + @@ -245,6 +242,8 @@ "handle_time from t482101H "; sql += " where isnull(handle_time,'') <> '' and isnull(handle_time,'') < getdate()"; sql += " and userCode=" + GridUtils.prossSqlParm(userCode) + " and receiver like '%" + email + "%'"; 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; @@ -276,84 +275,6 @@ "update_time=getdate() \n"; sql += " where docCode=" + GridUtils.prossSqlParm(mail.getDocCode()); sql += " select @@ROWCOUNT"; return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; } } @Override public void saveAttachment(List<MailFileEntity> mailFile) { try { } catch (Exception e) { throw e; } } @Override public List<AttachmentEntity> getAttachmentEntityList(String unIdSeq) { String unId = null; if (StringUtils.isBlank(unIdSeq)) { return null; } String[] array = unIdSeq.split(";"); unId = array[0];//在有值时候第一个必定是unId ArrayList<String> fieldId = new ArrayList<>(Arrays.asList(array)); fieldId.remove(0);//去掉第一个元素(UNID) String sql = " set nocount on \n" + " declare @unid varchar(50) = " + GridUtils.prossSqlParm(unId) + ",@fieldid varchar(1000) = " + GridUtils.prossSqlParm(StringUtils.join(fieldId, ",")) + " \n"; sql += " select UNID,seq,DocCode,RowId,FieldId,FormId, \n" + " PhysicalPath,PhysicalFile,OriginalFileName,FileSize,FileType, \n" + " AuthorCode,AuthorName,SmallPicPath,UploadTime,OriginalPicture \n" + " from _sys_Attachment \n" + " where unid = @unid "; if (fieldId.size() > 0) { if (isNumeric(fieldId.get(0))) { sql += " and seq in(select list from GetInStr(@fieldid)) \n"; } else { sql += " and fieldid in(select list from GetInStr(@fieldid)) \n"; } } List<Map<String, Object>> list = this.jdbcTemplate.queryForList(sql); List<AttachmentEntity> attachmentList = new ArrayList<AttachmentEntity>(); for (int i = 0; list != null && i < list.size(); i++) { AttachmentEntity attachment = new AttachmentEntity(); attachment.setUnid(unId); attachment.setPhysicalFile(list.get(i).get("PhysicalFile") == null ? null : (String) list.get(i).get("PhysicalFile")); attachment.setOriginalFileName(list.get(i).get("OriginalFileName") == null ? null : (String) list.get(i).get("OriginalFileName")); attachment.setOriginalPicture(list.get(i).get("OriginalPicture") == null ? null : (byte[]) list.get(i).get("OriginalPicture")); //附件处理 attachmentList.add(attachment); } return attachmentList; } /** * 判断是否为数字 * * @param str * @return */ private static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("\\d+"); Matcher matcher = pattern.matcher(str); return matcher.matches(); } @Transactional(rollbackFor = Exception.class) @Override public Integer deleteAttachment(List<String> unId) { try { if (unId == null || unId.size() == 0) { return 0; } String sql = " set nocount on \n" + " declare @unid varchar(4000) = '" + StringUtils.join(unId, ",") + "' \n"; sql += "delete _sys_Attachment where unid in (select list from GetInStr(@unid)) \n"; sql += "select @@ROWCOUNT"; return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; src/com/yc/crm/mail/service/MailServiceIfc.java
@@ -41,4 +41,5 @@ * @return */ Integer setQuickReply(String docCode,String content) throws MessagingException; } src/com/yc/crm/mail/service/MailServiceImpl.java
@@ -33,11 +33,12 @@ */ @Service public class MailServiceImpl extends BaseService implements MailServiceIfc { @Autowired MailIfc mailIfc; @Autowired MailAccountIfc mailAccountIfc; @Autowired MailFileIfc mailFileIfc; @Override public void receivingEmails(T482102Entity emailEntity, FoundationEntity foundation) throws MessagingException { @@ -179,7 +180,7 @@ //下面附件内容 if (StringUtils.isNotBlank(t482101H.getAttachmentList())) {//有附件内容 //获取到附件内容 List<AttachmentEntity> attachmentEntities = mailIfc.getAttachmentEntityList(t482101H.getAttachmentList()); List<AttachmentEntity> attachmentEntities = mailFileIfc.getAttachmentEntityList(t482101H.getAttachmentList()); if (attachmentEntities != null && attachmentEntities.size() > 0) { for (AttachmentEntity a : attachmentEntities) { InputStream inputStream = new ByteArrayInputStream(a.getOriginalPicture()); @@ -437,7 +438,7 @@ String nextResult = result.toString(); if (nextResult.contains(cId)) {//有嵌套内容 //替换 nextResult = nextResult.replace("cid:" + cId + "", shoppingImageServer + "/mail/attachment/82/482101/" + unId + "@p@" + p.getPhysicalFile()); nextResult = nextResult.replace("cid:" + cId + "", shoppingImageServer + "/uploads/email/82/482101/" + unId + "@p@" + p.getPhysicalFile()); result.setLength(0);//清空先 result.append(nextResult); }