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
e1df123d
Commit
e1df123d
authored
Nov 15, 2023
by
钱坤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
私募的latest_nav也使用融合净值
parent
a91f0c9c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
8 deletions
+56
-8
FundInfoCustomMapper.java
...pu/fund/mapper/generator/custom/FundInfoCustomMapper.java
+2
-0
FundLatestNavService.java
...ava/com/tanpu/fund/service/impl/FundLatestNavService.java
+36
-8
FundInfoCustomMapper.xml
...main/resources/mybatis/customize/FundInfoCustomMapper.xml
+18
-0
No files found.
src/main/java/com/tanpu/fund/mapper/generator/custom/FundInfoCustomMapper.java
View file @
e1df123d
...
...
@@ -66,4 +66,6 @@ public interface FundInfoCustomMapper {
* @return
*/
List
<
FundLatestNav
>
getFundLatestNet
(
@Param
(
"start"
)
Date
start
);
List
<
FundLatestNav
>
getFundLatestNetInRH
(
@Param
(
"start"
)
Date
start
);
}
src/main/java/com/tanpu/fund/service/impl/FundLatestNavService.java
View file @
e1df123d
...
...
@@ -48,14 +48,31 @@ public class FundLatestNavService {
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
))
{
List
<
FundLatestNav
>
latestListRH
=
fundInfoCustomMapper
.
getFundLatestNetInRH
(
startTime
);
List
<
FundLatestNav
>
navList
=
new
ArrayList
<>(
latestListRH
.
size
()
+
latestList
.
size
()
+
1
);
navList
.
addAll
(
latestList
);
navList
.
addAll
(
latestListRH
);
navList
.
sort
((
p1
,
p2
)
->
{
int
dif
=
p1
.
getFundId
().
compareTo
(
p2
.
getFundId
());
if
(
dif
!=
0
)
{
return
dif
;
}
if
(
p1
.
getPriceDate
()
==
null
)
{
return
-
1
;
}
if
(
p1
.
getPriceDate
()
==
null
)
{
return
1
;
}
return
p1
.
getPriceDate
().
compareTo
(
p1
.
getPriceDate
());
});
log
.
info
(
"私募新净值统计, count: {}, start: {}"
,
navList
.
size
(),
DateUtils
.
format
(
startTime
));
if
(
CollectionUtils
.
isEmpty
(
navList
))
{
log
.
info
(
"私募没有新净值数据,结束"
);
return
;
}
int
p
=
0
;
while
(
p
<
latest
List
.
size
())
{
List
<
FundLatestNav
>
batchList
=
latestList
.
subList
(
p
,
Math
.
min
(
latest
List
.
size
(),
p
+
200
));
while
(
p
<
nav
List
.
size
())
{
List
<
FundLatestNav
>
batchList
=
navList
.
subList
(
p
,
Math
.
min
(
nav
List
.
size
(),
p
+
200
));
if
(
CollectionUtils
.
isEmpty
(
batchList
))
{
break
;
}
...
...
@@ -64,12 +81,21 @@ public class FundLatestNavService {
latestNavExample
.
createCriteria
().
andFundIdIn
(
idList
);
Map
<
String
,
List
<
FundLatestNav
>>
existMap
=
fundLatestNavMapper
.
selectByExample
(
latestNavExample
)
.
stream
().
collect
(
Collectors
.
groupingBy
(
FundLatestNav:
:
getFundId
));
FundLatestNavExample
updateExample
=
new
FundLatestNavExample
();
for
(
FundLatestNav
latestNav
:
batchList
)
{
// 这几个字段不用更新
latestNav
.
setUpdateTime
(
null
);
if
(
existMap
.
containsKey
(
latestNav
.
getFundId
()))
{
latestNav
.
setId
(
null
);
latestNav
.
setCreateTime
(
null
);
List
<
FundLatestNav
>
existNavs
=
existMap
.
get
(
latestNav
.
getFundId
());
if
(
CollectionUtils
.
isNotEmpty
(
existNavs
))
{
// update
latestNav
.
setId
(
existMap
.
get
(
latestNav
.
getFundId
()).
get
(
0
).
getId
());
fundLatestNavMapper
.
updateByPrimaryKeySelective
(
latestNav
);
FundLatestNav
eNav
=
existNavs
.
get
(
0
);
if
(
eNav
.
getPriceDate
().
compareTo
(
latestNav
.
getPriceDate
())
<=
0
)
{
updateExample
.
clear
();
updateExample
.
createCriteria
().
andFundIdEqualTo
(
latestNav
.
getFundId
());
fundLatestNavMapper
.
updateByExampleSelective
(
latestNav
,
updateExample
);
}
}
else
{
// insert
fundLatestNavMapper
.
insertSelective
(
latestNav
);
...
...
@@ -79,8 +105,10 @@ public class FundLatestNavService {
}
Date
newStartTime
=
latestList
.
stream
().
map
(
FundLatestNav:
:
getCreateTime
).
max
(
Date:
:
compareTo
).
get
();
Date
newStartTimeRH
=
latestListRH
.
stream
().
map
(
FundLatestNav:
:
getCreateTime
).
max
(
Date:
:
compareTo
).
get
();
FundLatestNav
target
=
new
FundLatestNav
();
target
.
setCreateTime
(
newStartTime
);
// 存储较小的那个,保证两个表里的都能被扫描到.
target
.
setCreateTime
(
newStartTime
.
before
(
newStartTimeRH
)
?
newStartTime
:
newStartTimeRH
);
int
c
=
fundLatestNavMapper
.
updateByExampleSelective
(
target
,
example
);
log
.
info
(
"私募新净值更新起始时间,affected: {}, start: {}"
,
c
,
DateUtils
.
format
(
newStartTime
));
}
...
...
src/main/resources/mybatis/customize/FundInfoCustomMapper.xml
View file @
e1df123d
...
...
@@ -82,4 +82,22 @@
left join fund_nav res on t.fund_id = res.fund_id and t.price_date = res.price_date
</select>
<select
id=
"getFundLatestNetInRH"
resultType=
"com.tanpu.fund.entity.generator.FundLatestNav"
>
select
res.fund_id as fundId,
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.update_time as createTime
from
(SELECT fund_id, max(price_date) as price_date FROM fund_nav_sub_pp_rh_view WHERE
update_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_sub_pp_rh_view res on t.fund_id = res.fund_id and t.price_date = res.price_date
</select>
</mapper>
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