Commit 176fdfdd authored by 张亚辉's avatar 张亚辉

私有基金

parent e66ec272
......@@ -105,5 +105,17 @@ public interface ProductApi {
@ApiOperation("私有基金历史业绩")
@GetMapping("/privatefund/historyprofit")
CommonResp<PrivateHistoryprofitResp> getHistoryprofit(@RequestParam("id") String id);
CommonResp<List<TrackRecordVO>> getHistoryprofit(@RequestParam("id") String id);
@ApiOperation("历史净值")
@GetMapping("/privatefund/track/net")
CommonResp<Page<TrackNetVO>> getPrivateFundTrackNetListInfo(@ApiParam("产品id") @RequestParam("id") String id, @ApiParam("分页对象") Pageable page);
@ApiOperation("风险评估")
@GetMapping("/privatefund/get/risk/rating")
CommonResp<List<RiskRatingVO>> getPrivateFundRiskRatingInfo(@ApiParam("产品id") @RequestParam("id") String id);
@ApiOperation("获取私募产品")
@GetMapping("/privatefund/list")
CommonResp<List<ProductInfoVO>> getPrivateFundList(@ApiParam("产品id") @RequestParam("ids") List<String> ids);
}
......@@ -11,6 +11,7 @@ import com.tanpu.fund.api.model.req.ProductInfoReq;
import com.tanpu.fund.api.model.resp.*;
import com.tanpu.fund.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
......@@ -112,11 +113,38 @@ public class ProductController implements ProductApi {
@Override
public CommonResp<PrivateFundDetailResp> getPrivateDetail(String id) {
if (StringUtils.isEmpty(id)) {
return CommonResp.error(CommonResp.PARAMETER_INVALID_STATUS_CODE, CommonResp.PARAMETER_INVALID_MESSAGE);
}
return CommonResp.success(this.productService.getPrivateDetail(id));
}
@Override
public CommonResp<PrivateHistoryprofitResp> getHistoryprofit(String id) {
public CommonResp<List<TrackRecordVO>> getHistoryprofit(String id) {
if (StringUtils.isEmpty(id)) {
return CommonResp.error(CommonResp.PARAMETER_INVALID_STATUS_CODE, CommonResp.PARAMETER_INVALID_MESSAGE);
}
return CommonResp.success(this.productService.getHistoryprofit(id));
}
@Override
public CommonResp<Page<TrackNetVO>> getPrivateFundTrackNetListInfo(String id, Pageable page) {
if (StringUtils.isEmpty(id)) {
return CommonResp.error(CommonResp.PARAMETER_INVALID_STATUS_CODE, CommonResp.PARAMETER_INVALID_MESSAGE);
}
return CommonResp.success(this.productService.getPrivateFundTrackNetList(id, page));
}
@Override
public CommonResp<List<RiskRatingVO>> getPrivateFundRiskRatingInfo(String id) {
if (StringUtils.isEmpty(id)) {
return CommonResp.error(CommonResp.PARAMETER_INVALID_STATUS_CODE, CommonResp.PARAMETER_INVALID_MESSAGE);
}
return CommonResp.success(this.productService.getPrivateFundRiskRating(id));
}
@Override
public CommonResp<List<ProductInfoVO>> getPrivateFundList(List<String> ids) {
return CommonResp.success(this.productService.getPrivateFundList(ids));
}
}
......@@ -52,5 +52,11 @@ public interface ProductService {
PrivateFundDetailResp getPrivateDetail(String id);
PrivateHistoryprofitResp getHistoryprofit(String id);
List<TrackRecordVO> getHistoryprofit(String id);
Page<TrackNetVO> getPrivateFundTrackNetList(String id, Pageable page);
List<RiskRatingVO> getPrivateFundRiskRating(String id);
List<ProductInfoVO> getPrivateFundList(List<String> ids);
}
......@@ -73,6 +73,9 @@ public class ProductServiceImpl implements ProductService, Constant {
@Resource
private FundCountMapper fundCountMapper;
@Resource
private IfaImportedFundCountMapper ifaImportedFundCountMapper;
@Resource
private FundInfoCustomMapper fundInfoCustomMapper;
......@@ -1296,9 +1299,9 @@ public class ProductServiceImpl implements ProductService, Constant {
IfaImportedFundInfo fundInfo = ifaImportedFundInfoMapper.selectByPrimaryKey(id);
//查询收益率
FundCountExample example = new FundCountExample();
IfaImportedFundCountExample example = new IfaImportedFundCountExample();
example.createCriteria().andFundIdEqualTo(id).andDeleteTagEqualTo(BizEnums.DeleteTag.tag_init);
List<FundCount> fundCountList = fundCountMapper.selectByExample(example);
List<IfaImportedFundCount> fundCountList = ifaImportedFundCountMapper.selectByExample(example);
//查询净值
PageMethod.startPage(1, 1);
......@@ -1325,26 +1328,124 @@ public class ProductServiceImpl implements ProductService, Constant {
}
@Override
public PrivateHistoryprofitResp getHistoryprofit(String id) {
FundCountExample example = new FundCountExample();
example.createCriteria().andFundIdEqualTo(id).andDeleteTagEqualTo(BizEnums.DeleteTag.tag_init);
List<FundCount> fundCountList = fundCountMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(fundCountList)) {
FundCount fundCount = fundCountList.get(0);
return PrivateHistoryprofitResp.builder()
.fundId(fundCount.getFundId())
.ret3m(BigDecimalUtil.toString(fundCount.getRet3m(), 2))
.ret6m(BigDecimalUtil.toString(fundCount.getRet6m(), 2))
.ret1y(BigDecimalUtil.toString(fundCount.getRet1y(), 2))
.ret2y(BigDecimalUtil.toString(fundCount.getRet2y(), 2))
.ret3y(BigDecimalUtil.toString(fundCount.getRet3y(), 2))
.ret4y(BigDecimalUtil.toString(fundCount.getRet4y(), 2))
.ret5y(BigDecimalUtil.toString(fundCount.getRet5y(), 2))
.retIncep(BigDecimalUtil.toString(fundCount.getRetIncep(), 2))
.build();
}
return null;
public List<TrackRecordVO> getHistoryprofit(String id) {
IfaImportedFundCountExample example = new IfaImportedFundCountExample();
example.createCriteria().andFundIdEqualTo(id).andDeleteTagEqualTo(ZERO_NUM);
List<IfaImportedFundCount> fundCounts = this.ifaImportedFundCountMapper.selectByExample(example);
if (CollectionUtils.isEmpty(fundCounts)) {
return new ArrayList<>();
}
IfaImportedFundCount fundCount = fundCounts.get(0);
return getPrivateFundTrackRecordVOS(fundCount);
}
@Override
public Page<TrackNetVO> getPrivateFundTrackNetList(String id, Pageable page) {
com.github.pagehelper.Page<TrackNetVO> startPage = PageMethod.startPage(page.getPageNumber(),
page.getPageSize());
IfaImportedFundNavExample example = new IfaImportedFundNavExample();
example.createCriteria().andFundIdEqualTo(id).andDeleteTagEqualTo(ZERO_NUM);
example.setOrderByClause("price_date desc");
List<IfaImportedFundNav> fundNavs = this.ifaImportedFundNavMapper.selectByExample(example);
// 净值相同日期去重
fundNavs = fundNavs.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(IfaImportedFundNav::getPriceDate))), ArrayList::new));
return new Page<>(page, startPage.getTotal(), fundNavs.stream()
.sorted(Comparator.comparing(IfaImportedFundNav::getPriceDate).reversed())
.map(f -> {
TrackNetVO vo = new TrackNetVO();
vo.setPriceDate(DateUtil.format(f.getPriceDate(), DatePattern.NORM_DATE_PATTERN));
vo.setNav(BigDecimalUtil.toString(f.getNav(), 4));
vo.setCumulativeNav(BigDecimalUtil.toString(f.getCumulativeNav(), 4));
return vo;
}).collect(Collectors.toList()));
}
@Override
public List<RiskRatingVO> getPrivateFundRiskRating(String id) {
IfaImportedFundCountExample example = new IfaImportedFundCountExample();
example.createCriteria().andFundIdEqualTo(id).andDeleteTagEqualTo(ZERO_NUM);
List<IfaImportedFundCount> fundCounts = this.ifaImportedFundCountMapper.selectByExample(example);
if (CollectionUtils.isEmpty(fundCounts)) {
return new ArrayList<>(0);
}
IfaImportedFundCount fundCount = fundCounts.get(0);
return Lists.newArrayList(
new RiskRatingVO("最近一年", multiply100(fundCount.getMaxdrawdown1y()),
multiply100(fundCount.getStddev1y()), BigDecimalUtil.toString(fundCount.getSharperatio1y())),
new RiskRatingVO("最近二年", multiply100(fundCount.getMaxdrawdown2y()),
multiply100(fundCount.getStddev2y()), BigDecimalUtil.toString(fundCount.getSharperatio2y())),
new RiskRatingVO("最近三年", multiply100(fundCount.getMaxdrawdown3y()),
multiply100(fundCount.getStddev3y()), BigDecimalUtil.toString(fundCount.getSharperatio3y())),
new RiskRatingVO("最近四年", multiply100(fundCount.getMaxdrawdown4y()),
multiply100(fundCount.getStddev4y()), BigDecimalUtil.toString(fundCount.getSharperatio4y())),
new RiskRatingVO("最近五年", multiply100(fundCount.getMaxdrawdown5y()),
multiply100(fundCount.getStddev5y()), BigDecimalUtil.toString(fundCount.getSharperatio5y())),
new RiskRatingVO("成立以来", multiply100(fundCount.getMaxdrawdownIncep()),
multiply100(fundCount.getStddevIncep()), BigDecimalUtil.toString(fundCount.getSharperatioIncep())));
}
@Override
public List<ProductInfoVO> getPrivateFundList(List<String> ids) {
List<IfaImportedFundInfo> fundInfoList;
{
IfaImportedFundInfoExample example = new IfaImportedFundInfoExample();
example.createCriteria().andIdIn(ids).andDeleteTagEqualTo(BizEnums.DeleteTag.tag_init);
fundInfoList = ifaImportedFundInfoMapper.selectByExample(example);
}
Map<String, IfaImportedFundCount> fundCountMap;
{
IfaImportedFundCountExample example = new IfaImportedFundCountExample();
example.createCriteria().andFundIdIn(ids).andDeleteTagEqualTo(BizEnums.DeleteTag.tag_init);
List<IfaImportedFundCount> countList = ifaImportedFundCountMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(countList)) {
fundCountMap = countList.stream().collect(Collectors.toMap(IfaImportedFundCount::getFundId, c -> c));
} else {
fundCountMap = null;
}
}
if (CollectionUtils.isNotEmpty(fundInfoList)) {
return fundInfoList.stream().map(item -> {
IfaImportedFundCount importedFundCount = null;
if (fundCountMap.containsKey(item.getId())) {
importedFundCount = fundCountMap.get(item.getId());
}
ProductInfoVO p = new ProductInfoVO();
p.setProductName(item.getFundName());
p.setRet1m(importedFundCount == null ? null : BigDecimalUtil.toString(importedFundCount.getRet1m(), 2));
p.setNet(importedFundCount == null ? null : Net.builder().netDate(importedFundCount.getPriceDate().getTime())
.netValue(BigDecimalUtil.toString(importedFundCount.getNetNav(), 4))
.build());
return p;
}).collect(Collectors.toList());
}
return new ArrayList<>();
}
private ArrayList<TrackRecordVO> getPrivateFundTrackRecordVOS(IfaImportedFundCount fundCount) {
return Lists.newArrayList(
new TrackRecordVO("近三个月", multiply100(fundCount.getRet3m()), multiply100(fundCount.getRet3mBm1())),
new TrackRecordVO("近半年", multiply100(fundCount.getRet6m()), multiply100(fundCount.getRet6mBm1())),
new TrackRecordVO("近一年", multiply100(fundCount.getRet1y()), multiply100(fundCount.getRet1yBm1())),
new TrackRecordVO("近二年", multiply100(fundCount.getRet2y()), multiply100(fundCount.getRet2yBm1())),
new TrackRecordVO("近三年", multiply100(fundCount.getRet3y()), multiply100(fundCount.getRet3yBm1())),
new TrackRecordVO("近四年", multiply100(fundCount.getRet4y()), multiply100(fundCount.getRet4yBm1())),
new TrackRecordVO("近五年", multiply100(fundCount.getRet5y()), multiply100(fundCount.getRet5yBm1())),
new TrackRecordVO("成立以来", multiply100(fundCount.getRetIncep()), multiply100(fundCount.getRetIncepBm1())));
}
}
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