Pu Zhibing
2025-03-14 3c66b754ee314ae87d0f2eda2fa86a30ea2304e7
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
package com.ruoyi.dataInterchange.model;
 
import io.netty.buffer.ByteBuf;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
 
/**
 * 车辆定位信息
 *
 * @author zhibing.pu
 * @Date 2025/2/24 11:56
 */
@Data
public class GnssData {
    /**
     * 定位信息是否使用国家测绘局批准的地图表米插件进行加密
     * 加密标识
     * 1:已加密
     * 0:未加密
     */
    @Field(type = FieldType.Integer)
    private int encrypt;
    /**
     * 日月年
     */
    @Field(type = FieldType.Text)
    private String date;
    /**
     * 时分秒
     */
    @Field(type = FieldType.Text)
    private String time;
    /**
     * 经度
     */
    @Field(type = FieldType.Integer)
    private int lon;
    /**
     * 纬度
     */
    @Field(type = FieldType.Integer)
    private int lat;
    /**
     * 速度
     */
    @Field(type = FieldType.Integer)
    private int vec1;
    /**
     * 行驶记录速度
     */
    @Field(type = FieldType.Integer)
    private int vec2;
    /**
     * 车辆当前总里程数
     */
    @Field(type = FieldType.Integer)
    private int vec3;
    /**
     * 方向
     */
    @Field(type = FieldType.Integer)
    private int direction;
    /**
     * 海拔高度
     */
    @Field(type = FieldType.Integer)
    private int altitude;
    /**
     * 车辆状态
     */
    @Field(type = FieldType.Integer)
    private int state;
    /**
     * 报警状态
     */
    @Field(type = FieldType.Integer)
    private int alarm;
    
    /**
     * 解析报文
     */
    public GnssData decode(ByteBuf byteBuf) {
        this.encrypt = byteBuf.readByte();
        int d = byteBuf.readByte();
        int m = byteBuf.readByte();
        int y = byteBuf.readShort();
        this.date = y + "-" + String.format("%02d", m) + "-" + String.format("%02d", d);
        int h = byteBuf.readByte();
        int mi = byteBuf.readByte();
        int s = byteBuf.readByte();
        this.time = String.format("%02d", h) + ":" + String.format("%02d", mi) + ":" + String.format("%02d", s);
        this.lon = byteBuf.readInt();
        this.lat = byteBuf.readInt();
        this.vec1 = byteBuf.readShort();
        this.vec2 = byteBuf.readShort();
        this.vec3 = byteBuf.readInt();
        this.direction = byteBuf.readShort();
        this.altitude = byteBuf.readShort();
        this.state = byteBuf.readInt();
        this.alarm = byteBuf.readInt();
        return this;
    }
}