左晓为主开发手持机充值管理机
zuoxiao
2023-11-14 5a843ba11b991722f8f2af386f0e546e2769f7c3
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
package com.dayu.recharge.socketBean;
 
import com.dayu.recharge.tools.ArraysUtil;
import com.dayu.recharge.tools.BcdUtil;
import com.dayu.recharge.utils.CRC8;
import com.dayu.recharge.utils.MornyUtil;
import com.dayu.recharge.utils.SocketUtil;
 
/**
 * Copyright (C), 2022,
 * Author: zuo
 * Date: 2022/2/7 16:15
 * Description: 充值
 */
public class RechargeRequestBean extends BaseSocketBean {
    String control;//控制域C表示报文传输方向和所提供的传输服务类型的信息,0x00代表此帧报文是由中心端发出的下行报文;0x01 表示此帧报文是由终端发出的上行报文;
 
    String initCode;///= new String[16];//设备注册号
    String xuLie;// = new String[3];//充值管理机序列号(低)充值管理机序列号(中)充值管理机序列号(高)
    String AFN = "95";
    String initPeasantCode;// = new String[16];//农户注册编号
    String balance;// = new String[4];// 充值金额(低)---充值金额(高) 16进制     单位:0.01元
    String orderId;//= new String[8];//订单号
 
    @Override
    public byte[] toByte() {
        byte[] data = new byte[49];
        data[0] = CRC8.hexStrToBinaryStr(this.control)[0];
        byte[] initCodeBytes = CRC8.hexStrToBinaryStr(this.initCode);
        ArraysUtil.copyof(data, initCodeBytes, 1);
        byte[] machineCodeByte = CRC8.hexStrToBinaryStr(this.xuLie);
        ArraysUtil.copyof(data, machineCodeByte, 17);
        ArraysUtil.copyof(data, CRC8.hexStrToBinaryStr(this.AFN)[0], 20);
        byte[] initPeasantCodeByte = CRC8.hexStrToBinaryStr(this.initPeasantCode);
        ArraysUtil.copyof(data, initPeasantCodeByte, 21);
        byte[] balanceByte = CRC8.hexStrToBinaryStr(SocketUtil.get10to16LowHigh(MornyUtil.changeY2F(balance), 8));
        ArraysUtil.copyof(data, balanceByte, 37);
        byte[] orderIdByte = BcdUtil.strToBcd(this.orderId);
        ArraysUtil.copyof(data, orderIdByte, 41);
        return data;
    }
 
    @Override
    public String toString() {
        return
                control +
                        initCode +
                        xuLie +
                        AFN +
                        initPeasantCode +
                        balance +
                        orderId;
    }
 
    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 getXuLie() {
        return xuLie;
    }
 
    public void setXuLie(String xuLie) {
        this.xuLie = xuLie;
    }
 
    public String getAFN() {
        return AFN;
    }
 
    public void setAFN(String AFN) {
        this.AFN = AFN;
    }
 
    public String getInitPeasantCode() {
        return initPeasantCode;
    }
 
    public void setInitPeasantCode(String initPeasantCode) {
        this.initPeasantCode = initPeasantCode;
    }
 
    public String getBalance() {
        return balance;
    }
 
    public void setBalance(String balance) {
        this.balance = balance;
    }
 
    public String getOrderId() {
        return orderId;
    }
 
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
 
}