|  |  | 
 |  |  |  */ | 
 |  |  | public class ManageCard extends BaseCard implements Serializable { | 
 |  |  |     public String cardType = CardCommon.MANAGE_CRAD;//卡类型 | 
 |  |  |     public int arerNumber;//区域号(底位在前高位在后) | 
 |  |  |  | 
 |  |  |     public String getCardData() { | 
 |  |  |         return cardData; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * M1卡的0扇区0块通常用于存储一些基本的卡片信息 | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     public String userCard; //用户卡号 | 
 |  |  |  | 
 |  |  |     public byte type;//当前状态 00:充值管理机写 01:控制器反写的  当01时将1扇区0块原管理卡信息改成用户卡内容 | 
 |  |  |     public byte cardWriteState;//当前状态 00:充值管理机写 01:控制器反写的  当01时将1扇区0块原管理卡信息改成用户卡内容 | 
 |  |  |  | 
 |  |  |     public int totalElectric;//总用电量位 底位在前,高位在后  1位小数点  含1位小数点的整数 | 
 |  |  |  | 
 |  |  |     public int getTotalElectric() { | 
 |  |  |         return totalElectric; | 
 |  |  |     public int getArerNumber() { | 
 |  |  |         return arerNumber; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public byte getType() { | 
 |  |  |         return type; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setType(byte type) { | 
 |  |  |         this.type = type; | 
 |  |  |     public void setArerNumber(int arerNumber) { | 
 |  |  |         this.arerNumber = arerNumber; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getUserCard() { | 
 |  |  | 
 |  |  |         this.userCard = userCard; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public byte getCardWriteState() { | 
 |  |  |         return cardWriteState; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setCardWriteState(byte cardWriteState) { | 
 |  |  |         this.cardWriteState = cardWriteState; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static ManageCard getBean(List<byte[]> data) { | 
 |  |  |  | 
 |  |  |         if (data != null) { | 
 |  |  |             ManageCard manageCard = new ManageCard(); | 
 |  |  |  | 
 |  |  |             byte[] zero = data.get(0); | 
 |  |  |             byte[] passWordByte = new byte[4]; | 
 |  |  |             System.arraycopy(zero, 5, passWordByte, 0, passWordByte.length); | 
 |  |  |             manageCard.setUserCard(HexUtil.bytesToHex(passWordByte)); | 
 |  |  |             manageCard.setType(zero[9]); | 
 |  |  |             byte[] totalElectricByte = new byte[4]; | 
 |  |  |             System.arraycopy(zero, 10, totalElectricByte, 0, totalElectricByte.length); | 
 |  |  |             manageCard.totalElectric = HexUtil.get16To10LowHightByBytes(totalElectricByte); | 
 |  |  |             return manageCard; | 
 |  |  |             try { | 
 |  |  |                 ManageCard manageCard = new ManageCard(); | 
 |  |  |                 byte[] zero = data.get(0); | 
 |  |  |                 byte[] arerNumberByte = new byte[4]; | 
 |  |  |                 System.arraycopy(zero, 1, arerNumberByte, 0, arerNumberByte.length); | 
 |  |  |                 manageCard.arerNumber = HexUtil.get16To10LowHightByBytes(arerNumberByte); | 
 |  |  |                 byte[] passWordByte = new byte[4]; | 
 |  |  |                 System.arraycopy(zero, 5, passWordByte, 0, passWordByte.length); | 
 |  |  |                 manageCard.setUserCard(HexUtil.bytesToHex(passWordByte)); | 
 |  |  |                 manageCard.setCardWriteState(zero[13]); | 
 |  |  |                 return manageCard; | 
 |  |  |             } catch (Exception e) { | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  | 
 |  |  |             byte[] data = new byte[16]; | 
 |  |  |             data[0] = HexUtil.hexToByte(cardType); | 
 |  |  |  | 
 |  |  |             byte[] cardDataByte = HexUtil.hexToByteArray(cardData); | 
 |  |  |             System.arraycopy(cardDataByte, 0, data, 1, cardDataByte.length); | 
 |  |  |             //区域号 | 
 |  |  |             byte[] arerNumberBytes = new byte[4]; | 
 |  |  |             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[] userCardByts = HexUtil.hexToByteArray(userCard); | 
 |  |  |             if (userCard != null) { | 
 |  |  |                 System.arraycopy(userCardByts, 0, data, 5, userCardByts.length); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             data[13] = cardWriteState; | 
 |  |  |             data[15] = getByteSum(data); | 
 |  |  |             return data; | 
 |  |  |         } |