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


import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyExplore;
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyExploreService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
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
@Slf4j
public class ExploreReportJob {

    @Autowired
    private IKuaishouReportDailyExploreService exploreService;

    static ExecutorService executorService = Executors.newFixedThreadPool(5);

    /**
     * 快手全量计划物料数据
     */
    @XxlJob("groupExploreReportJob")
    public void execute() {
        List<KuaishouReportDailyExplore> list = exploreService.getUnitListByStudyStatus();
        list.forEach(group -> executorService.submit(() ->
                exploreService.getExploreUnitReports(group.getAccountId(), group.getUnitId())
        ));
        XxlJobHelper.log("获取广告组加速探索报表信息");
    }

}
