package com.qmth.jkserver.dto;

import java.util.Comparator;

import org.apache.commons.lang3.StringUtils;

import com.qmth.jkserver.core.exception.JkServerException;
import com.qmth.jkserver.model.ExamStudentAnswer;

/**
 * OW 导出时 考生客观题答案排序
 * @author tianjun
 *
 */
public class ExamStudentAnswerSorter implements Comparator<ExamStudentAnswer>{

	@Override
	public int compare(ExamStudentAnswer o1, ExamStudentAnswer o2) {
		if(o1.getPaperId() == null || o2.getPaperId() == null ){
			System.out.println("2222");
		}
		if(o1.getPaperId().compareTo(o2.getPaperId()) < 0){
			return -1;
		}
		else if(o1.getPaperId().compareTo(o2.getPaperId())  > 0) {
			return 1;
		}
		else{
			if(StringUtils.isEmpty(o1.getTicketNo()) || StringUtils.isEmpty(o2.getTicketNo())){
				return 0;
			}
			else{
				if(o1.getTicketNo().compareTo(o2.getTicketNo()) < 0){
					return -1;
				}
				else if(o1.getTicketNo().compareTo(o2.getTicketNo()) > 0){
					return 1;
				}
				else{
					return 0;
				}
			}
		}
	}

}
