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/6/4 14:42
|
*/
|
@Data
|
public class DOWNWarnMsgFileListReq {
|
/**
|
* 车牌号
|
*/
|
private String vehicleNo;
|
/**
|
* 车牌颜色
|
*/
|
private int vehicleColor;
|
/**
|
* 子业务类型标识
|
*/
|
private int dataType;
|
/**
|
* 后续数据长度
|
*/
|
private int dataLength;
|
/**
|
* 报警信息ID
|
*/
|
private String infoId;
|
|
/**
|
* 编码报文
|
*/
|
public byte[] encode() {
|
ByteBuf byteBuf = Unpooled.buffer(120);
|
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());
|
byte[] bytes2 = new byte[0];
|
try {
|
bytes2 = this.getInfoId().getBytes("GBK");
|
} catch (UnsupportedEncodingException e) {
|
throw new RuntimeException(e);
|
}
|
for (int i = 0; i < this.getDataLength(); i++) {
|
if (i < bytes2.length) {
|
byteBuf.writeByte(bytes2[i]);
|
} else {
|
byteBuf.writeByte(0x00);
|
}
|
}
|
byte[] bytes = ByteBufUtil.getBytes(byteBuf);
|
byteBuf.release();
|
return bytes;
|
}
|
|
}
|