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
b5d9866f
Commit
b5d9866f
authored
Apr 29, 2022
by
钱坤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基金净值缓存刷新触发job
parent
fe9f3516
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
0 deletions
+120
-0
FeignForHangjia.java
...in/java/com/tanpu/fund/feign/hangjia/FeignForHangjia.java
+22
-0
FeignbackForHangjiaBack.java
...com/tanpu/fund/feign/hangjia/FeignbackForHangjiaBack.java
+35
-0
FundNavCacheJob.java
src/main/java/com/tanpu/fund/job/FundNavCacheJob.java
+63
-0
No files found.
src/main/java/com/tanpu/fund/feign/hangjia/FeignForHangjia.java
0 → 100644
View file @
b5d9866f
package
com
.
tanpu
.
fund
.
feign
.
hangjia
;
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-hangjia-back"
,
url
=
"${tanpu.hangjia-back.svc:}"
,
path
=
"/py/jijinhangjia"
)
public
interface
FeignForHangjia
{
@GetMapping
(
"/api/tamp/cache/fund/nav/reload"
)
CommonResp
reloadFundNav4Ifa
(
@RequestParam
(
"sign"
)
String
sign
,
@RequestParam
(
"ifa_id"
)
String
ifaId
);
@GetMapping
(
"/api/tamp/cache/fund/nav/reload"
)
CommonResp
reloadMostUsedFundNav
(
@RequestParam
(
"sign"
)
String
sign
,
@RequestParam
(
"limit"
)
int
limit
);
}
src/main/java/com/tanpu/fund/feign/hangjia/FeignbackForHangjiaBack.java
0 → 100644
View file @
b5d9866f
package
com
.
tanpu
.
fund
.
feign
.
hangjia
;
import
com.alibaba.fastjson.JSON
;
import
com.tanpu.common.model.tanpuroom.Type
;
import
com.tanpu.common.resp.CommonResp
;
import
com.tanpu.fund.feign.product.FeignForProduct
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Slf4j
@Component
public
class
FeignbackForHangjiaBack
implements
FallbackFactory
<
FeignForHangjia
>
{
@Override
public
FeignForHangjia
create
(
Throwable
throwable
)
{
return
new
FeignForHangjia
()
{
@Override
public
CommonResp
reloadFundNav4Ifa
(
String
sign
,
String
ifaId
)
{
log
.
error
(
"FeignForHangjia.reloadFundNav4Ifa 发生异常, sign: {}, ifaId: {}"
,
sign
,
ifaId
,
throwable
);
return
CommonResp
.
error
(
"基金净值缓存刷新发生异常"
);
}
@Override
public
CommonResp
reloadMostUsedFundNav
(
String
sign
,
int
limit
)
{
log
.
error
(
"FeignForHangjia.reloadMostUsedFundNav 发生异常, sign: {}, limit: {}"
,
sign
,
limit
,
throwable
);
return
CommonResp
.
error
(
"基金净值缓存刷新发生异常"
);
}
};
}
}
src/main/java/com/tanpu/fund/job/FundNavCacheJob.java
0 → 100644
View file @
b5d9866f
package
com
.
tanpu
.
fund
.
job
;
import
com.tanpu.common.resp.CommonResp
;
import
com.tanpu.common.utils.DateUtils
;
import
com.tanpu.common.utils.RedisUtils
;
import
com.tanpu.fund.feign.hangjia.FeignForHangjia
;
import
com.tanpu.fund.service.impl.FundLatestNavService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* @author: zyh
* <p>
*/
@Slf4j
@Component
public
class
FundNavCacheJob
{
@Resource
private
FeignForHangjia
feignForHangjia
;
@Value
(
"${tanpu.fund.nav.cache.ifa:}"
)
private
String
ifaIdList
;
@Value
(
"${tanpu.most.used.fund.nav.cache.limit:200}"
)
private
int
limit
;
@Scheduled
(
cron
=
"10 1 * * * ?"
)
public
void
execute
()
{
long
start
=
System
.
currentTimeMillis
();
String
sign
=
DateUtils
.
format
(
DateUtils
.
nowDate
()).
replace
(
" "
,
""
);
try
{
if
(
StringUtils
.
isNotBlank
(
ifaIdList
))
{
log
.
info
(
"刷新指定ifa的基金净值缓存job开始"
);
String
[]
ss
=
ifaIdList
.
split
(
","
);
for
(
String
id
:
ss
)
{
log
.
info
(
"开始刷新ifa="
+
id
+
"的基金净值缓存"
);
CommonResp
resp
=
feignForHangjia
.
reloadFundNav4Ifa
(
sign
,
id
);
log
.
info
(
"ifa="
+
id
+
"的基金净值缓存刷新结果: "
+
resp
);
Thread
.
sleep
(
1000
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
""
,
e
);
}
finally
{
log
.
info
(
"私募基金最新净值更新job结束, 耗时: {}ms"
,
System
.
currentTimeMillis
()
-
start
);
}
try
{
log
.
info
(
"开始刷新使用最多基金净值缓存, limit: "
+
limit
);
sign
=
DateUtils
.
format
(
DateUtils
.
nowDate
()).
replace
(
" "
,
""
);
CommonResp
resp
=
feignForHangjia
.
reloadMostUsedFundNav
(
sign
,
limit
);
log
.
info
(
"使用最多基金净值缓存刷新结果: "
+
resp
);
}
catch
(
Exception
e
)
{
log
.
error
(
""
,
e
);
}
finally
{
log
.
info
(
"基金净值缓存刷新触发job结束, 耗时: {}ms"
,
System
.
currentTimeMillis
()
-
start
);
}
}
}
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