| package com.dayu.qiheonlinelibrary.card; | 
|   | 
| import com.dayu.baselibrary.tools.HexUtil; | 
| import com.dayu.qiheonlinelibrary.dao.QHOnLineAppDatabase; | 
| import com.dayu.qiheonlinelibrary.utils.CardCommon; | 
|   | 
|   | 
| import java.io.Serializable; | 
| import java.util.List; | 
|   | 
| /** | 
|  * Copyright (C), 2023, | 
|  * Author: zuo | 
|  * Date: 2023-11-08 10:19 | 
|  * Description: 管理卡  第1扇区 0块 | 
|  */ | 
| public class ManageCard extends BaseCard implements Serializable { | 
|     public String cardType = CardCommon.MANAGE_CRAD;//卡类型 | 
|     public int arerNumber;//区域号(底位在前高位在后) | 
|   | 
|   | 
|     /** | 
|      * M1卡的0扇区0块通常用于存储一些基本的卡片信息 | 
|      * 0-4字节是卡号 | 
|      */ | 
|     public String userCard; //用户卡号 | 
|   | 
|     public byte cardWriteState;//当前状态 00:充值管理机写 01:控制器反写的  当01时将1扇区0块原管理卡信息改成用户卡内容 | 
|   | 
|   | 
|     public int getArerNumber() { | 
|         return arerNumber; | 
|     } | 
|   | 
|     public void setArerNumber(int arerNumber) { | 
|         this.arerNumber = arerNumber; | 
|     } | 
|   | 
|     public String getUserCard() { | 
|         return userCard; | 
|     } | 
|   | 
|     public void setUserCard(String userCard) { | 
|         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) { | 
|             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; | 
|     } | 
|   | 
|   | 
|     public byte[] toByte(QHOnLineAppDatabase QHOnLineAppDatabase) { | 
|         setCardData(QHOnLineAppDatabase, cardType); | 
|         Zero zero = new Zero(); | 
|         return zero.toByte(); | 
|     } | 
|   | 
|     public class Zero { | 
|         public byte[] toByte() { | 
|             byte[] data = new byte[16]; | 
|             data[0] = HexUtil.hexToByte(cardType); | 
|   | 
|             //区域号 | 
|             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; | 
|         } | 
|   | 
|     } | 
|   | 
| } |