mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 13:42:07 +08:00
小板编号前五位补0修改从1开始
This commit is contained in:
+13
@@ -70,6 +70,19 @@ public class SnowflakeIdWorker3rd {
|
||||
return Integer.parseInt(formatted_date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成小板短编号。
|
||||
*
|
||||
* <p>编号以固定的 {@code 1} 开始,再拼接五位组织编号,避免其他系统截取前五位时出现前导零。</p>
|
||||
*
|
||||
* @param organId 组织编号
|
||||
* @param id 小板序列号
|
||||
* @return 小板短编号
|
||||
*/
|
||||
public static String generatePlateNo(Long organId, long id) {
|
||||
return "1" + String.format("%05d", organId) + obtainingTime() + Long.toString(id).substring(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得下一个ID (该方法是线程安全)
|
||||
*
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.cf.imes.framework.id.core.util;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class SnowflakeIdWorker3rdTest {
|
||||
|
||||
@Test
|
||||
void generatePlateNoStartsWithOneAndKeepsFiveDigitOrganId() {
|
||||
String plateNo = SnowflakeIdWorker3rd.generatePlateNo(7L, 123456L);
|
||||
|
||||
assertTrue(plateNo.startsWith("1"));
|
||||
assertEquals("00007", plateNo.substring(1, 6));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user