Commit 043baf6d authored by zp's avatar zp

添加

parent 0085289b
...@@ -93,9 +93,4 @@ public interface ProductApi { ...@@ -93,9 +93,4 @@ public interface ProductApi {
@ApiOperation("动态回撤") @ApiOperation("动态回撤")
@GetMapping("/dynamic/retreat") @GetMapping("/dynamic/retreat")
CommonResp<DynamicRetreatVO> getDynamicRetreatInfo(@RequestParam("id") String id); CommonResp<DynamicRetreatVO> getDynamicRetreatInfo(@RequestParam("id") String id);
@ApiOperation("开放日赎回日查询")
@GetMapping("/fund/date")
CommonResp<FundDateResp> getFundDateByFundIdInfo(
@ApiParam(value = "基金id", required = true) @Valid @NotEmpty(message = "基金id不能为空") @RequestParam("fundId") String fundId);
} }
package com.tanpu.fund.controller; package com.tanpu.fund.controller;
import com.tanpu.common.auth.mapping.TanpuInterfaceLoginAuth;
import com.tanpu.common.model.Page; import com.tanpu.common.model.Page;
import com.tanpu.common.model.Pageable; import com.tanpu.common.model.Pageable;
import com.tanpu.common.model.product.req.ProductListReq; import com.tanpu.common.model.product.req.ProductListReq;
import com.tanpu.common.model.product.resp.*; import com.tanpu.common.model.product.resp.*;
import com.tanpu.common.model.user.resp.SysConstantResp;
import com.tanpu.common.resp.CommonResp; import com.tanpu.common.resp.CommonResp;
import com.tanpu.fund.api.ProductApi; import com.tanpu.fund.api.ProductApi;
import com.tanpu.fund.api.model.req.FundQaAskReq;
import com.tanpu.fund.api.model.req.FundQaListReq;
import com.tanpu.fund.api.model.req.NetReq; import com.tanpu.fund.api.model.req.NetReq;
import com.tanpu.fund.api.model.req.ProductInfoReq; import com.tanpu.fund.api.model.req.ProductInfoReq;
import com.tanpu.fund.api.model.resp.*; import com.tanpu.fund.api.model.resp.*;
import com.tanpu.fund.feign.user.FeignClientForFatools;
import com.tanpu.fund.service.ProductService; import com.tanpu.fund.service.ProductService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -105,11 +99,4 @@ public class ProductController implements ProductApi { ...@@ -105,11 +99,4 @@ public class ProductController implements ProductApi {
public CommonResp<DynamicRetreatVO> getDynamicRetreatInfo(String id) { public CommonResp<DynamicRetreatVO> getDynamicRetreatInfo(String id) {
return CommonResp.success(this.productService.getDynamicRetreat(id)); return CommonResp.success(this.productService.getDynamicRetreat(id));
} }
@Override
public CommonResp<FundDateResp> getFundDateByFundIdInfo(String fundId) {
return CommonResp.success(this.productService.getFundDateByFundId(fundId));
}
} }
package com.tanpu.fund.feign.user;
import com.tanpu.common.model.product.resp.ProductLabel;
import com.tanpu.common.model.user.resp.ColumnVO;
import com.tanpu.common.model.user.resp.SysConstantResp;
import com.tanpu.common.resp.CommonResp;
import com.tanpu.fund.api.model.resp.UserInfoVo;
import feign.Headers;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
//@FeignClient(value = "fatools", fallbackFactory = FeignbackForFatools.class, url = "http://127.0.0.1:8189/fatools")
@FeignClient(value = "fatools", contextId = "fatoolsUser", fallbackFactory = FeignbackForFatools.class, path = "/fatools")
public interface FeignClientForFatools {
@PostMapping(value = "/h6/userinfo/queryinfos")
@Headers({"Content-Type: application/json"})
CommonResp<ArrayList<UserInfoVo>> queryUsersList(List<String> userIds);
@GetMapping(value = "/h5/tag/querybyrelid", produces = {"application/json"})
CommonResp<List<ProductLabel>> querytagbyrelid(@RequestParam("relId") String relId);
@GetMapping(value = "/h5/sysconstant/queryByconstantGroup", produces = {"application/json"})
CommonResp<List<SysConstantResp>> queryLabels(@RequestParam("constantGroup") String constantGroup);
@GetMapping("/column")
CommonResp<List<ColumnVO>> getColumnInfo(@RequestParam("id") String id);
@ApiOperation("批量查询标签信息")
@GetMapping("/batch/get/label")
CommonResp<Map<String, List<ProductLabel>>> batchGetLabelByIdInfo(@RequestParam("list")@Valid @NotEmpty List<String> list);
}
package com.tanpu.fund.feign.user;
import com.alibaba.fastjson.JSON;
import com.tanpu.common.model.product.resp.ProductLabel;
import com.tanpu.common.model.user.resp.ColumnVO;
import com.tanpu.common.model.user.resp.SysConstantResp;
import com.tanpu.common.resp.CommonResp;
import com.tanpu.fund.api.model.resp.UserInfoVo;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
@Component
public class FeignbackForFatools implements FallbackFactory<FeignClientForFatools> {
@Override
public FeignClientForFatools create(Throwable throwable) {
return new FeignClientForFatools() {
@Override
public CommonResp<ArrayList<UserInfoVo>> queryUsersList(List<String> userIds) {
log.error("请求信息", throwable);
log.error("FeignClientForUser.queryUsersList用户信息查询失败");
return null;
}
@Override
public CommonResp<List<ProductLabel>> querytagbyrelid(String relId) {
log.error("请求信息", throwable);
log.error("FeignClientForUser.querytagbyrelid 查询标签失败 relId:{}", relId);
return null;
}
@Override
public CommonResp<List<SysConstantResp>> queryLabels(String constantGroup) {
log.error("请求信息", throwable);
log.error("FeignClientForUser.queryLabels 查询标签失败 constantGroup:{}", constantGroup);
return null;
}
@Override
public CommonResp<List<ColumnVO>> getColumnInfo(String id) {
log.error("请求信息", throwable);
log.error("FeignClientForUser.getColumnInfo 查询栏目失败 id:{}", id);
return null;
}
@Override
public CommonResp<Map<String, List<ProductLabel>>> batchGetLabelByIdInfo(@Valid @NotEmpty List<String> list) {
log.error("请求信息", throwable);
log.error("FeignClientForUser.getColumnInfo 查询栏目失败 id:{}", JSON.toJSONString(list));
return null;
}
};
}
}
package com.tanpu.fund.job;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.tanpu.fund.enums.ProDisFreEnums;
import com.tanpu.fund.enums.ProStatusEnums;
import com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 计算收益率
*
* 周收益率
*/
public class ProfitRateJob implements SimpleJob {
@Autowired
FundInfoCustomMapper fundInfoCustomMapper;
@Autowired
FundCountService profitRateService;
@Override
public void execute(ShardingContext shardingContext) {
//查询按周披露净值的基金
queryFundInfoNavVos(0, ProDisFreEnums.Week.getType());
}
private void queryFundInfoNavVos(int pageSize, int proDisFre){
//查询按周披露净值的基金
List<Integer> statusList = new ArrayList<>();
statusList.add(ProStatusEnums.OPENING.getType());
statusList.add(ProStatusEnums.CHANGEMANGER.getType());
List<String> fundIds = fundInfoCustomMapper.queryFundNavByCondition(proDisFre, statusList, pageSize, 500);
//查询计算
{
if(!CollectionUtils.isEmpty(fundIds)) {
//TODO 区间时间
Date startDate = null;
Date endDate = null;
profitRateService.sectionProfitRate(proDisFre, startDate, endDate, fundIds);
}
}
if (!CollectionUtils.isEmpty(fundIds) && fundIds.size() == 500) {
//递归每次取500条基金数据
queryFundInfoNavVos(pageSize + 500, proDisFre);
}
}
}
...@@ -9,8 +9,6 @@ import com.tanpu.common.model.Page; ...@@ -9,8 +9,6 @@ import com.tanpu.common.model.Page;
import com.tanpu.common.model.Pageable; import com.tanpu.common.model.Pageable;
import com.tanpu.common.model.product.req.ProductListReq; import com.tanpu.common.model.product.req.ProductListReq;
import com.tanpu.common.model.product.resp.*; import com.tanpu.common.model.product.resp.*;
import com.tanpu.common.model.user.resp.ColumnVO;
import com.tanpu.common.resp.CommonResp;
import com.tanpu.common.utils.BigDecimalUtil; import com.tanpu.common.utils.BigDecimalUtil;
import com.tanpu.fund.api.model.FundInfoVO; import com.tanpu.fund.api.model.FundInfoVO;
import com.tanpu.fund.api.model.req.NetReq; import com.tanpu.fund.api.model.req.NetReq;
...@@ -18,13 +16,10 @@ import com.tanpu.fund.api.model.req.ProductInfoReq; ...@@ -18,13 +16,10 @@ import com.tanpu.fund.api.model.req.ProductInfoReq;
import com.tanpu.fund.api.model.resp.*; import com.tanpu.fund.api.model.resp.*;
import com.tanpu.fund.entity.generator.*; import com.tanpu.fund.entity.generator.*;
import com.tanpu.fund.enums.FilterTypeEnum; import com.tanpu.fund.enums.FilterTypeEnum;
import com.tanpu.fund.enums.FundStatusEnum;
import com.tanpu.fund.enums.ProStrategyEnums; import com.tanpu.fund.enums.ProStrategyEnums;
import com.tanpu.fund.feign.user.FeignClientForFatools;
import com.tanpu.fund.mapper.generator.*; import com.tanpu.fund.mapper.generator.*;
import com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper; import com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper;
import com.tanpu.fund.service.ProductService; import com.tanpu.fund.service.ProductService;
import com.tanpu.fund.utils.LabelUtil;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -32,7 +27,6 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -32,7 +27,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -81,9 +75,6 @@ public class ProductServiceImpl implements ProductService, Constant { ...@@ -81,9 +75,6 @@ public class ProductServiceImpl implements ProductService, Constant {
@Resource @Resource
private FundRiskStatsMapper fundRiskStatsMapper; private FundRiskStatsMapper fundRiskStatsMapper;
@Resource
private FeignClientForFatools fatools;
@Resource @Resource
private FundRateMappingMapper fundRateMappingMapper; private FundRateMappingMapper fundRateMappingMapper;
...@@ -158,24 +149,6 @@ public class ProductServiceImpl implements ProductService, Constant { ...@@ -158,24 +149,6 @@ public class ProductServiceImpl implements ProductService, Constant {
} }
} }
// 栏目信息
CommonResp<List<ColumnVO>> resp = fatools.getColumnInfo(id);
if (resp.isSuccess() && CollectionUtils.isNotEmpty(resp.getAttributes())) {
vo.setVos(resp.getAttributes());
}
// 查询研报信息是否有研报
Map<String, Object> fundInfoReport = getFundReport(Lists.newArrayList(Lists.newArrayList(id)));
if (fundInfoReport != null && fundInfoReport.containsKey(id)) {
vo.setIsReport(1);
} else {
vo.setIsReport(0);
}
// 标签信息
LabelUtil labelUtil = new LabelUtil();
vo.setProductLabels(labelUtil.getList(labelUtil.getMap(Lists.newArrayList(id), fatools), id));
vo.setIsAppoint(fundInfo.getType()); vo.setIsAppoint(fundInfo.getType());
vo.setRiskLevel(fundInfo.getRiskLevel()); vo.setRiskLevel(fundInfo.getRiskLevel());
...@@ -1026,13 +999,11 @@ public class ProductServiceImpl implements ProductService, Constant { ...@@ -1026,13 +999,11 @@ public class ProductServiceImpl implements ProductService, Constant {
// 起投金额 // 起投金额
Map<String, FundRateMapping> rateMappingMap = getStringFundRateMappingMap(list); Map<String, FundRateMapping> rateMappingMap = getStringFundRateMappingMap(list);
LabelUtil labelUtil = new LabelUtil();
Map<String, List<ProductLabel>> productLabelMap = labelUtil.getMap(list, fatools);
// 查询研报信息是否有研报 // 查询研报信息是否有研报
Map<String, Object> fundInfoReport = getFundReport(Lists.newArrayList(fundInfoMap.keySet())); Map<String, Object> fundInfoReport = getFundReport(Lists.newArrayList(fundInfoMap.keySet()));
return fundCounts.stream().map(p -> getProductInfoVO(fundInfoMap, rateMappingMap, p, productLabelMap, labelUtil, fundInfoReport.keySet())) return fundCounts.stream().map(p -> getProductInfoVO(fundInfoMap, rateMappingMap, p,fundInfoReport.keySet()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
...@@ -1043,8 +1014,6 @@ public class ProductServiceImpl implements ProductService, Constant { ...@@ -1043,8 +1014,6 @@ public class ProductServiceImpl implements ProductService, Constant {
private ProductInfoVO getProductInfoVO(Map<String, FundInfo> fundInfoMap, Map<String, FundRateMapping> rateMappingMap, private ProductInfoVO getProductInfoVO(Map<String, FundInfo> fundInfoMap, Map<String, FundRateMapping> rateMappingMap,
FundCount fundCount, FundCount fundCount,
Map<String, List<ProductLabel>> productLabelMap,
LabelUtil labelUtil,
Set<String> fundInfoReports) { Set<String> fundInfoReports) {
ProductInfoVO vo = new ProductInfoVO(); ProductInfoVO vo = new ProductInfoVO();
BeanUtils.copyProperties(fundCount, vo); BeanUtils.copyProperties(fundCount, vo);
...@@ -1078,7 +1047,6 @@ public class ProductServiceImpl implements ProductService, Constant { ...@@ -1078,7 +1047,6 @@ public class ProductServiceImpl implements ProductService, Constant {
// 最新净值 // 最新净值
vo.setNet(new Net(fundCount.getEndDate().getTime(), BigDecimalUtil.toString(fundCount.getNetNav(), 4))); vo.setNet(new Net(fundCount.getEndDate().getTime(), BigDecimalUtil.toString(fundCount.getNetNav(), 4)));
vo.setProductLabels(labelUtil.getList(productLabelMap, vo.getFundId()));
getMinInvestmentShare(rateMappingMap, fundCount.getFundId(), vo); getMinInvestmentShare(rateMappingMap, fundCount.getFundId(), vo);
return vo; return vo;
......
package com.tanpu.fund.utils;
import com.tanpu.common.model.product.resp.ProductLabel;
import com.tanpu.common.resp.CommonResp;
import com.tanpu.fund.feign.user.FeignClientForFatools;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LabelUtil {
public Map<String, List<ProductLabel>> getMap(List<String> ls, FeignClientForFatools fatools) {
CommonResp<Map<String, List<ProductLabel>>> resp = fatools.batchGetLabelByIdInfo(ls);
if (resp.isSuccess()) {
return resp.getAttributes();
}
return new HashMap<>(0);
}
public List<ProductLabel> getList(Map<String, List<ProductLabel>> map, String id) {
if (!map.isEmpty()) {
return map.get(id);
}
return new ArrayList<>(0);
}
}
package com.tanpu.fund.service.impl;
import com.tanpu.fund.enums.ProStatusEnums;
import com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("dev")
public class ProfitRateServiceImplTest {
@Autowired
FundCountService profitRateService;
@Resource
FundInfoCustomMapper fundInfoCustomMapper;
@Resource
FundNavMapper fundNavMapper;
@Test
public void sectionProfitRate() {
//基金 HF0000000A
// profitRateService.sectionProfitRate();
}
private void queryFundInfoNavVos(int pageSize, int proDisFre){
//查询按周披露净值的基金
List<Integer> statusList = new ArrayList<>();
statusList.add(ProStatusEnums.OPENING.getType());
statusList.add(ProStatusEnums.CHANGEMANGER.getType());
statusList.add(ProStatusEnums.CLOSE.getType());
List<String> fundInfoNavVos = fundInfoCustomMapper.queryFundNavByCondition(proDisFre, statusList, pageSize - 500, 500);
//查询计算
{
if(!CollectionUtils.isEmpty(fundInfoNavVos)) {
Date startDate = null;
Date endDate = null;
profitRateService.sectionProfitRate(proDisFre, startDate, endDate, fundInfoNavVos);
}
}
if (!CollectionUtils.isEmpty(fundInfoNavVos) && fundInfoNavVos.size() == 500) {
//递归每次取500条基金数据
queryFundInfoNavVos(pageSize + 500, proDisFre);
}
}
}
\ No newline at end of file
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