package com.xjrsoft.module.job;

import cn.hutool.extra.spring.SpringUtil;
import com.xjrsoft.module.base.service.IBaseCourseSubjectService;
import com.xjrsoft.module.xycxedu.service.IExamSubjectScoreService;
import com.xjrsoft.module.xycxedu.service.IXycxeduExamListService;
import com.xjrsoft.module.xycxedu.util.DataUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author dzx
 * @date 2024/5/8
 */
@Component
@Slf4j
public class ExamScoreDataTask {

    @Autowired
    private IXycxeduExamListService examListService;

    @Autowired
    private IExamSubjectScoreService scoreService;

    @Autowired
    private IBaseCourseSubjectService courseService;
    @Scheduled(cron = "0 */15 * * * ?")
    public void RefreshConnectionPool() {
        String active = SpringUtil.getActiveProfile();
        if(!"prod".equals(active)){
            log.info("非正式环境，无法执行数据推送");
            //return;
        }
        doExecute();
    }

    void doExecute(){
        //同步考试计划数据
        DataUtil dataUtil = new DataUtil();
        dataUtil.examListData(examListService);

        //同步成绩
        dataUtil.studentScoreData(examListService, scoreService, courseService);
    }


}
