Pu Zhibing
2025-06-19 a05b419384e148fc950c77553816a2d05144f4ae
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
package com.ruoyi.dataInterchange.model;
 
import com.ruoyi.dataInterchange.util.jtt809.common.Jtt809Util;
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/6/4 15:11
 */
@Data
public class File {
    /**
     * 文件名称长度
     */
    @Field(type = FieldType.Integer)
    private int fileNameLength;
    /**
     * 文件名称
     */
    @Field(type = FieldType.Text)
    private String fileName;
    /**
     * 文件类型
     * 0x00: 图片
     * 0x01: 音频
     * 0x02: 视频
     * 0x03: 记录文件
     * 0x04: 其他
     */
    @Field(type = FieldType.Integer)
    private int fileType;
    /**
     * 文件大小
     */
    @Field(type = FieldType.Integer)
    private int fileSize;
    /**
     * 文件URL的长度
     */
    @Field(type = FieldType.Integer)
    private int fileUrlLength;
    /**
     * 文件URL
     */
    @Field(type = FieldType.Text)
    private String fileUrl;
    
    
    /**
     * 解析报文
     */
    public File decode(ByteBuf byteBuf) {
        try {
            //文件名称长度
            this.fileNameLength = byteBuf.readByte();
            //文件名称
            this.fileName = Jtt809Util.readGBKString(byteBuf,fileNameLength);
            //文件类型
            this.fileType = byteBuf.readByte();
            //文件大小
            this.fileSize = byteBuf.readInt();
            //文件URL的长度
            this.fileUrlLength = byteBuf.readByte();
            //文件URL
            this.fileUrl = Jtt809Util.readGBKString(byteBuf,fileUrlLength);
        }catch (Exception e){
            e.printStackTrace();
        }
        return this;
    }
}