Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
extend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
park
extend
Commits
f4f43501
Commit
f4f43501
authored
Jun 22, 2020
by
lixian7
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改唯一建生成方式
parent
fb0548f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
3 deletions
+59
-3
domain/src/main/java/com/hikcreate/edl/pub/web/mobile/domain/impl/BindServiceImpl.java
+6
-3
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/util/UnqIdUtil.java
+53
-0
No files found.
domain/src/main/java/com/hikcreate/edl/pub/web/mobile/domain/impl/BindServiceImpl.java
View file @
f4f43501
...
...
@@ -9,6 +9,7 @@ import com.hikcreate.common.sdk.response.apiparam.Response;
import
com.hikcreate.common.sdk.response.apiparam.ResponseGenerator
;
import
com.hikcreate.common.sdk.response.statuscode.StatusCode
;
import
com.hikcreate.edl.pub.web.mobile.domain.IBindService
;
import
com.hikcreate.edl.pub.web.mobile.infra.core.util.UnqIdUtil
;
import
com.hikcreate.edl.pub.web.mobile.infra.data.cache.BindCache
;
import
com.hikcreate.edl.pub.web.mobile.infra.data.cache.DrivingLicenseCache
;
import
com.hikcreate.edl.pub.web.mobile.infra.data.cache.VechicleCache
;
...
...
@@ -34,6 +35,7 @@ import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ResultList;
import
com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ViolationInfoRes
;
import
com.hikcreate.edl.pub.web.mobile.infra.model.param.response.YearCheckInfoRes
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.stereotype.Service
;
...
...
@@ -67,12 +69,12 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
ViolationCache
violationCache
;
@Resource
DrivingLicenseCache
drivingLicenseCache
;
@Autowired
UnqIdUtil
unqIdUtil
;
@Override
public
Response
bind
(
ParkBindInfo
info
)
{
info
.
setGmtBindTime
(
DateTime
.
now
().
toString
());
//判断规则1:用户已绑定的车辆不超过3辆,包括已解绑但未过一个月的车辆
QueryWrapper
boundQuery
=
new
QueryWrapper
();
boundQuery
.
eq
(
"user_id"
,
info
.
getUserId
());
...
...
@@ -111,7 +113,8 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
}
info
.
setUnqId
(
UUID
.
randomUUID
().
toString
());
info
.
setUnqId
(
unqIdUtil
.
getUnqId
());
info
.
setGmtBindTime
(
DateTime
.
now
().
toString
());
mapper
.
insert
(
info
);
return
ResponseGenerator
.
success
(
new
BindInfoRes
(
info
.
getUnqId
()));
}
...
...
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/util/UnqIdUtil.java
0 → 100644
View file @
f4f43501
package
com
.
hikcreate
.
edl
.
pub
.
web
.
mobile
.
infra
.
core
.
util
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
import
java.util.concurrent.TimeUnit
;
/**
* 唯一建工具类
*
* @author lixian
* @description
* @date 2020/6/22 16:24
**/
@Component
public
class
UnqIdUtil
{
@Autowired
StringRedisTemplate
redisTemplate
;
String
redisKey
=
"park:unqid:random"
;
public
static
void
main
(
String
[]
args
)
{
long
random
=
11114432543
l
;
random
=
random
%
10000000
;
System
.
out
.
println
(
StrUtil
.
fillBefore
(
String
.
valueOf
(
random
),
'0'
,
8
));
}
/**
* 获取唯一建
* 16(日期)+8(随机数)
*
* @return
*/
public
String
getUnqId
()
{
String
id
=
""
;
id
=
id
.
concat
(
DateUtil
.
format
(
new
Date
(),
DatePattern
.
PURE_DATETIME_MS_FORMAT
));
long
random
=
redisTemplate
.
opsForValue
().
increment
(
redisKey
,
1
);
if
(
random
==
1
)
{
redisTemplate
.
expire
(
redisKey
,
60
l
,
TimeUnit
.
SECONDS
);
}
random
=
random
%
10000000
;
id
=
id
.
concat
(
StrUtil
.
fillBefore
(
String
.
valueOf
(
random
),
'0'
,
8
));
System
.
out
.
println
(
"id:"
+
id
);
return
id
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment