From b6779014ad6b2627d0a7e4d170d918d001fc03db Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期三, 08 五月 2024 10:44:01 +0800
Subject: [PATCH] 1.修复16进制低位在前高位在后转换成10进制时的bug 2.完成充值相关功能 3.优化导出记录相关信息

---
 qihealonelibrary/src/main/java/com/dayu/qihealonelibrary/card/UserCard.java |   68 ++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/qihealonelibrary/src/main/java/com/dayu/qihealonelibrary/card/UserCard.java b/qihealonelibrary/src/main/java/com/dayu/qihealonelibrary/card/UserCard.java
index ce0fc24..7ae89d7 100644
--- a/qihealonelibrary/src/main/java/com/dayu/qihealonelibrary/card/UserCard.java
+++ b/qihealonelibrary/src/main/java/com/dayu/qihealonelibrary/card/UserCard.java
@@ -20,13 +20,13 @@
     public int arerNumber;//鍖哄煙鍙�(搴曚綅鍦ㄥ墠楂樹綅鍦ㄥ悗)
 
     public int deviceNumberl;//璁惧缂栧彿(搴曚綅鍦ㄥ墠楂樹綅鍦ㄥ悗)
-    public byte rechargeTimes;//鍏呭�兼鏁�
+    public short rechargeTimes;//鍏呭�兼鏁�
 
     public int totalWater;//鐢ㄦ埛鎬荤敤姘撮噺  搴曚綅鍦ㄥ墠锛岄珮浣嶅湪鍚�2浣嶅皬鏁扮偣  鍚袱涓皬鏁扮偣鐨勬暣鏁�
 
     public int totalElectric;//鎬荤敤鐢甸噺浣� 搴曚綅鍦ㄥ墠锛岄珮浣嶅湪鍚�  1浣嶅皬鏁扮偣  鍚�1浣嶅皬鏁扮偣鐨勬暣鏁�
 
-    public int balance;//鍓╀綑閲戦 搴曚綅鍦ㄥ墠  2浣嶅皬鏁扮偣锛屽崟浣嶅厓
+    public int balance;//鍓╀綑閲戦 搴曚綅鍦ㄥ墠  2浣嶅皬鏁扮偣锛屽崟浣嶅垎
 
     public int surplusWater;//鍓╀綑姘撮噺 搴曚綅鍦ㄥ墠  2浣嶅皬鏁扮偣銆�鍗曚綅绔嬫柟绫�
 
@@ -48,32 +48,31 @@
 
             byte[] arerNumberByte = new byte[2];
             System.arraycopy(zero, 1, arerNumberByte, 0, arerNumberByte.length);
-            userCard.arerNumber = HexUtil.get16to10LowHigh(HexUtil.bytesToHex(arerNumberByte));
+            userCard.arerNumber =  HexUtil.get16To10LowHightByBytes(arerNumberByte);
 
             byte[] deviceNumberlByte = new byte[2];
             System.arraycopy(zero, 3, deviceNumberlByte, 0, deviceNumberlByte.length);
-            userCard.deviceNumberl =  HexUtil.get16to10LowHigh(HexUtil.bytesToHex(deviceNumberlByte));
+            userCard.deviceNumberl =  HexUtil.get16To10LowHightByBytes(deviceNumberlByte);
 
             userCard.rechargeTimes = HexUtil.hexToByte(HexUtil.byteToHex(zero[5]));
 
             byte[] totalWaterByte = new byte[4];
-            System.arraycopy(zero, 3, totalWaterByte, 0, totalWaterByte.length);
-            userCard.totalWater = HexUtil.get16to10LowHigh(HexUtil.bytesToHex(totalWaterByte));
+            System.arraycopy(zero, 6, totalWaterByte, 0, totalWaterByte.length);
+            userCard.totalWater = HexUtil.get16To10LowHightByBytes(totalWaterByte);
 
             byte[] totalElectricByte = new byte[4];
-            System.arraycopy(zero, 3, totalElectricByte, 0, totalElectricByte.length);
-            userCard.totalElectric = HexUtil.get16to10LowHigh(HexUtil.bytesToHex(totalElectricByte));
+            System.arraycopy(zero, 10, totalElectricByte, 0, totalElectricByte.length);
+            userCard.totalElectric = HexUtil.get16To10LowHightByBytes(totalElectricByte);
 
             //绗�1鍧楄В鏋�
             byte[] one = data.get(1);
-
             byte[] balanceByte = new byte[4];
             System.arraycopy(one, 0, balanceByte, 0, balanceByte.length);
-            userCard.balance = HexUtil.get16to10LowHigh(HexUtil.bytesToHex(balanceByte));
+            userCard.balance =HexUtil.get16To10LowHightByBytes(balanceByte);
 
             byte[] surplusWaterByte = new byte[4];
             System.arraycopy(one, 4, surplusWaterByte, 0, surplusWaterByte.length);
-            userCard.surplusWater = HexUtil.get16to10LowHigh(HexUtil.bytesToHex(surplusWaterByte));
+            userCard.surplusWater = HexUtil.get16To10LowHightByBytes(surplusWaterByte);
 
             byte[] rechargeDateByte = new byte[3];
             System.arraycopy(one, 12, rechargeDateByte, 0, rechargeDateByte.length);
@@ -104,21 +103,35 @@
             try {
                 byte[] data = new byte[16];
                 data[0] = HexUtil.hexToByte(cardType);
-                byte[] arerNumberBytes = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(arerNumber));
+                //鍖哄煙鍙�
+                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 = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(deviceNumberl));
+                //璁惧缂栧彿
+                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 = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(totalWater));
+
+                //鐢ㄦ埛鎬荤敤姘撮噺
+                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 = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(totalElectric));
+                //鎬荤敤鐢甸噺浣�
+                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);
                 }
@@ -143,16 +156,19 @@
 
 
             try {
-                byte[] balanceBytes = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(balance));
+                byte[] balanceBytes = new byte[4];
+                byte[] balanceDatas = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(balance));
+                System.arraycopy(balanceDatas, 0, balanceBytes, 0, balanceDatas.length);
                 if (balanceBytes != null) {
                     System.arraycopy(balanceBytes, 0, data, 0, balanceBytes.length);
                 }
 
-                byte[] surplusWaterBytes = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(surplusWater));
+                byte[] surplusWaterBytes = new byte[4];
+                byte[] surplusWaterDatas = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(surplusWater));
+                System.arraycopy(surplusWaterDatas, 0, surplusWaterBytes, 0, surplusWaterDatas.length);
                 if (surplusWaterBytes != null) {
-                    System.arraycopy(surplusWaterBytes, 0, data, 0, surplusWaterBytes.length);
+                    System.arraycopy(surplusWaterBytes, 0, data, 4, surplusWaterBytes.length);
                 }
-
 
                 if (rechargeDate != null) {
                     // 鑾峰彇骞淬�佹湀銆佹棩銆佹椂銆佸垎銆佺
@@ -186,14 +202,18 @@
             byte[] data = new byte[16];
 
             try {
-                byte[] balanceBytes = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(balance));
+                byte[] balanceBytes = new byte[4];
+                byte[] balanceDatas = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(balance));
+                System.arraycopy(balanceDatas, 0, balanceBytes, 0, balanceDatas.length);
                 if (balanceBytes != null) {
                     System.arraycopy(balanceBytes, 0, data, 0, balanceBytes.length);
                 }
 
-                byte[] surplusWaterBytes = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(surplusWater));
+                byte[] surplusWaterBytes = new byte[4];
+                byte[] surplusWaterDatas = HexUtil.hexToByteArray(HexUtil.get10To16LowHigh(surplusWater));
+                System.arraycopy(surplusWaterDatas, 0, surplusWaterBytes, 0, surplusWaterDatas.length);
                 if (surplusWaterBytes != null) {
-                    System.arraycopy(surplusWaterBytes, 0, data, 0, surplusWaterBytes.length);
+                    System.arraycopy(surplusWaterBytes, 0, data, 4, surplusWaterBytes.length);
                 }
 
                 if (rechargeDate != null) {
@@ -258,11 +278,11 @@
         this.deviceNumberl = deviceNumberl;
     }
 
-    public byte getRechargeTimes() {
+    public short getRechargeTimes() {
         return rechargeTimes;
     }
 
-    public void setRechargeTimes(byte rechargeTimes) {
+    public void setRechargeTimes(short rechargeTimes) {
         this.rechargeTimes = rechargeTimes;
     }
 

--
Gitblit v1.8.0