package com.friday.custody.quartz;

import com.friday.custody.service.basicService.*;
import com.friday.custody.service.basicService.TongyiDirectionalConvertibleBondsService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

@Slf4j
@DisallowConcurrentExecution
@Component
public class UpdateTongyiJob extends QuartzJobBean {
    @Value("${custody.quartz.updateTongyiByScheduled.switch}")
    private Boolean updateTongyiByScheduledSwitch;
    @Autowired
    TongyiUnissuedDataService tongyiUnissuedDataService;
    @Autowired
    TongyiDirectionalupDataService tongyiDirectionalupDataService;
    @Autowired
    TongyiConvertibleBondsDataService tongyiConvertibleBondsDataService;
    @Autowired
    TongyiCeliverableBondDataService tongyiCeliverableBondDataService;
    @Autowired
    TongyiDirectionalConvertibleBondsService tongyiDirectionalConvertibleBondsService;
    @Override
    protected void executeInternal(JobExecutionContext context) {
        if (!updateTongyiByScheduledSwitch) {
            log.warn("每天更新再融资数据开关:未开启!");
            return;
        }
        log.info("全市场待发行 更新");
            tongyiUnissuedDataService.updateTongyiUnissuedToTempTable();
            log.info("定增 更新");
            tongyiDirectionalupDataService.updateTongyiDirectionalupToTempTable();
            log.info("可转债已发行 更新");
            tongyiConvertibleBondsDataService.updateTongyiConvertibleBondsToTempTable();
            log.info("定向可转债 更新");
            tongyiDirectionalConvertibleBondsService.updateDirectionalConvertibleBondsToTempTable();
            log.info("可交债 更新");
            tongyiCeliverableBondDataService.updateTongyiCeliverableToTempTable();
    }
}
