package com.friday.custody.quartz;

import com.friday.custody.service.logicService.LogicInternalService;
import com.friday.custody.common.CustodyContants;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.quartz.QuartzJobBean;

/**
 * 每天更新0点更新
 */
@Slf4j
@DisallowConcurrentExecution
public class UpdateZhongxToatlAssetJob extends QuartzJobBean {
    @Value("${custody.quartz.updateZhongxTotalAssetByScheduled.switch}")
    private Boolean updateZhongxTotalAssetSwitch;
    @Autowired
    private LogicInternalService logicInternalService;
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        if (!updateZhongxTotalAssetSwitch) {
            log.warn("每天0点更新中信资产合计数据开关:未开启!");
            return;
        }
        int loopTime = CustodyContants.UPDATE_BY_DAY_DAILY_LOOP_TIME;//更新15 初始化 365
        log.info("UpdateZhongxToatlAssetJob开始执行！");
        logicInternalService.updateZhongxTotalAsset(loopTime);
    }
}
