update 修复生成订单bug

This commit is contained in:
Guoqs
2024-05-28 17:53:47 +08:00
parent bbb337cb0b
commit 67413c9883

View File

@@ -1,5 +1,6 @@
package com.jsowell.common.util.id;
import com.jsowell.common.constant.Constants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
@@ -191,7 +192,12 @@ public class SnowflakeIdWorker {
}
private static Long getDataCenterId() {
int[] ints = StringUtils.toCodePoints(SystemUtils.getHostName());
String hostName = SystemUtils.getHostName();
if (StringUtils.isBlank(hostName)) {
hostName = Constants.DEFAULT;
}
int[] ints = StringUtils.toCodePoints(hostName);
log.info("HostName: {}", hostName);
int sums = 0;
for (int i : ints) {
sums += i;