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();
|
}
|
}
|