|
@@ -91,6 +91,9 @@ public class EmailParseService {
|
|
|
@Autowired
|
|
|
private ReportWriterFactory reportWriterFactory;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ChannelMapper channelMapper;
|
|
|
+
|
|
|
public EmailParseService(EmailTypeRuleMapper emailTypeRuleMapper, EmailRuleConfig emailRuleConfig,
|
|
|
EmailFieldMappingMapper emailFieldMapper, EmailParserFactory emailParserFactory,
|
|
|
EmailParseInfoMapper emailParseInfoMapper, EmailFileInfoMapper emailFileInfoMapper,
|
|
@@ -98,7 +101,8 @@ public class EmailParseService {
|
|
|
AssetMapper assetMapper, NavMapper navMapper, FundService fundService,
|
|
|
FundAliasMapper fundAliasMapper,
|
|
|
ValuationTableMapper valuationTableMapper, ValuationTableAttributeMapper valuationTableAttributeMapper,
|
|
|
- FundPositionDetailMapper fundPositionDetailMapper, DistributionMapper distributionMapper, CompanyInformationMapper companyInformationMapper, FileManageMapper fileManageMapper, FundInfoMapper fundInfoMapper) {
|
|
|
+ FundPositionDetailMapper fundPositionDetailMapper, DistributionMapper distributionMapper, CompanyInformationMapper companyInformationMapper,
|
|
|
+ FileManageMapper fileManageMapper, FundInfoMapper fundInfoMapper,ChannelMapper channelMapper) {
|
|
|
this.emailTypeRuleMapper = emailTypeRuleMapper;
|
|
|
this.emailRuleConfig = emailRuleConfig;
|
|
|
this.emailFieldMapper = emailFieldMapper;
|
|
@@ -112,7 +116,7 @@ public class EmailParseService {
|
|
|
this.navMapper = navMapper;
|
|
|
this.fundService = fundService;
|
|
|
this.fundAliasMapper = fundAliasMapper;
|
|
|
-
|
|
|
+ this.channelMapper = channelMapper;
|
|
|
this.valuationTableMapper = valuationTableMapper;
|
|
|
this.valuationTableAttributeMapper = valuationTableAttributeMapper;
|
|
|
this.fundPositionDetailMapper = fundPositionDetailMapper;
|
|
@@ -195,12 +199,15 @@ public class EmailParseService {
|
|
|
String emailDate = CollUtil.isNotEmpty(emailContentInfoDTOList) ? emailContentInfoDTOList.get(0).getEmailDate() : null;
|
|
|
Integer emailType = CollUtil.isNotEmpty(emailContentInfoDTOList) ? emailContentInfoDTOList.get(0).getEmailType() : null;
|
|
|
Integer emailId = CollUtil.isNotEmpty(emailContentInfoDTOList) ? emailContentInfoDTOList.get(0).getEmailId() : null;
|
|
|
- String senderEmail = CollUtil.isNotEmpty(emailContentInfoDTOList) ? emailContentInfoDTOList.get(0).getSenderEmail() : null;
|
|
|
+ String senderEmail = CollUtil.isNotEmpty(emailContentInfoDTOList) ? emailContentInfoDTOList.get(0).getSenderEmail() : "";
|
|
|
Date parseDate = new Date();
|
|
|
int emailParseStatus = EmailParseStatusConst.SUCCESS;
|
|
|
EmailParseInfoDO emailParseInfoDO = buildEmailParseInfo(emailId, emailAddress, senderEmail, emailDate, emailTitle, emailType, emailParseStatus, parseDate);
|
|
|
emailId = saveEmailParseInfo(emailParseInfoDO);
|
|
|
-
|
|
|
+ Integer channelId = channelMapper.selectChannelIdByEmail(emailAddress);
|
|
|
+ if(channelId == null){
|
|
|
+ channelId=-1;
|
|
|
+ }
|
|
|
// python 报告解析接口结果
|
|
|
List<ParseResult<ReportData>> dataList = ListUtil.list(false);
|
|
|
for (Map.Entry<EmailContentInfoDTO, List<EmailFundNavDTO>> fileNameNavEntry : fileNameNavMap.entrySet()) {
|
|
@@ -258,7 +265,7 @@ public class EmailParseService {
|
|
|
log.error("保存文件管理信息报错:"+e.getMessage(),e);
|
|
|
}
|
|
|
// 保存净值表和规模表
|
|
|
- saveNavAndAssetNet(fileId, fundNavDTOList, parseDate);
|
|
|
+ saveNavAndAssetNet(channelId,fileId, fundNavDTOList, parseDate);
|
|
|
saveValuationInfo(fileId, fundNavDTOList);
|
|
|
}
|
|
|
|
|
@@ -620,13 +627,13 @@ public class EmailParseService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private void saveNavAndAssetNet(Integer fileId, List<EmailFundNavDTO> fundNavDTOList, Date parseDate) {
|
|
|
+ private void saveNavAndAssetNet(Integer channelId,Integer fileId, List<EmailFundNavDTO> fundNavDTOList, Date parseDate) {
|
|
|
if (CollUtil.isEmpty(fundNavDTOList)) {
|
|
|
return;
|
|
|
}
|
|
|
// 净值数据
|
|
|
List<EmailFundNavDO> emailFundNavDOList = fundNavDTOList.stream()
|
|
|
- .map(e -> buildEmailFundNavDo(fileId, e, parseDate)).filter(CollUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toList());
|
|
|
+ .map(e -> buildEmailFundNavDo(channelId,fileId, e, parseDate)).filter(CollUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toList());
|
|
|
if (CollUtil.isNotEmpty(emailFundNavDOList)) {
|
|
|
// 先删除文件id下的净值数据(考虑到重新解析的需求,如果是首次解析,那么file_id下不存在净值数据)
|
|
|
emailFundNavMapper.deleteByFileId(fileId);
|
|
@@ -637,7 +644,7 @@ public class EmailParseService {
|
|
|
}
|
|
|
// 保存规模数据
|
|
|
List<EmailFundAssetDO> emailFundAssetDOList = fundNavDTOList.stream()
|
|
|
- .map(e -> buildEmailFundAssetDo(fileId, e, parseDate)).filter(CollUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toList());
|
|
|
+ .map(e -> buildEmailFundAssetDo(channelId,fileId, e, parseDate)).filter(CollUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toList());
|
|
|
if (CollUtil.isNotEmpty(emailFundAssetDOList)) {
|
|
|
// 先删除file_id下的规模数据(考虑到重新解析的需求,如果是首次解析,那么file_id下不存在规模数据)
|
|
|
emailFundAssetMapper.deleteByFileId(fileId);
|
|
@@ -707,6 +714,7 @@ public class EmailParseService {
|
|
|
EmailFundNavDO fundNavDO = new EmailFundNavDO();
|
|
|
fundNavDO.setFundId(insertDO.getFundId());
|
|
|
fundNavDO.setNav(insertDO.getNav());
|
|
|
+ fundNavDO.setChannelId(insertDO.getChannelId());
|
|
|
fundNavDO.setPriceDate(insertDO.getPriceDate());
|
|
|
fundNavDO.setCumulativeNavWithdrawal(insertDO.getCumulativeNavWithdrawal());
|
|
|
fundNavDO.setFileId(fileId);
|
|
@@ -720,11 +728,12 @@ public class EmailParseService {
|
|
|
if (CollUtil.isEmpty(assetDOList)) {
|
|
|
return;
|
|
|
}
|
|
|
+ Integer channelId = assetDOList.get(0).getChannelId();
|
|
|
Map<String, List<AssetDO>> fundIdNavMap = assetDOList.stream().collect(Collectors.groupingBy(AssetDO::getFundId));
|
|
|
for (Map.Entry<String, List<AssetDO>> entry : fundIdNavMap.entrySet()) {
|
|
|
List<AssetDO> assetDOS = entry.getValue();
|
|
|
List<String> priceDateList = assetDOS.stream().map(AssetDO::getPriceDate).map(e -> DateUtil.format(e, DateConst.YYYY_MM_DD)).collect(Collectors.toList());
|
|
|
- List<String> dateList = assetMapper.queryFundNavByDate(entry.getKey(), priceDateList);
|
|
|
+ List<String> dateList = assetMapper.queryFundNavByDate(entry.getKey(), priceDateList,channelId);
|
|
|
List<AssetDO> updateAssetDoList = assetDOS.stream().filter(e -> dateList.contains(DateUtil.format(e.getPriceDate(), DateConst.YYYY_MM_DD))).collect(Collectors.toList());
|
|
|
List<AssetDO> insertAssetDoList = assetDOS.stream().filter(e -> !dateList.contains(DateUtil.format(e.getPriceDate(), DateConst.YYYY_MM_DD))).collect(Collectors.toList());
|
|
|
if (CollUtil.isNotEmpty(insertAssetDoList)) {
|
|
@@ -742,7 +751,7 @@ public class EmailParseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<EmailFundAssetDO> buildEmailFundAssetDo(Integer fileId, EmailFundNavDTO fundNavDTO, Date parseDate) {
|
|
|
+ private List<EmailFundAssetDO> buildEmailFundAssetDo(Integer channelId,Integer fileId, EmailFundNavDTO fundNavDTO, Date parseDate) {
|
|
|
List<EmailFundAssetDO> fundAssetDOList = CollUtil.newArrayList();
|
|
|
BigDecimal assetNet = StrUtil.isNotBlank(fundNavDTO.getAssetNet()) ? new BigDecimal(fundNavDTO.getAssetNet()) : null;
|
|
|
BigDecimal assetShare = StrUtil.isNotBlank(fundNavDTO.getAssetShare()) ? new BigDecimal(fundNavDTO.getAssetShare()) : null;
|
|
@@ -756,6 +765,7 @@ public class EmailParseService {
|
|
|
for (String fundId : fundNavDTO.getFundIdList()) {
|
|
|
EmailFundAssetDO emailFundAssetDO = new EmailFundAssetDO();
|
|
|
emailFundAssetDO.setFileId(fileId);
|
|
|
+ emailFundAssetDO.setChannelId(channelId);
|
|
|
emailFundAssetDO.setPriceDate(priceDate);
|
|
|
emailFundAssetDO.setFundId(fundId);
|
|
|
emailFundAssetDO.setFundName(fundNavDTO.getFundName());
|
|
@@ -774,6 +784,7 @@ public class EmailParseService {
|
|
|
} else {
|
|
|
EmailFundAssetDO emailFundAssetDO = new EmailFundAssetDO();
|
|
|
emailFundAssetDO.setFileId(fileId);
|
|
|
+ emailFundAssetDO.setChannelId(channelId);
|
|
|
emailFundAssetDO.setPriceDate(priceDate);
|
|
|
emailFundAssetDO.setFundName(fundNavDTO.getFundName());
|
|
|
emailFundAssetDO.setRegisterNumber(fundNavDTO.getRegisterNumber());
|
|
@@ -791,7 +802,7 @@ public class EmailParseService {
|
|
|
return fundAssetDOList;
|
|
|
}
|
|
|
|
|
|
- private List<EmailFundNavDO> buildEmailFundNavDo(Integer fileId, EmailFundNavDTO fundNavDTO, Date parseDate) {
|
|
|
+ private List<EmailFundNavDO> buildEmailFundNavDo(Integer channelId,Integer fileId, EmailFundNavDTO fundNavDTO, Date parseDate) {
|
|
|
List<EmailFundNavDO> fundNavDOList = CollUtil.newArrayList();
|
|
|
Date priceDate = DateUtil.parse(fundNavDTO.getPriceDate(), DateConst.YYYY_MM_DD);
|
|
|
BigDecimal nav = StrUtil.isNotBlank(fundNavDTO.getNav()) ? new BigDecimal(fundNavDTO.getNav()) : null;
|
|
@@ -802,6 +813,7 @@ public class EmailParseService {
|
|
|
for (String fundId : fundNavDTO.getFundIdList()) {
|
|
|
EmailFundNavDO emailFundNavDO = new EmailFundNavDO();
|
|
|
emailFundNavDO.setFileId(fileId);
|
|
|
+ emailFundNavDO.setChannelId(channelId);
|
|
|
emailFundNavDO.setIsStored(isStored);
|
|
|
emailFundNavDO.setPriceDate(priceDate);
|
|
|
emailFundNavDO.setNav(nav);
|
|
@@ -821,6 +833,7 @@ public class EmailParseService {
|
|
|
} else {
|
|
|
EmailFundNavDO emailFundNavDO = new EmailFundNavDO();
|
|
|
emailFundNavDO.setFileId(fileId);
|
|
|
+ emailFundNavDO.setChannelId(channelId);
|
|
|
emailFundNavDO.setPriceDate(priceDate);
|
|
|
emailFundNavDO.setNav(nav);
|
|
|
emailFundNavDO.setCumulativeNavWithdrawal(cumulativeNavWithdrawal);
|
|
@@ -911,7 +924,7 @@ public class EmailParseService {
|
|
|
String fundId = navDO.getFundId();
|
|
|
String priceDate = DateUtils.format(navDO.getPriceDate(), DateUtils.YYYY_MM_DD);
|
|
|
//上一期单位净值
|
|
|
- NavDO preNavDO = navMapper.queryLastNavByFundIdDate(fundId,priceDate);
|
|
|
+ NavDO preNavDO = navMapper.queryLastNavByFundIdDate(fundId,priceDate,navDO.getChannelId());
|
|
|
if(preNavDO == null){
|
|
|
return BigDecimal.valueOf(0);
|
|
|
}
|