|
@@ -1,6 +1,7 @@
|
|
|
package com.smppw.analysis.domain.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.smppw.analysis.domain.dao.FundInformationDao;
|
|
|
import com.smppw.analysis.domain.service.BaseIndicatorServiceV2;
|
|
|
import com.smppw.analysis.domain.service.NavService;
|
|
|
import com.smppw.common.pojo.IStrategy;
|
|
@@ -13,17 +14,19 @@ import com.smppw.core.IndicatorService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class BaseIndicatorServiceV2Impl implements BaseIndicatorServiceV2 {
|
|
|
private final NavService navService;
|
|
|
+ private final FundInformationDao fundInformationDao;
|
|
|
|
|
|
- public BaseIndicatorServiceV2Impl(NavService navService) {
|
|
|
+ public BaseIndicatorServiceV2Impl(NavService navService, FundInformationDao fundInformationDao) {
|
|
|
this.navService = navService;
|
|
|
+ this.fundInformationDao = fundInformationDao;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -37,36 +40,28 @@ public class BaseIndicatorServiceV2Impl implements BaseIndicatorServiceV2 {
|
|
|
NavType navType = req.getNavType();
|
|
|
String riskOfFreeId = req.getRiskOfFreeId();
|
|
|
|
|
|
- List<String> benchmarkIdList = new ArrayList<>();
|
|
|
- for (Map.Entry<String, String> secBenchmarkIdMapEntry : secBenchmarkIdMap.entrySet()) {
|
|
|
- String benchmarkId = secBenchmarkIdMapEntry.getValue();
|
|
|
- if (StrUtil.isNotEmpty(benchmarkId)) {
|
|
|
- benchmarkIdList.add(benchmarkId);
|
|
|
- }
|
|
|
- }
|
|
|
+ List<String> benchmarkIdList = secBenchmarkIdMap.values().stream().distinct().collect(Collectors.toList());
|
|
|
CurveType curveType = CurveType.getCurveType(raiseType, strategy);
|
|
|
if (StrUtil.isNotEmpty(riskOfFreeId)) {
|
|
|
benchmarkIdList.add(riskOfFreeId);
|
|
|
}
|
|
|
Map<String, List<DateValue>> allNavMap = navService.getSecIdDateValueNavListMapFromRedisAndDB(mainSecIdList, benchmarkIdList, indexIdList,
|
|
|
null, null, navType, visibility, curveType.getId(), strategy.getStrategyId(), new HashMap<>(), false);
|
|
|
-
|
|
|
- return IndicatorService.getInstance().calcMultipleSecMultipleTimeRangeIndicator(req, allNavMap);
|
|
|
+ Map<String, Frequency> secFreqMap = this.fundInformationDao.getNavFrequency(mainSecIdList);
|
|
|
+ return IndicatorService.getInstance().calcMultipleSecMultipleTimeRangeIndicator(req, allNavMap, secFreqMap);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, List<IndicatorCalcPropertyDto>> getMultipleSecTrend(List<String> mainSecIdList, Map<String, String> secBenchmarkIdMap, List<String> indexIdList, DateIntervalDto dateIntervalDto, Frequency frequency, BigDecimal fixedIncome, BigDecimal initValue, RaiseType raiseType, IStrategy strategy, Visibility visibility, NavType navType, List<TrendType> trendTypeV2List, Boolean ifExtract, Integer userId) {
|
|
|
- List<String> benchmarkIdList = new ArrayList<>();
|
|
|
- for (Map.Entry<String, String> secBenchmarkIdMapEntry : secBenchmarkIdMap.entrySet()) {
|
|
|
- String benchmarkId = secBenchmarkIdMapEntry.getValue();
|
|
|
- if (StrUtil.isNotEmpty(benchmarkId)) {
|
|
|
- benchmarkIdList.add(benchmarkId);
|
|
|
- }
|
|
|
- }
|
|
|
+ public Map<String, List<IndicatorCalcPropertyDto>> getMultipleSecTrend(List<String> mainSecIdList, Map<String, String> secBenchmarkIdMap,
|
|
|
+ List<String> indexIdList, DateIntervalDto dateIntervalDto, Frequency frequency,
|
|
|
+ BigDecimal fixedIncome, BigDecimal initValue, RaiseType raiseType, IStrategy strategy,
|
|
|
+ Visibility visibility, NavType navType, List<TrendType> trendTypeV2List, Boolean ifExtract, Integer userId) {
|
|
|
+ List<String> benchmarkIdList = secBenchmarkIdMap.values().stream().distinct().collect(Collectors.toList());
|
|
|
CurveType curveType = CurveType.getCurveType(raiseType, strategy);
|
|
|
Map<String, List<DateValue>> allNavMap = navService.getSecIdDateValueNavListMapFromRedisAndDB(mainSecIdList, benchmarkIdList, indexIdList,
|
|
|
null, null, navType, visibility, curveType.getId(), strategy.getStrategyId(), new HashMap<>(), false);
|
|
|
-
|
|
|
- return IndicatorService.getInstance().getMultipleSecTrend(mainSecIdList, secBenchmarkIdMap, indexIdList, dateIntervalDto, frequency, fixedIncome, initValue, trendTypeV2List, allNavMap);
|
|
|
+ Map<String, Frequency> secFreqMap = this.fundInformationDao.getNavFrequency(mainSecIdList);
|
|
|
+ return IndicatorService.getInstance().getMultipleSecTrend(mainSecIdList, secBenchmarkIdMap, indexIdList, dateIntervalDto, fixedIncome,
|
|
|
+ initValue, frequency, trendTypeV2List, secFreqMap, allNavMap);
|
|
|
}
|
|
|
}
|