From 11f9478b32b710e022c328972fd2e07c72a62df8 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期三, 15 六月 2022 10:56:35 +0800
Subject: [PATCH] 新增生成编号工具

---
 src/main/java/com/hx/util/code/NumberTool.java |  101 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/hx/util/code/NumberTool.java b/src/main/java/com/hx/util/code/NumberTool.java
new file mode 100644
index 0000000..99f0d43
--- /dev/null
+++ b/src/main/java/com/hx/util/code/NumberTool.java
@@ -0,0 +1,101 @@
+package com.hx.util.code;
+
+import com.hx.util.DateUtil;
+import com.hx.util.StringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
+
+import java.util.Date;
+import java.util.Random;
+
+/**鐢熸垚缂栧彿宸ュ叿
+ */
+public class NumberTool {
+
+    /**澶у皬鍐欏瓧姣�*/
+    private static final String LETTER_ARR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    /**澶у皬鍐欏瓧姣嶅拰鏁板瓧*/
+    private static final String LETTER_NUMBER = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+    /**灏忓啓瀛楁瘝*/
+    private static final String LETTER_SMALL = "abcdefghijklmnopqrstuvwxyz";
+    /**澶у啓瀛楁瘝*/
+    private static final String LETTER_BIG = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+
+    /**闅忔満鑾峰ぇ鍐欏瓧姣嶇粍鍚�
+     * @param lengrhCount 闀垮害
+     * @return
+     */
+    public static String letterBig(long lengrhCount){
+        char[] c = LETTER_BIG.toCharArray();
+        Random random = new Random();
+
+        StringBuilder data = new StringBuilder();
+        for( int i = 0; i < lengrhCount; i ++) {
+            data.append(c[random.nextInt(c.length)]);
+        }
+        return data.toString();
+    }
+
+
+    /**闅忔満鑾峰皬鍐欏瓧姣嶇粍鍚�
+     * @param lengrhCount 闀垮害
+     * @return
+     */
+    public static String letterSmall(long lengrhCount){
+        char[] c = LETTER_SMALL.toCharArray();
+        Random random = new Random();
+
+        StringBuilder data = new StringBuilder();
+        for( int i = 0; i < lengrhCount; i ++) {
+            data.append(c[random.nextInt(c.length)]);
+        }
+        return data.toString();
+    }
+
+
+    /**闅忔満鑾峰彇澶у皬鍐欏瓧姣嶅拰鏁板瓧缁勫悎
+     * @param lengrhCount 闀垮害
+     * @return
+     */
+    public static String letterNumber(long lengrhCount){
+        char[] c = LETTER_NUMBER.toCharArray();
+        Random random = new Random();
+
+        StringBuilder data = new StringBuilder();
+        for( int i = 0; i < lengrhCount; i ++) {
+            data.append(c[random.nextInt(c.length)]);
+        }
+        return data.toString();
+    }
+
+    /**闅忔満鑾峰彇澶у皬鍐欏瓧姣嶇粍鍚�
+     * @param lengrhCount 闀垮害
+     * @return
+     */
+    public static String letterRandom(long lengrhCount){
+        char[] c = LETTER_ARR.toCharArray();
+        Random random = new Random();
+
+        StringBuilder data = new StringBuilder();
+        for( int i = 0; i < lengrhCount; i ++) {
+            data.append(c[random.nextInt(c.length)]);
+        }
+        return data.toString();
+    }
+
+    /**闅忔満鐢熸垚瀛楃涓诧紙0-9锛�
+     * @param lengthCount 闀垮害
+     * @return
+     */
+    public static String generateCardNo(long lengthCount) {
+        Random r=new Random();
+        //瀹氫箟鍙橀暱瀛楃涓�
+        StringBuilder str = new StringBuilder();
+        for(int i=0;i<lengthCount;i++){
+            str.append(r.nextInt(10));
+        }
+        return str.toString();
+    }
+
+
+}

--
Gitblit v1.8.0