DeviceDataItem.java
4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package cn.com.glsx.schedulerjob.model;
import java.io.Serializable;
public class DeviceDataItem implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 包类型:0-定位包,1-心跳包
*/
private int pktype;
/**
* 设备类型(int):0-有线,1-无线
*/
private int wiretype;
/**
* 设备号
*/
private String imei;
/**
* 设备类型(string)
*/
private String devtype;
/**
* 定位类型:0-GPS,1-基站,2-WIFI,3-北斗,4-GPS/北斗混合
* 【规则】pktype==1(心跳包)时该值无效
*/
private int loctype;
/**
* 经度(float)
* 【规则】pktype==1(心跳包)时该值无效
*/
private float lng;
/**
* 纬度(float)
* 【规则】pktype==1(心跳包)时该值无效
*/
private float lat;
/**
* 速度(int)
* 【规则】pktype==1(心跳包)时该值无效
*/
private int spd;
/**
* 方向(int)
* 【规则】pktype==1(心跳包)时该值无效
*/
private int dir;
/**
* 电量(int)
* 【规则】pktype==1(心跳包)时该值无效
*/
private int bat;
/**
* 定位时间(long)
* 【规则】pktype==1(心跳包)时该值无效
*/
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;
}