Pu Zhibing
2025-04-09 b8a3a680f3e6720a8329bfaae571b09659aace52
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
package com.ruoyi.dataInterchange.model;
 
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import lombok.Data;
 
import java.io.UnsupportedEncodingException;
 
/**
 * 远程录像回放请求
 *
 * @author zhibing.pu
 * @Date 2025/3/21 9:57
 */
@Data
public class DOWNPlaybackMsgStartup {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private Integer vehicleColor;
    /**
     * 子业务类型标识
     */
    private Integer dataType;
    /**
     * 后续数据长度
     */
    private Integer dataLength;
    /**
     * 逻辑通道号
     */
    private Integer channelId;
    /**
     * 视频类型
     * 0x00: 音视频
     * 0x01: 音频
     * 0x02: 视频
     */
    private Integer avttemType;
    /**
     * 码流类型
     * 0:所有码流
     * 1:主码流
     * 2:子码流
     */
    private Integer streamType;
    /**
     * 存储器类型
     * 0:所有存储器
     * 1:主存储器
     * 2:灾备存储器
     */
    private Integer memType;
    /**
     * 回放起始时间
     */
    private Long playbackStartTime;
    /**
     * 回放结束时间
     */
    private Long playbackEndTime;
    /**
     * 时效口令
     */
    private String authorizeCode;
    /**
     * 车辆进入跨域地区后5min之内的任一位置
     */
    private String gnssData;
    
    
    /**
     * 编码回复报文
     */
    public byte[] encode() {
        ByteBuf byteBuf = Unpooled.buffer(148);
        byte[] bytes1 = new byte[0];
        try {
            bytes1 = this.getVehicleNo().getBytes("GBK");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        for (int i = 0; i < 21; i++) {
            if (i < bytes1.length) {
                byteBuf.writeByte(bytes1[i]);
            } else {
                byteBuf.writeByte(0x00);
            }
        }
        byteBuf.writeByte(this.getVehicleColor());
        byteBuf.writeShort(this.getDataType());
        byteBuf.writeInt(this.getDataLength());
        byteBuf.writeChar(this.getChannelId());
        byteBuf.writeChar(this.getAvttemType());
        byteBuf.writeChar(this.getStreamType());
        byteBuf.writeChar(this.getMemType());
        byteBuf.writeLong(this.getPlaybackStartTime());
        byteBuf.writeLong(this.getPlaybackEndTime());
        byte[] bytes2 = new byte[0];
        try {
            bytes2 = this.getAuthorizeCode().getBytes("GBK");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        for (int i = 0; i < 64; i++) {
            if (i < bytes2.length) {
                byteBuf.writeByte(bytes2[i]);
            } else {
                byteBuf.writeByte(0x00);
            }
        }
        byte[] bytes3 = new byte[0];
        try {
            bytes3 = this.getGnssData().getBytes("GBK");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        for (int i = 0; i < 36; i++) {
            if (i < bytes3.length) {
                byteBuf.writeByte(bytes3[i]);
            } else {
                byteBuf.writeByte(0x00);
            }
        }
        byte[] bytes = ByteBufUtil.getBytes(byteBuf);
        byteBuf.release();
        return bytes;
    }
}