package com.ssj.service.task;

import com.ssj.bean.sys.homework.domain.KnowledgeProficiency;
import com.ssj.framework.core.persistence.PagingHibernateJdbcDao;
import com.ssj.framework.core.util.SystemResourceLocator;
import com.ssj.service.sys.situation.service.LearningConditionService;
import com.ssj.taskthread.Task;

import java.util.List;

public class SyncGenerateKnowledgeProficiencyTask extends Task {

    private String vipId;

    public SyncGenerateKnowledgeProficiencyTask(String vipId) {
        super();
        this.vipId = vipId;
    }

    @Override
    public void run() {
        try {


            logger.info("生成知识点熟练度数据处理任务开始，vipId={}", vipId);
            LearningConditionService learningConditionService = SystemResourceLocator.getBean(LearningConditionService.class);
            PagingHibernateJdbcDao pagingHibernateJdbcDao = SystemResourceLocator.getBean(PagingHibernateJdbcDao.class);
            List<KnowledgeProficiency> knowledgeProficiencyList =
                    learningConditionService.getKnowledgeProficiencyList(vipId, 0, "");
            if (!knowledgeProficiencyList.isEmpty()) {
                pagingHibernateJdbcDao.batchUpdate(knowledgeProficiencyList);
            }
            logger.info("生成知识点熟练度数据处理任务结束，vipId={}", vipId);
        } catch (Exception e) {
            logger.error("生成知识点熟练度数据异常", e);
        }
    }


}
