1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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 org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author: zyh
* <p>
*/
@Slf4j
@Component
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);
}
}
}