package com.qmth.teachcloud.mark.params;

import com.qmth.teachcloud.mark.dto.mark.SpecialTagDTO;
import com.qmth.teachcloud.mark.dto.mark.manage.TrackDTO;
import com.qmth.teachcloud.mark.entity.*;
import org.apache.commons.lang3.StringUtils;

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

/**
 * 标准评卷结果对象(管理员直接分打)
 */
public class MarkHeaderGroupResult {

    public static final String SPLIT = ",";

    private Integer groupNumber;

    /**
     * 考生编号
     */
    private Long studentId;

    /**
     * 总分
     */
    private List<MarkScoreList> markerScore;
    private double groupScore;

    /**
     * 分值列表
     */
    private Double[] scoreList;

    /**
     * 阅卷轨迹列表
     */
    private TrackDTO[] trackList;

    /**
     * 特殊标记列表
     */
    private SpecialTagDTO[] specialTagList;


    /**
     * 所花时间
     */
    private int spent;


    public Integer getGroupNumber() {
        return groupNumber;
    }

    public void setGroupNumber(Integer groupNumber) {
        this.groupNumber = groupNumber;
    }

    public List<MarkScoreList> getMarkerScore() {
        return markerScore;
    }

    public void setMarkerScore(List<MarkScoreList> markerScore) {
        this.markerScore = markerScore;
    }

    public double getGroupScore() {
        return groupScore;
    }

    public void setGroupScore(double groupScore) {
        this.groupScore = groupScore;
    }

    public String getScoreList() {
        List<Object> list = new ArrayList<Object>();
        for (int i = 0; i < scoreList.length; i++) {
            Double d = scoreList[i];
            if (d % 1 == 0) {
                list.add(d.intValue());
            } else {
                list.add(d);
            }
        }
        return StringUtils.join(list, SPLIT);
    }

    public void setScoreList(Double[] scoreList) {
        this.scoreList = scoreList;
    }

    public TrackDTO[] getTrackList() {
        return trackList;
    }

    public void setTrackList(TrackDTO[] trackList) {
        this.trackList = trackList;
    }

    public int getSpent() {
        return spent;
    }

    public void setSpent(int spent) {
        this.spent = spent;
    }

    public Long getStudentId() {
        return studentId;
    }

    public void setStudentId(Long studentId) {
        this.studentId = studentId;
    }

    public List<MarkHeaderTrack> getTrackList(MarkArbitrateHistory history) {
        List<MarkHeaderTrack> list = new LinkedList<>();
        if (trackList != null) {
            for (TrackDTO dto : trackList) {
                list.add(dto.transform(history));
            }
        }
        return list;
    }

    public List<MarkHeaderTrack> getTrackList(MarkHeaderGroupResult markResult, MarkStudent markStudent, Long userId) {
        List<MarkHeaderTrack> list = new LinkedList<>();
        if (trackList != null) {
            for (TrackDTO dto : trackList) {
                list.add(dto.transform(markResult, markStudent, userId));
            }
        }
        return list;
    }

    public List<MarkTrack> getTrackList(MarkTask markTask, Long userId) {
        List<MarkTrack> list = new LinkedList<>();
        if (trackList != null) {
            for (TrackDTO dto : trackList) {
                list.add(dto.transform(markTask, userId));
            }
        }
        return list;
    }

    public List<MarkHeaderTag> getHeaderTagList(MarkArbitrateHistory library) {
        List<MarkHeaderTag> list = new LinkedList<>();
        if (specialTagList != null) {
            for (SpecialTagDTO dto : specialTagList) {
                list.add(dto.transform(library));
            }
        }
        return list;
    }

    public List<MarkHeaderTag> getHeaderTagList(MarkHeaderGroupResult markResult, Long userId) {
        List<MarkHeaderTag> list = new LinkedList<>();
        if (specialTagList != null) {
            for (SpecialTagDTO dto : specialTagList) {
                list.add(dto.transform(markResult, userId));
            }
        }
        return list;
    }

}
