Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tamp_public_fund
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭熊
tamp_public_fund
Commits
043baf6d
Commit
043baf6d
authored
Jan 26, 2021
by
zp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加
parent
0085289b
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1 addition
and
304 deletions
+1
-304
ProductApi.java
src/main/java/com/tanpu/fund/api/ProductApi.java
+0
-5
ProductController.java
...ain/java/com/tanpu/fund/controller/ProductController.java
+0
-13
FeignClientForFatools.java
...java/com/tanpu/fund/feign/user/FeignClientForFatools.java
+0
-42
FeignbackForFatools.java
...n/java/com/tanpu/fund/feign/user/FeignbackForFatools.java
+0
-63
ProfitRateJob.java
src/main/java/com/tanpu/fund/job/ProfitRateJob.java
+0
-59
ProductServiceImpl.java
.../java/com/tanpu/fund/service/impl/ProductServiceImpl.java
+1
-33
LabelUtil.java
src/main/java/com/tanpu/fund/utils/LabelUtil.java
+0
-29
ProfitRateServiceImplTest.java
...om/tanpu/fund/service/impl/ProfitRateServiceImplTest.java
+0
-60
No files found.
src/main/java/com/tanpu/fund/api/ProductApi.java
View file @
043baf6d
...
...
@@ -93,9 +93,4 @@ public interface ProductApi {
@ApiOperation
(
"动态回撤"
)
@GetMapping
(
"/dynamic/retreat"
)
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
);
}
src/main/java/com/tanpu/fund/controller/ProductController.java
View file @
043baf6d
package
com
.
tanpu
.
fund
.
controller
;
import
com.tanpu.common.auth.mapping.TanpuInterfaceLoginAuth
;
import
com.tanpu.common.model.Page
;
import
com.tanpu.common.model.Pageable
;
import
com.tanpu.common.model.product.req.ProductListReq
;
import
com.tanpu.common.model.product.resp.*
;
import
com.tanpu.common.model.user.resp.SysConstantResp
;
import
com.tanpu.common.resp.CommonResp
;
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.ProductInfoReq
;
import
com.tanpu.fund.api.model.resp.*
;
import
com.tanpu.fund.feign.user.FeignClientForFatools
;
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
;
...
...
@@ -105,11 +99,4 @@ public class ProductController implements ProductApi {
public
CommonResp
<
DynamicRetreatVO
>
getDynamicRetreatInfo
(
String
id
)
{
return
CommonResp
.
success
(
this
.
productService
.
getDynamicRetreat
(
id
));
}
@Override
public
CommonResp
<
FundDateResp
>
getFundDateByFundIdInfo
(
String
fundId
)
{
return
CommonResp
.
success
(
this
.
productService
.
getFundDateByFundId
(
fundId
));
}
}
src/main/java/com/tanpu/fund/feign/user/FeignClientForFatools.java
deleted
100644 → 0
View file @
0085289b
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
);
}
src/main/java/com/tanpu/fund/feign/user/FeignbackForFatools.java
deleted
100644 → 0
View file @
0085289b
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
;
}
};
}
}
src/main/java/com/tanpu/fund/job/ProfitRateJob.java
deleted
100644 → 0
View file @
0085289b
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
);
}
}
}
src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java
View file @
043baf6d
...
...
@@ -9,8 +9,6 @@ import com.tanpu.common.model.Page;
import
com.tanpu.common.model.Pageable
;
import
com.tanpu.common.model.product.req.ProductListReq
;
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.fund.api.model.FundInfoVO
;
import
com.tanpu.fund.api.model.req.NetReq
;
...
...
@@ -18,13 +16,10 @@ import com.tanpu.fund.api.model.req.ProductInfoReq;
import
com.tanpu.fund.api.model.resp.*
;
import
com.tanpu.fund.entity.generator.*
;
import
com.tanpu.fund.enums.FilterTypeEnum
;
import
com.tanpu.fund.enums.FundStatusEnum
;
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.custom.FundInfoCustomMapper
;
import
com.tanpu.fund.service.ProductService
;
import
com.tanpu.fund.utils.LabelUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -32,7 +27,6 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -81,9 +75,6 @@ public class ProductServiceImpl implements ProductService, Constant {
@Resource
private
FundRiskStatsMapper
fundRiskStatsMapper
;
@Resource
private
FeignClientForFatools
fatools
;
@Resource
private
FundRateMappingMapper
fundRateMappingMapper
;
...
...
@@ -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
.
setRiskLevel
(
fundInfo
.
getRiskLevel
());
...
...
@@ -1026,13 +999,11 @@ public class ProductServiceImpl implements ProductService, Constant {
// 起投金额
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
()));
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
());
}
...
...
@@ -1043,8 +1014,6 @@ public class ProductServiceImpl implements ProductService, Constant {
private
ProductInfoVO
getProductInfoVO
(
Map
<
String
,
FundInfo
>
fundInfoMap
,
Map
<
String
,
FundRateMapping
>
rateMappingMap
,
FundCount
fundCount
,
Map
<
String
,
List
<
ProductLabel
>>
productLabelMap
,
LabelUtil
labelUtil
,
Set
<
String
>
fundInfoReports
)
{
ProductInfoVO
vo
=
new
ProductInfoVO
();
BeanUtils
.
copyProperties
(
fundCount
,
vo
);
...
...
@@ -1078,7 +1047,6 @@ public class ProductServiceImpl implements ProductService, Constant {
// 最新净值
vo
.
setNet
(
new
Net
(
fundCount
.
getEndDate
().
getTime
(),
BigDecimalUtil
.
toString
(
fundCount
.
getNetNav
(),
4
)));
vo
.
setProductLabels
(
labelUtil
.
getList
(
productLabelMap
,
vo
.
getFundId
()));
getMinInvestmentShare
(
rateMappingMap
,
fundCount
.
getFundId
(),
vo
);
return
vo
;
...
...
src/main/java/com/tanpu/fund/utils/LabelUtil.java
deleted
100644 → 0
View file @
0085289b
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
);
}
}
src/test/java/com/tanpu/fund/service/impl/ProfitRateServiceImplTest.java
deleted
100644 → 0
View file @
0085289b
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment