From 8e51195319ea210e7ba06aabdabc40d64df14b08 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期日, 07 四月 2024 17:58:17 +0800
Subject: [PATCH] fix:出场车辆新增判断是否支付过的接口

---
 src/main/java/com/boying/util/StringUtil.java |  182 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 182 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/boying/util/StringUtil.java b/src/main/java/com/boying/util/StringUtil.java
index ce93eb1..929bd9c 100644
--- a/src/main/java/com/boying/util/StringUtil.java
+++ b/src/main/java/com/boying/util/StringUtil.java
@@ -1,8 +1,15 @@
 package com.boying.util;
 
+import java.util.Arrays;
 import java.util.UUID;
 
 public class StringUtil {
+
+    /** 16杩涘埗涓殑瀛楃闆� */
+    private static final String HEX_CHAR = "0123456789ABCDEF";
+
+    /** 16杩涘埗涓殑瀛楃闆嗗搴旂殑瀛楄妭鏁扮粍 */
+    private static final byte[] HEX_STRING_BYTE = HEX_CHAR.getBytes();
 
     public static boolean isNullOrEmpty(String str) {
         if (null == str || "".equalsIgnoreCase(str.trim())
@@ -11,8 +18,183 @@
         }
         return false;
     }
+    public static byte[] convertNum(String s){
+        String[] split = s.split("-");
+        byte[] bytes = new byte[split.length];
+        for (int i = 0; i < split.length; i++) {
+            String s1 = split[i];
+            byte b = Byte.parseByte("0x"+s1);
+            bytes[i]=b;
+        }
+        return bytes;
+    }
+
+    public static String toStr(String[] strs){
+        String s = Arrays.toString(strs);
+        String substring = s.substring(1, s.length() - 1);
+        String s1 = substring.replaceAll(",", "");
+        String s2 = s1.replaceAll(" ", "");
+        return s2;
+    }
+
+    public static byte[] toBytes(String strs){
+        String[] split = strs.split("-");
+        byte[] bytes = new byte[split.length];
+        for (int i = 0; i < split.length; i++) {
+            String s = split[i];
+            bytes[i] = (byte) Byte.parseByte(s);
+        }
+        return bytes;
+    }
+
+    public static byte[] hex2Byte(String hex) {
+        System.out.println();
+        String[] parts = hex.split("-");
+        byte[] bytes = new byte[parts.length];
+        for (int i = 0; i < parts.length; i++) {
+            bytes[i] = (byte) (Integer.parseInt(parts[i],10));
+            System.out.print(bytes[i]+ " ");
+        }
+        return bytes;
+    }
 
     public static String getUUID() {
         return UUID.randomUUID().toString().replaceAll("-", "");
     }
+
+    /**
+     * 灏嗘寚瀹歜yte鏁扮粍浠�16杩涘埗鐨勫舰寮忔墦鍗板埌鎺у埗鍙�
+     *
+     * @param hint String
+     * @param b    byte[]
+     * @return void
+     */
+    public static void printHexString(String hint, byte[] b) {
+        System.out.print(hint);
+        for (int i = 0; i < b.length; i++) {
+            String hex = Integer.toHexString(b[i] & 0xFF);
+            if (hex.length() == 1) {
+                hex = '0' + hex;
+            }
+            System.out.print(hex.toUpperCase() + " ");
+        }
+    }
+
+    /**
+     * @param b byte[]
+     * @return String
+     */
+    public static String Bytes2HexString(byte[] b) {
+        String ret = "";
+        for (int i = 0; i < b.length; i++) {
+            String hex = Integer.toHexString(b[i] & 0xFF);
+            if (hex.length() == 1) {
+                hex = '0' + hex;
+            }
+            ret += " 0x" + hex.toUpperCase();
+        }
+        return ret;
+    }
+
+    /**
+     * 灏嗘寚瀹氬瓧绗︿覆src锛屼互姣忎袱涓瓧绗﹀垎鍓茶浆鎹负16杩涘埗褰㈠紡 濡傦細"2B44EFD9" 鈥�> byte[]{0x2B, 0脳44, 0xEF,
+     * 0xD9}
+     *
+     * @param src String
+     * @return byte[]
+     */
+    public static byte[] HexString2Bytes(String src) {
+        if (null == src || 0 == src.length()) {
+            return null;
+        }
+       // String s1 = src.replaceAll("-", "");
+        byte[] ret = new byte[src.length() / 2];
+        byte[] tmp = src.getBytes();
+        for (int i = 0; i < (tmp.length / 2); i++) {
+            ret[i] = (byte)uniteBytes(tmp[i * 2], tmp[i * 2 + 1]);
+        }
+        return ret;
+    }
+
+    /**
+     * 灏嗕袱涓狝SCII瀛楃鍚堟垚涓�涓瓧鑺傦紱 濡傦細"EF"鈥�> 0xEF
+     *
+     * @param src0 byte
+     * @param src1 byte
+     * @return byte
+     */
+    public static byte uniteBytes(byte src0, byte src1) {
+        byte _b0 = Byte.decode("0x" + new String(new byte[]{src0})).byteValue();
+        _b0 = (byte) (_b0 << 4);
+        byte _b1 = Byte.decode("0x" + new String(new byte[]{src1})).byteValue();
+        byte ret = (byte) (_b0 ^ _b1);
+        return ret;
+    }
+
+    /**
+     * 10杩涘埗瀛楄妭鏁扮粍杞崲涓�16杩涘埗瀛楄妭鏁扮粍
+     *
+     * byte鐢ㄤ簩杩涘埗琛ㄧず鍗犵敤8浣嶏紝16杩涘埗鐨勬瘡涓瓧绗﹂渶瑕佺敤4浣嶄簩杩涘埗浣嶆潵琛ㄧず锛屽垯鍙互鎶婃瘡涓猙yte
+     * 杞崲鎴愪袱涓浉搴旂殑16杩涘埗瀛楃锛屽嵆鎶奲yte鐨勯珮4浣嶅拰浣�4浣嶅垎鍒浆鎹㈡垚鐩稿簲鐨�16杩涘埗瀛楃锛屽啀鍙栧搴�16杩涘埗瀛楃鐨勫瓧鑺�
+     *
+     * @param b 10杩涘埗瀛楄妭鏁扮粍
+     * @return 16杩涘埗瀛楄妭鏁扮粍
+     */
+    public static byte[] byte2hex(byte[] b) {
+        int length = b.length;
+        byte[] b2 = new byte[length << 1];
+        int pos;
+        for(int i=0; i<length; i++) {
+            pos = 2*i;
+            b2[pos] = HEX_STRING_BYTE[(b[i] & 0xf0) >> 4];
+            b2[pos+1] = HEX_STRING_BYTE[b[i] & 0x0f];
+        }
+        return b2;
+    }
+
+    /**
+     * 16杩涘埗瀛楄妭鏁扮粍杞崲涓�10杩涘埗瀛楄妭鏁扮粍
+     *
+     * 涓や釜16杩涘埗瀛楄妭瀵瑰簲涓�涓�10杩涘埗瀛楄妭锛屽垯灏嗙涓�涓�16杩涘埗瀛楄妭瀵瑰簲鎴�16杩涘埗瀛楃琛ㄤ腑鐨勪綅缃�(0~15)骞跺悜宸︾Щ鍔�4浣嶏紝
+     * 鍐嶄笌绗簩涓�16杩涘埗瀛楄妭瀵瑰簲鎴�16杩涘埗瀛楃琛ㄤ腑鐨勪綅缃�(0~15)杩涜鎴栬繍绠楋紝鍒欏緱鍒板搴旂殑10杩涘埗瀛楄妭
+     * @param b 10杩涘埗瀛楄妭鏁扮粍
+     * @return 16杩涘埗瀛楄妭鏁扮粍
+     */
+    public static byte[] hex2byte(byte[] b) {
+        if(b.length%2 != 0) {
+            throw new IllegalArgumentException("byte array length is not even!");
+        }
+
+        int length = b.length >> 1;
+        byte[] b2 = new byte[length];
+        int pos;
+        for(int i=0; i<length; i++) {
+            pos = i << 1;
+            b2[i] = (byte) (HEX_CHAR.indexOf( b[pos] ) << 4 | HEX_CHAR.indexOf( b[pos+1] ) );
+        }
+        return b2;
+    }
+
+    /**
+     * 灏�16杩涘埗瀛楄妭鏁扮粍杞垚10杩涘埗瀛楃涓�
+     * @param b 16杩涘埗瀛楄妭鏁扮粍
+     * @return 10杩涘埗瀛楃涓�
+     */
+    public static String hex2Str(byte[] b) {
+        return new String(hex2byte(b));
+    }
+
+    /**
+     * 灏�10杩涘埗瀛楄妭鏁扮粍杞垚16杩涘埗瀛楃涓�
+     * @param b 10杩涘埗瀛楄妭鏁扮粍
+     * @return 16杩涘埗瀛楃涓�
+     */
+    public static String byte2HexStr(byte[] b) {
+        return Integer.toHexString(Integer.parseInt(new String(b)));
+    }
+
+
+    public static void main(String[] args) {
+
+    }
 }

--
Gitblit v1.9.1