package com.xintong.visualinspection.bean;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.xintong.visualinspection.util.CustomJsonDateDeserializer;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 文件名：Job
 * 版本信息：日期：2017/4/18 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
 */
@Data
public class FwqStatisticsBean implements Serializable {
    //编号
    private Integer id;

    // 父部门id
    private Long parent_dept_id;

    // 部门id
    private Long dept_id;

    //开始日期
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = CustomJsonDateDeserializer.class)
    private Date start_date;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = CustomJsonDateDeserializer.class)
    private Date end_date;


    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = CustomJsonDateDeserializer.class)
    private Date update_time;

    private Long task_id;

    private String name;

    private String parent_name;

    private int score;

    private Integer check_item_id;

    private Integer item_id;

    private int checked_num;

    private int checked_people_num;

//    private int people_num;

    private int score_fifteen;

    private int score_fifty;

    private int score_over_fifty;

    private int all_check_score;

    // 满分
    private int check_no_score;

    // 平均得分
    private String score_avg;

    // 平均人均扣分
    private float check_score_avg;

    private List<String> checked_socre_name = new ArrayList<String>();

    private List<Integer> checked_score = new ArrayList<Integer>();

    private List<Integer> seq_checked_score = new ArrayList<Integer>();

    private List<Organ> dept_list;
    private List<Integer> checked_score_ids = new ArrayList<Integer>();


    private String start_score;
    private String end_score;

    // 查询标记
    private Integer queryType;

    // 月份
    private String mth;

    // 上月
    private String prev_mth;

    // 收费站名称
    private String feeStationName;
    private String pfeeStationName;

    private User user;

    // 
    private Integer order_type;

    // 排名
    private Integer ranking;

    // 排名变化
    private Integer ranking_change;

    // 照片
    private String pics;

    // 稽查人员id
    private Integer checkman_id;

    private String checkman_name;

    // 被考核人的姓名
    private String checked_name;


    private String check_task_name;

    private String check_task_time_name;

    private List<Integer> position_ids;

    private Integer score_flag;

    // 其他稽查不同类型
    private Integer check_type;
    // 扣分合计
    private Integer check_total_score = 0;
    // 公司受检次数
    private Integer company_check_num = 0;
    // 公司扣分合计
    private Integer company_total_score= 0;
    // 第三方暗访受检次数
    private Integer third_check_num = 0;
    // 第三方暗访扣分合计
    private Integer third_total_score = 0;
    // 现场受检次数
    private Integer onsite_check_num = 0;
    // 现场扣分合计
    private Integer onsite_total_score = 0;

    // 其他
    private Integer other_check_num = 0;
    private Integer other_total_score = 0;

    // 总平均扣分
    private String check_total_avg = "0";
    // 公司排名
    private Integer company_ranking2;
    // 道管排名
    private Integer fee_station_ranking2;

    private Integer check_t_num = 0;

    private Integer check_t_score = 0;

    private Integer check_x_num = 0;

    private Integer check_x_score = 0;

    private Integer check_s_num = 0;

    private Integer check_s_score = 0;

    private Integer check_all_num = 0;

    private Integer check_all_score = 0;

    private Integer period_id = 0;

    // 比较大小 1 小 ， -1 大
    public int compareTo(FwqStatisticsBean o2) {
        if (this.getChecked_num() != 0 && o2.getChecked_num() != 0) {
            double a = this.getAll_check_score() / (this.getChecked_num() + 0.00) /*/ this.getPeople_num()*/;
            double b = o2.getAll_check_score() / (o2.getChecked_num() + 0.00) /*/ o2.getPeople_num()*/;
            if (a > b) {
                return 1;
            } else if (a < b) {
                return -1;
            } else {
                return 0;
            }
        } else {
            if (this.getChecked_num() == 0 && o2.getChecked_num() != 0) {
                return -1;
            } else if (o2.getChecked_num() == 0 && this.getChecked_num() != 0) {
                return 1;
            } else {
                return 0;
            }
        }
    }

    // 比较大小 1 小 ， -1 大 
    // 方法2
    public int compare2To(FwqStatisticsBean o2) {
        double a = -1, b = -1;
        if (this.getChecked_num() != 0) {
            a = this.getAll_check_score() / (this.getChecked_num() + 0.00);
        }
        if (o2.getChecked_num() != 0) {
            b = o2.getAll_check_score() / (o2.getChecked_num() + 0.00);
        }
        if (a > b) {
            return 1;
        } else if (a < b) {
            return -1;
        } else {
            return 0;
        }
    }

    //比较大小 1 小 ， -1 大 
    // 方法3
    public int compare3To(FwqStatisticsBean o2) {
        double a = -1, b = -1;
        if (Float.valueOf(this.getCheck_total_avg()) != 0) {
            a = Float.valueOf(this.getCheck_total_avg());
        }
        if (Float.valueOf(o2.getCheck_total_avg()) != 0) {
            b = Float.valueOf(o2.getCheck_total_avg());
        }
        if (a > b) {
            return 1;
        } else if (a < b) {
            return -1;
        } else {
            return 0;
        }
    }

    //比较大小 1 小 ， -1 大
    // 方法3
    public int compare4To(FwqStatisticsBean o2) {
        if (this.getId() > o2.getId()) {
            return 1;
        } else if (this.getId().equals(o2.getId())) {
            if (Float.valueOf(this.getCheck_total_avg()) != 0 && Float.valueOf(o2.getCheck_total_avg()) != 0) {
                if (Float.valueOf(this.getCheck_total_avg()) < Float.valueOf(o2.getCheck_total_avg())) {
                    return -1;
                } else if (Float.valueOf(this.getCheck_total_avg()) > Float.valueOf(o2.getCheck_total_avg())) {
                    return 1;
                } else {
                    return 0;
                }
            } else {
                if (Float.valueOf(this.getCheck_total_avg()) == 0) {
                    return -1;
                } else if (Float.valueOf(o2.getCheck_total_avg()) == 0) {
                    return 1;
                } else {
                    return 0;
                }
            }
        } else {
            return -1;
        }
    }

}
