package com.ruoyi.report.vo;

import java.util.Comparator;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.constant.PatentType;

import lombok.Data;


@Data
public class ClassStatisticsInfoVo implements Comparator<ClassStatisticsInfoVo> {
	
	public ClassStatisticsInfoVo() {
		this.higherSchool=0L;
		this.researchInstitute=0L;
		this.enterprise=0L;
		this.institutions=0L;
		this.individual=0L;
		this.totalCnt=0L;
	}
	
	@Override
	public int compare(ClassStatisticsInfoVo o1, ClassStatisticsInfoVo o2) {
		if(o1==null && o2==null) {
			return 0;
		}else if(o1==null) {
			return -1;
		}else if(o2==null) {
			return 1;
		}
		
		
		if("非本区划".equals(o1.getAreaName()) && "非本区划".equals(o2.getAreaName())) {
			int res=compareByPt(o1,o2);
			if(res!=0) {
				return res;
			}else {
				return (int)(o2.getTotalCnt()-o1.getTotalCnt());
			}
		}else if("非本区划".equals(o1.getAreaName())){
			return -1;
		}else if("非本区划".equals(o2.getAreaName())){
			return 1;
		}else {
			int res=compareByPt(o1,o2);
			if(res!=0) {
				return res;
			}
			return (int)(o2.getTotalCnt()-o1.getTotalCnt());
		}
		

	}
	
	public int compareByPt(ClassStatisticsInfoVo o1, ClassStatisticsInfoVo o2) {
		if (o1 == null && o2 == null) {
			return 0;
		} else {
			if (o1 == null) {
				return -1;
			} else if (o2 == null) {
				return 1;
			} else {
				PatentType tp1 = PatentType.valueOfByName(o1.getPatentType());
				PatentType tp2 = PatentType.valueOfByName(o2.getPatentType());
				if (tp1 == null && tp2 == null) {
					return 0;
				} else if (tp1 == null) {
					return -1;
				} else if (tp2 == null) {
					return 1;
				} else {
					return Integer.parseInt(tp1.getTypeId()) - Integer.parseInt(tp2.getTypeId());
				}
			}
		}
	}

	private String areaCode;
	private String areaName;
	private String patentType;
	/** 年份 */
	@Excel(name = "年份")
	private String year;

	/** 月份 */
	@Excel(name = "月份")
	private String month;
	
	
	
	/** 大专院校 */
	@Excel(name = "大专院校")
	private Long higherSchool;

	/** 科研机构 */
	@Excel(name = "科研机构")
	private Long researchInstitute;

	/** 企业 */
	@Excel(name = "企业")
	private Long enterprise;

	/** 事业单位 */
	@Excel(name = "机关团体")
	private Long institutions;

	/** 个人 */
	@Excel(name = "个人")
	private Long individual;

	/** 合计 */
	@Excel(name = "合计")
	private Long totalCnt;

	
	
	
	

}
