|
|
|
@ -21,6 +21,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.text.NumberFormat; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.time.Instant; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.*; |
|
|
|
@ -289,14 +290,20 @@ public class CommonUtil {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getHaxCodeByLong(String str,int changdu){ |
|
|
|
|
long time = new Date().getTime(); |
|
|
|
|
int hashValue = (str+time).hashCode(); // 获取哈希值(32位)
|
|
|
|
|
// 将32位哈希值转换为6位长度的纯数字形式
|
|
|
|
|
String s = Math.abs(hashValue) + ""; |
|
|
|
|
String substring = s.substring(0, changdu); |
|
|
|
|
return substring; |
|
|
|
|
// 计算输入字符串的哈希值
|
|
|
|
|
int hash = str.hashCode(); |
|
|
|
|
|
|
|
|
|
// 结合当前时间戳和哈希值作为种子
|
|
|
|
|
long seed = Instant.now().toEpochMilli() ^ hash; |
|
|
|
|
|
|
|
|
|
// 使用种子生成一个唯一的数字
|
|
|
|
|
long uniqueNumber = Math.abs(seed) % (long)Math.pow(10, changdu); |
|
|
|
|
|
|
|
|
|
// 将生成的数字转换为字符串,并确保长度正确
|
|
|
|
|
return String.format("%0" + changdu + "d", uniqueNumber); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Date addDate(Date date, int second) { |
|
|
|
|
if(Objects.isNull(date)){ |
|
|
|
|
return null; |
|
|
|
|