From 6553439b4b6013f23b7fe60549837b2fd03719b9 Mon Sep 17 00:00:00 2001 From: LJW Date: Fri, 15 Nov 2024 17:05:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=BC=96=E7=A0=81=E7=94=9F=E6=88=90):?= =?UTF-8?q?=20=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/MultiModuleCodeGenerator.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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")); +// } } }