DeviceDataItem.java 5.33 KB
package cn.com.glsx.schedulerjob.model;

import com.alibaba.fastjson.annotation.JSONField;
import java.io.Serializable;

public class DeviceDataItem implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 包类型:0-定位包,1-心跳包
     */
    @JSONField(name = "pktype")
    private int pktype;

    /**
     * 设备类型(int):0-有线,1-无线
     */
    @JSONField(name = "wiretype")
    private int wiretype;

    /**
     * 设备号
     */
    @JSONField(name = "imei")
    private String imei;

    /**
     * 设备类型(string)
     */
    @JSONField(name = "devtype")
    private String devtype;

    /**
     * 定位类型:0-GPS,1-基站,2-WIFI,3-北斗,4-GPS/北斗混合
     * 【规则】pktype==1(心跳包)时该值无效
     */
    @JSONField(name = "loctype")
    private int loctype;

    /**
     * 经度(float)
     * 【规则】pktype==1(心跳包)时该值无效
     */
    @JSONField(name = "lng")
    private float lng;

    /**
     * 纬度(float)
     * 【规则】pktype==1(心跳包)时该值无效
     */
    @JSONField(name = "lat")
    private float lat;

    /**
     * 速度(int)
     * 【规则】pktype==1(心跳包)时该值无效
     */
    @JSONField(name = "spd")
    private int spd;

    /**
     * 方向(int)
     * 【规则】pktype==1(心跳包)时该值无效
     */
    @JSONField(name = "dir")
    private int dir;

    /**
     * 电量(int)
     * 【规则】pktype==1(心跳包)时该值无效
     */
    @JSONField(name = "bat")
    private int bat;

    /**
     * 定位时间(long)
     * 【规则】pktype==1(心跳包)时该值无效
     */
    @JSONField(name = "t")
    private long t;

    // 无参构造:JSON反序列化必备(数组子项必须有无参构造)
    public DeviceDataItem() {
    }

    // 全参构造:测试/业务手动构建对象(快速赋值所有字段)
    public DeviceDataItem(int pktype, int wiretype, String imei, String devtype, int loctype,
                          float lng, float lat, int spd, int dir, int bat, long t) {
        this.pktype = pktype;
        this.wiretype = wiretype;
        this.imei = imei;
        this.devtype = devtype;
        this.loctype = loctype;
        this.lng = lng;
        this.lat = lat;
        this.spd = spd;
        this.dir = dir;
        this.bat = bat;
        this.t = t;
    }

    // 全字段Getter & Setter:JSON序列化/反序列化、业务取值必备
    public int getPktype() {
        return pktype;
    }

    public void setPktype(int pktype) {
        this.pktype = pktype;
    }

    public int getWiretype() {
        return wiretype;
    }

    public void setWiretype(int wiretype) {
        this.wiretype = wiretype;
    }

    public String getImei() {
        return imei;
    }

    public void setImei(String imei) {
        this.imei = imei;
    }

    public String getDevtype() {
        return devtype;
    }

    public void setDevtype(String devtype) {
        this.devtype = devtype;
    }

    public int getLoctype() {
        return loctype;
    }

    public void setLoctype(int loctype) {
        this.loctype = loctype;
    }

    public float getLng() {
        return lng;
    }

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

    public float getLat() {
        return lat;
    }

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

    public int getSpd() {
        return spd;
    }

    public void setSpd(int spd) {
        this.spd = spd;
    }

    public int getDir() {
        return dir;
    }

    public void setDir(int dir) {
        this.dir = dir;
    }

    public int getBat() {
        return bat;
    }

    public void setBat(int bat) {
        this.bat = bat;
    }

    public long getT() {
        return t;
    }

    public void setT(long t) {
        this.t = t;
    }

    @Override
    public String toString() {
        return "DeviceDataItem{" +
                "pktype=" + pktype +
                ", wiretype=" + wiretype +
                ", imei='" + imei + '\'' +
                ", devtype='" + devtype + '\'' +
                ", loctype=" + loctype +
                ", lng=" + lng +
                ", lat=" + lat +
                ", spd=" + spd +
                ", dir=" + dir +
                ", bat=" + bat +
                ", t=" + t +
                '}';
    }

    // -------------------------- 业务常量:避免魔法值,提升可读性 --------------------------
    /**
     * 包类型 - 定位包
     */
    public static final int PKTYPE_LOCATION = 0;
    /**
     * 包类型 - 心跳包
     */
    public static final int PKTYPE_HEARTBEAT = 1;

    /**
     * 设备类型(int) - 有线
     */
    public static final int WIRETYPE_WIRED = 0;
    /**
     * 设备类型(int) - 无线
     */
    public static final int WIRETYPE_WIRELESS = 1;

    /**
     * 定位类型 - GPS
     */
    public static final int LOCTYPE_GPS = 0;
    /**
     * 定位类型 - 基站
     */
    public static final int LOCTYPE_BASE_STATION = 1;
    /**
     * 定位类型 - WIFI
     */
    public static final int LOCTYPE_WIFI = 2;
    /**
     * 定位类型 - 北斗
     */
    public static final int LOCTYPE_BEIDOU = 3;
    /**
     * 定位类型 - GPS/北斗混合
     */
    public static final int LOCTYPE_GPS_BEIDOU = 4;
}