Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tamp_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_fund
Commits
b63b33c8
Commit
b63b33c8
authored
Feb 18, 2022
by
钱坤
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/api_opt_branch' into dev
parents
dd1ef7df
7b7395a1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1449 additions
and
1 deletion
+1449
-1
pom.xml
pom.xml
+19
-0
FundLatestNav.java
...n/java/com/tanpu/fund/entity/generator/FundLatestNav.java
+106
-0
FundLatestNavExample.java
...com/tanpu/fund/entity/generator/FundLatestNavExample.java
+839
-0
FundLatestNavJob.java
src/main/java/com/tanpu/fund/job/FundLatestNavJob.java
+38
-0
FundLatestNavMapper.java
.../com/tanpu/fund/mapper/generator/FundLatestNavMapper.java
+30
-0
FundInfoCustomMapper.java
...pu/fund/mapper/generator/custom/FundInfoCustomMapper.java
+9
-0
FundLatestNavService.java
...ava/com/tanpu/fund/service/impl/FundLatestNavService.java
+87
-0
ProductPrivateServiceImpl.java
...om/tanpu/fund/service/impl/ProductPrivateServiceImpl.java
+6
-0
ProductServiceImpl.java
.../java/com/tanpu/fund/service/impl/ProductServiceImpl.java
+5
-1
FundInfoCustomMapper.xml
...main/resources/mybatis/customize/FundInfoCustomMapper.xml
+19
-0
FundLatestNavMapper.xml
src/main/resources/mybatis/generator/FundLatestNavMapper.xml
+291
-0
No files found.
pom.xml
View file @
b63b33c8
...
@@ -352,6 +352,25 @@
...
@@ -352,6 +352,25 @@
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugin>
<plugin>
<groupId>
org.mybatis.generator
</groupId>
<artifactId>
mybatis-generator-maven-plugin
</artifactId>
<version>
1.3.5
</version>
<configuration>
<!--允许移动生成的文件 -->
<verbose>
true
</verbose>
<!-- 是否覆盖 -->
<overwrite>
true
</overwrite>
</configuration>
<dependencies>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
5.1.47
</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</plugins>
</build>
</build>
...
...
src/main/java/com/tanpu/fund/entity/generator/FundLatestNav.java
0 → 100644
View file @
b63b33c8
package
com
.
tanpu
.
fund
.
entity
.
generator
;
import
java.math.BigDecimal
;
import
java.util.Date
;
public
class
FundLatestNav
{
private
Long
id
;
private
String
fundId
;
private
Date
priceDate
;
private
BigDecimal
nav
;
private
BigDecimal
cumulativeNav
;
private
BigDecimal
cumulativeNavWithdrawal
;
private
Integer
ishighOrLow
;
private
BigDecimal
tohighNavRatio
;
private
Date
createTime
;
private
Date
updateTime
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getFundId
()
{
return
fundId
;
}
public
void
setFundId
(
String
fundId
)
{
this
.
fundId
=
fundId
==
null
?
null
:
fundId
.
trim
();
}
public
Date
getPriceDate
()
{
return
priceDate
;
}
public
void
setPriceDate
(
Date
priceDate
)
{
this
.
priceDate
=
priceDate
;
}
public
BigDecimal
getNav
()
{
return
nav
;
}
public
void
setNav
(
BigDecimal
nav
)
{
this
.
nav
=
nav
;
}
public
BigDecimal
getCumulativeNav
()
{
return
cumulativeNav
;
}
public
void
setCumulativeNav
(
BigDecimal
cumulativeNav
)
{
this
.
cumulativeNav
=
cumulativeNav
;
}
public
BigDecimal
getCumulativeNavWithdrawal
()
{
return
cumulativeNavWithdrawal
;
}
public
void
setCumulativeNavWithdrawal
(
BigDecimal
cumulativeNavWithdrawal
)
{
this
.
cumulativeNavWithdrawal
=
cumulativeNavWithdrawal
;
}
public
Integer
getIshighOrLow
()
{
return
ishighOrLow
;
}
public
void
setIshighOrLow
(
Integer
ishighOrLow
)
{
this
.
ishighOrLow
=
ishighOrLow
;
}
public
BigDecimal
getTohighNavRatio
()
{
return
tohighNavRatio
;
}
public
void
setTohighNavRatio
(
BigDecimal
tohighNavRatio
)
{
this
.
tohighNavRatio
=
tohighNavRatio
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
\ No newline at end of file
src/main/java/com/tanpu/fund/entity/generator/FundLatestNavExample.java
0 → 100644
View file @
b63b33c8
This diff is collapsed.
Click to expand it.
src/main/java/com/tanpu/fund/job/FundLatestNavJob.java
0 → 100644
View file @
b63b33c8
package
com
.
tanpu
.
fund
.
job
;
import
com.tanpu.common.utils.RedisUtils
;
import
com.tanpu.fund.service.impl.FundLatestNavService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
javax.annotation.Resource
;
/**
* @author: zyh
* <p>
*/
@Slf4j
public
class
FundLatestNavJob
{
@Resource
private
FundLatestNavService
fundLatestNavService
;
@Resource
private
RedisUtils
redisUtils
;
@Scheduled
(
cron
=
"5 4/10 * * * ?"
)
public
void
execute
()
{
long
start
=
System
.
currentTimeMillis
();
try
{
log
.
info
(
"私募基金最新净值更新job开始"
);
redisUtils
.
lockAndExecute
(
""
+
this
.
getClass
().
getSimpleName
(),
1
,
200
,
()
->
{
fundLatestNavService
.
sync
();
return
1
;
});
}
catch
(
RedisUtils
.
LockUnacquiredException
ee
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
""
,
e
);
}
finally
{
log
.
info
(
"私募基金最新净值更新job结束, 耗时: {}ms"
,
System
.
currentTimeMillis
()
-
start
);
}
}
}
src/main/java/com/tanpu/fund/mapper/generator/FundLatestNavMapper.java
0 → 100644
View file @
b63b33c8
package
com
.
tanpu
.
fund
.
mapper
.
generator
;
import
com.tanpu.fund.entity.generator.FundLatestNav
;
import
com.tanpu.fund.entity.generator.FundLatestNavExample
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
public
interface
FundLatestNavMapper
{
long
countByExample
(
FundLatestNavExample
example
);
int
deleteByExample
(
FundLatestNavExample
example
);
int
deleteByPrimaryKey
(
Long
id
);
int
insert
(
FundLatestNav
record
);
int
insertSelective
(
FundLatestNav
record
);
List
<
FundLatestNav
>
selectByExample
(
FundLatestNavExample
example
);
FundLatestNav
selectByPrimaryKey
(
Long
id
);
int
updateByExampleSelective
(
@Param
(
"record"
)
FundLatestNav
record
,
@Param
(
"example"
)
FundLatestNavExample
example
);
int
updateByExample
(
@Param
(
"record"
)
FundLatestNav
record
,
@Param
(
"example"
)
FundLatestNavExample
example
);
int
updateByPrimaryKeySelective
(
FundLatestNav
record
);
int
updateByPrimaryKey
(
FundLatestNav
record
);
}
\ No newline at end of file
src/main/java/com/tanpu/fund/mapper/generator/custom/FundInfoCustomMapper.java
View file @
b63b33c8
...
@@ -2,12 +2,14 @@ package com.tanpu.fund.mapper.generator.custom;
...
@@ -2,12 +2,14 @@ package com.tanpu.fund.mapper.generator.custom;
import
com.tanpu.common.model.product.resp.FilePreviewResp
;
import
com.tanpu.common.model.product.resp.FilePreviewResp
;
import
com.tanpu.common.model.tanpuroom.Type
;
import
com.tanpu.common.model.tanpuroom.Type
;
import
com.tanpu.fund.entity.generator.FundLatestNav
;
import
com.tanpu.fund.entity.generator.FundNav
;
import
com.tanpu.fund.entity.generator.FundNav
;
import
org.apache.ibatis.annotations.MapKey
;
import
org.apache.ibatis.annotations.MapKey
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -57,4 +59,11 @@ public interface FundInfoCustomMapper {
...
@@ -57,4 +59,11 @@ public interface FundInfoCustomMapper {
@Select
(
"select t.id as id,t.fund_short_name as value from fund_info t where t.fund_short_name like #{productName} and t.delete_tag=0"
)
@Select
(
"select t.id as id,t.fund_short_name as value from fund_info t where t.fund_short_name like #{productName} and t.delete_tag=0"
)
List
<
Type
>
getFundInfoLikeName
(
@Param
(
"productName"
)
String
productName
);
List
<
Type
>
getFundInfoLikeName
(
@Param
(
"productName"
)
String
productName
);
/**
* 获取*私募*基金最新净值
*
* @return
*/
List
<
FundLatestNav
>
getFundLatestNet
(
@Param
(
"start"
)
Date
start
);
}
}
src/main/java/com/tanpu/fund/service/impl/FundLatestNavService.java
0 → 100644
View file @
b63b33c8
package
com
.
tanpu
.
fund
.
service
.
impl
;
import
com.tanpu.common.utils.DateUtils
;
import
com.tanpu.fund.entity.generator.FundLatestNav
;
import
com.tanpu.fund.entity.generator.FundLatestNavExample
;
import
com.tanpu.fund.entity.generator.FundNav
;
import
com.tanpu.fund.mapper.generator.FundLatestNavMapper
;
import
com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Service
@Slf4j
public
class
FundLatestNavService
{
@Resource
private
FundLatestNavMapper
fundLatestNavMapper
;
@Resource
private
FundInfoCustomMapper
fundInfoCustomMapper
;
public
List
<
FundNav
>
getLatestNavBy
(
List
<
String
>
fundIdList
)
{
if
(
CollectionUtils
.
isEmpty
(
fundIdList
))
{
return
new
ArrayList
<>();
}
FundLatestNavExample
example
=
new
FundLatestNavExample
();
example
.
createCriteria
().
andFundIdIn
(
fundIdList
);
List
<
FundLatestNav
>
navList
=
fundLatestNavMapper
.
selectByExample
(
example
);
return
navList
.
stream
().
map
(
p
->
{
FundNav
target
=
new
FundNav
();
BeanUtils
.
copyProperties
(
p
,
target
);
return
target
;
}).
collect
(
Collectors
.
toList
());
}
public
void
sync
(){
FundLatestNavExample
example
=
new
FundLatestNavExample
();
example
.
createCriteria
().
andFundIdEqualTo
(
"DF17000000110"
);
List
<
FundLatestNav
>
list
=
fundLatestNavMapper
.
selectByExample
(
example
);
Date
startTime
=
list
.
get
(
0
).
getCreateTime
();
List
<
FundLatestNav
>
latestList
=
fundInfoCustomMapper
.
getFundLatestNet
(
startTime
);
log
.
info
(
"私募新净值统计, count: {}, start: {}"
,
latestList
.
size
(),
DateUtils
.
format
(
startTime
));
if
(
CollectionUtils
.
isEmpty
(
latestList
))
{
log
.
info
(
"私募没有新净值数据,结束"
);
return
;
}
int
p
=
0
;
while
(
p
<
latestList
.
size
())
{
List
<
FundLatestNav
>
batchList
=
latestList
.
subList
(
p
,
Math
.
min
(
latestList
.
size
(),
p
+
200
));
if
(
CollectionUtils
.
isEmpty
(
batchList
))
{
break
;
}
List
<
String
>
idList
=
batchList
.
stream
().
map
(
FundLatestNav:
:
getFundId
).
collect
(
Collectors
.
toList
());
FundLatestNavExample
latestNavExample
=
new
FundLatestNavExample
();
latestNavExample
.
createCriteria
().
andFundIdIn
(
idList
);
Map
<
String
,
List
<
FundLatestNav
>>
existMap
=
fundLatestNavMapper
.
selectByExample
(
latestNavExample
)
.
stream
().
collect
(
Collectors
.
groupingBy
(
FundLatestNav:
:
getFundId
));
for
(
FundLatestNav
latestNav
:
batchList
)
{
latestNav
.
setUpdateTime
(
null
);
if
(
existMap
.
containsKey
(
latestNav
.
getFundId
()))
{
// update
latestNav
.
setId
(
existMap
.
get
(
latestNav
.
getFundId
()).
get
(
0
).
getId
());
fundLatestNavMapper
.
updateByPrimaryKeySelective
(
latestNav
);
}
else
{
// insert
fundLatestNavMapper
.
insertSelective
(
latestNav
);
}
}
p
+=
200
;
}
Date
newStartTime
=
latestList
.
stream
().
map
(
FundLatestNav:
:
getCreateTime
).
max
(
Date:
:
compareTo
).
get
();
FundLatestNav
target
=
new
FundLatestNav
();
target
.
setCreateTime
(
newStartTime
);
int
c
=
fundLatestNavMapper
.
updateByExampleSelective
(
target
,
example
);
log
.
info
(
"私募新净值更新起始时间,affected: {}, start: {}"
,
c
,
DateUtils
.
format
(
newStartTime
));
}
}
src/main/java/com/tanpu/fund/service/impl/ProductPrivateServiceImpl.java
View file @
b63b33c8
...
@@ -362,12 +362,18 @@ public class ProductPrivateServiceImpl implements ProductPrivateService, Constan
...
@@ -362,12 +362,18 @@ public class ProductPrivateServiceImpl implements ProductPrivateService, Constan
}
}
private
List
<
PersonnelInfo
>
getPersonnelInfos
(
List
<
String
>
ids
)
{
private
List
<
PersonnelInfo
>
getPersonnelInfos
(
List
<
String
>
ids
)
{
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
return
new
ArrayList
<>();
}
PersonnelInfoExample
example1
=
new
PersonnelInfoExample
();
PersonnelInfoExample
example1
=
new
PersonnelInfoExample
();
example1
.
createCriteria
().
andIdIn
(
ids
);
example1
.
createCriteria
().
andIdIn
(
ids
);
return
this
.
personnelInfoMapper
.
selectByExample
(
example1
);
return
this
.
personnelInfoMapper
.
selectByExample
(
example1
);
}
}
private
Map
<
String
,
PersonnelInfo
>
getPersonnelInfoMap
(
List
<
String
>
ids
)
{
private
Map
<
String
,
PersonnelInfo
>
getPersonnelInfoMap
(
List
<
String
>
ids
)
{
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
return
new
HashMap
<>();
}
List
<
PersonnelInfo
>
personnelInfos
=
getPersonnelInfos
(
ids
);
List
<
PersonnelInfo
>
personnelInfos
=
getPersonnelInfos
(
ids
);
return
personnelInfos
.
stream
().
collect
(
Collectors
.
toMap
(
PersonnelInfo:
:
getId
,
s
->
s
));
return
personnelInfos
.
stream
().
collect
(
Collectors
.
toMap
(
PersonnelInfo:
:
getId
,
s
->
s
));
}
}
...
...
src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java
View file @
b63b33c8
...
@@ -124,6 +124,8 @@ public class ProductServiceImpl implements ProductService, Constant {
...
@@ -124,6 +124,8 @@ public class ProductServiceImpl implements ProductService, Constant {
@Resource
@Resource
private
FeignForProduct
product
;
private
FeignForProduct
product
;
@Resource
private
FundLatestNavService
fundLatestNavService
;
@Override
@Override
public
Page
<
ProductInfoVO
>
getProductList
(
ProductInfoReq
req
)
{
public
Page
<
ProductInfoVO
>
getProductList
(
ProductInfoReq
req
)
{
...
@@ -2507,7 +2509,9 @@ public class ProductServiceImpl implements ProductService, Constant {
...
@@ -2507,7 +2509,9 @@ public class ProductServiceImpl implements ProductService, Constant {
}
}
// 查询基金最新净值
// 查询基金最新净值
List
<
FundNav
>
fundInfoNewNet
=
fundInfoCustomMapper
.
getFundInfoNewNet
(
fundInfoList
.
stream
().
map
(
Type:
:
getId
).
collect
(
Collectors
.
toList
()));
List
<
FundNav
>
fundInfoNewNet
=
fundLatestNavService
.
getLatestNavBy
(
fundInfoList
.
stream
().
map
(
Type:
:
getId
).
collect
(
Collectors
.
toList
()));
// 下面这个sql太慢了,换个新方案
// List<FundNav> fundInfoNewNet = fundInfoCustomMapper.getFundInfoNewNet(fundInfoList.stream().map(Type::getId).collect(Collectors.toList()));
Map
<
String
,
FundNav
>
fundNavMap
=
null
;
Map
<
String
,
FundNav
>
fundNavMap
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
fundInfoNewNet
))
{
if
(
CollectionUtils
.
isNotEmpty
(
fundInfoNewNet
))
{
fundNavMap
=
fundInfoNewNet
.
stream
().
collect
(
Collectors
.
toMap
(
FundNav:
:
getFundId
,
c
->
c
));
fundNavMap
=
fundInfoNewNet
.
stream
().
collect
(
Collectors
.
toMap
(
FundNav:
:
getFundId
,
c
->
c
));
...
...
src/main/resources/mybatis/customize/FundInfoCustomMapper.xml
View file @
b63b33c8
...
@@ -64,4 +64,23 @@
...
@@ -64,4 +64,23 @@
left join ifa_imported_fund_nav res on t.fund_id = res.fund_id and t.price_date = res.price_date
left join ifa_imported_fund_nav res on t.fund_id = res.fund_id and t.price_date = res.price_date
</select>
</select>
<select
id=
"getFundLatestNet"
resultType=
"com.tanpu.fund.entity.generator.FundLatestNav"
>
select
res.fund_id as fundId,
res.fund_code as fundCode,
res.price_date as priceDate,
res.nav as nav,
res.cumulative_nav as cumulativeNav,
res.cumulative_nav_withdrawal as cumulativeNavWithdrawal,
res.ishigh_or_low as ishighOrLow,
res.tohigh_nav_ratio as tohighNavRatio,
res.create_time as createTime
from
(SELECT fund_id, max(price_date) as price_date FROM fund_nav WHERE
create_time
<![CDATA[ >]]>
#{start, jdbcType=TIMESTAMP} and delete_tag = 0
and nav is not null and cumulative_nav is not null
GROUP by fund_id) t
left join fund_nav res on t.fund_id = res.fund_id and t.price_date = res.price_date
</select>
</mapper>
</mapper>
src/main/resources/mybatis/generator/FundLatestNavMapper.xml
0 → 100644
View file @
b63b33c8
This diff is collapsed.
Click to expand it.
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