浏览代码

fix:邮件解析-修复估值表解析后转化净值数据报错的问题

mozuwen 7 月之前
父节点
当前提交
3bfb2375ad
共有 1 个文件被更改,包括 10 次插入22 次删除
  1. 10 22
      service-daq/src/main/java/com/simuwang/daq/service/ValuationEmailParser.java

+ 10 - 22
service-daq/src/main/java/com/simuwang/daq/service/ValuationEmailParser.java

@@ -136,29 +136,17 @@ public class ValuationEmailParser extends AbstractEmailParser {
             return null;
         }
         List<EmailFundNavDTO> emailFundNavDTOList = CollUtil.newArrayList();
-        Map<String, List<AssetsValuationResult.Record>> dateSuccessRecordMap = parseSuccessList.stream().collect(Collectors.groupingBy(AssetsValuationResult.Record::getDate));
-        for (Map.Entry<String, List<AssetsValuationResult.Record>> successRecordEntry : dateSuccessRecordMap.entrySet()) {
-            String date = successRecordEntry.getKey();
-            List<AssetsValuationResult.Record> recordList = successRecordEntry.getValue();
-            String fundName = recordList.stream().map(AssetsValuationResult.Record::getParseValuationInfo)
-                    .filter(Objects::nonNull).map(ParseValuationInfo::getFundName).distinct().findFirst().orElse(null);
-            String registerNumber = recordList.stream().map(AssetsValuationResult.Record::getParseValuationInfo)
-                    .filter(Objects::nonNull).map(ParseValuationInfo::getRegisterNumber).distinct().findFirst().orElse(null);
-            String nav = recordList.stream().map(AssetsValuationResult.Record::getNav).filter(Objects::nonNull).distinct().findFirst().orElse(null);
-            String cumulativeNavWithdrawal = recordList.stream().map(AssetsValuationResult.Record::getCumulativeNavWithdrawal).filter(Objects::nonNull).distinct().findFirst().orElse(null);
-            String assetNet = recordList.stream().map(AssetsValuationResult.Record::getAssetNet).filter(Objects::nonNull).distinct().findFirst().orElse(null);
-            String assetShare = recordList.stream().map(AssetsValuationResult.Record::getAssetShare).filter(Objects::nonNull).distinct().findFirst().orElse(null);
-            List<String> fundIdList = recordList.stream().map(AssetsValuationResult.Record::getFundId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
-
+        // 考虑一个估值表匹配到多个基金的情况
+        for (AssetsValuationResult.Record record : parseSuccessList) {
             EmailFundNavDTO fundNavDTO = new EmailFundNavDTO();
-            fundNavDTO.setFundName(fundName);
-            fundNavDTO.setRegisterNumber(registerNumber);
-            fundNavDTO.setPriceDate(date);
-            fundNavDTO.setNav(nav);
-            fundNavDTO.setCumulativeNavWithdrawal(cumulativeNavWithdrawal);
-            fundNavDTO.setAssetNet(assetNet);
-            fundNavDTO.setAssetShare(assetShare);
-            fundNavDTO.setFundIdList(fundIdList);
+            fundNavDTO.setFundName(record.getParseValuationInfo() != null ? record.getParseValuationInfo().getFundName() : null);
+            fundNavDTO.setRegisterNumber(record.getParseValuationInfo() != null ? record.getParseValuationInfo().getRegisterNumber() : null);
+            fundNavDTO.setPriceDate(record.getDate());
+            fundNavDTO.setNav(record.getNav());
+            fundNavDTO.setCumulativeNavWithdrawal(record.getCumulativeNavWithdrawal());
+            fundNavDTO.setAssetNet(record.getAssetNet());
+            fundNavDTO.setAssetShare(record.getAssetShare());
+            fundNavDTO.setFundIdList(StrUtil.isNotBlank(record.getFundId()) ? ListUtil.toList(record.getFundId()) : null);
             emailFundNavDTOList.add(fundNavDTO);
         }
         return emailFundNavDTOList;