|
@@ -46,6 +46,8 @@ import org.springframework.util.StopWatch;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
@@ -206,9 +208,10 @@ public class EmailParseService {
|
|
|
}
|
|
|
|
|
|
private String getDestinationPath(String filepath, String extension) {
|
|
|
- String fileName = Paths.get(filepath).getFileName().toString();
|
|
|
+ Path path = Paths.get(filepath);
|
|
|
+ String fileName = path.getFileName().toString();
|
|
|
String baseName = fileName.substring(0, fileName.length() - extension.length());
|
|
|
- return Paths.get(filepath).getParent().resolve(baseName).toString();
|
|
|
+ return path.getParent().resolve(baseName).toString();
|
|
|
}
|
|
|
|
|
|
public void saveRelatedTable(String emailKey, String emailAddress,
|
|
@@ -217,6 +220,9 @@ public class EmailParseService {
|
|
|
List<ParseResult<ReportData>> dataList = ListUtil.list(false);
|
|
|
for (Map.Entry<EmailContentInfoDTO, List<EmailZipFileDTO>> entry : emailZipFileMap.entrySet()) {
|
|
|
EmailContentInfoDTO emailContentInfoDTO = entry.getKey();
|
|
|
+ if (emailContentInfoDTO.getFileName() != null && emailContentInfoDTO.getFileName().endsWith(".html")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
Integer emailId = emailContentInfoDTO.getEmailId();
|
|
|
EmailParseInfoDO emailParseInfoDO = buildEmailParseInfo(emailId, emailAddress, emailContentInfoDTO);
|
|
|
emailParseInfoDO.setEmailKey(emailKey);
|
|
@@ -224,9 +230,6 @@ public class EmailParseService {
|
|
|
if (emailId == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- if (emailContentInfoDTO.getFileName() != null && emailContentInfoDTO.getFileName().endsWith(".html")) {
|
|
|
- continue;
|
|
|
- }
|
|
|
|
|
|
List<EmailZipFileDTO> zipFiles = entry.getValue();
|
|
|
if (CollUtil.isNotEmpty(zipFiles)) {
|
|
@@ -272,10 +275,9 @@ public class EmailParseService {
|
|
|
private ParseResult<ReportData> parseReportAndHandleResult(int fileId, String fileName,
|
|
|
String filepath, Integer emailType, String aiFileId) {
|
|
|
ParseResult<ReportData> result = new ParseResult<>();
|
|
|
- if ((!Objects.equals(EmailTypeConst.REPORT_EMAIL_TYPE, emailType)
|
|
|
- && !Objects.equals(EmailTypeConst.REPORT_LETTER_EMAIL_TYPE, emailType))
|
|
|
- || StrUtil.isBlank(fileName)
|
|
|
- || fileName.endsWith(".html")) {
|
|
|
+ boolean reportFlag = !Objects.equals(EmailTypeConst.REPORT_EMAIL_TYPE, emailType)
|
|
|
+ && !Objects.equals(EmailTypeConst.REPORT_LETTER_EMAIL_TYPE, emailType);
|
|
|
+ if (reportFlag || StrUtil.isBlank(fileName) || fileName.endsWith(".html")) {
|
|
|
result.setStatus(ReportParseStatus.NOT_A_REPORT.getCode());
|
|
|
result.setMsg(StrUtil.format(ReportParseStatus.NOT_A_REPORT.getMsg(), fileName));
|
|
|
return result;
|
|
@@ -288,6 +290,9 @@ public class EmailParseService {
|
|
|
}
|
|
|
// 类型识别---先识别季度报告,没有季度再识别年度报告,最后识别月报
|
|
|
ReportType reportType = ReportParseUtils.matchReportType(fileName);
|
|
|
+ if (Objects.equals(EmailTypeConst.REPORT_LETTER_EMAIL_TYPE, emailType)) {
|
|
|
+ reportType = ReportType.LETTER;
|
|
|
+ }
|
|
|
// 解析器--如果开启python解析则直接调用python接口,否则根据文件后缀获取对应解析器
|
|
|
ReportParserFileType fileType;
|
|
|
String fileSuffix = StrUtil.subAfter(fileName, ".", true);
|
|
@@ -486,7 +491,7 @@ public class EmailParseService {
|
|
|
saveFile.setReadable(true);
|
|
|
if (!saveFile.exists()) {
|
|
|
if (!saveFile.getParentFile().exists()) {
|
|
|
- saveFile.getParentFile().mkdirs();
|
|
|
+ Files.createDirectories(saveFile.getParentFile().toPath());
|
|
|
saveFile.getParentFile().setExecutable(true);
|
|
|
}
|
|
|
}
|