Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f98310fe
authored
Apr 21, 2021
by
fz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.crep16进制返回,16位长度,超出截取后16位,不足前面补0
1 parent
729d2c76
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
src/main/java/com/glsx/smart/service/impl/AiLockingKeyServiceImpl.java
src/main/java/com/glsx/smart/service/impl/AiLockingKeyServiceImpl.java
View file @
f98310f
...
@@ -16,6 +16,7 @@ import com.glsx.smart.service.SmartVehicleBlueKeyService;
...
@@ -16,6 +16,7 @@ import com.glsx.smart.service.SmartVehicleBlueKeyService;
import
com.glsx.smart.utils.AesEncryptUtils
;
import
com.glsx.smart.utils.AesEncryptUtils
;
import
com.glsx.smart.utils.SnowflakeWorker
;
import
com.glsx.smart.utils.SnowflakeWorker
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.text.StrBuilder
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -272,8 +273,19 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -272,8 +273,19 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
//获取crep(雪花算法+userid)
//获取crep(雪花算法+userid)
private
String
getCrepCode
()
{
private
String
getCrepCode
()
{
String
snowId
=
snowflakeWorker
.
nextId
()+
""
;
String
snowId
=
Long
.
toHexString
(
snowflakeWorker
.
nextId
())
;
int
len
=
snowId
.
length
();
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
();
}
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment