左晓为主开发手持机充值管理机
zuoxiao
2024-04-25 8d53327d1b3df1aea5f9eb9fa22c644ccfeeabf1
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
package com.dayu.henanlibrary.socketBean;
 
import com.dayu.baselibrary.tools.ArraysUtil;
import com.dayu.baselibrary.tools.BcdUtil;
import com.dayu.baselibrary.utils.CRC8;
 
/**
 * Copyright (C), 2022,
 * Author: zuo
 * Date: 2022/2/7 12:22
 * Description:开卡报文
 */
public class InitCardRequestBean extends BaseSocketBean {
 
    String control = "01";//控制域
    String initCode;//设备注册号
    String machineCode;//充值管理机序列号
    String AFN = "93";
    String orderId;//= new String[8];//订单号
    String name;// = new String[13];//姓名
    String phone;//= new String[6];
    String idCard;//= new String[18];
 
    @Override
    public byte[] toByte() {
        byte[] data = new byte[65];
        data[0] = CRC8.hexStrToBinaryStr(control)[0];
        byte[] initCodeBytes = CRC8.hexStrToBinaryStr(initCode);
        ArraysUtil.copyof(data, initCodeBytes, 1);
        byte[] machineCodeByte = CRC8.hexStrToBinaryStr(machineCode);
        ArraysUtil.copyof(data, machineCodeByte, 17);
        ArraysUtil.copyof(data, CRC8.hexStrToBinaryStr(AFN)[0], 20);
        byte[] orderIdByte = BcdUtil.strToBcd(this.orderId);
        ArraysUtil.copyof(data, orderIdByte, 21);
        byte[] myNameByte = new byte[12];
        byte[] nameByte = CRC8.hexStrToBinaryStr(this.name);
        if (nameByte.length != 12) {
            ArraysUtil.copyof(myNameByte, nameByte, 0);
        } else {
            myNameByte = nameByte;
        }
        ArraysUtil.copyof(data, myNameByte, 29);
        byte[] phoneByte = BcdUtil.strToBcd(this.phone);
        ArraysUtil.copyof(data, phoneByte, 41);
        byte[] idCardByte = CRC8.hexStrToBinaryStr(this.idCard);
        ArraysUtil.copyof(data, idCardByte, 47);
        return data;
    }
 
    @Override
    public String toString() {
        return
                control +
                        initCode +
                        machineCode +
                        AFN +
                        orderId +
                        name +
                        phone +
                        idCard;
    }
 
    public String getControl() {
        return control;
    }
 
    public void setControl(String control) {
        this.control = control;
    }
 
    public String getInitCode() {
        return initCode;
    }
 
    public void setInitCode(String initCode) {
        this.initCode = initCode;
    }
 
    public String getMachineCode() {
        return machineCode;
    }
 
    public void setMachineCode(String machineCode) {
        this.machineCode = machineCode;
    }
 
    public String getAFN() {
        return AFN;
    }
 
    public void setAFN(String AFN) {
        this.AFN = AFN;
    }
 
    public String getOrderId() {
        return orderId;
    }
 
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getPhone() {
        return phone;
    }
 
    public void setPhone(String phone) {
        this.phone = phone;
    }
 
    public String getIdCard() {
        return idCard;
    }
 
    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }
 
 
}