package com.ssj.service.sys.situation.service.impl;

import com.ssj.framework.basic.utils.StringUtils;
import com.ssj.framework.core.util.SystemResourceLocator;
import com.ssj.service.sys.situation.bo.DimesionCount;
import com.ssj.service.sys.situation.constant.SituationConstant;
import com.ssj.service.sys.situation.service.LearningSituationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

public class HomeworkKnowHowSituation extends AbstractKnowledgeSituation{
    private static Logger logger = LoggerFactory.getLogger(HomeworkSituation.class);


    public HomeworkKnowHowSituation (String studentId, String courseName){
        this.studentId = studentId;
        this.courseName = courseName;
        this.learningSituationService = (LearningSituationService) SystemResourceLocator.getBean("learningSituationServiceImpl");
        this.getCalculate();
    }


    @Override
    public void getKnowDimensionCount() {
        List<Map<String, Object>> wrongList = this.learningSituationService.getHomeworkKnowHowModuleData(this.studentId, this.courseName, SituationConstant.getBeginTime(),
                SituationConstant.getEndTime(), 1);
        //各维度总体数量
        List<Map<String, Object>> totalList = this.learningSituationService.getHomeworkKnowHowModuleData(this.studentId, this.courseName, SituationConstant.getBeginTime(),
                SituationConstant.getEndTime(), 2);
        super.findKnowDimensionCount(wrongList, totalList);

    }

    @Override
    public void getSkillDimensionCount() {

    }

    @Override
    public void getKnowledgeCount() {
        if (StringUtils.isNotEmpty(this.studentId)){
            List<Map<String, Object>> wrongList = learningSituationService.getHomeworkWrongKnowHowClassData(this.studentId, this.courseName,
                    SituationConstant.getBeginTime(), SituationConstant.getEndTime());
            List<Map<String, Object>> totalList = learningSituationService.getHomeworkAllKnowHowClassData(this.studentId, this.courseName,
                    SituationConstant.getBeginTime(), SituationConstant.getEndTime());
            Double temp = null;
            if (wrongList != null && wrongList.size() > 0){
                temp = (Double)wrongList.get(0).get("understanding");
                this.understandWrongCount = temp == null ? 0 : temp.intValue();
                temp = (Double)wrongList.get(0).get("memorize");
                this.memoryWrongCount = temp == null ? 0 : temp.intValue();
                temp = (Double)wrongList.get(0).get("apply");
                this.applyWrongCount = temp == null ? 0 : temp.intValue();
            }
            if (totalList != null && totalList.size() > 0){
                temp = (Double)totalList.get(0).get("understanding");
                this.understandTotalCount = temp == null ? 0 : temp.intValue();
                temp = (Double)totalList.get(0).get("memorize");
                this.memoryTotalCount = temp == null ? 0 : temp.intValue();
                temp = (Double)totalList.get(0).get("apply");
                this.applyTotalCount = temp == null ? 0 : temp.intValue();
            }
        }
    }


    public List<DimesionCount> getKnowList() {
        return knowList;
    }

    public void setKnowList(List<DimesionCount> knowList) {
        this.knowList = knowList;
    }

    public List<DimesionCount> getSkillList() {
        return skillList;
    }

    public void setSkillList(List<DimesionCount> skillList) {
        this.skillList = skillList;
    }

    public int getUnderstandWrongCount() {
        return understandWrongCount;
    }

    public void setUnderstandWrongCount(int understandWrongCount) {
        this.understandWrongCount = understandWrongCount;
    }

    public int getUnderstandTotalCount() {
        return understandTotalCount;
    }

    public void setUnderstandTotalCount(int understandTotalCount) {
        this.understandTotalCount = understandTotalCount;
    }

    public int getMemoryWrongCount() {
        return memoryWrongCount;
    }

    public void setMemoryWrongCount(int memoryWrongCount) {
        this.memoryWrongCount = memoryWrongCount;
    }

    public int getMemoryTotalCount() {
        return memoryTotalCount;
    }

    public void setMemoryTotalCount(int memoryTotalCount) {
        this.memoryTotalCount = memoryTotalCount;
    }

    public int getApplyWrongCount() {
        return applyWrongCount;
    }

    public void setApplyWrongCount(int applyWrongCount) {
        this.applyWrongCount = applyWrongCount;
    }

    public int getApplyTotalCount() {
        return applyTotalCount;
    }

    public void setApplyTotalCount(int applyTotalCount) {
        this.applyTotalCount = applyTotalCount;
    }
}
