| | |
| | | package com.ruoyi.dataInterchange.model; |
| | | |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.buffer.ByteBufUtil; |
| | | import io.netty.buffer.Unpooled; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private Long dateTime; |
| | | |
| | | |
| | | /** |
| | | * 编码回复报文 |
| | | */ |
| | | public byte[] encode() { |
| | | ByteBuf byteBuf = Unpooled.buffer(38); |
| | | byte[] bytes1 = this.getVehicleNo().getBytes(); |
| | | 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.getControlType()); |
| | | byteBuf.writeChar(this.getFastTime()); |
| | | if (null != this.getDateTime()) { |
| | | byteBuf.writeLong(this.getDateTime()); |
| | | } else { |
| | | byteBuf.writeLong(0x00); |
| | | } |
| | | byte[] bytes = ByteBufUtil.getBytes(byteBuf); |
| | | byteBuf.release(); |
| | | return bytes; |
| | | } |
| | | |
| | | } |