package com.qmth.qrzk.supplypaper.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.qmth.qrzk.repository.common.enumeration.PaperFormat;

/**
 * 各省份打印项目（课程）信息
 * @author zhengmin
 *
 */
@Entity
@Table(name="qr_print_prov_task_item")
public class PrintProvTaskItem {

	public static final int PAPER_FORMAT_MERGE = 0;
	public static final int PAPER_FORMAT_SEPARATE = 1;
	public static final int PAPER_FORMAT_ALL = 2;
		
	@Id
	@GeneratedValue
	private Long id;
	
	@Column(name="task_id")
	private Long taskId;
	
	@Column(name="batch_id")
	private Integer batchId;
	
	@Column(name="course_code",length=10)
	private String courseCode;
	
	@Column(name="course_name",length=50)
	private String courseName;
	
	@Column(name="paper_format")
	private int paperFormat;
	
	@Column(name="paper_id")
	private Long paperId;
	
	@Column(name="blank_count")
	private int blankCount;
	
	@Column(name="blank_printed_count")
	private int blankPrintedCount;
	
	@Column(name="acid_count")
	private int acidCount;
	
	@Column(name="acid_printed_count")
	private int acidPrintedCount;
	
	@Column(name="answer_count")
	private int answerCount;
	
	@Column(name="paper_printed_count")
	private int paperPrintedCount;
	
	@Column(name="answer_printed_count")
	private int answerPrintedCount;
	
	@Column(name="is_paper_scanned")
	private Boolean isPaperScanned;
	
	@Column(name="is_answer_scanned")
	private Boolean isAnswerScanned;
	
	@Transient
	private String paperFormatLabel;
	
	@Transient
	private boolean complete;
	
	@Transient
	private boolean paperPrintComplete;
	
	@Transient
	private boolean answerPrintComplete;
	
	@Transient
	private String printSortNo;//客户端排序
	
	@Transient
	private boolean shouldPrintPaper;
	
	public String getPrintSortNo() {
		return printSortNo;
	}

	public void setPrintSortNo(String printSortNo) {
		this.printSortNo = printSortNo;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCourseCode() {
		return courseCode;
	}

	public void setCourseCode(String courseCode) {
		this.courseCode = courseCode;
	}

	public String getCourseName() {
		return courseName;
	}

	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}

	public boolean isComplete() {
		if(this.blankPrintedCount >= this.blankCount && this.acidPrintedCount >= this.acidCount 
				&& this.answerPrintedCount >= this.answerCount){
			complete = true;
		}
		else{
			complete = false;
		}
		return complete;
	}
	
	public boolean isPaperPrintComplete() {
		if(this.blankPrintedCount >= this.blankCount && this.acidPrintedCount >= this.acidCount){
			paperPrintComplete = true;
		}
		else{
			paperPrintComplete = false;
		}
		return paperPrintComplete;
	}

	public boolean isAnswerPrintComplete() {
		if(this.answerPrintedCount >= this.answerCount){
			answerPrintComplete = true;
		}
		else{
			answerPrintComplete = false;
		}
		return answerPrintComplete;
	}
	
	public void setComplete(boolean complete) {
		this.complete = complete;
	}

	
	public int getPaperFormat() {
		return paperFormat;
	}

	public void setPaperFormat(int paperFormat) {
		this.paperFormat = paperFormat;
	}

	public String getPaperFormatLabel() {
		paperFormatLabel = null;
		switch(paperFormat){
		case 0:
				paperFormatLabel = PaperFormat.MERGE.getValue();
			break;
		case 1:
				paperFormatLabel = PaperFormat.SEPERATE.getValue();
			break;
		case 2:
				paperFormatLabel = "合卷网评卷各一份";//2016-01-20 张璇要求把“分卷”改成“网评卷”
		}
		return paperFormatLabel;
	}

	public int getBlankCount() {
		return blankCount;
	}

	public void setBlankCount(int blankCount) {
		this.blankCount = blankCount;
	}

	public int getAcidCount() {
		return acidCount;
	}

	public void setAcidCount(int acidCount) {
		this.acidCount = acidCount;
	}

	public void setPaperFormatLabel(String paperFormatLabel) {
		this.paperFormatLabel = paperFormatLabel;
	}
	
	public Long getTaskId() {
		return taskId;
	}

	public void setTaskId(Long taskId) {
		this.taskId = taskId;
	}

	
	public int getAnswerCount() {
		return answerCount;
	}

	public void setAnswerCount(int answerCount) {
		this.answerCount = answerCount;
	}

	public int getPaperPrintedCount() {
		return paperPrintedCount;
	}

	public void setPaperPrintedCount(int paperPrintedCount) {
		this.paperPrintedCount = paperPrintedCount;
	}

	public int getAnswerPrintedCount() {
		return answerPrintedCount;
	}

	public void setAnswerPrintedCount(int answerPrintedCount) {
		this.answerPrintedCount = answerPrintedCount;
	}

	public int getBlankPrintedCount() {
		return blankPrintedCount;
	}

	public void setBlankPrintedCount(int blankPrintedCount) {
		this.blankPrintedCount = blankPrintedCount;
	}

	public int getAcidPrintedCount() {
		return acidPrintedCount;
	}

	public void setAcidPrintedCount(int acidPrintedCount) {
		this.acidPrintedCount = acidPrintedCount;
	}
	

	public Integer getBatchId() {
		return batchId;
	}

	public void setBatchId(Integer batchId) {
		this.batchId = batchId;
	}
	

	public Long getPaperId() {
		return paperId;
	}

	public void setPaperId(Long paperId) {
		this.paperId = paperId;
	}

	public PrintProvTaskItem(int batchId,String courseCode, String courseName,
			int paperFormat, Long paperId,int blankCount, int acidCount) {
		super();
		this.courseCode = courseCode;
		this.batchId = batchId;
		this.courseName = courseName;
		this.paperFormat = paperFormat;
		this.paperId = paperId;
		this.blankCount = blankCount;
		this.acidCount = acidCount;
		this.blankPrintedCount = 0;
		this.acidPrintedCount = 0;
		this.paperPrintedCount = 0;
	}

	public PrintProvTaskItem() {
		super();
		this.blankPrintedCount = 0;
		this.acidPrintedCount = 0;
		this.paperPrintedCount = 0;
	}

	public Boolean getIsPaperScanned() {
		return isPaperScanned;
	}

	public void setIsPaperScanned(Boolean isPaperScanned) {
		this.isPaperScanned = isPaperScanned;
	}

	public Boolean getIsAnswerScanned() {
		return isAnswerScanned;
	}

	public void setIsAnswerScanned(Boolean isAnswerScanned) {
		this.isAnswerScanned = isAnswerScanned;
	}
	
	public boolean isShouldPrintPaper(){
		return this.blankCount + this.acidCount > 0;
	}
}
