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


import com.ssj.service.sys.situation.bo.DimesionCount;
import com.ssj.service.sys.situation.service.KnowledgeSituation;

import java.util.ArrayList;
import java.util.List;


public class ProxySituation extends AbstractKnowledgeSituation {
    private String studentId;
    private String courseName;
    /**
     * 知识维度数量列表
     */
    private List<DimesionCount> knowList = new ArrayList<>();
    /**
     * 技能维度数量列表
     */
    private List<DimesionCount> skillList = new ArrayList<>();
    /**
     * 理解类错题数量
     */
    private int understandWrongCount = 0;
    /**
     * 理解类总数量
     */
    private int understandTotalCount = 0;
    /**
     * 记忆类错题数量
     */
    private int memoryWrongCount = 0;
    /**
     * 记忆类总数量
     */
    private int memoryTotalCount = 0;
    /**
     * 应用类错题数量
     */
    private int applyWrongCount = 0;
    /**
     * 应用类总数量
     */
    private int applyTotalCount = 0;

    private KnowledgeSituation homework;
    private KnowledgeSituation homeworkKnowHow;
    private KnowledgeSituation one2one;

    public ProxySituation (String studentId, String courseName, KnowledgeSituation homework, KnowledgeSituation homeworkKnowHow,  KnowledgeSituation one2one){
        this.studentId = studentId;
        this.courseName = courseName;
        this.homework = homework;
        this.homeworkKnowHow = homeworkKnowHow;
        this.one2one = one2one;
        this.getCalculate();
    }


    @Override
    public void getKnowDimensionCount() {
        List<DimesionCount> temp = new ArrayList<>();
        temp = ((HomeworkSituation) homework).getKnowList();
        this.appendKnowDimesionCount(temp);
        temp = ((HomeworkKnowHowSituation) homeworkKnowHow).getKnowList();
        this.appendKnowDimesionCount(temp);
    }

    /**
     * 往知识维度列表添加数据
     * @param temp
     */
    private void appendKnowDimesionCount (List<DimesionCount> temp) {
        if (temp != null){
            for (DimesionCount dc : temp){
                boolean isExist = false;
                for (DimesionCount know : this.knowList){
                    if (know.getName().equals(dc.getName())){
                        know.setWrongCount(know.getWrongCount() + dc.getWrongCount());
                        know.setTotalCount(know.getTotalCount() + dc.getTotalCount());
                        isExist = true;
                    }
                }
                if (!isExist){
                    this.knowList.add(dc);
                }
            }
        }
    }

    @Override
    public void getSkillDimensionCount() {
//        this.skillList = ((One2OneSituation)one2one).getSkillList();
    }

    @Override
    public void getKnowledgeCount() {
        //作业（选对错题）
        this.understandWrongCount += ((HomeworkSituation)homework).getUnderstandWrongCount();
        this.understandTotalCount += ((HomeworkSituation)homework).getUnderstandTotalCount();
        this.memoryWrongCount += ((HomeworkSituation)homework).getMemoryWrongCount();
        this.memoryTotalCount += ((HomeworkSituation)homework).getMemoryTotalCount();
        this.applyWrongCount += ((HomeworkSituation)homework).getApplyWrongCount();
        this.applyTotalCount += ((HomeworkSituation)homework).getApplyTotalCount();

        //作业（选知识点）
        this.understandWrongCount += ((HomeworkKnowHowSituation)homeworkKnowHow).getUnderstandWrongCount();
        this.understandTotalCount += ((HomeworkKnowHowSituation)homeworkKnowHow).getUnderstandTotalCount();
        this.memoryWrongCount += ((HomeworkKnowHowSituation)homeworkKnowHow).getMemoryWrongCount();
        this.memoryTotalCount += ((HomeworkKnowHowSituation)homeworkKnowHow).getMemoryTotalCount();
        this.applyWrongCount += ((HomeworkKnowHowSituation)homeworkKnowHow).getApplyWrongCount();
        this.applyTotalCount += ((HomeworkKnowHowSituation)homeworkKnowHow).getApplyTotalCount();
    }

    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;
    }
}
