package cn.com.ctop.job.kuaishou.handler;

import cn.com.ctop.common.module.utils.Check;
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCreativeService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Component
public class KuaiShouCleanMaterialJob {
    @Autowired
    private IKuaishouReportDailyCreativeService kuaiShouCleanMaterialReportService;
    static ExecutorService executorService = Executors.newFixedThreadPool(5);

    @XxlJob("kuaiShouCleanMaterial")
    public void execute() {
        List<String> signatureList = kuaiShouCleanMaterialReportService.getSignature();
        if (Check.isNull(signatureList)) {
            XxlJobHelper.log("素材数据获取为空");
            XxlJobHelper.handleFail();
            return ;
        }
        signatureList.forEach(signature-> executorService.submit(()-> kuaiShouCleanMaterialReportService.calculationReport(signature)));
        return ;
    }
}
