diff --git a/src/main/java/com/tanpu/fund/mapper/generator/custom/FundInfoCustomMapper.java b/src/main/java/com/tanpu/fund/mapper/generator/custom/FundInfoCustomMapper.java index 30d38e1d794547f802d1f3e5e03eff10ace83daf..f16b02570a836aae45f498c8ed51825ee5c74a4f 100644 --- a/src/main/java/com/tanpu/fund/mapper/generator/custom/FundInfoCustomMapper.java +++ b/src/main/java/com/tanpu/fund/mapper/generator/custom/FundInfoCustomMapper.java @@ -29,6 +29,14 @@ public interface FundInfoCustomMapper { List<FundNav> getFundInfoLastNet(@Param("list") List<String> fundIdList); + /** + * 获å–基金最新净值 + * + * @param fundIdList + * @return + */ + List<FundNav> getFundInfoNewNet(@Param("list") List<String> fundIdList); + @Select("select t.id as fileId,t.logical_path as previewUrl from fund_file_record t where t.id in(${list})") List<FilePreviewResp> getFilePreviewUrl(@Param("list") String list); } diff --git a/src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java b/src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java index 54e51279237f2e954d42b32513a53cb214453c27..df7f4591b238c180ef1a68c35390325a8c8d2ad3 100644 --- a/src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java +++ b/src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java @@ -1174,7 +1174,18 @@ public class ProductServiceImpl implements ProductService, Constant { // æŸ¥è¯¢ç ”æŠ¥ä¿¡æ¯æ˜¯å¦æœ‰ç ”报 // Map<String, Object> fundInfoReport = getFundReport(Lists.newArrayList(fundInfoMap.keySet())); - return fundInfos.stream().map(p -> getProductInfoVO(fundCountMap, rateMappingMap, p, null, productType)) + //查询净值 + Map<String, FundNav> fundNavMap; + { + List<FundNav> navList = fundInfoCustomMapper.getFundInfoNewNet(list); + if (CollectionUtils.isNotEmpty(navList)) { + fundNavMap = navList.stream().collect(Collectors.toMap(FundNav::getFundId, c -> c)); + } else { + fundNavMap = null; + } + } + + return fundInfos.stream().map(p -> getProductInfoVO(fundCountMap, rateMappingMap, p, null, productType, fundNavMap)) .collect(Collectors.toList()); } @@ -1183,45 +1194,49 @@ public class ProductServiceImpl implements ProductService, Constant { // return fundInfoCustomMapper.getFundInfoReport(ids); // } - private ProductInfoVO getProductInfoVO(Map<String, FundInfo> fundCountMap, Map<String, FundRateMapping> rateMappingMap, + private ProductInfoVO getProductInfoVO(Map<String, FundCount> fundCountMap, Map<String, FundRateMapping> rateMappingMap, FundInfo fundInfo, - Set<String> fundInfoReports, Integer productType) { + Set<String> fundInfoReports, Integer productType, Map<String, FundNav> fundNavMap) { ProductInfoVO vo = new ProductInfoVO(); if (fundCountMap.containsKey(fundInfo.getId())) { + FundCount fundCount = fundCountMap.get(fundInfo.getId()); + BeanUtils.copyProperties(fundCount, vo); + vo.setRet1m(multiply100(fundCount.getRet1m())); + vo.setRet1y(multiply100(fundCount.getRet1y())); + vo.setRetIncep(multiply100(fundCount.getRetIncep())); + vo.setCumulativeProfit(BigDecimalUtil.toString(fundCount.getCumulativeNav())); } vo.setProductType(productType); - vo.setRet1m(multiply100(fundCount.getRet1m())); - vo.setRet1y(multiply100(fundCount.getRet1y())); - String fundId = fundCount.getFundId(); + String fundId = fundInfo.getId(); vo.setFundId(fundId); - vo.setRetIncep(multiply100(fundCount.getRetIncep())); - vo.setCumulativeProfit(BigDecimalUtil.toString(fundCount.getCumulativeNav())); - if (fundInfoMap.get(fundId) != null) { - FundInfo fundInfo = fundInfoMap.get(fundId); - // 指数id - vo.setRatioId(ProductEnums.IndexEnum.getValue(fundInfo.getPrimaryBenchmarkId())); - vo.setProductName(fundInfo.getFundShortName()); - // getProductCode(indexIdMap, vo, fundInfo); - vo.setOpenDay(fundInfo.getOpenDay()); - vo.setDesc(fundInfo.getDescInfo()); + // 指数id + vo.setRatioId(ProductEnums.IndexEnum.getValue(fundInfo.getPrimaryBenchmarkId())); + vo.setProductName(fundInfo.getFundShortName()); + // getProductCode(indexIdMap, vo, fundInfo); + vo.setOpenDay(fundInfo.getOpenDay()); + vo.setDesc(fundInfo.getDescInfo()); - // 风险ç‰çº§ - vo.setRiskLevel(fundInfo.getRiskLevel()); - } + // 风险ç‰çº§ + vo.setRiskLevel(fundInfo.getRiskLevel()); if (fundInfoReports != null && fundInfoReports.contains(fundId)) { vo.setIsReport(1); } else { vo.setIsReport(0); } - vo.setIsAppoint(fundCount.getType()); + vo.setIsAppoint(fundInfo.getType()); // 最新净值 - vo.setNet(new Net(fundCount.getEndDate().getTime(), BigDecimalUtil.toString(fundCount.getNetNav(), 4), BigDecimalUtil.toString(fundCount.getCumulativeNav(), 4))); + if (fundNavMap.containsKey(fundId)) { + FundNav fundNav = fundNavMap.get(fundId); + vo.setNet(new Net(fundNav.getPriceDate().getTime(), + BigDecimalUtil.toString(fundNav.getNav(), 4), + BigDecimalUtil.toString(fundNav.getCumulativeNavWithdrawal(), 4))); + } - getMinInvestmentShare(rateMappingMap, fundCount.getFundId(), vo); + getMinInvestmentShare(rateMappingMap, fundInfo.getId(), vo); return vo; } diff --git a/src/main/resources/mybatis/customize/FundInfoCustomMapper.xml b/src/main/resources/mybatis/customize/FundInfoCustomMapper.xml index 2f22d3b18edb3756d8efdbdf371f5c369df1307a..d5f29c9301e4c06810687713fa0f924afa6648c9 100644 --- a/src/main/resources/mybatis/customize/FundInfoCustomMapper.xml +++ b/src/main/resources/mybatis/customize/FundInfoCustomMapper.xml @@ -30,4 +30,15 @@ AND delete_tag = 0 </select> + <select id="getFundInfoNewNet" parameterType="java.lang.String" resultType="com.tanpu.fund.entity.generator.FundNav"> + select res.* from + (SELECT * FROM tamp_product.fund_nav WHERE fund_id in + <foreach close=")" collection="list" item="fundId" open="(" separator=","> + #{fundId} + </foreach> + order BY price_date desc) res + GROUP BY res.fund_id; + AND delete_tag = 0 + </select> + </mapper>