|
@@ -173,7 +173,7 @@ public class EmailParseService {
|
|
|
|
|
|
// 保存相关信息 -> 邮件信息表,邮件文件表,邮件净值表,邮件规模表,基金净值表
|
|
|
saveRelatedTable(emailEntry.getKey(), mailboxInfoDTO.getAccount(), emailZipFileMap);
|
|
|
- log.info("结束邮件解析 -> 邮箱信息:{},开始时间:{},结束时间:{}", mailboxInfoDTO,
|
|
|
+ log.info("结束邮件解析 -> 邮箱信息:{},开始时间:{},结束时间:{}", emailEntry.getValue(),
|
|
|
DateUtil.format(startDate, DateConst.YYYY_MM_DD_HH_MM_SS), DateUtil.format(endDate, DateConst.YYYY_MM_DD_HH_MM_SS));
|
|
|
}
|
|
|
}
|
|
@@ -254,6 +254,44 @@ public class EmailParseService {
|
|
|
if (emailContentInfoDTO.getFileName() != null && emailContentInfoDTO.getFileName().endsWith(".html")) {
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ // 待解析文件数据处理,不支持已存在的文件重复解析
|
|
|
+ List<EmailZipFileDTO> dtos = ListUtil.list(false);
|
|
|
+ List<EmailZipFileDTO> zipFiles = entry.getValue();
|
|
|
+ if (CollUtil.isEmpty(zipFiles)) {
|
|
|
+ dtos.add(new EmailZipFileDTO(emailContentInfoDTO.getFilePath(), emailContentInfoDTO.getEmailType()));
|
|
|
+ } else {
|
|
|
+ dtos.addAll(zipFiles);
|
|
|
+ }
|
|
|
+
|
|
|
+ String emailTitle = emailContentInfoDTO.getEmailTitle();
|
|
|
+ // 数据库已存在的数据过滤
|
|
|
+ Iterator<EmailZipFileDTO> iterator = dtos.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ EmailZipFileDTO dto = iterator.next();
|
|
|
+ Integer emailType = dto.getEmailType();
|
|
|
+ String filename = dto.getFilename();
|
|
|
+ if (Objects.equals(emailType, EmailTypeConst.REPORT_LETTER_EMAIL_TYPE)) {
|
|
|
+ int count = this.emailFileInfoMapper.getLetterFilenameSuccessCount(filename);
|
|
|
+ if (count > 0) {
|
|
|
+ iterator.remove();
|
|
|
+ log.info("邮件{} 附件{} 已存在解析成功的记录,不用重新解析。", emailTitle, filename);
|
|
|
+ }
|
|
|
+ } else if (Objects.equals(emailType, EmailTypeConst.REPORT_EMAIL_TYPE)) {
|
|
|
+ // todo 定期报告
|
|
|
+ } else if (EmailTypeConst.REPORT_EMAIL_TYPES.contains(emailType)) {
|
|
|
+ // todo 其他报告
|
|
|
+ } else {
|
|
|
+ log.info("邮件{} 类型{} 不支持解析。", emailTitle, emailType);
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(dtos)) {
|
|
|
+ log.warn("邮件{} 所有文件都已经解析成功过,不能重复解析了", emailTitle);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
Integer emailId = emailContentInfoDTO.getEmailId();
|
|
|
EmailParseInfoDO emailParseInfoDO = buildEmailParseInfo(emailId, emailAddress, emailContentInfoDTO);
|
|
|
emailParseInfoDO.setEmailKey(emailKey);
|
|
@@ -262,22 +300,11 @@ public class EmailParseService {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- List<EmailZipFileDTO> zipFiles = entry.getValue();
|
|
|
- if (CollUtil.isNotEmpty(zipFiles)) {
|
|
|
- for (EmailZipFileDTO zipFile : zipFiles) {
|
|
|
- EmailFileInfoDO emailFile = saveEmailFileInfo(emailId, null, zipFile.getFilename(), zipFile.getFilepath(), null);
|
|
|
- // 解析并保存报告
|
|
|
- ParseResult<ReportData> parseResult = this.parseReportAndHandleResult(emailFile.getId(), zipFile.getFilename(),
|
|
|
- zipFile.getFilepath(), zipFile.getEmailType(), emailFile.getAiFileId());
|
|
|
- dataList.add(parseResult);
|
|
|
- }
|
|
|
- } else {
|
|
|
- String fileName = emailContentInfoDTO.getFileName();
|
|
|
- EmailFileInfoDO emailFile = saveEmailFileInfo(emailId, emailContentInfoDTO.getFileId(), fileName,
|
|
|
- emailContentInfoDTO.getFilePath(), emailContentInfoDTO.getAiFileId());
|
|
|
+ for (EmailZipFileDTO zipFile : dtos) {
|
|
|
+ EmailFileInfoDO emailFile = saveEmailFileInfo(emailId, null, zipFile.getFilename(), zipFile.getFilepath(), null);
|
|
|
// 解析并保存报告
|
|
|
- ParseResult<ReportData> parseResult = this.parseReportAndHandleResult(emailFile.getId(), fileName,
|
|
|
- emailContentInfoDTO.getFilePath(), emailContentInfoDTO.getEmailType(), emailFile.getAiFileId());
|
|
|
+ ParseResult<ReportData> parseResult = this.parseReportAndHandleResult(emailFile.getId(), zipFile.getFilename(),
|
|
|
+ zipFile.getFilepath(), zipFile.getEmailType(), emailFile.getAiFileId());
|
|
|
dataList.add(parseResult);
|
|
|
}
|
|
|
|
|
@@ -590,7 +617,7 @@ public class EmailParseService {
|
|
|
senderEmail = getSenderEmail(message);
|
|
|
emailType = EmailUtil.getEmailTypeBySubject(emailTitle, emailTypeMap);
|
|
|
if (emailType == null) {
|
|
|
- log.warn("{} 邮件不满足解析条件 -> 邮件主题:{},邮件日期:{}", folderName, emailTitle, emailDateStr);
|
|
|
+ log.warn("{} 邮件不满足解析条件 -> 邮件主题:{},邮件日期:{}", folderName, emailTitle, emailDateStr);
|
|
|
continue;
|
|
|
}
|
|
|
log.info("{} 邮件{} 基本信息获取完成,开始下载附件!邮件日期:{}", folderName, emailTitle, emailDateStr);
|