refactor(编码生成): 规则修改

This commit is contained in:
LJW 2024-11-15 17:05:12 +08:00
parent e599a0cb5d
commit 6553439b4b

View File

@ -3,6 +3,7 @@ package com.ktg.generator.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
@ -35,17 +36,23 @@ public class MultiModuleCodeGenerator {
int currentSequence = moduleSequence.getSequence().incrementAndGet();
// 格式化序列号确保是四位不足的地方用 0 填充
String sequenceStr = String.format("%04d", currentSequence);
// String sequenceStr = String.format("%04d", currentSequence);
int random = new Random().nextInt(9999);
String sequenceStr = String.format("%04d", random);
// 拼接前缀日期和序列号
return modulePrefix + currentDate + sequenceStr;
}
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
System.out.println(generateTaskCode("RKT"));
System.out.println(generateTaskCode("MOD"));
}
int random = new Random().nextInt(9999);
String sequenceStr = String.format("%04d", random);
System.out.println(sequenceStr);
// for (int i = 0; i < 10; i++) {
// System.out.println(generateTaskCode("RKT"));
// System.out.println(generateTaskCode("MOD"));
// }
}
}