左晓为主开发手持机充值管理机
zuoxiao
2024-07-29 fc1ec55e6ad56dc92737657750bcca7ed49f53eb
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
package com.dayu.qiheonlinelibrary.card;
 
import com.dayu.baselibrary.tools.HexUtil;
import com.dayu.qiheonlinelibrary.utils.CardCommon;
 
import java.io.Serializable;
 
/**
 * Created by Android Studio.
 * author: zuo
 * Date: 2024-07-13
 * Time: 15:47
 * 备注:
 */
public class ManagerToUserCard extends BaseCard implements Serializable {
 
    public String cardType = CardCommon.USER_CARD_TYPE_1;//写卡标志 A1刷卡开泵前 A8刷卡开泵后  A2叠加充值
 
    public int arerNumber;//区域号(底位在前高位在后)
 
    public int deviceNumberl;//设备编号(底位在前高位在后)
    public short rechargeTimes;//充值次数
 
    public int totalWater;//用户总用水量  底位在前,高位在后2位小数点  含两个小数点的整数
 
    public int totalElectric;//总用电量位 底位在前,高位在后  1位小数点  含1位小数点的整数
 
 
 
    /**
     * 用户卡0块
     */
    public class Zero extends BaseCard {
        public byte[] toByte() {
            try {
                byte[] data = new byte[16];
                data[0] = HexUtil.hexToByte(cardType);
                //区域号
                byte[] arerNumberBytes = new byte[2];
                byte[] arerNumberDatas = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(arerNumber));
                System.arraycopy(arerNumberDatas, 0, arerNumberBytes, 0, arerNumberDatas.length);
                if (arerNumberBytes != null) {
                    System.arraycopy(arerNumberBytes, 0, data, 1, arerNumberBytes.length);
                }
                //设备编号
                byte[] deviceNumberlBytes = new byte[2];
                byte[] deviceNumberlDatas = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(deviceNumberl));
                System.arraycopy(deviceNumberlDatas, 0, deviceNumberlBytes, 0, deviceNumberlDatas.length);
                if (deviceNumberlBytes != null) {
                    System.arraycopy(deviceNumberlBytes, 0, data, 3, deviceNumberlBytes.length);
                }
                //充值次数
                byte rechargeTimesByte = HexUtil.hexToByte(HexUtil.get10to16(rechargeTimes));
                data[5] = rechargeTimesByte;
 
                //用户总用水量
                byte[] totalWaterBytes = new byte[4];
                byte[] totalWaterDatas = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(totalWater));
                System.arraycopy(totalWaterDatas, 0, totalWaterBytes, 0, totalWaterDatas.length);
                if (totalWaterBytes != null) {
                    System.arraycopy(totalWaterBytes, 0, data, 6, totalWaterBytes.length);
                }
                //总用电量位
                byte[] totalElectricBytes = new byte[4];
                byte[] totalElectricDatas = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(totalElectric));
                System.arraycopy(totalElectricDatas, 0, totalElectricBytes, 0, totalElectricDatas.length);
                if (totalElectricBytes != null) {
                    System.arraycopy(totalElectricBytes, 0, data, 10, totalElectricBytes.length);
                }
                data[15] = getByteSum(data);
                return data;
            } catch (Exception e) {
                e.printStackTrace();
            }
 
            return null;
        }
 
    }
 
    public void setArerNumber(int arerNumber) {
        this.arerNumber = arerNumber;
    }
 
    public void setDeviceNumberl(int deviceNumberl) {
        this.deviceNumberl = deviceNumberl;
    }
 
    public void setRechargeTimes(short rechargeTimes) {
        this.rechargeTimes = rechargeTimes;
    }
 
    public void setTotalWater(int totalWater) {
        this.totalWater = totalWater;
    }
 
    public void setTotalElectric(int totalElectric) {
        this.totalElectric = totalElectric;
    }
    public byte[] getZeroBytes() {
        Zero zero = new Zero();
        return zero.toByte();
    }
}