From 1eaa7387085a2bc0f434ba46eb2d61991d42cd3e Mon Sep 17 00:00:00 2001
From: zhanghl <253316343@qq.com>
Date: 星期二, 15 四月 2025 11:51:06 +0800
Subject: [PATCH] 工厂 车间管理

---
 aps-common/aps-common-core/src/main/java/com/aps/common/core/utils/uuid/IdUtils.java |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/aps-common/aps-common-core/src/main/java/com/aps/common/core/utils/uuid/IdUtils.java b/aps-common/aps-common-core/src/main/java/com/aps/common/core/utils/uuid/IdUtils.java
index 892afff..bbaf496 100644
--- a/aps-common/aps-common-core/src/main/java/com/aps/common/core/utils/uuid/IdUtils.java
+++ b/aps-common/aps-common-core/src/main/java/com/aps/common/core/utils/uuid/IdUtils.java
@@ -1,5 +1,9 @@
 package com.aps.common.core.utils.uuid;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicLong;
+
 /**
  * ID鐢熸垚鍣ㄥ伐鍏风被
  * 
@@ -46,4 +50,24 @@
     {
         return UUID.fastUUID().toString(true);
     }
+
+    private static AtomicLong id;
+    /**
+     * 鐢熸垚Long 绫诲瀷鍞竴ID
+     */
+    public synchronized static Long getId() {
+        //濡傛灉闇�瑕佹洿闀� 鎴栬�呮洿澶у啑浣欑┖闂�, 鍙渶瑕� time * 10^n   鍗冲彲
+        //褰撳墠鍙繚璇�1姣 鐢熸垚 10000鏉′笉閲嶅
+        Long time = Long.valueOf(new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()))*10000;
+        if (id == null) {
+            id = new AtomicLong(time);
+            return id.get();
+        }
+        if (time <= id.get()) {
+            id.addAndGet(1);
+        } else {
+            id = new AtomicLong(time);
+        }
+        return id.get();
+    }
 }

--
Gitblit v1.9.3