From 86719a90118b4b458ae593b53457f23c11ee8d44 Mon Sep 17 00:00:00 2001
From: Administrator <zhubaomin>
Date: 星期四, 25 七月 2024 15:27:52 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java
index f3f8dfc..6819327 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java
@@ -511,9 +511,9 @@
 			for (int i = 0; i < 4; i++) {
 				bs[from + i] = Integer.valueOf(value & 0xff).byteValue();// 灏嗘渶浣庝綅淇濆瓨鍦ㄤ綆瀛楄妭
 				value = value >> 8; // 鍚戝彸绉�8浣�
-			if(value == 0){
-				break ;
-			}
+				if(value == 0){
+					break ;
+				}
 			}
 		} else {
 			throw new Exception("int2Bytes鏃舵暟缁勮秺鐣�");
@@ -1035,6 +1035,31 @@
 	    return fromIndex ;
 	}
 
+	/**
+	 * 鍗佸叚杩涘埗杞瓧鑺傛暟缁�
+	 * @param hex the hex string
+	 * @return 杩斿洖 byte[]
+	 */
+	public static int hex2Bytes_LE(String hex, byte[] bs, int fromIndex) {
+		if (hex == null || hex.equals("")) {
+			return fromIndex;
+		}
+		hex = hex.toUpperCase(Locale.ENGLISH);
+		int length = hex.length() / 2;
+		char[] hexChars = hex.toCharArray();
+		byte[] d = new byte[length];
+		for (int i = 0; i < length; i++) {
+			int pos = i * 2;
+			d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
+		}
+		for(int i = 0 ; i < d.length; i++){
+			bs[fromIndex++] = d[(d.length - 1) - i] ;
+		}
+		return fromIndex ;
+	}
+
+
+
 	private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
 //	/**
 //	 * 灏哹yte[]杞崲涓�16杩涘埗瀛楃涓�
@@ -1185,6 +1210,31 @@
 	}
 
 	/**
+	 * 灏忕妯″紡銆婃暟鎹綆浣嶅湪鏁扮粍浣庡瓧鑺傘��
+	 * 鏁村舰杞垚BCD缂栫爜锛屽瓧鑺傞『搴忔槸鍊掔殑
+	 * @param i
+	 * @param bs
+	 * @param from
+	 * @return 杩斿洖
+	 */
+	public static void int2BCD_LE(int i, byte[] bs, int from)throws Exception {
+		String str = "" + i;
+		byte[] b = null;
+		if (str.length() % 2 == 0) {
+			b = new byte[str.length() / 2];
+		} else {
+			b = new byte[(str.length() / 2) + 1];
+		}
+		encodeBCD_LE(str, b, 0, b.length);
+
+		int len = bs.length ;
+		int bLen = b.length ;
+		for(int j = 0; (j < len && j < bLen); j++){
+			bs[from + j] = b[j] ;
+		}
+	}
+
+	/**
 	 * 澶х妯″紡銆婃暟鎹綆浣嶅湪鏁扮粍楂樺瓧鑺傘��
 	 * 闀挎暣褰㈣浆鎴怋CD缂栫爜
 	 * @param l

--
Gitblit v1.8.0