瀏覽代碼

feat:捕获输出基金净值明细数据的异常

mozuwen 1 月之前
父節點
當前提交
e9ccd80396

+ 17 - 8
service-manage/src/main/java/com/simuwang/manage/service/competition/FundNavService.java

@@ -2,6 +2,7 @@ package com.simuwang.manage.service.competition;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.map.MapUtil;
 import com.simuwang.base.common.conts.DateConst;
 import com.simuwang.base.common.util.NavDataUtil;
@@ -70,14 +71,22 @@ public class FundNavService {
         }
         Map<String, List<NavDO>> fundIdNavMap = navDOList.stream().collect(Collectors.groupingBy(NavDO::getFundId));
         for (Map.Entry<String, List<NavDO>> fundIdNavEntry : fundIdNavMap.entrySet()) {
-            String fundId = fundIdNavEntry.getKey();
-            log.info("组装基金净值明细数据 -> 基金id:{}", fundId);
-            List<NavDO> fundNavDoList = fundIdNavEntry.getValue();
-            List<AssetDO> fundAssetDoList = fundIdAssetMap.get(fundId);
-            FundAndCompanyInfoDO fundInfoDO = fundIdCompanyNameMap.get(fundId);
-            List<FundNavDataDTO> fundNavDataDTOList = buildFundNavDataDTO(fundInfoDO, fundNavDoList, fundAssetDoList);
-            log.info("基金净值明细数据:{}", fundNavDataDTOList);
-            navDataDTOList.addAll(fundNavDataDTOList);
+            try {
+                String fundId = fundIdNavEntry.getKey();
+                log.info("组装基金净值明细数据 -> 基金id:{}", fundId);
+                List<NavDO> fundNavDoList = fundIdNavEntry.getValue() != null ? fundIdNavEntry.getValue() : CollUtil.newArrayList();
+                List<AssetDO> fundAssetDoList = fundIdAssetMap.get(fundId) != null ? fundIdAssetMap.get(fundId) : CollUtil.newArrayList();
+                FundAndCompanyInfoDO fundInfoDO = fundIdCompanyNameMap.get(fundId);
+                if (fundInfoDO == null) {
+                    log.error("基金信息不存在,fundId:{}", fundId);
+                    continue;
+                }
+                List<FundNavDataDTO> fundNavDataDTOList = buildFundNavDataDTO(fundInfoDO, fundNavDoList, fundAssetDoList);
+                log.info("基金净值明细数据:{}", fundNavDataDTOList);
+                navDataDTOList.addAll(fundNavDataDTOList);
+            } catch (Exception e) {
+                log.error("组装基金净值明细数据异常,fundId:{}, 堆栈信息:{}", fundIdNavEntry.getKey(), ExceptionUtil.stacktraceToString(e));
+            }
         }
         return navDataDTOList;
     }