use of com.tony.billing.response.fund.DailyFundHistoryValueResponse in project BillingDubbo by TonyJiangWJ.
the class FundHistoryValueServiceImpl method getFundHistoryValuesByAssessmentDate.
@Override
public DailyFundHistoryValueResponse getFundHistoryValuesByAssessmentDate(String assessmentDate) {
Long userId = UserIdContainer.getUserId();
List<FundInfo> userFunds = fundInfoMapper.getFundInfoDistinctByUser(userId);
DailyFundHistoryValueResponse response = ResponseUtil.success(new DailyFundHistoryValueResponse());
response.setAssessmentDate(assessmentDate);
if (CollectionUtils.isNotEmpty(userFunds)) {
Map<String, String> fundInfoMap = new HashMap<>(userFunds.size());
for (FundInfo fundInfo : userFunds) {
fundInfoMap.put(fundInfo.getFundCode(), fundInfo.getFundName());
}
response.setFundInfoMap(fundInfoMap);
List<FundHistoryValue> dailyFundHistoryValues = mapper.getFundHistoriesByFundCodes(userFunds.stream().map(FundInfo::getFundCode).collect(Collectors.toList()), assessmentDate);
if (CollectionUtils.isNotEmpty(dailyFundHistoryValues)) {
Map<String, List<FundHistoryValue>> fundHistoryValues = dailyFundHistoryValues.parallelStream().collect(Collectors.groupingBy(FundHistoryValue::getFundCode));
Map<String, List<String>> resultMap = fundHistoryValues.entrySet().stream().map(entry -> {
String fundCode = entry.getKey();
List<String> increaseRateList = entry.getValue().stream().map(FundHistoryValue::getAssessmentIncreaseRate).collect(Collectors.toList());
Map<String, List<String>> map = new HashMap<>(1);
map.put(fundCode, increaseRateList);
return map;
}).reduce(new HashMap<>(userFunds.size()), (a, b) -> {
a.putAll(b);
return a;
});
response.setIncreaseRateMapping(resultMap);
// 计算总增长率
generateTotalIncreaseRateInfo(response, userId);
response.reverseFundCodeAndName();
response.reverseRateList();
}
}
return response;
}
Aggregations