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;
|
}
|
}
|