Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
8037c5a8
Commit
8037c5a8
authored
Aug 14, 2023
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一码通添加单机redisson分布式锁
parent
3a476ecb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
16 deletions
+41
-16
RedissonManager.java
...join/amos/boot/module/ymt/biz/config/RedissonManager.java
+22
-8
EquipmentCategoryServiceImpl.java
...le/ymt/biz/service/impl/EquipmentCategoryServiceImpl.java
+19
-8
No files found.
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/config/RedissonManager.java
View file @
8037c5a8
...
...
@@ -16,24 +16,38 @@ public class RedissonManager {
//集群环境使用
@Value
(
"${spring.redis.cluster.nodes}"
)
private
String
clusterNodes
;
//
@Value("${spring.redis.cluster.nodes}")
//
private String clusterNodes;
//通用
@Value
(
"${spring.redis.password}"
)
private
String
password
;
//单机环境使用
@Value
(
"${spring.redis.host}"
)
private
String
host
;
//单机环境使用
@Value
(
"${spring.redis.port}"
)
private
String
port
;
@Bean
public
RedissonClient
redissonClient
()
{
log
.
info
(
"clusterNodes{}"
,
clusterNodes
);
log
.
info
(
"password{}"
,
password
);
//集群环境使用
// log.info("clusterNodes{}",clusterNodes);
// log.info("password{}",password);
//
// Config config = new Config();
// config.useClusterServers()
// .addNodeAddress(clusterNodes.split(","))
// .setPassword(password);
// return Redisson.create(config);
//单机打包使用
Config
config
=
new
Config
();
config
.
useClusterServers
()
.
addNodeAddress
(
clusterNodes
.
split
(
","
))
.
setPassword
(
password
);
config
.
useSingleServer
().
setAddress
(
host
+
":"
+
port
).
setPassword
(
password
);
return
Redisson
.
create
(
config
);
}
}
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/service/impl/EquipmentCategoryServiceImpl.java
View file @
8037c5a8
...
...
@@ -1044,15 +1044,26 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String
supervisionCode
=
String
.
valueOf
(
superviseMap
.
get
(
"supervisionCode"
));
EquipmentCategoryServiceImpl
categoryService
=
(
EquipmentCategoryServiceImpl
)
AopContext
.
currentProxy
();
//生成码
//集群模式使用
RLock
lock
=
redissonClient
.
getLock
(
LOCK_KEY
);
lock
.
lock
();
// 获取锁
log
.
info
(
"加锁成功"
);
codeMap
=
categoryService
.
creatCode
(
city
,
county
,
equCategory
,
code96333
,
supervisionCode
);
log
.
info
(
"生成码成功"
);
lock
.
unlock
();
// 释放锁
log
.
info
(
"释放锁"
);
log
.
info
(
"已生成对应监管码或96333电梯识别码"
);
// lock.lock(); // 获取锁
// log.info("加锁成功");
// codeMap = categoryService.creatCode(city, county, equCategory, code96333, supervisionCode);
// log.info("生成码成功");
// lock.unlock(); // 释放锁
// log.info("释放锁");
// log.info("已生成对应监管码或96333电梯识别码");
//单机模式使用
boolean
flag
=
false
;
if
(
lock
.
tryLock
(
3
,
100
,
TimeUnit
.
SECONDS
))
{
codeMap
=
categoryService
.
creatCode
(
city
,
county
,
equCategory
,
code96333
,
supervisionCode
);
log
.
info
(
"已生成对应监管码或96333电梯识别码"
);
flag
=
true
;
}
if
(
flag
){
lock
.
unlock
();
// 释放锁
log
.
info
(
"释放锁"
);
}
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map
.
remove
(
"data"
);
supervisionMap
.
put
(
"CODE96333"
,
codeMap
.
get
(
"code96333"
));
...
...
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