zhangherong
2025-07-11 0c929802702bca00b24b8c74f52723b21ba5b4c2
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
package org.jeecg.common.util;
 
import org.apache.commons.lang3.StringUtils;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
 
public class OrgCodeSplitUtil {
    public static List<String> splitOrgCode(String orgCode) {
        if(StringUtils.isBlank(orgCode)) {
            return Collections.emptyList();
        }
        if(orgCode.length() % 3 != 0) {
            return Collections.emptyList();
        }
        List<String> list = new ArrayList<>();
        int length = orgCode.length();
        for (int i = length; i > 0; i -= 3) {
            list.add(orgCode.substring(0, i));
        }
        return list;
    }
 
    public static void main(String[] args) {
        String orgCode = "A01A01A01";
        List<String> list = splitOrgCode(orgCode);
        System.out.println(list);
    }
}