|
@@ -26,6 +26,7 @@ import jakarta.mail.search.ReceivedDateTerm;
|
|
|
import jakarta.mail.search.SearchTerm;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
@@ -43,12 +44,15 @@ public class EmailParseService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(EmailParseService.class);
|
|
|
|
|
|
+ @Value("${email.file.path}")
|
|
|
+ private String path;
|
|
|
+
|
|
|
private final EmailTypeRuleMapper emailTypeRuleMapper;
|
|
|
private final EmailRuleConfig emailRuleConfig;
|
|
|
private final EmailFieldMappingMapper emailFieldMapper;
|
|
|
private final EmailParserFactory emailParserFactory;
|
|
|
private final EmailParseInfoMapper emailParseInfoMapper;
|
|
|
- private final FundInfomationMapper fundInfomationMapper;
|
|
|
+ private final FundInfoMapper fundInfoMapper;
|
|
|
private final EmailFileInfoMapper emailFileInfoMapper;
|
|
|
private final EmailFundNavMapper emailFundNavMapper;
|
|
|
private final EmailFundAssetMapper emailFundAssetMapper;
|
|
@@ -56,7 +60,7 @@ public class EmailParseService {
|
|
|
|
|
|
public EmailParseService(EmailTypeRuleMapper emailTypeRuleMapper, EmailRuleConfig emailRuleConfig,
|
|
|
EmailFieldMappingMapper emailFieldMapper, EmailParserFactory emailParserFactory,
|
|
|
- EmailParseInfoMapper emailParseInfoMapper, FundInfomationMapper fundInfomationMapper,
|
|
|
+ EmailParseInfoMapper emailParseInfoMapper, FundInfoMapper fundInfoMapper,
|
|
|
EmailFileInfoMapper emailFileInfoMapper, EmailFundNavMapper emailFundNavMapper,
|
|
|
EmailFundAssetMapper emailFundAssetMapper, FundAliasMapper fundAliasMapper) {
|
|
|
this.emailTypeRuleMapper = emailTypeRuleMapper;
|
|
@@ -64,7 +68,7 @@ public class EmailParseService {
|
|
|
this.emailFieldMapper = emailFieldMapper;
|
|
|
this.emailParserFactory = emailParserFactory;
|
|
|
this.emailParseInfoMapper = emailParseInfoMapper;
|
|
|
- this.fundInfomationMapper = fundInfomationMapper;
|
|
|
+ this.fundInfoMapper = fundInfoMapper;
|
|
|
this.emailFileInfoMapper = emailFileInfoMapper;
|
|
|
this.emailFundNavMapper = emailFundNavMapper;
|
|
|
this.emailFundAssetMapper = emailFundAssetMapper;
|
|
@@ -296,7 +300,7 @@ public class EmailParseService {
|
|
|
|
|
|
private List<String> matchFund(String fundName, String registerNumber) {
|
|
|
// 1.基金名称 + 备案编码 一起进行匹配
|
|
|
- List<String> fundIdList = fundInfomationMapper.queryFundByNameAndRegisterNumber(fundName, registerNumber);
|
|
|
+ List<String> fundIdList = fundInfoMapper.queryFundByNameAndRegisterNumber(fundName, registerNumber);
|
|
|
if (CollUtil.isNotEmpty(fundIdList)) {
|
|
|
return fundIdList;
|
|
|
}
|
|
@@ -306,7 +310,7 @@ public class EmailParseService {
|
|
|
}
|
|
|
// 2.基金名称匹配
|
|
|
if (StrUtil.isNotBlank(fundName)) {
|
|
|
- List<String> fundIds = fundInfomationMapper.queryFundByName(fundName);
|
|
|
+ List<String> fundIds = fundInfoMapper.queryFundByName(fundName);
|
|
|
if (CollUtil.isNotEmpty(fundIds)) {
|
|
|
return fundIdList;
|
|
|
}
|
|
@@ -317,7 +321,7 @@ public class EmailParseService {
|
|
|
}
|
|
|
// 3.备案编码匹配
|
|
|
if (StrUtil.isNotBlank(fundName)) {
|
|
|
- List<String> fundIds = fundInfomationMapper.queryFundByRegisterNumber(registerNumber);
|
|
|
+ List<String> fundIds = fundInfoMapper.queryFundByRegisterNumber(registerNumber);
|
|
|
if (CollUtil.isNotEmpty(fundIds)) {
|
|
|
return fundIds;
|
|
|
}
|
|
@@ -408,7 +412,6 @@ public class EmailParseService {
|
|
|
// 获取邮件日期大于等于startDate的邮件(搜索条件只支持按天)
|
|
|
SearchTerm startDateTerm = new ReceivedDateTerm(ComparisonTerm.GE, startDate);
|
|
|
Message[] messages = folder.search(startDateTerm);
|
|
|
- String path = "/data/file/nav";
|
|
|
Map<String, List<EmailContentInfoDTO>> emailMessageMap = MapUtil.newHashMap();
|
|
|
for (Message message : messages) {
|
|
|
List<EmailContentInfoDTO> emailContentInfoDTOList = CollUtil.newArrayList();
|
|
@@ -439,8 +442,8 @@ public class EmailParseService {
|
|
|
emailContentInfoDTO.setEmailContent(content.toString());
|
|
|
emailContentInfoDTO.setEmailDate(emailDateStr);
|
|
|
String fileName = message.getSubject() + DateUtil.format(emailDate, DateConst.YYYYMMDDHHMMSS24);
|
|
|
- String filePath = path + mailboxInfoDTO.getAccount() + "/" + fileName + ".html";
|
|
|
- File savefile = new File(path + filePath);
|
|
|
+ String filePath = path + mailboxInfoDTO.getAccount() + "/" + DateUtil.format(emailDate, DateConst.YYYY_MM_DD) + "/" + fileName + ".html";
|
|
|
+ File savefile = new File(filePath);
|
|
|
savefile.setReadable(true);
|
|
|
if (!savefile.exists()) {
|
|
|
if (!savefile.getParentFile().exists()) {
|