package com.tofly.ghrq_route.module.plan.domain;

import com.google.gson.annotations.SerializedName;
import com.tofly.ghrq_route.common.util.app.AppUtil;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.Unique;

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

/**
 * Created by Amu on 2017/3/18.
 */
@Entity(nameInDb = "DB_OFFLINE_PLAN")
@SuppressWarnings("serial")
public class PlanBean implements Serializable {
    /**
     "delFlag":"1",
     "id":8,
     "mainPlanId":8,
     "childNum":1,
     "childBeginDate":"2020-05-25 00:00:00",
     "childEndDate":"2020-05-31 23:59:59",
     "periodId":1,
     "preiodName":"自定义时间",
     "deviceTypeId":7,
     "deviceTypeName":"节点",
     "percent":null,
     "lastTime":"2020-05-18 14:42:04",
     "userId":41,
     "userIdName":"穆国庆",
     "companyid":3,
     "deptName":"研发管理部",
     "regionId":43,
     "regionName":"123",
     "childPlanState":"1",
     "chilePlanStateName":"未开始",
     "isovertototal":null,
     "percent1":null,
     "createUser":20,
     "createUserName":"梁罗",
     "description":"管线点测试1",
     "createTime":"2020-05-18 14:42:04"
     */
/*    public static final int PLAN_STATE_OFF = 3;
    public static final int PLAN_STATE_OVER = 4;
    public static final int PLAN_STATE_TRANSFERING = 5;
    public static final int PLAN_STATE_TRANSFERED = 7;*/

    public static final int PLAN_STATE_VALID = 0;
    public static final int PLAN_STATE_NOT_VALID = 1;

    public static final int PLAN_STATE_NOT_CHECKED = 0;
    public static final int PLAN_STATE_CHECKED = 1;

    public static final String PLAN_BEAN_KEY = "plan_bean";

    public static class PlanPeriodType {
        public static final int PLAN_PERIOD_ONE_DAY = 1;
        public static final int PLAN_PERIOD_TWO_DAY = 2;
        public static final int PLAN_PERIOD_ONE_WEEK = 3;
        public static final int PLAN_PERIOD_HALF_MONTH = 4;
        public static final int PLAN_PERIOD_ONE_MONTH = 5;
        public static final int PLAN_PERIOD_TWO_MONTH_TYX = 6;      //调压箱
        public static final int PLAN_PERIOD_HALF_YEAR_TYX = 7;      //调压箱
        public static final int PLAN_PERIOD_ONE_MONTH_TYG = 8;      //调压柜
        public static final int PLAN_PERIOD_HALF_YEAR_TYG = 9;      //调压柜
        public static final int PLAN_PERIOD_TWO_YEAR_TYG = 10;      //调压柜
    }

    public static final int SELECT_STATE_UNSTARTED = 1;
    public static final int SELECT_STATE_ING = 2;
    public static final int SELECT_STATE_TODAY = 3;
    public static final int SELECT_STATE_ALL = 8;

    public static class PlAN_STATE_TYPE{
        public static final int PLAN_STATE_UNSTARTED = 1;
        public static final int PLAN_STATE_ING = 2;
        public static final int PLAN_STATE_OVER = 3;
        public static final int PLAN_STATE_OVER_TIME = 4;
        public static final int PLAN_STATE_UNSTARTED_TRANSFER_APPLY = 5;
        public static final int PLAN_STATE_ING_TRANSFER_APPLY = 6;
        public static final int PLAN_STATE_TRANSFERED = 7;
        public static final int PLAN_STATE_DESTROYED = 8;
        public static final int PLAN_STATE_CANCELED = 9;
        public static final int PLAN_STATE_NEXT_APPOINT = 10;
    }

    @Id @NotNull @Unique
    @SerializedName(value = "id")
    private String plan_id;
    @SerializedName(value = "childPlanState")
    private int plan_state;     //巡检状态 1：未开始，2：正在执行 3：已结束 4：超时未完成  5：申请转移(未开始) 6：申请转移(正在执行)7：计划已转移 8:作废 9:计划取消 10：计划顺延
    private String plan_overdate; //到位时间
    @SerializedName(value = "childBeginDate")
    private String plan_begindate;
    @SerializedName(value = "childEndDate")
    private String plan_enddate;
    @SerializedName(value = "createTime")
    private String create_time;
    private String download_time;
    private String percent = "";     //到位情况
    private String percent1 = "";    //从服务器上获取的完成率
    private String percent2 = "";   //本地自己计算的完成率
    @SerializedName(value = "description")
    private String plan_name;
    @SerializedName(value = "regionId")
    private String region_id;
    @SerializedName(value = "regionName")
    private String region_name;
    @SerializedName(value = "periodId")
    private String period_id;
    @SerializedName(value = "preiodName")
    private String period_name;
    @SerializedName(value = "userId")
    private String user_id;
    @SerializedName(value = "userIdName")
    private String user_name;   //上传者
    private int isvalid;        //是否有效 0：作废 1：有效[选填]
    //private int check_state;  //是否审核 0：未审核 1：已审核[选填]
    private int type;       //0是點，1是线
    @SerializedName(value = "planMode")
    private int plan_mode;  //巡检类型 0：人巡 1：车巡
    @SerializedName(value = "pointNum")
    private int point_num;  //当前计划下的任务点的个数
    private double total;   //工作总量(管线->长度， 设备->个数)
    private double total1;
    private String isovertototal;
    private String isovertototal1;
    @SerializedName(value = "chilePlanStateName")
    private String plan_process_name;
    @SerializedName(value = "isNeedOperate", alternate = "isneedoperate")
    private int isNeedOperate; //是否可以录入的计划
    private int isUpload = 0;  //是否上传：0是未上传，1是已上传
    private String pointInfo;  //计划的点的经纬度信息
    private String checkContent;  // 0: 一般计划 1：调压计划 空:非录入设备计划
    private double tolerance;     //到位容差

    public static class PlanDeviceType {
        public static final int PLAN_DEVICE_TYPE_XJD = 1;
        public static final int PLAN_DEVICE_TYPE_LG = 2;
        public static final int PLAN_DEVICE_TYPE_GYGX = 3;
        //public static final int PLAN_DEVICE_TYPE_TYX = 2;
        //public static final int PLAN_DEVICE_TYPE_TYG = 3;
        public static final int PLAN_DEVICE_TYPE_FAMEN = 4;
        public static final int PLAN_DEVICE_TYPE_YHXJ = 5;
        public static final int PLAN_DEVICE_TYPE_XJX = 6;
        public static final int PLAN_DEVICE_TYPE_JD = 7;
        public static final int PLAN_DEVICE_TYPE_TYG = 8;
        public static final int PLAN_DEVICE_TYPE_CGYGX = 9;
        public static final int PLAN_DEVICE_TYPE_ZYGX = 10;
        public static final int PLAN_DEVICE_TYPE_DYGX = 11;
        public static final int PLAN_DEVICE_TYPE_CGYGX_CAR = 13;
        public static final int PLAN_DEVICE_TYPE_ZYGX_CAR = 14;
        public static final int PLAN_DEVICE_TYPE_UNKONW = 15;
        public static final int PLAN_DEVICE_TYPE_CSZ= 16;
        public static final int PLAN_DEVICE_TYPE_YSG = 17;
        public static final int PLAN_DEVICE_TYPE_GYGX_CAR = 18;
        public static final int PLAN_DEVICE_TYPE_YHZG = 19;
        public static final int PLAN_DEVICE_TYPE_TYX = 20;
        public static final int PLAN_DEVICE_TYPE_FASHI = 21;
        public static final int PLAN_DEVICE_TYPE_YBZ = 22;
    }

    @SerializedName(value = "deviceTypeId")
    private int device_type_id;
    @SerializedName(value = "deviceTypeName")
    private String device_type_name;

    /*申请计划重算时计划的状态 0:已申请 1：计算中 2：计算完成*/
    public static final int PLAN_CALCULATE_APPLYED = 0;
    public static final int PLAN_CALCULATE_ING = 1;
    public static final int PLAN_CALCULATE_FINISHED = 2;
    public static final int PLAN_CALCULATE_UPDATED = 3;
    public static final int PLAN_CALCULATE_UNAPPLYED = 4;

    private int state;  //计划重算的时候需要使用该状态

    @Generated(hash = 341186539)
    public PlanBean(@NotNull String plan_id, int plan_state, String plan_overdate, String plan_begindate,
            String plan_enddate, String create_time, String download_time, String percent, String percent1, String percent2,
            String plan_name, String region_id, String region_name, String period_id, String period_name, String user_id,
            String user_name, int isvalid, int type, int plan_mode, int point_num, double total, double total1,
            String isovertototal, String isovertototal1, String plan_process_name, int isNeedOperate, int isUpload,
            String pointInfo, String checkContent, double tolerance, int device_type_id, String device_type_name,
            int state) {
        this.plan_id = plan_id;
        this.plan_state = plan_state;
        this.plan_overdate = plan_overdate;
        this.plan_begindate = plan_begindate;
        this.plan_enddate = plan_enddate;
        this.create_time = create_time;
        this.download_time = download_time;
        this.percent = percent;
        this.percent1 = percent1;
        this.percent2 = percent2;
        this.plan_name = plan_name;
        this.region_id = region_id;
        this.region_name = region_name;
        this.period_id = period_id;
        this.period_name = period_name;
        this.user_id = user_id;
        this.user_name = user_name;
        this.isvalid = isvalid;
        this.type = type;
        this.plan_mode = plan_mode;
        this.point_num = point_num;
        this.total = total;
        this.total1 = total1;
        this.isovertototal = isovertototal;
        this.isovertototal1 = isovertototal1;
        this.plan_process_name = plan_process_name;
        this.isNeedOperate = isNeedOperate;
        this.isUpload = isUpload;
        this.pointInfo = pointInfo;
        this.checkContent = checkContent;
        this.tolerance = tolerance;
        this.device_type_id = device_type_id;
        this.device_type_name = device_type_name;
        this.state = state;
    }

    @Generated(hash = 1985632014)
    public PlanBean() {

    }

    public String getPlan_id() {
        return plan_id;
    }

    public void setPlan_id(String plan_id) {
        this.plan_id = plan_id;
    }

    public String getRegion_id() {
        return region_id;
    }

    public void setRegion_id(String region_id) {
        this.region_id = region_id;
    }

    public String getUser_id() {
        return user_id;
    }

    public void setUser_id(String user_id) {
        this.user_id = user_id;
    }

    public String getPeriod_id() {
        return period_id;
    }

    public void setPeriod_id(String period_id) {
        this.period_id = period_id;
    }

    public int getPlan_state() {
        return plan_state;
    }

    public void setPlan_state(int plan_state) {
        this.plan_state = plan_state;
    }

    public String getPlan_begindate() {
        return plan_begindate;
    }

    public void setPlan_begindate(String plan_begindate) {
        this.plan_begindate = plan_begindate;
    }

    public String getPlan_enddate() {
        return plan_enddate;
    }

    public void setPlan_enddate(String plan_enddate) {
        this.plan_enddate = plan_enddate;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getPercent() {
        return percent;
    }

    public void setPercent(String percent) {
        this.percent = percent;
    }

    public String getPercent1() {
        return percent1;
    }

    public void setPercent1(String percent1) {
        this.percent1 = percent1;
    }

    public int getIsvalid() {
        return isvalid;
    }

    public void setIsvalid(int isvalid) {
        this.isvalid = isvalid;
    }

    public String getPlan_name() {
        return plan_name;
    }

    public void setPlan_name(String plan_name) {
        this.plan_name = plan_name;
    }

    public String getRegion_name() {
        return region_name;
    }

    public void setRegion_name(String region_name) {
        this.region_name = region_name;
    }

    public String getPeriod_name() {
        return period_name;
    }

    public void setPeriod_name(String period_name) {
        this.period_name = period_name;
    }

    public int getDevice_type_id() {
        return device_type_id;
    }

    public void setDevice_type_id(int device_type_id) {
        this.device_type_id = device_type_id;
    }

    public String getDevice_type_name() {
        return device_type_name;
    }

    public void setDevice_type_name(String device_type_name) {
        this.device_type_name = device_type_name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getPlan_mode() {
        return plan_mode;
    }

    public void setPlan_mode(int plan_mode) {
        this.plan_mode = plan_mode;
    }

    public int getPoint_num() {
        return point_num;
    }

    public void setPoint_num(int point_num) {
        this.point_num = point_num;
    }

    public int isNeedOperate() {
        return isNeedOperate;
    }

    public void setNeedOperate(int needOperate) {
        isNeedOperate = needOperate;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public boolean isDeviceType(){
        return checkContent != null;
    }

    public static List<Integer> getDeviceTypes(){
        List<Integer> deviceTypes = new ArrayList<>();
        deviceTypes.add(PlanDeviceType.PLAN_DEVICE_TYPE_FAMEN);
        deviceTypes.add(PlanDeviceType.PLAN_DEVICE_TYPE_TYG);
        deviceTypes.add(PlanDeviceType.PLAN_DEVICE_TYPE_CSZ);
        return deviceTypes;
    }

    public boolean isLineType() {
        return type == 1;
    }

    public boolean isCommonDeviceType() {
        return checkContent != null && checkContent.equals("0");
    }

    public boolean isAdjustDeviceType() {
        return checkContent != null && checkContent.equals("1");
    }

    public boolean isDangerDeviceType() {
        return device_type_id == PlanDeviceType.PLAN_DEVICE_TYPE_YHXJ
                || device_type_id == PlanDeviceType.PLAN_DEVICE_TYPE_YHZG;

    }

    public boolean isNotOperateDeviceType(){
        return (device_type_id == PlanBean.PlanDeviceType.PLAN_DEVICE_TYPE_XJD ||
                type == OfflinePathBean.PATH_TYPE_LINE);
    }

    public int getIsNeedOperate() {
        return this.isNeedOperate;
    }

    public void setIsNeedOperate(int isNeedOperate) {
        this.isNeedOperate = isNeedOperate;
    }

    public int getIsUpload() {
        return this.isUpload;
    }

    public void setIsUpload(int isUpload) {
        this.isUpload = isUpload;
    }

    public String getUser_name() {
        return this.user_name;
    }

    public void setUser_name(String user_name) {
        this.user_name = user_name;
    }

    public String getPlan_process_name() {
        return this.plan_process_name;
    }

    public void setPlan_process_name(String plan_process_name) {
        this.plan_process_name = plan_process_name;
    }

    public String getPlan_overdate() {
        return this.plan_overdate;
    }

    public void setPlan_overdate(String plan_overdate) {
        this.plan_overdate = plan_overdate;
    }

    public boolean isOutOfDate(){
        return AppUtil.isOutOfDate(plan_begindate, plan_enddate);
    }

    public String getDownload_time() {
        return this.download_time;
    }

    public void setDownload_time(String download_time) {
        this.download_time = download_time;
    }

    public String getPercent2() {
        return this.percent2;
    }

    public void setPercent2(String percent2) {
        this.percent2 = percent2;
    }

    public String getPointInfo() {
        return this.pointInfo;
    }

    public void setPointInfo(String pointInfo) {
        this.pointInfo = pointInfo;
    }

    public String getCheckContent() {
        return this.checkContent;
    }

    public void setCheckContent(String checkContent) {
        this.checkContent = checkContent;
    }

    public double getTolerance() {
        return tolerance;
    }

    public void setTolerance(double tolerance) {
        this.tolerance = tolerance;
    }

    public double getTotal() {
        return this.total;
    }

    public void setTotal(double total) {
        this.total = total;
    }

    public double getTotal1() {
        return this.total1;
    }

    public void setTotal1(double total1) {
        this.total1 = total1;
    }

    public String getIsovertototal() {
        return this.isovertototal;
    }

    public void setIsovertototal(String isovertototal) {
        this.isovertototal = isovertototal;
    }

    public String getIsovertototal1() {
        return this.isovertototal1;
    }

    public void setIsovertototal1(String isovertototal1) {
        this.isovertototal1 = isovertototal1;
    }
}
