liujie
2026-04-09 3adfcc5a9829a0231bf95c1a7e3aaad1d28b05d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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;
    }
 
}