//numer为一次生成流水码的总数,三位默认39303 从001-zzz
private static List<String> generateCode(int number) {
List<String> result=new ArrayList<>();
int j=1;
for (int i=1 ;i<=number;i=j){
StringBuilder streamCode = new StringBuilder();
while (i > 0) {
int remainder = i % 34;
char digit = getCharForDigit(remainder);
streamCode.insert(0, digit);
i = i / 34;
}
// 补齐到3位
while (streamCode.length() < 3) {
streamCode.insert(0, '0');
}
result.add(streamCode.toString());
++j;
}
return result;
}
private static char getCharForDigit(int digit) {
char[] charSet = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K',
'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z'};
if (digit >= 0 && digit < charSet.length) {
return charSet[digit];
} else {
throw new IllegalArgumentException("Invalid digit: " + digit);
}
}