diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/util/PropertyUtils.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/util/PropertyUtils.java index 47f5a81..598ec8e 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/util/PropertyUtils.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/util/PropertyUtils.java @@ -1,6 +1,7 @@ package com.chinaunicom.mall.ebtp.common.util; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.RandomUtil; import org.springframework.beans.factory.annotation.Value; /** @@ -30,15 +31,17 @@ public class PropertyUtils { * @return */ public static String getSnowflakeId() { - long l = IdUtil.getSnowflake(WORKER_ID, DATACENTER_ID).nextId(); - return String.valueOf(l); + return String.valueOf(getSnowflakeLongId()); } + /** * 生成雪花id * * @return */ public static long getSnowflakeLongId() { - return IdUtil.getSnowflake(WORKER_ID, DATACENTER_ID).nextId(); + long workerId = RandomUtil.getRandom().nextLong(31); + long datacenterId = RandomUtil.getRandom().nextLong(31); + return IdUtil.getSnowflake(workerId, datacenterId).nextId(); } }