|
@@ -174,7 +174,7 @@ public class EmailParseService {
|
|
List<EmailFundNavDO> emailFundNavDOList = fundNavDTOList.stream()
|
|
List<EmailFundNavDO> emailFundNavDOList = fundNavDTOList.stream()
|
|
.map(e -> buildEmailFundNavDo(fileId, e, parseDate)).filter(CollUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toList());
|
|
.map(e -> buildEmailFundNavDo(fileId, e, parseDate)).filter(CollUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toList());
|
|
if (CollUtil.isNotEmpty(emailFundNavDOList)) {
|
|
if (CollUtil.isNotEmpty(emailFundNavDOList)) {
|
|
- // 先删除文件id下的净值数据(考虑到重新解析的需求,如果是首次解析,那么fiel_id下不存在净值数据)
|
|
|
|
|
|
+ // 先删除文件id下的净值数据(考虑到重新解析的需求,如果是首次解析,那么file_id下不存在净值数据)
|
|
emailFundNavMapper.deleteByFileId(fileId);
|
|
emailFundNavMapper.deleteByFileId(fileId);
|
|
emailFundNavMapper.batchInsert(emailFundNavDOList);
|
|
emailFundNavMapper.batchInsert(emailFundNavDOList);
|
|
List<NavDO> navDOList = emailFundNavDOList.stream().filter(e -> StrUtil.isNotBlank(e.getFundId()))
|
|
List<NavDO> navDOList = emailFundNavDOList.stream().filter(e -> StrUtil.isNotBlank(e.getFundId()))
|
|
@@ -185,7 +185,7 @@ public class EmailParseService {
|
|
List<EmailFundAssetDO> emailFundAssetDOList = fundNavDTOList.stream()
|
|
List<EmailFundAssetDO> emailFundAssetDOList = fundNavDTOList.stream()
|
|
.map(e -> buildEmailFundAssetDo(fileId, e, parseDate)).filter(CollUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toList());
|
|
.map(e -> buildEmailFundAssetDo(fileId, e, parseDate)).filter(CollUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toList());
|
|
if (CollUtil.isNotEmpty(emailFundAssetDOList)) {
|
|
if (CollUtil.isNotEmpty(emailFundAssetDOList)) {
|
|
- // 先删除file_id下的规模数据(考虑到重新解析的需求,如果是首次解析,那么fiel_id下不存在规模数据)
|
|
|
|
|
|
+ // 先删除file_id下的规模数据(考虑到重新解析的需求,如果是首次解析,那么file_id下不存在规模数据)
|
|
emailFundAssetMapper.deleteByFileId(fileId);
|
|
emailFundAssetMapper.deleteByFileId(fileId);
|
|
emailFundAssetMapper.batchInsert(emailFundAssetDOList);
|
|
emailFundAssetMapper.batchInsert(emailFundAssetDOList);
|
|
List<AssetDO> assetDOList = emailFundAssetDOList.stream().filter(e -> StrUtil.isNotBlank(e.getFundId()))
|
|
List<AssetDO> assetDOList = emailFundAssetDOList.stream().filter(e -> StrUtil.isNotBlank(e.getFundId()))
|
|
@@ -206,7 +206,13 @@ public class EmailParseService {
|
|
List<NavDO> updateNavDoList = navDOS.stream().filter(e -> dateList.contains(DateUtil.format(e.getPriceDate(), DateConst.YYYY_MM_DD))).collect(Collectors.toList());
|
|
List<NavDO> updateNavDoList = navDOS.stream().filter(e -> dateList.contains(DateUtil.format(e.getPriceDate(), DateConst.YYYY_MM_DD))).collect(Collectors.toList());
|
|
List<NavDO> insertNavDoList = navDOS.stream().filter(e -> !dateList.contains(DateUtil.format(e.getPriceDate(), DateConst.YYYY_MM_DD))).collect(Collectors.toList());
|
|
List<NavDO> insertNavDoList = navDOS.stream().filter(e -> !dateList.contains(DateUtil.format(e.getPriceDate(), DateConst.YYYY_MM_DD))).collect(Collectors.toList());
|
|
if (CollUtil.isNotEmpty(insertNavDoList)) {
|
|
if (CollUtil.isNotEmpty(insertNavDoList)) {
|
|
- navMapper.batchInsert(insertNavDoList);
|
|
|
|
|
|
+ Map<Date, List<NavDO>> priceDateNavDoListMap = insertNavDoList.stream().collect(Collectors.groupingBy(NavDO::getPriceDate));
|
|
|
|
+ boolean hasDuplicationDateData = priceDateNavDoListMap.values().stream().map(List::size).anyMatch(e -> e > 1);
|
|
|
|
+ if (!hasDuplicationDateData) {
|
|
|
|
+ navMapper.batchInsert(insertNavDoList);
|
|
|
|
+ }
|
|
|
|
+ // 要插入的数据中存在相同日期的数据 -> 只能一条一条的插入数据了
|
|
|
|
+ insertNavDoList.forEach(e -> saveNavDo(ListUtil.toList(e)));
|
|
}
|
|
}
|
|
if (CollUtil.isNotEmpty(updateNavDoList)) {
|
|
if (CollUtil.isNotEmpty(updateNavDoList)) {
|
|
navMapper.batchUpdate(updateNavDoList);
|
|
navMapper.batchUpdate(updateNavDoList);
|
|
@@ -226,7 +232,13 @@ public class EmailParseService {
|
|
List<AssetDO> updateAssetDoList = assetDOS.stream().filter(e -> dateList.contains(DateUtil.format(e.getPriceDate(), DateConst.YYYY_MM_DD))).collect(Collectors.toList());
|
|
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());
|
|
List<AssetDO> insertAssetDoList = assetDOS.stream().filter(e -> !dateList.contains(DateUtil.format(e.getPriceDate(), DateConst.YYYY_MM_DD))).collect(Collectors.toList());
|
|
if (CollUtil.isNotEmpty(insertAssetDoList)) {
|
|
if (CollUtil.isNotEmpty(insertAssetDoList)) {
|
|
- assetMapper.batchInsert(insertAssetDoList);
|
|
|
|
|
|
+ Map<Date, List<AssetDO>> priceDateAssetDoListMap = insertAssetDoList.stream().collect(Collectors.groupingBy(AssetDO::getPriceDate));
|
|
|
|
+ boolean hasDuplicationDateData = priceDateAssetDoListMap.values().stream().map(List::size).anyMatch(e -> e > 1);
|
|
|
|
+ if (!hasDuplicationDateData) {
|
|
|
|
+ assetMapper.batchInsert(insertAssetDoList);
|
|
|
|
+ }
|
|
|
|
+ // 要插入的数据中存在相同日期的数据 -> 只能一条一条的插入数据了
|
|
|
|
+ insertAssetDoList.forEach(e -> saveAssetDo(ListUtil.toList(e)));
|
|
}
|
|
}
|
|
if (CollUtil.isNotEmpty(updateAssetDoList)) {
|
|
if (CollUtil.isNotEmpty(updateAssetDoList)) {
|
|
assetMapper.batchUpdate(updateAssetDoList);
|
|
assetMapper.batchUpdate(updateAssetDoList);
|
|
@@ -413,7 +425,7 @@ public class EmailParseService {
|
|
}
|
|
}
|
|
|
|
|
|
// 说明未匹配基金已经写入别名表
|
|
// 说明未匹配基金已经写入别名表
|
|
- if(CollUtil.isEmpty(fundIdList) && CollUtil.isNotEmpty(fundAliasDOList)){
|
|
|
|
|
|
+ if (CollUtil.isEmpty(fundIdList) && CollUtil.isNotEmpty(fundAliasDOList)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -422,11 +434,11 @@ public class EmailParseService {
|
|
fundIdList = fundIdList.stream().filter(e -> !collect.contains(e)).toList();
|
|
fundIdList = fundIdList.stream().filter(e -> !collect.contains(e)).toList();
|
|
}
|
|
}
|
|
|
|
|
|
- log.info("写入别名表 -> 基金名称:{},备案编码:{},基金id:{}", fundName, registerNumber, fundIdList);
|
|
|
|
- List<FundAliasDO> fundAliasDOS = CollUtil.isNotEmpty(fundIdList) ? ListUtil.toList(buildFundAliasDO(fundName, registerNumber, null))
|
|
|
|
|
|
+ List<FundAliasDO> fundAliasDOS = CollUtil.isEmpty(fundIdList) ? ListUtil.toList(buildFundAliasDO(fundName, registerNumber, null))
|
|
: fundIdList.stream().map(e -> buildFundAliasDO(fundName, registerNumber, e)).toList();
|
|
: fundIdList.stream().map(e -> buildFundAliasDO(fundName, registerNumber, e)).toList();
|
|
- if(CollUtil.isNotEmpty(fundAliasDOS)){
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(fundAliasDOS)) {
|
|
fundAliasMapper.batchInsert(fundAliasDOS);
|
|
fundAliasMapper.batchInsert(fundAliasDOS);
|
|
|
|
+ log.info("写入别名表 -> 基金名称:{},备案编码:{},基金id:{}", fundName, registerNumber, fundIdList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|