puzhibing
2 天以前 ea7595c4c75926f85388574b261b8ba90cf60e0d
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
package com.ruoyi.dataInterchange.model;
 
import cn.hutool.core.util.ArrayUtil;
import com.ruoyi.dataInterchange.pojo.BaseModel;
import com.ruoyi.dataInterchange.util.jtt809.common.ByteArrayUtil;
import com.ruoyi.dataInterchange.util.jtt809.common.Jtt809Util;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
 
import java.util.Arrays;
import java.util.List;
 
/**
 * 上报报警信息
 *
 * @author zhibing.pu
 * @Date 2025/3/3 14:50
 */
@Data
@Document(indexName = "up_warn_msg_adpt_info")
public class UPWarnMsgAdptInfo extends BaseModel {
    /**
     * 车牌号
     */
    @Field(type = FieldType.Text)
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    @Field(type = FieldType.Integer)
    private int vehicleColor;
    /**
     * 子业务类型标识
     */
    @Field(type = FieldType.Integer)
    private int dataType;
    /**
     * 后续数据长度
     */
    @Field(type = FieldType.Integer)
    private int dataLength;
    /**
     * 报警信息来源
     * 0x01: 车载终端
     * 0x02: 企业监控平台
     * 0x03: 政府监管平台
     * 0x09: 其他
     */
    @Field(type = FieldType.Integer)
    private int warnSrc;
    /**
     * 报警类型
     * 0x0001: 超速报警
     * 0x0002: 疲劳驾驶报警
     * 0x0003: 紧急报警
     * 0x0004: 进入指定区域报警
     * 0x0005: 离开指定区域报警
     * 0x0006: 路段堵塞报警
     * 0x0007: 危险路段报警
     * 0x0008: 越界报警
     * 0x0009: 盗警
     */
    @Field(type = FieldType.Integer)
    private int warnType;
    /**
     * 报警时间
     */
    @Field(type = FieldType.Integer)
    private long warnTime;
    /**
     * 信息ID
     */
    @Field(type = FieldType.Text)
    private String infoId;
    /**
     * 驾驶员姓名长度
     */
    @Field(type = FieldType.Integer)
    private int driverLength;
    /**
     * 驾驶员姓名
     */
    @Field(type = FieldType.Text)
    private String driver;
    /**
     * 驾驶员驾照号码长度
     */
    @Field(type = FieldType.Integer)
    private int driverNoLength;
    /**
     * 驾驶员驾照号码
     */
    @Field(type = FieldType.Text)
    private String driverNo;
    /**
     * 报警级别
     */
    @Field(type = FieldType.Integer)
    private int level;
    /**
     * 经度
     */
    @Field(type = FieldType.Integer)
    private int longitude;
    /**
     * 纬度
     */
    @Field(type = FieldType.Integer)
    private int latitude;
    /**
     * 海拔
     */
    @Field(type = FieldType.Integer)
    private int altitude;
    /**
     * 行车速度
     */
    @Field(type = FieldType.Integer)
    private int speed;
    /**
     * 行驶记录速度
     */
    @Field(type = FieldType.Integer)
    private int vec2;
    /**
     * 报警状态
     * 1:报警开始
     * 2:报警结束
     */
    @Field(type = FieldType.Integer)
    private int status;
    /**
     * 方向
     */
    @Field(type = FieldType.Integer)
    private int direction;
    /**
     * 报警数据长度
     */
    @Field(type = FieldType.Integer)
    private int infoLength;
    /**
     * 上报报警信息内容
     */
    @Field(type = FieldType.Text)
    private String infoContent;
    /**
     * 报警处理结果
     * 0x00:处理中
     * 0x01:已处理完毕
     * 0x02:不作处理
     * 0x03:将来处理
     */
    @Field(type = FieldType.Integer)
    private int result;
    /**
     * 报警督办发起时间
     */
    @Field(type = FieldType.Long)
    private long pushTime;
 
    
    /**
     * 解析报文
     */
    public UPWarnMsgAdptInfo decode1(WarnMsg warnMsg) {
        try {
            byte[] data = warnMsg.getData();
            ByteBuf byteBuf = Unpooled.wrappedBuffer(data);
            this.vehicleNo = warnMsg.getVehicleNo();
            this.vehicleColor = warnMsg.getVehicleColor();
            this.dataType = warnMsg.getDataType();
            this.dataLength = warnMsg.getDataLength();
 
            //报警信息来源
            this.warnSrc = byteBuf.readByte();
            //报警类型
            this.warnType = byteBuf.readShort();
            byte[] readableBytes = new byte[8];
            byteBuf.readBytes(readableBytes);
            String time = ByteArrayUtil.bytes2HexStr(readableBytes);
            //报警时间
            this.warnTime = Long.parseLong(time, 16);
            //信息ID
            this.infoId = Integer.valueOf(byteBuf.readInt()).toString();
            //报警数据长度
            this.infoLength = byteBuf.readInt();
            //上报报警信息内容
            this.infoContent = Jtt809Util.readGBKString(byteBuf, this.infoLength);
        }catch (Exception e){
            e.printStackTrace();
        }
        return this;
    }
 
    /**
     * 解析报文(川标)
     */
    public UPWarnMsgAdptInfo decode2(WarnMsg warnMsg) {
        try {
            byte[] data = warnMsg.getData();
            ByteBuf byteBuf = Unpooled.wrappedBuffer(data);
            this.vehicleNo = warnMsg.getVehicleNo();
            this.vehicleColor = warnMsg.getVehicleColor();
            this.dataType = warnMsg.getDataType();
            this.dataLength = warnMsg.getDataLength();
 
            //报警信息来源
            this.warnSrc = byteBuf.readByte();
            //报警类型
            this.warnType = byteBuf.readShort();
            byte[] readableBytes = new byte[8];
            byteBuf.readBytes(readableBytes);
            String time = ByteArrayUtil.bytes2HexStr(readableBytes);
            //报警时间
            this.warnTime = Long.parseLong(time, 16);
            //团标扩展
            //信息ID
            this.infoId = Jtt809Util.readGBKString(byteBuf,32);
            //驾驶员姓名长度
            this.driverLength = byteBuf.readByte();
            //驾驶员姓名
            this.driver = Jtt809Util.readGBKString(byteBuf,this.driverLength);
            //驾驶员驾照号码长度
            this.driverNoLength = byteBuf.readByte();
            //驾驶员驾照号码
            this.driverNo = Jtt809Util.readGBKString(byteBuf,this.driverNoLength);
            //报警级别
            this.level = byteBuf.readByte();
            //经度
            this.longitude = byteBuf.readInt();
            //纬度
            this.latitude = byteBuf.readInt();
            //海拔高度
            this.altitude = byteBuf.readUnsignedShort();
            //行车速度
            this.speed = byteBuf.readUnsignedShort();
            //行驶记录速度
            this.vec2 = byteBuf.readUnsignedShort();
            //报警状态
            this.status = byteBuf.readByte();
            //方向
            this.direction = byteBuf.readUnsignedShort();
            //报警数据长度
            this.infoLength = byteBuf.readUnsignedShort();
            //报警信息内容
            this.infoContent = Jtt809Util.readGBKString(byteBuf,this.infoLength);
        }catch (Exception e){
            e.printStackTrace();
        }
        return this;
    }
}