diff --git a/ktg-generator/src/main/java/com/ktg/generator/util/MultiModuleCodeGenerator.java b/ktg-generator/src/main/java/com/ktg/generator/util/MultiModuleCodeGenerator.java index 45ca70e..f73c164 100644 --- a/ktg-generator/src/main/java/com/ktg/generator/util/MultiModuleCodeGenerator.java +++ b/ktg-generator/src/main/java/com/ktg/generator/util/MultiModuleCodeGenerator.java @@ -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")); +// } } }