FundLatestNavJob.java 1.17 KB
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);
        }
    }
}