|
@@ -79,7 +79,7 @@ public class NavEmailParser extends AbstractEmailParser {
|
|
|
Optional.ofNullable(fundNavDTOList).ifPresent(emailFundNavDTOList::addAll);
|
|
|
}
|
|
|
// 4.解析邮件zip,rar附件
|
|
|
- if (StrUtil.isNotBlank(emailContentInfoDTO.getFilePath()) && ExcelUtil.isZip(emailContentInfoDTO.getFileName())) {
|
|
|
+ if (StrUtil.isNotBlank(emailContentInfoDTO.getFilePath()) && (ExcelUtil.isZip(emailContentInfoDTO.getFileName()) || ExcelUtil.isRAR(emailContentInfoDTO.getFileName()))) {
|
|
|
List<EmailFundNavDTO> fundNavDTOList = parsePackageFile(emailContentInfoDTO, emailContentInfoDTO.getFileName(), emailContentInfoDTO.getFilePath(), emailFieldMap);
|
|
|
Optional.ofNullable(fundNavDTOList).ifPresent(emailFundNavDTOList::addAll);
|
|
|
}
|
|
@@ -105,18 +105,41 @@ public class NavEmailParser extends AbstractEmailParser {
|
|
|
}
|
|
|
|
|
|
private List<EmailFundNavDTO> parsePackageFile(EmailContentInfoDTO emailContentInfoDTO, String fileName, String filePath, Map<String, List<String>> emailFieldMap) {
|
|
|
- String destPath = filePath.replaceAll(".zip", "").replaceAll(".ZIP", "");
|
|
|
- log.info("压缩包地址:{},解压后文件地址:{}", filePath, destPath);
|
|
|
- List<String> dir = ExcelUtil.extractCompressedFiles(filePath, destPath);
|
|
|
List<EmailFundNavDTO> emailFundNavDTOList = CollUtil.newArrayList();
|
|
|
- for (String zipFilePath : dir) {
|
|
|
- emailFundNavDTOList.addAll(parseZipFile(emailContentInfoDTO, zipFilePath, emailFieldMap));
|
|
|
- File file = new File(zipFilePath);
|
|
|
- if (file.isDirectory()) {
|
|
|
- for (String navFilePath : Objects.requireNonNull(file.list())) {
|
|
|
- emailFundNavDTOList.addAll(parseZipFile(emailContentInfoDTO, navFilePath, emailFieldMap));
|
|
|
+ if(ExcelUtil.isZip(filePath)){
|
|
|
+ String destPath = filePath.replaceAll(".zip", "").replaceAll(".ZIP", "");
|
|
|
+ log.info("压缩包地址:{},解压后文件地址:{}", filePath, destPath);
|
|
|
+ List<String> dir = ExcelUtil.extractCompressedFiles(filePath, destPath);
|
|
|
+ for (String zipFilePath : dir) {
|
|
|
+ emailFundNavDTOList.addAll(parseZipFile(emailContentInfoDTO, zipFilePath, emailFieldMap));
|
|
|
+ File file = new File(zipFilePath);
|
|
|
+ if (file.isDirectory()) {
|
|
|
+ for (String navFilePath : Objects.requireNonNull(file.list())) {
|
|
|
+ emailFundNavDTOList.addAll(parseZipFile(emailContentInfoDTO, navFilePath, emailFieldMap));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ if(ExcelUtil.isRAR(filePath)){
|
|
|
+ String destPath = filePath.replaceAll(".rar", "").replaceAll(".RAR", "");
|
|
|
+ File destFile = new File(destPath);
|
|
|
+ if (!destFile.exists()) {
|
|
|
+ destFile.mkdirs();
|
|
|
+ }
|
|
|
+ List<String> rarDir = ExcelUtil.extractRar(filePath, destPath);
|
|
|
+ for (String rarFilePath : rarDir) {
|
|
|
+ emailFundNavDTOList.addAll(parseZipFile(emailContentInfoDTO, rarFilePath, emailFieldMap));
|
|
|
+ File file = new File(rarFilePath);
|
|
|
+ if (file.isDirectory()) {
|
|
|
+ for (String navFilePath : Objects.requireNonNull(file.list())) {
|
|
|
+ emailFundNavDTOList.addAll(parseZipFile(emailContentInfoDTO, navFilePath, emailFieldMap));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
}
|
|
|
return emailFundNavDTOList;
|
|
|
}
|