From d20d38e22b06559d758c568769017e2acf632583 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期三, 23 四月 2025 14:06:48 +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/CreateRandom.java | 121 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 121 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java
new file mode 100644
index 0000000..38a13ca
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java
@@ -0,0 +1,121 @@
+package com.dy.common.util;
+
+import java.util.Random;
+
+@SuppressWarnings("unused")
+public class CreateRandom {
+
+ public static int random(int max, int min){
+ return new Random().nextInt(max) % (max - min + 1) + min;
+ }
+
+ /*
+ public static void main(String[] args) {
+// System.out.println(CreateRandom.random(1, 0));
+// System.out.println(CreateRandom.random(2, 0));
+// System.out.println(CreateRandom.random(3, 0));
+// System.out.println(CreateRandom.random(4, 0));
+// System.out.println(CreateRandom.random(5, 0));
+// System.out.println(CreateRandom.random(100, 0));
+// System.out.println(CreateRandom.random(1256, 1234));
+ System.out.println("=======================");
+ for(int i = 0 ; i < 100; i++){
+ System.out.println(create_between(10, 100));
+ }
+ }
+ */
+
+
+ /**
+ * 4浣嶉殢鏈烘暟鎹�
+ * @return 闅忔満鏁�
+ */
+ public static int Random_4(){
+ return new Random().nextInt(9999) % (9999 - 1000 + 1) + 1000;
+ }
+ /**
+ * 5浣嶉殢鏈烘暟鎹�
+ * @return 闅忔満鏁�
+ */
+ public static int Random_5(){
+ return new Random().nextInt(99999) % (99999 - 10000 + 1) + 10000;
+ }
+ /**
+ * 6浣嶉殢鏈烘暟鎹�
+ * @return 闅忔満鏁�
+ */
+ public static int Random_6(){
+ return new Random().nextInt(999999) % (999999 - 100000 + 1) + 100000;
+ }
+
+
+ /**
+ * 鍒涘缓scape浣嶉殢鏈烘暟
+ * @param scape 浣嶆暟
+ * @return 闅忔満鏁�
+ */
+ public String create(int scape){
+ if(scape < 1){
+ scape = 6 ;
+ }
+ double d = Math.random();
+ String s = String.valueOf(d);
+ int index ;
+ String ss ;
+ try{
+ index = s.indexOf('.') + 1;
+ ss = s.substring(index , index + scape);
+ } catch(Exception e){
+ ss = "740414";
+ }
+ return ss ;
+ }
+
+ /**
+ * 鍒涘缓涓や釜鏁存暟涔嬮棿鐨勯殢鏈烘暟
+ * @param min 鏈�灏忔暟
+ * @param max 鏈�澶ф暟
+ * @return 闅忔満鏁�
+ */
+ public static int create_between(int min , int max){
+ if(max < min){
+ return min ;
+ }
+ if(max - min < min/2){
+ return min ;
+ }
+ int len = String.valueOf(min).length() ;
+ String s = String.valueOf(Math.random() * 10000000);
+ s = s.substring(0 ,len) ;
+ int n = Integer.parseInt(s) ;
+ if(n < min || n > max){
+ n = create_between(min , max) ;
+ }
+ return n ;
+ }
+
+
+ /**
+ * 寰楀埌涓�涓皬浜巑ax鐨勯殢鏈烘暟
+ * @param max 鏈�澶ф暟
+ * @return 闅忔満鏁�
+ */
+ public int create_less(int max){
+ if(max > 9){
+ max = 9 ;
+ }
+ double d = Math.random();
+ int n = 0;
+ int m;
+ String s = String.valueOf(d);
+ for(int i = 4 ; i < s.length() ; i++){
+ m = Integer.parseInt(s.charAt(i)+"");
+ if(m < max){
+ n = m ;
+ break ;
+ }
+ }
+ return n ;
+ }
+
+}
--
Gitblit v1.8.0