From ee711d38f66222915bc81332c98af677fa5cd96c Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期二, 16 七月 2024 22:17:02 +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 | 31 ++++++++++++++++++++++++++++--- 1 files changed, 28 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 d0f7034..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鏃舵暟缁勮秺鐣�"); @@ -1210,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