|  |  |  | 
|---|
|  |  |  | package com.dayu.qihealonelibrary.card; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dayu.baselibrary.tools.HexUtil; | 
|---|
|  |  |  | import com.dayu.qihealonelibrary.dao.AppDatabase; | 
|---|
|  |  |  | import com.dayu.qihealonelibrary.utils.MyCommon; | 
|---|
|  |  |  | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; | 
|---|
|  |  |  | import com.dayu.qihealonelibrary.utils.CardCommon; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | 
|---|
|  |  |  | * 备注:电量单价卡 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class ElectricPriceCard extends BaseCard implements Serializable { | 
|---|
|  |  |  | public String cardType = MyCommon.ELECTRIC_PRICE; | 
|---|
|  |  |  | public String cardType = CardCommon.ELECTRIC_PRICE; | 
|---|
|  |  |  | public Float electricPrice;// 电量单价(低)单位是元,3位小数点 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Float getElectricPrice() { | 
|---|
|  |  |  | 
|---|
|  |  |  | this.electricPrice = electricPrice; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public byte[] toByte(AppDatabase appDatabase) { | 
|---|
|  |  |  | setCardData(appDatabase, cardType); | 
|---|
|  |  |  | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { | 
|---|
|  |  |  | setCardData(QHAloneAppDatabase, cardType); | 
|---|
|  |  |  | Zero zero = new Zero(); | 
|---|
|  |  |  | return zero.toByte(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static ElectricPriceCard getBean(List<byte[]> data){ | 
|---|
|  |  |  | ElectricPriceCard regionCard=new ElectricPriceCard(); | 
|---|
|  |  |  | byte[] zero=data.get(0); | 
|---|
|  |  |  | regionCard.cardType= HexUtil.byteToHex(zero[0]); | 
|---|
|  |  |  | public static ElectricPriceCard getBean(List<byte[]> data) { | 
|---|
|  |  |  | ElectricPriceCard regionCard = new ElectricPriceCard(); | 
|---|
|  |  |  | byte[] zero = data.get(0); | 
|---|
|  |  |  | regionCard.cardType = HexUtil.byteToHex(zero[0]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | byte[] cardDataByte = new byte[4]; | 
|---|
|  |  |  | System.arraycopy(zero, 1, cardDataByte, 0, cardDataByte.length); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | byte[] electricPriceByte = new byte[4]; | 
|---|
|  |  |  | System.arraycopy(zero, 5, electricPriceByte, 0, electricPriceByte.length); | 
|---|
|  |  |  | regionCard.electricPrice = HexUtil.bytesToFloat(electricPriceByte); | 
|---|
|  |  |  | regionCard.electricPrice = HexUtil.hexToFloatLowHigh(electricPriceByte); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return regionCard; | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 第1扇区0块 存储的数据 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class Zero  { | 
|---|
|  |  |  | public class Zero { | 
|---|
|  |  |  | public byte[] toByte() { | 
|---|
|  |  |  | byte[] data = new byte[16]; | 
|---|
|  |  |  | data[0] = HexUtil.hexToByte(cardType); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | byte[] regionBytes = HexUtil.hexToByteArray(cardData); | 
|---|
|  |  |  | byte[] regionBytes = new byte[4]; | 
|---|
|  |  |  | byte[] regionDatas = HexUtil.hexToByteArray(cardData); | 
|---|
|  |  |  | System.arraycopy(regionDatas, 0, regionBytes, 0, regionDatas.length); | 
|---|
|  |  |  | if (regionBytes != null) { | 
|---|
|  |  |  | System.arraycopy(regionBytes, 0, data, 1, regionBytes.length); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | byte[] controllerCodelBytes = HexUtil.folatToByte(electricPrice); | 
|---|
|  |  |  | byte[] controllerCodelBytes = new byte[4]; | 
|---|
|  |  |  | byte[] controllerCodelDatas = HexUtil.hexToByteArray(HexUtil.floatToHexLowHigh(electricPrice)); | 
|---|
|  |  |  | System.arraycopy(controllerCodelDatas, 0, controllerCodelBytes, 0, controllerCodelDatas.length); | 
|---|
|  |  |  | if (controllerCodelBytes != null) { | 
|---|
|  |  |  | System.arraycopy(controllerCodelBytes, 0, data, 5, controllerCodelBytes.length); | 
|---|
|  |  |  | } | 
|---|