Commit f98310fe by fz

1.crep16进制返回,16位长度,超出截取后16位,不足前面补0

1 parent 729d2c76
......@@ -16,6 +16,7 @@ import com.glsx.smart.service.SmartVehicleBlueKeyService;
import com.glsx.smart.utils.AesEncryptUtils;
import com.glsx.smart.utils.SnowflakeWorker;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.text.StrBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -272,8 +273,19 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
//获取crep(雪花算法+userid)
private String getCrepCode() {
String snowId = snowflakeWorker.nextId()+"";
String snowId =Long.toHexString(snowflakeWorker.nextId());
int len = snowId.length();
return snowId.substring(len-16,len);
if(len == 16)
return snowId;
else if(len>16){
return snowId.substring(len-16,len);
}else {
int count = 16 - len;
StrBuilder builder = new StrBuilder();
for (int i = 0;i<count;i++){
builder.append("0");
}
return builder.append(snowId).toString();
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!