package com.qmth.teachcloud.mark.dto.mark.manage;

import java.io.Serializable;

import com.qmth.teachcloud.common.contant.SystemConstant;
import com.qmth.teachcloud.mark.entity.*;
import com.qmth.teachcloud.mark.params.MarkHeaderGroupResult;

/**
 * 阅卷轨迹交换类
 *
 * @author luoshi
 */
public class TrackDTO implements Serializable {

    private static final long serialVersionUID = 4336042741848228793L;

    private Integer mainNumber;

    private String subNumber;

    private int number;

    private double score;

    private double positionX;

    private double positionY;

    private int offsetIndex;

    private int offsetX;

    private int offsetY;

    private boolean unanswered;

    public TrackDTO() {

    }

    public TrackDTO(MarkTrack track) {
        String questionNumber = track.getQuestionNumber();
        String str[] = questionNumber.split("\\.");
        setMainNumber(Integer.parseInt(str[0]));
        setSubNumber(str[1]);
        setNumber(track.getNumber());
        setScore(track.getScore());
        setPositionX(track.getPositionX());
        setPositionY(track.getPositionY());
        setOffsetIndex(track.getOffsetIndex());
        setOffsetX(track.getOffsetX());
        setOffsetY(track.getOffsetY());
    }

    public TrackDTO(MarkHeaderTrack track) {
        String questionNumber = track.getQuestionNumber();
        String str[] = questionNumber.split("\\.");
        setMainNumber(Integer.parseInt(str[0]));
        setSubNumber(str[1]);
        setNumber(track.getNumber());
        setScore(track.getScore());
        setPositionX(track.getPositionX());
        setPositionY(track.getPositionY());
        setOffsetIndex(track.getOffsetIndex());
        setOffsetX(track.getOffsetX());
        setOffsetY(track.getOffsetY());
    }

    public MarkTrack transform(MarkTask markTask, Long userId) {
        MarkTrack track = new MarkTrack();
        track.setId(SystemConstant.getDbUuid());
        track.setTaskId(markTask.getId());
        track.setQuestionNumber(getMainNumber() + "." + getSubNumber());
        track.setNumber(getNumber());
        track.setStudentId(markTask.getStudentId());
        track.setExamId(markTask.getExamId());
        track.setPaperNumber(markTask.getPaperNumber());
        track.setGroupNumber(markTask.getGroupNumber());
        track.setUserId(userId);
        track.setScore(getScore());
        track.setPositionX(getPositionX());
        track.setPositionY(getPositionY());
        track.setOffsetIndex(getOffsetIndex());
        track.setOffsetX(getOffsetX());
        track.setOffsetY(getOffsetY());
        return track;
    }

    public MarkHeaderTrack transform(MarkArbitrateHistory history) {
        MarkHeaderTrack track = new MarkHeaderTrack();
        track.setQuestionNumber(getMainNumber() + "." + getSubNumber());
        track.setNumber(getNumber());
        track.setStudentId(history.getStudentId());
        track.setExamId(history.getExamId());
        track.setPaperNumber(history.getPaperNumber());
        track.setGroupNumber(history.getGroupNumber());
        track.setUserId(history.getUpdateUserId());
        track.setScore(getScore());
        track.setPositionX(getPositionX());
        track.setPositionY(getPositionY());
        track.setOffsetIndex(getOffsetIndex());
        track.setOffsetX(getOffsetX());
        track.setOffsetY(getOffsetY());
        return track;
    }

    public MarkHeaderTrack transform(MarkHeaderGroupResult markResult, MarkStudent markStudent, Long userId) {
        MarkHeaderTrack track = new MarkHeaderTrack();
        track.setStudentId(markResult.getStudentId());
        track.setQuestionNumber(getMainNumber() + "." + getSubNumber());
        track.setNumber(getNumber());
        track.setStudentId(markResult.getStudentId());
        track.setExamId(markStudent.getExamId());
        track.setPaperNumber(markStudent.getPaperNumber());
        track.setGroupNumber(markResult.getGroupNumber());
        track.setUserId(userId);
        track.setScore(getScore());
        track.setPositionX(getPositionX());
        track.setPositionY(getPositionY());
        track.setOffsetIndex(getOffsetIndex());
        track.setOffsetX(getOffsetX());
        track.setOffsetY(getOffsetY());
        return track;
    }

    public Integer getMainNumber() {
        return mainNumber;
    }

    public void setMainNumber(Integer mainNumber) {
        this.mainNumber = mainNumber;
    }

    public String getSubNumber() {
        return subNumber;
    }

    public void setSubNumber(String subNumber) {
        this.subNumber = subNumber;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public double getPositionX() {
        return positionX;
    }

    public void setPositionX(double positionX) {
        this.positionX = positionX;
    }

    public double getPositionY() {
        return positionY;
    }

    public void setPositionY(double positionY) {
        this.positionY = positionY;
    }

    public int getOffsetIndex() {
        return offsetIndex;
    }

    public void setOffsetIndex(int offsetIndex) {
        this.offsetIndex = offsetIndex;
    }

    public int getOffsetX() {
        return offsetX;
    }

    public void setOffsetX(int offsetX) {
        this.offsetX = offsetX;
    }

    public int getOffsetY() {
        return offsetY;
    }

    public void setOffsetY(int offsetY) {
        this.offsetY = offsetY;
    }

    public boolean isUnanswered() {
        return unanswered;
    }

    public void setUnanswered(boolean unanswered) {
        this.unanswered = unanswered;
    }

}
