|
@@ -414,13 +414,8 @@ public class EmailParseService {
|
|
|
|
|
|
public Map<Integer, List<String>> getEmailType() {
|
|
|
Map<Integer, List<String>> emailTypeMap = MapUtil.newHashMap(3, true);
|
|
|
-// EmailTypeRuleDO emailTypeRuleDO = emailTypeRuleMapper.getEmailTypeRule();
|
|
|
-// String nav = emailTypeRuleDO != null && StrUtil.isNotBlank(emailTypeRuleDO.getNav()) ? emailTypeRuleDO.getNav() : emailRuleConfig.getNav();
|
|
|
-// String valuation = emailTypeRuleDO != null && StrUtil.isNotBlank(emailTypeRuleDO.getValuation()) ? emailTypeRuleDO.getValuation() : emailRuleConfig.getValuation();
|
|
|
-// String report = emailTypeRuleDO != null && StrUtil.isNotBlank(emailTypeRuleDO.getReport()) ? emailTypeRuleDO.getReport() : emailRuleConfig.getReport();
|
|
|
-// emailTypeMap.put(EmailTypeConst.VALUATION_EMAIL_TYPE, Arrays.stream(valuation.split(",")).toList());
|
|
|
-// emailTypeMap.put(EmailTypeConst.NAV_EMAIL_TYPE, Arrays.stream(nav.split(",")).toList());
|
|
|
-// emailTypeMap.put(EmailTypeConst.REPORT_EMAIL_TYPE, ListUtil.toList("月报", "周报", "月度报告"));
|
|
|
+ emailTypeMap.put(EmailTypeConst.REPORT_EMAIL_TYPE,
|
|
|
+ ListUtil.toList("月报", "月度报告", "季报", "季度报告", "年报", "年度报告"));
|
|
|
emailTypeMap.put(EmailTypeConst.REPORT_LETTER_EMAIL_TYPE,
|
|
|
ListUtil.toList("确认单", "确认函", "交易确认数据", "赎回确认", "申购确认", "分红确认", "确认表", "交易确认", "确认"));
|
|
|
return emailTypeMap;
|
|
@@ -452,32 +447,35 @@ public class EmailParseService {
|
|
|
}
|
|
|
Map<String, List<EmailContentInfoDTO>> emailMessageMap = MapUtil.newHashMap();
|
|
|
for (Message message : messages) {
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
List<EmailContentInfoDTO> emailContentInfoDTOList = CollUtil.newArrayList();
|
|
|
String uuidKey = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
Integer emailType;
|
|
|
String senderEmail;
|
|
|
+ String emailTitle = null;
|
|
|
try {
|
|
|
Date emailDate = message.getSentDate();
|
|
|
boolean isNotParseConditionSatisfied = emailDate == null || (endDate != null && emailDate.compareTo(endDate) > 0) || (startDate != null && emailDate.compareTo(startDate) < 0);
|
|
|
if (isNotParseConditionSatisfied) {
|
|
|
continue;
|
|
|
}
|
|
|
+ emailTitle = message.getSubject();
|
|
|
senderEmail = getSenderEmail(message);
|
|
|
- emailType = EmailUtil.getEmailTypeBySubject(message.getSubject(), emailTypeMap);
|
|
|
+ emailType = EmailUtil.getEmailTypeBySubject(emailTitle, emailTypeMap);
|
|
|
String emailDateStr = DateUtil.format(emailDate, DateConst.YYYY_MM_DD_HH_MM_SS);
|
|
|
if (emailType == null) {
|
|
|
- log.info("邮件不满足解析条件 -> 邮件主题:{},邮件日期:{}", message.getSubject(), emailDateStr);
|
|
|
+ log.info("邮件不满足解析条件 -> 邮件主题:{},邮件日期:{}", emailTitle, emailDateStr);
|
|
|
continue;
|
|
|
}
|
|
|
- log.info("邮件采集成功 -> 邮件主题:{},邮件日期:{}", message.getSubject(), emailDateStr);
|
|
|
+ log.info("邮件{} 基本信息获取完成,开始下载附件!邮件日期:{}", emailTitle, emailDateStr);
|
|
|
Object content = message.getContent();
|
|
|
|
|
|
if (content instanceof Multipart multipart) {
|
|
|
- this.reMultipart(mailboxInfoDTO.getAccount(), message.getSubject(), emailDate, multipart, emailContentInfoDTOList);
|
|
|
+ this.reMultipart(mailboxInfoDTO.getAccount(), emailTitle, emailDate, multipart, emailContentInfoDTOList);
|
|
|
} else if (content instanceof Part part) {
|
|
|
- this.rePart(mailboxInfoDTO.getAccount(), message.getSubject(), emailDate, part, emailContentInfoDTOList);
|
|
|
+ this.rePart(mailboxInfoDTO.getAccount(), emailTitle, emailDate, part, emailContentInfoDTOList);
|
|
|
} else {
|
|
|
- log.warn("不支持的邮件数据 {}", message.getSubject());
|
|
|
+ log.warn("不支持的邮件数据 {}", emailTitle);
|
|
|
}
|
|
|
|
|
|
if (CollUtil.isNotEmpty(emailContentInfoDTOList)) {
|
|
@@ -487,9 +485,12 @@ public class EmailParseService {
|
|
|
});
|
|
|
emailMessageMap.put(uuidKey, emailContentInfoDTOList);
|
|
|
}
|
|
|
- log.info("邮件{} 采集内容是:{}", message.getSubject(), emailContentInfoDTOList);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("获取邮箱的邮件报错,堆栈信息:{}", ExceptionUtil.stacktraceToString(e));
|
|
|
+ log.error("获取邮箱的邮件{} 报错,堆栈信息:{}", emailTitle, ExceptionUtil.stacktraceToString(e));
|
|
|
+ } finally {
|
|
|
+ if (log.isInfoEnabled()) {
|
|
|
+ log.info("邮件{} 下载完成,总计耗时{} ms", emailTitle, System.currentTimeMillis() - start);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
folder.close(false);
|
|
@@ -508,6 +509,7 @@ public class EmailParseService {
|
|
|
|
|
|
String fileName = MimeUtility.decodeText(part.getFileName());
|
|
|
emailContentInfoDTO.setFileName(fileName);
|
|
|
+ emailContentInfoDTO.setFileSize((long) part.getSize());
|
|
|
|
|
|
String realPath = filePath + emailDate + fileName;
|
|
|
|
|
@@ -549,7 +551,6 @@ public class EmailParseService {
|
|
|
try {
|
|
|
senderAddress = message.getFrom();
|
|
|
if (senderAddress == null || senderAddress.length == 0) {
|
|
|
- log.info("发件人获取失败=============================");
|
|
|
return null;
|
|
|
}
|
|
|
// 此时的address是含有编码(MIME编码方式)后的文本和实际的邮件地址
|
|
@@ -560,7 +561,6 @@ public class EmailParseService {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- log.info("发件人地址:{}========================senderAddress size:{}", address, senderAddress.length);
|
|
|
// 正则表达式匹配邮件地址
|
|
|
Pattern pattern = Pattern.compile("<(\\S+)>");
|
|
|
Matcher matcher = pattern.matcher(address);
|