左晓为主开发手持机充值管理机
zuoxiao
2024-02-29 1c549ae7af5f8d7bdeecb4ad38ab181af4831821
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
package com.dayu.recharge.card;
 
import com.dayu.recharge.tools.HexUtil;
import com.dayu.recharge.utils.MyCommon;
 
import java.io.Serializable;
import java.util.List;
 
/**
 * author: zuo
 * Date: 2024-02-29
 * Time: 16:29
 * 备注:区域标号卡
 */
public class RegionCard implements Serializable {
 
    public String cardType = MyCommon.REGION;//卡命令
 
    public short region;//区域地址(低前高后) 可以识别某县镇村
 
    public short controllerCodel;// 控制器编号(低前高后) 本区域内控制器编号
 
 
 
    public byte[] toByte() {
        RegionCard.Zero zero = new RegionCard.Zero();
        return zero.toByte();
    }
 
 
 
    public static RegionCard getBean(List<byte[]> data){
        RegionCard regionCard=new RegionCard();
        byte[] zero=data.get(0);
        regionCard.cardType=HexUtil.byteToHex(zero[0]);
 
        return regionCard;
    }
 
 
 
    public class Zero extends BaseCard {
        public byte[] toByte() {
            byte[] data = new byte[16];
            data[0] = HexUtil.hexToByte(cardType);
 
            byte[] regionBytes = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(region));
            if (regionBytes != null) {
                System.arraycopy(regionBytes, 0, data, 1, regionBytes.length);
            }
 
            byte[] controllerCodelBytes = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(controllerCodel));
            if (controllerCodelBytes != null) {
                System.arraycopy(controllerCodelBytes, 0, data, 3, controllerCodelBytes.length);
            }
 
 
            data[15] = getByteSum(data);
            return data;
        }
 
    }
 
 
}