Pu Zhibing
2025-03-14 3c66b754ee314ae87d0f2eda2fa86a30ea2304e7
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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.time.LocalDateTime;
import java.time.ZoneOffset;
 
/**
 * 报警督办请求
 *
 * @author zhibing.pu
 * @Date 2025/3/3 15:14
 */
@Data
public class DOWNWarnMsgUrgeTodoReq {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private int vehicleColor;
    /**
     * 子业务类型标识
     */
    private int dataType;
    /**
     * 后续数据长度
     */
    private int dataLength;
    /**
     * 报警信息来源
     * 0x01: 车载终端
     * 0x02: 企业监控平台
     * 0x03: 政府监管平台
     * 0x09: 其他
     */
    private int warnSrc;
    /**
     * 报警类型
     */
    private int warnType;
    /**
     * 报警时间
     */
    private long warnTime;
    /**
     * 报警督办ID
     */
    private int supervisionId;
    /**
     * 督办截止时间
     */
    private long supervisionEndTime;
    /**
     * 督办级别
     * 0x00: 紧急
     * 0x01: 一般
     */
    private int supervisionLevel;
    /**
     * 督办人
     */
    private String supervisor;
    /**
     * 督办联系电话
     */
    private String supervisorTel;
    /**
     * 督办联系电子邮件
     */
    private String supervisorEmail;
    
    
    public DOWNWarnMsgUrgeTodoReq build(UPWarnMsgAdptInfo upWarnMsgAdptInfo) {
        this.vehicleNo = upWarnMsgAdptInfo.getVehicleNo();
        this.vehicleColor = upWarnMsgAdptInfo.getVehicleColor();
        this.warnSrc = upWarnMsgAdptInfo.getWarnSrc();
        this.warnType = upWarnMsgAdptInfo.getWarnType();
        this.warnTime = upWarnMsgAdptInfo.getWarnTime();
        this.supervisionId = upWarnMsgAdptInfo.getInfoId();
        this.supervisionEndTime = LocalDateTime.now().plusDays(7).toEpochSecond(ZoneOffset.UTC);
        this.supervisionLevel = 0x01;
        this.supervisor = "谢茜";
        this.supervisorTel = "18808258011";
        this.supervisorEmail = "1360001080@qq.com";
        return this;
    }
    
    
    /**
     * 编码报文
     */
    public byte[] encode() {
        ByteBuf byteBuf = Unpooled.buffer(120);
        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.writeByte(this.getWarnSrc());
        byteBuf.writeShort(this.getWarnType());
        byteBuf.writeLong(this.getWarnTime());
        byteBuf.writeInt(this.getSupervisionId());
        byteBuf.writeLong(this.getSupervisionEndTime());
        byteBuf.writeByte(this.getSupervisionLevel());
        byte[] bytes2 = this.getSupervisor().getBytes();
        for (int i = 0; i < 16; i++) {
            if (i < bytes2.length) {
                byteBuf.writeByte(bytes2[i]);
            } else {
                byteBuf.writeByte(0x00);
            }
        }
        byte[] bytes3 = this.getSupervisorTel().getBytes();
        for (int i = 0; i < 20; i++) {
            if (i < bytes3.length) {
                byteBuf.writeByte(bytes3[i]);
            } else {
                byteBuf.writeByte(0x00);
            }
        }
        byte[] bytes4 = this.getSupervisorEmail().getBytes();
        for (int i = 0; i < 32; i++) {
            if (i < bytes4.length) {
                byteBuf.writeByte(bytes4[i]);
            } else {
                byteBuf.writeByte(0x00);
            }
        }
        byte[] bytes = ByteBufUtil.getBytes(byteBuf);
        byteBuf.release();
        return bytes;
    }
}