| | |
| | | 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()); |
| | |
| | | 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()); |
| | |
| | | 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; |
| | |
| | | * @param docCode |
| | | */ |
| | | abstract void updateMailHandle(String handleTime,String docCode); |
| | | |
| | | abstract Integer getMailTotal(String email, Integer mailType, boolean isNoRead,String userCode); |
| | | } |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | |
| | | 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(); |
| | |
| | | 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)) {//在有扩展名时候 |
| | |
| | | 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)); |
| | | } |
| | |
| | | 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)); |