package com.friday.custody.quartz;

import com.friday.custody.service.basicService.CdsProductInfoService;
import com.friday.custody.service.logicService.LogicInternalService;
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 UpdateDataZxJob extends QuartzJobBean {
    @Value("${custody.quartz.updateDataZxByScheduled.switch}")
    private Boolean updateDataFromZxSwitch;
    @Autowired
    private LogicInternalService logicInternalService;
    @Autowired
    private CdsProductInfoService cdsProductInfoService;
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        if (!updateDataFromZxSwitch) {
            log.warn("每天0点更新数据开关:未开启!");
            return;
        }
        logicInternalService.updateDataZx();
        cdsProductInfoService.syncFundInfoFromHtscCds();
    }
}
