Commit 37803487 authored by 张亚辉's avatar 张亚辉

myselect

parent 83afe43d
package com.tanpu.fund.api; package com.tanpu.fund.api;
import com.tanpu.common.model.product.resp.Net;
import com.tanpu.common.resp.CommonResp;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@Api(tags = "私募基金 PC端") @Api(tags = "私募基金 PC端")
public interface ProductForPcApi { public interface ProductForPcApi {
@ApiOperation("获取私募基金最新净值")
@GetMapping("/get/fund/newnet")
CommonResp<List<Net>> getFundNewnet(@RequestParam("list") List<String> list);
@ApiOperation("获取私有基金最新净值")
@GetMapping("/get/privatefund/newnet")
CommonResp<List<Net>> getPrivatefundNewnet(@RequestParam("list") List<String> list);
} }
package com.tanpu.fund.controller; package com.tanpu.fund.controller;
import com.tanpu.common.model.product.resp.Net;
import com.tanpu.common.resp.CommonResp;
import com.tanpu.fund.api.ProductForPcApi; import com.tanpu.fund.api.ProductForPcApi;
import com.tanpu.fund.service.ProductForPcService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController @RestController
@Slf4j @Slf4j
public class ProductForPcController implements ProductForPcApi { public class ProductForPcController implements ProductForPcApi {
@Resource
private ProductForPcService productForPcService;
@Override
public CommonResp<List<Net>> getFundNewnet(List<String> list) {
return CommonResp.success(productForPcService.getFundNewnet(list));
}
@Override
public CommonResp<List<Net>> getPrivatefundNewnet(List<String> list) {
return CommonResp.success(productForPcService.getPrivatefundNewnet(list));
}
} }
...@@ -30,13 +30,21 @@ public interface FundInfoCustomMapper { ...@@ -30,13 +30,21 @@ public interface FundInfoCustomMapper {
List<FundNav> getFundInfoLastNet(@Param("list") List<String> fundIdList); List<FundNav> getFundInfoLastNet(@Param("list") List<String> fundIdList);
/** /**
* 获取基金最新净值 * 获取*私募*基金最新净值
* *
* @param fundIdList * @param fundIdList
* @return * @return
*/ */
List<FundNav> getFundInfoNewNet(@Param("list") List<String> fundIdList); List<FundNav> getFundInfoNewNet(@Param("list") List<String> fundIdList);
/**
* 获取*私有*基金最新净值
*
* @param fundIdList
* @return
*/
List<FundNav> getPrivateFundInfoNewNet(@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})") @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); List<FilePreviewResp> getFilePreviewUrl(@Param("list") String list);
} }
package com.tanpu.fund.service; package com.tanpu.fund.service;
import com.tanpu.common.model.product.resp.Net;
import java.util.List;
/** /**
* @author: zyh * @author: zyh
*/ */
public interface ProductForPcService { public interface ProductForPcService {
List<Net> getFundNewnet(List<String> list);
List<Net> getPrivatefundNewnet(List<String> list);
} }
package com.tanpu.fund.service.impl; package com.tanpu.fund.service.impl;
import com.tanpu.common.model.product.resp.Net;
import com.tanpu.common.model.product.resp.NetBigDecimal;
import com.tanpu.common.utils.BigDecimalUtil;
import com.tanpu.fund.entity.generator.FundNav;
import com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper;
import com.tanpu.fund.service.ProductForPcService; import com.tanpu.fund.service.ProductForPcService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* @author: zyh * @author: zyh
*/ */
@Service @Service
public class ProductForPcServiceImpl implements ProductForPcService { public class ProductForPcServiceImpl implements ProductForPcService {
@Resource
private FundInfoCustomMapper fundInfoCustomMapper;
@Override
public List<Net> getFundNewnet(List<String> list) {
List<FundNav> fundInfoNewNet = fundInfoCustomMapper.getFundInfoNewNet(list);
if (CollectionUtils.isNotEmpty(fundInfoNewNet)) {
return fundInfoNewNet.stream().map(item -> Net.builder()
.fundId(item.getFundId())
.netDate(item.getPriceDate().getTime())
.netValue(BigDecimalUtil.toString(item.getNav(), 4))
.cumulativeNav(BigDecimalUtil.toString(item.getCumulativeNavWithdrawal(), 4))
.build()).collect(Collectors.toList());
}
return new ArrayList<>(0);
}
@Override
public List<Net> getPrivatefundNewnet(List<String> list) {
List<FundNav> fundInfoNewNet = fundInfoCustomMapper.getPrivateFundInfoNewNet(list);
if (CollectionUtils.isNotEmpty(fundInfoNewNet)) {
return fundInfoNewNet.stream().map(item -> Net.builder()
.fundId(item.getFundId())
.netDate(item.getPriceDate().getTime())
.netValue(BigDecimalUtil.toString(item.getNav(), 4))
.cumulativeNav(BigDecimalUtil.toString(item.getCumulativeNavWithdrawal(), 4))
.build()).collect(Collectors.toList());
}
return new ArrayList<>(0);
}
} }
...@@ -32,7 +32,17 @@ ...@@ -32,7 +32,17 @@
<select id="getFundInfoNewNet" parameterType="java.lang.String" resultType="com.tanpu.fund.entity.generator.FundNav"> <select id="getFundInfoNewNet" parameterType="java.lang.String" resultType="com.tanpu.fund.entity.generator.FundNav">
select res.* from select res.* from
(SELECT * FROM tamp_product.fund_nav WHERE fund_id in (SELECT * FROM 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
</select>
<select id="getPrivateFundInfoNewNet" parameterType="java.lang.String" resultType="com.tanpu.fund.entity.generator.FundNav">
select res.* from
(SELECT * FROM ifa_imported_fund_nav WHERE fund_id in
<foreach close=")" collection="list" item="fundId" open="(" separator=","> <foreach close=")" collection="list" item="fundId" open="(" separator=",">
#{fundId} #{fundId}
</foreach> </foreach>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment