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

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Index;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Amu on 2017/7/28.
 */

@Entity(nameInDb = "DB_OFFLINE_PATH", indexes = {@Index(value = "temp_id DESC,  plan_id DESC", unique = true)})
@SuppressWarnings("serial")
public class OfflinePathBean implements Serializable {
    /**
     * id : 5F2F54459B684C619B2D97FAFD288B0C
     * temp_id : 90EDF71F81B64733A48CFF5759B2808B
     * point_id : PIPESECTIONLP-P487456
     * lat : 29.577655157
     * lng : 106.517685993
     * isover : 0
     */
    public static final int PATH_TYPE_POINT = 0;
    public static final int PATH_TYPE_LINE = 1;

    public static final int POINTLINE_NOT_OVER = 0;
    public static final int POINTLINE_IS_OVER = 1;

    public static final int POINT_STATE_UNFINISHED = 0;
    public static final int POINT_STATE_FINISHED = 1;

    public static final String PLAN_POINT_BEAN_KEY = "plan_point_bean";

    @Id(autoincrement = true)
    @Expose(serialize = false, deserialize = false)
    public Long id;
    @Expose @SerializedName(value = "tempId")
    private String temp_id;
    @Expose @SerializedName(value = "planChildId")
    private String plan_id;
    @SerializedName(value = "pathId")
    private String path_id;
    @Expose
    private int type;
    private double lat;
    private double lng;
    @Expose(serialize = false, deserialize = false)
    private String addr;
    @SerializedName(value = "order", alternate = "num")
    private int order;
    private int isover = 0;
    private int state = 0;   //0:未完成 1完成
    private int isupload = 0;
    private int ispast = 0;
    @Expose @SerializedName(value = "checkTime")
    private String check_time;
    private int isoffupload = 0;
    private String first_left_time;
    @Expose @SerializedName(value = "gpsSpeed")
    private String gps_speed;
    @SerializedName(value = "planMode")
    private int plan_mode;  //巡检类型 0：人巡 1：车巡
    @SerializedName(value = "childBeginDate")
    private String child_begin_date;
    @SerializedName(value = "childEndDate")
    private String child_end_date;
    @SerializedName(value = "userId")
    private String userid;
    private String rfid;
    @SerializedName(value = "pointId")
    private String point_id;
    @SerializedName(value = "troubleId")
    private String trouble_id;
    private String over_time;
    private String code;
    private String geometry;
    private String finish_time;
    private int pageindex;

    @Generated(hash = 1124227744)
    public OfflinePathBean(Long id, String temp_id, String plan_id, String path_id, int type, double lat,
            double lng, String addr, int order, int isover, int state, int isupload, int ispast,
            String check_time, int isoffupload, String first_left_time, String gps_speed, int plan_mode,
            String child_begin_date, String child_end_date, String userid, String rfid, String point_id,
            String trouble_id, String over_time, String code, String geometry, String finish_time,
            int pageindex) {
        this.id = id;
        this.temp_id = temp_id;
        this.plan_id = plan_id;
        this.path_id = path_id;
        this.type = type;
        this.lat = lat;
        this.lng = lng;
        this.addr = addr;
        this.order = order;
        this.isover = isover;
        this.state = state;
        this.isupload = isupload;
        this.ispast = ispast;
        this.check_time = check_time;
        this.isoffupload = isoffupload;
        this.first_left_time = first_left_time;
        this.gps_speed = gps_speed;
        this.plan_mode = plan_mode;
        this.child_begin_date = child_begin_date;
        this.child_end_date = child_end_date;
        this.userid = userid;
        this.rfid = rfid;
        this.point_id = point_id;
        this.trouble_id = trouble_id;
        this.over_time = over_time;
        this.code = code;
        this.geometry = geometry;
        this.finish_time = finish_time;
        this.pageindex = pageindex;
    }

    @Generated(hash = 456600550)
    public OfflinePathBean() {
    }

    public String getTemp_id() {
        return temp_id;
    }

    public void setTemp_id(String temp_id) {
        this.temp_id = temp_id;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public double getLng() {
        return lng;
    }

    public void setLng(double lng) {
        this.lng = lng;
    }

    public int getIsover() {
        return isover;
    }

    public void setIsover(int isover) {
        this.isover = isover;
    }

    public int getIsupload() {
        return this.isupload;
    }

    public void setIsupload(int isupload) {
        this.isupload = isupload;
    }

    public int getIspast() {
        return this.ispast;
    }

    public void setIspast(int ispast) {
        this.ispast = ispast;
    }

    public String getPath_id() {
        return this.path_id;
    }

    public void setPath_id(String path_id) {
        this.path_id = path_id;
    }

    public int getType() {
        return this.type;
    }

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

    public int getOrder() {
        return this.order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public String getCheck_time() {
        return this.check_time;
    }

    public void setCheck_time(String check_time) {
        this.check_time = check_time;
    }

    public String getGps_speed() {
        return this.gps_speed;
    }

    public void setGps_speed(String gps_speed) {
        this.gps_speed = gps_speed;
    }

    public int getPlan_mode() {
        return this.plan_mode;
    }

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

    public String getPlan_id() {
        return this.plan_id;
    }

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

    public String getChild_begin_date() {
        return this.child_begin_date;
    }

    public void setChild_begin_date(String child_begin_date) {
        this.child_begin_date = child_begin_date;
    }

    public String getChild_end_date() {
        return this.child_end_date;
    }

    public void setChild_end_date(String child_end_date) {
        this.child_end_date = child_end_date;
    }

    public String getUserid() {
        return this.userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public int getIsoffupload() {
        return this.isoffupload;
    }

    public void setIsoffupload(int isoffupload) {
        this.isoffupload = isoffupload;
    }

    public String getFirst_left_time() {
        return first_left_time;
    }

    public void setFirst_left_time(String first_left_time) {
        this.first_left_time = first_left_time;
    }

    public String getRfid() {
        return this.rfid;
    }

    public void setRfid(String rfid) {
        this.rfid = rfid;
    }

    public String getPoint_id() {
        return this.point_id;
    }

    public void setPoint_id(String point_id) {
        this.point_id = point_id;
    }

    public String getTrouble_id() {
        return this.trouble_id;
    }

    public void setTrouble_id(String trouble_id) {
        this.trouble_id = trouble_id;
    }

    public String getOver_time() {
        return this.over_time;
    }

    public void setOver_time(String over_time) {
        this.over_time = over_time;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getAddr() {
        return this.addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    public int getState() {
        return this.state;
    }

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

    public String getGeometry() {
        return this.geometry;
    }

    public void setGeometry(String geometry) {
        this.geometry = geometry;
    }

    public String getFinish_time() {
        return this.finish_time;
    }

    public void setFinish_time(String finish_time) {
        this.finish_time = finish_time;
    }

    public Long getId() {
        return this.id;
    }

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

    public int getPageindex() {
        return this.pageindex;
    }

    public void setPageindex(int pageindex) {
        this.pageindex = pageindex;
    }

    public static final String TEMP_ID = "temp_id";
    public static final String POINT_ID = "point_id";
    public static final String LAT = "lat";
    public static final String LNG = "lng";
    public static final String CODE = "code";

    public HashMap<String, Object> getAttrsFromPathBean(){
        HashMap<String, Object> attributes = new HashMap<>();
        attributes.put(TEMP_ID, temp_id);
        attributes.put(POINT_ID, point_id);
        attributes.put(LAT, lng);
        attributes.put(LNG, lat);
        attributes.put(CODE, code);

        return attributes;
    }

    public static OfflinePathBean getPathBeanFromAttrs(Map<String, Object> attributes){
        OfflinePathBean offlinePathBean = new OfflinePathBean();
        if (attributes != null) {
            offlinePathBean.setTemp_id((String) attributes.get(TEMP_ID));
            offlinePathBean.setPoint_id((String) attributes.get(POINT_ID));
            offlinePathBean.setLng((double) attributes.get(LNG));
            offlinePathBean.setLat((double) attributes.get(LAT));
            offlinePathBean.setCode((String) attributes.get(CODE));

        }
        return offlinePathBean;
    }
}
