自动化立体仓库 - WCS系统
#
18516761980
2022-06-08 556c49e32f5f38cca479eb2a12025712b2f1807b
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
package com.zy.core.netty.domain;
 
import io.netty.buffer.ByteBuf;
import lombok.Data;
 
/**
 * 报文模型
 * Created by vincent on 2019-04-03
 */
@Data
public class ChPackage {
 
    /**
     * 唯一编码
     */
    private String uuid;
 
    /**
     * 源数据包缓冲区(引用)
     */
    private ByteBuf sourceBuff;
 
    /**
     * 原始消息对应的16进制字符串
     */
    private String sourceHexStr;
 
    /**
     * 请求体
     */
    private ByteBuf content;
 
    private byte[] bytes;
 
    private String ascii;
 
    private String ip;
 
    /**
     * 消息的校正码
     */
    private byte validCode;
 
    /**
     * 是否为校验异常包
     */
    private boolean errorPac;
 
    public static ChPackage valueOfEmpty(String uuid, String ip) {
        ChPackage chPackage = new ChPackage();
        chPackage.setUuid(uuid);
        chPackage.setIp(ip);
        return chPackage;
    }
 
//    public ByteBuf convert(ByteBuf byteBuf){
//        byteBuf.writeBytes(this.getHeader().getStartSymbol().getBytes(Constant.CHARSET_GBK))
//                .writeByte(this.getHeader().getCommandMark().getCode())
//                .writeByte(this.getHeader().getAckMark().getCode())
//                .writeBytes(this.getHeader().getUniqueNo().getBytes())
//                .writeByte(this.getHeader().getEncryptType().getCode())
//                .writeShort(this.getHeader().getContentLength())
//                .writeBytes(this.getBody().getContent())
//                .writeByte(this.getValidCode());
//        // 计算并设置校验码
//        this.setValidCode(ValidUtil.caculateValidByteFromBuff(byteBuf));
//        byteBuf.resetReaderIndex();
//        byteBuf.writerIndex(byteBuf.readableBytes() - 1).writeByte(this.getValidCode());
//        return byteBuf;
//    }
 
}