package com.tofly.watermeter.custom.util;

import cn.hutool.core.lang.Singleton;
import cn.hutool.core.lang.Snowflake;

import java.util.Date;

public class SnowflakeUtils {

    private static boolean isUseSystemClock = false;

    /**
     * 雪花算法生成ID
     * @param epochDate 起始时间
     * @param workerId 机器id
     * @param dataCenterId
     * @return
     */
    public static Long getId(Date epochDate, long workerId, long dataCenterId){

        Snowflake snowflake = Singleton.get(Snowflake.class,epochDate,workerId,dataCenterId,isUseSystemClock);
        return snowflake.nextId();

    }



}
