feat: 添加slrs业务子项目 修改问题文件
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.adc.da.util;
|
||||
|
||||
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
public class UUIDUtils {
|
||||
|
||||
public static Snowflake snowflake;
|
||||
|
||||
public static Snowflake getSnowflake() {
|
||||
return snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务编码
|
||||
*/
|
||||
private static long serverCode;
|
||||
|
||||
/**
|
||||
* 中心端编码
|
||||
*
|
||||
*/
|
||||
private static long appCenter;
|
||||
|
||||
@Value("${application.code}")
|
||||
public static void setServerCode(long serverCode) {
|
||||
UUIDUtils.serverCode = serverCode;
|
||||
}
|
||||
|
||||
@Value("${application.center}")
|
||||
public static void setAppCenter(long appCenter) {
|
||||
UUIDUtils.appCenter = appCenter;
|
||||
}
|
||||
|
||||
|
||||
public static void setSnowflake(Snowflake snowflake) {
|
||||
IdUtil.getSnowflake(serverCode,appCenter);
|
||||
}
|
||||
|
||||
public static String randomUUID10() {
|
||||
return RandomUtil.randomString(10);
|
||||
}
|
||||
|
||||
public static String randomUUID20() {
|
||||
return RandomUtil.randomString(20);
|
||||
}
|
||||
|
||||
public static String randomUUID(int length) {
|
||||
return RandomUtil.randomString(length);
|
||||
}
|
||||
|
||||
public static String randomSnowflakeID(){
|
||||
return snowflake.nextIdStr();
|
||||
}
|
||||
|
||||
|
||||
public static String getUUIDPath(String uuid){
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append("/");
|
||||
builder.append((uuid.substring(0, 3).hashCode())%100+"").append("/");
|
||||
builder.append((uuid.substring(7,10).hashCode())%100+"").append("/");
|
||||
builder.append((uuid.substring(11,14).hashCode())%100+"").append("/");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String getAttTable(){
|
||||
int nextInt = RandomUtil.randomInt(10)+1;
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append("ATT_FILE_").append(String.format("%02d", nextInt));
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user