package com.estate.expert.admin.utils;
|
|
/**
|
* @ClassName AlphaCodeUtils
|
* @Description
|
* @Author daisyli
|
* @Date 2023/9/8
|
**/
|
public class AlphaCodeUtils {
|
|
/**
|
* 获取下一个字母
|
* @param current 当前字母
|
* @return 下一个字母
|
*/
|
public static String getNext(String current) {
|
if (current == null || current.isEmpty()) {
|
return "A";
|
}
|
char[] chars = current.toCharArray();
|
int index = chars.length - 1;
|
while (index >= 0 && chars[index] == 'Z') {
|
chars[index] = 'A';
|
index--;
|
}
|
if (index < 0) {
|
return "A" + new String(chars);
|
} else {
|
chars[index]++;
|
return new String(chars);
|
}
|
}
|
|
/**
|
* 获取下一个字母
|
* @param current 当前字母
|
* @return 下一个字母
|
*/
|
public static String getSubNext(String current) {
|
if (current == null || current.isEmpty()) {
|
return "000";
|
}
|
|
String arr[] = current.split("-");
|
int lastIndex = current.lastIndexOf("-");
|
int index = arr.length - 1;
|
String result = current.substring(0, lastIndex + 1);
|
|
int num = Integer.parseInt(arr[index]);
|
num++;
|
|
if (num < 10) {
|
result = result + "00" + num;
|
} else if (num < 100) {
|
result = result + "0" + num;
|
} else {
|
result = result + "" + num;
|
}
|
|
return result;
|
}
|
|
}
|