Commit c7107fb7 authored by zp's avatar zp

私募排行

parent 78cc6a16
......@@ -118,7 +118,6 @@
<factorypathentry kind="VARJAR" id="M2_REPO/io/reactivex/rxnetty/0.4.9/rxnetty-0.4.9.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/netflix/ribbon/ribbon-core/2.3.0/ribbon-core-2.3.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/netflix/ribbon/ribbon-httpclient/2.3.0/ribbon-httpclient-2.3.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/sun/jersey/jersey-client/1.19.1/jersey-client-1.19.1.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar" enabled="true" runInBatchMode="false"/>
......@@ -188,8 +187,21 @@
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/curator/curator-recipes/2.10.0/curator-recipes-2.10.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/codehaus/janino/janino/3.0.6/janino-3.0.6.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/codehaus/janino/commons-compiler/3.0.6/commons-compiler-3.0.6.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/commons/commons-collections4/4.0/commons-collections4-4.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/cn/hutool/hutool-all/5.3.9/hutool-all-5.3.9.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/poi/poi-ooxml/4.1.2/poi-ooxml-4.1.2.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/poi/poi/4.1.2/poi-4.1.2.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/commons/commons-collections4/4.4/commons-collections4-4.4.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/zaxxer/SparseBitSet/1.2/SparseBitSet-1.2.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/poi/poi-ooxml-schemas/4.1.2/poi-ooxml-schemas-4.1.2.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/xmlbeans/xmlbeans/3.1.0/xmlbeans-3.1.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/commons/commons-compress/1.19/commons-compress-1.19.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/virtuald/curvesapi/1.06/curvesapi-1.06.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/commons-validator/commons-validator/1.7/commons-validator-1.7.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/commons-digester/commons-digester/2.1/commons-digester-2.1.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/commons-logging/commons-logging/1.2/commons-logging-1.2.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/projectlombok/lombok/1.18.8/lombok-1.18.8.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/cloud/spring-cloud-starter-hystrix/1.3.5.RELEASE/spring-cloud-starter-hystrix-1.3.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/cloud/spring-cloud-netflix-core/2.1.2.RELEASE/spring-cloud-netflix-core-2.1.2.RELEASE.jar" enabled="true" runInBatchMode="false"/>
......
......@@ -3,6 +3,8 @@ package com.tanpu.fund.api;
import com.tanpu.common.model.Page;
import com.tanpu.common.model.Pageable;
import com.tanpu.common.model.adm.req.IfaNetImportReq;
import com.tanpu.common.model.fund.req.FundRankReq;
import com.tanpu.common.model.fund.resq.FundRankResp;
import com.tanpu.common.model.privatefund.resp.FundNavMessage;
import com.tanpu.common.model.product.req.NetReq;
import com.tanpu.common.model.product.req.ProductInfoReq;
......@@ -173,4 +175,12 @@ public interface ProductApi {
@ApiOperation("理财师净值导入")
@PostMapping("/ifa/net/import/check/save")
CommonResp<List<FundNavMessage>> importNetCheckSaveInfo(@RequestBody @Valid @NotEmpty(message = "请确定需要修改的信息") IfaNetImportReq req);
@ApiOperation("私募排行")
@PostMapping("/private/rank")
CommonResp<Page<FundRankResp>> getFundRankInfo(@RequestBody FundRankReq req);
@ApiOperation("私募排行统计")
@PostMapping("/private/rank/count")
CommonResp<Long> getFundRankCountInfo(@RequestBody FundRankReq req);
}
......@@ -4,6 +4,8 @@ import com.tanpu.common.auth.mapping.TanpuInterfaceLoginAuth;
import com.tanpu.common.model.Page;
import com.tanpu.common.model.Pageable;
import com.tanpu.common.model.adm.req.IfaNetImportReq;
import com.tanpu.common.model.fund.req.FundRankReq;
import com.tanpu.common.model.fund.resq.FundRankResp;
import com.tanpu.common.model.privatefund.resp.FundNavMessage;
import com.tanpu.common.model.product.req.NetReq;
import com.tanpu.common.model.product.req.ProductInfoReq;
......@@ -221,4 +223,14 @@ public class ProductController implements ProductApi {
public CommonResp<List<FundNavMessage>> importNetCheckSaveInfo(IfaNetImportReq req) {
return this.productService.importNetCheckSave(req);
}
@Override
public CommonResp<Page<FundRankResp>> getFundRankInfo(FundRankReq req) {
return null;
}
@Override
public CommonResp<Long> getFundRankCountInfo(FundRankReq req) {
return null;
}
}
package com.tanpu.fund.feign.product;
import com.tanpu.common.model.tanpuroom.Type;
import com.tanpu.common.resp.CommonResp;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-product", url = "http://127.0.0.1:8194/product")
@FeignClient(value = "service-product", path = "/product")
public interface FeignForProduct {
@ApiOperation("获取私募产品列表(只返回产品名称)")
@GetMapping("/get/fund/info/simple")
CommonResp<List<Type>> getSimpleFundList(@RequestParam("list") List<String> list);
}
package com.tanpu.fund.feign.product;
import com.alibaba.fastjson.JSON;
import com.tanpu.common.model.tanpuroom.Type;
import com.tanpu.common.resp.CommonResp;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class FeignbackForProduct implements FallbackFactory<FeignForProduct> {
@Override
public FeignForProduct create(Throwable throwable) {
return new FeignForProduct() {
@Override
public CommonResp<List<Type>> getSimpleFundList(List<String> list) {
log.error("FeignClientForFund.getSimpleFundList 获取私募产品列表(只返回产品名称参数: {}", JSON.toJSONString(list));
log.error("FeignClientForFund.getSimpleFundList 获取私募产品列表(只返回产品名称异常", throwable);
return CommonResp.error("基金信息查询异常");
}
};
}
}
......@@ -3,6 +3,8 @@ package com.tanpu.fund.service;
import com.tanpu.common.model.Page;
import com.tanpu.common.model.Pageable;
import com.tanpu.common.model.adm.req.IfaNetImportReq;
import com.tanpu.common.model.fund.req.FundRankReq;
import com.tanpu.common.model.fund.resq.FundRankResp;
import com.tanpu.common.model.privatefund.resp.FundNavMessage;
import com.tanpu.common.model.product.req.ProductListReq;
import com.tanpu.common.model.product.resp.DynamicRetreatVO;
......@@ -79,4 +81,8 @@ public interface ProductService {
List<Type> getSimpleFundList(List<String> list);
CommonResp<List<FundNavMessage>> importNetCheckSave(IfaNetImportReq req);
Page<FundRankResp> getFundRank(FundRankReq req);
Long getFundRankCountInfo(FundRankReq req);
}
package com.tanpu.fund.service.impl;
import com.tanpu.common.model.product.resp.Net;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
......@@ -7,6 +9,7 @@ import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.github.pagehelper.page.PageMethod;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.tanpu.common.auth.UserInfoThreadLocalHolder;
import com.tanpu.common.enums.BizEnums;
import com.tanpu.common.enums.Constant;
......@@ -15,6 +18,8 @@ import com.tanpu.common.enums.product.ProductEnums;
import com.tanpu.common.model.Page;
import com.tanpu.common.model.Pageable;
import com.tanpu.common.model.adm.req.IfaNetImportReq;
import com.tanpu.common.model.fund.req.FundRankReq;
import com.tanpu.common.model.fund.resq.FundRankResp;
import com.tanpu.common.model.privatefund.resp.FundNavMessage;
import com.tanpu.common.model.product.FundInfoVO;
import com.tanpu.common.model.product.req.NetReq;
......@@ -28,6 +33,7 @@ import com.tanpu.common.utils.BigDecimalUtil;
import com.tanpu.fund.entity.generator.*;
import com.tanpu.fund.enums.FilterTypeEnum;
import com.tanpu.fund.feign.diagnose.FeignClientForDiagnose;
import com.tanpu.fund.feign.product.FeignForProduct;
import com.tanpu.fund.feign.user.FeignClientForFatools;
import com.tanpu.fund.mapper.generator.*;
import com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper;
......@@ -115,6 +121,9 @@ public class ProductServiceImpl implements ProductService, Constant {
@Resource
private FeignClientForDiagnose feignClientForDiagnose;
@Resource
private FeignForProduct product;
@Override
public Page<ProductInfoVO> getProductList(ProductInfoReq req) {
......@@ -1690,7 +1699,222 @@ public class ProductServiceImpl implements ProductService, Constant {
return getListCommonResp(ifaNavMap, resultMessage, errorStatus, read);
}
@NotNull
@Override
public Page<FundRankResp> getFundRank(FundRankReq req) {
FundCountExample example = filterFundCountReq(req);
Pageable pageable = new Pageable(req.getPageNumber(), req.getPageSize());
com.github.pagehelper.Page<Object> objects = PageMethod.startPage(pageable);
List<FundCount> fundCounts = this.fundCountMapper.selectByExample(example);
if (CollectionUtils.isEmpty(fundCounts)) {
return new Page<>(pageable, new ArrayList<>(0));
}
FundInfoExample example1 = new FundInfoExample();
List<String> ids = fundCounts
.stream()
.map(FundCount::getFundId)
.collect(Collectors.toList());
example1.createCriteria().andIdIn(ids);
Map<String, String> fundNameMap = this.fundInfoMapper.selectByExample(example1)
.stream()
.collect(Collectors.toMap(FundInfo::getId, FundInfo::getFundShortName));
Set<String> fundSets = product.getSimpleFundList(ids)
.getAttributes()
.stream()
.map(Type::getId)
.collect(Collectors.toSet());
return new Page<>(pageable, objects.getTotal(), fundCounts
.stream()
.map(ls -> {
FundRankResp resp = new FundRankResp();
String fundId = ls.getFundId();
resp.setProductName(Type.builder().id(fundId).value(fundNameMap.get(fundId)).build());
boolean productType = true;
if (fundSets.contains(fundId)) {
productType = false;
}
resp.setProductType(Type.builder().id(productType ? "1" : "2").value(productType ? "私募基金" : "探普白名单").build());
if (ls.getEndDate() != null) {
resp.setNet(Net.builder().netValue(BigDecimalUtil.toString(ls.getNetNav(), 4)).netDate(ls.getEndDate().getTime()).build());
}
if (req.getRank() == null) {
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet1y()));
} else {
switch (req.getRank()) {
case "day":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet1day()));
break;
case "week":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet1w()));
break;
case "month":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet1m()));
break;
case "season":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet3m()));
break;
case "halfAYear":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet6m()));
break;
case "year":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet1y()));
break;
case "twoYear":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet2y()));
break;
case "threeYear":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet3y()));
break;
case "fiveYear":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRet5y()));
break;
case "retIncep":
resp.setRangeOfIncrease(BigDecimalUtil.multiply100(ls.getRetIncep()));
break;
}
}
return resp;
}).collect(Collectors.toList()));
}
private FundCountExample filterFundCountReq(FundRankReq req) {
FundCountExample example = new FundCountExample();
FundCountExample.Criteria criteria = example.createCriteria();
if (req == null) {
example.setOrderByClause("ret_1y desc");
} else {
if (CollectionUtils.isNotEmpty(req.getStrategys())) {
criteria.andSubstrategyIn(req.getStrategys()
.stream()
.map(Integer::valueOf)
.collect(Collectors.toList()));
}
if (req.getRet1y() != null) {
criteria.andRet1yBm1Between(new BigDecimal(req.getRet1y().getBegin()), new BigDecimal(req.getRet1y().getEnd()));
}
if (req.getMaxdrawdown1y() != null) {
criteria.andMaxdrawdown1yBetween(new BigDecimal(req.getMaxdrawdown1y().getBegin()), new BigDecimal(req.getMaxdrawdown1y().getEnd()));
}
if (req.getStddev1y() != null) {
criteria.andStddev1yBetween(new BigDecimal(req.getStddev1y().getBegin()), new BigDecimal(req.getStddev1y().getEnd()));
}
if (req.getSharperatio1y() != null) {
criteria.andSharperatio1yBetween(new BigDecimal(req.getSharperatio1y().getBegin()), new BigDecimal(req.getSharperatio1y().getEnd()));
}
if (StringUtils.isNotEmpty(req.getRank())) {
String sort = null;
switch (req.getRank()) {
case "day":
sort = "ret_1day ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
case "week":
sort = "ret_1w ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
case "month":
sort = "ret_1m ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
case "season":
sort = "ret_3m ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
case "halfAYear":
sort = "ret_6m ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
case "year":
sort = "ret_1y ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
case "twoYear":
sort = "ret_2y ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
case "threeYear":
sort = "ret_3y ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
case "fiveYear":
sort = "ret_5y ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
case "retIncep":
sort = "ret_incep ";
if (StringUtils.isNotEmpty(req.getRankSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc,";
}
break;
}
sort = sort + "net_nav ";
if (StringUtils.isNotEmpty(req.getNetSort())) {
sort = sort + req.getNetSort();
} else {
sort = sort + "desc";
}
example.setOrderByClause(sort);
} else {
example.setOrderByClause("ret_1y desc");
}
}
criteria.andDeleteTagEqualTo(0);
return example;
}
@Override
public Long getFundRankCountInfo(FundRankReq req) {
FundCountExample example = filterFundCountReq(req);
return this.fundCountMapper.countByExample(example);
}
private CommonResp<List<FundNavMessage>> getListCommonResp(Map<Long, IfaImportedFundNav> ifaNavMap,
List<FundNavMessage> resultMessage,
AtomicBoolean errorStatus,
......
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