fix
Helius
2022-04-08 45153b035bcd9e9b76fc3b3360e56430d6eb9312
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.xzx.log.util;
 
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
@Component
public class IdUtils {
 
    @Value("${workerId}")
    private String workerId;
 
    /**
     *  生成分布式唯一全局ID
     * @param prefix ID前缀
     * @param datacenterId 数据中心ID(0~31)  0:支付订单(pay_info) 1 订单xzx_order_info 2入库 3 用户 4账户 5回收数据
     * @return
     */
    public  String generate(String prefix,long datacenterId){
        Snowflake snowflake = IdUtil.createSnowflake(Convert.toLong(workerId), datacenterId);
        return prefix+snowflake.nextIdStr();
    }
}