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
e5e39d15
Commit
e5e39d15
authored
Aug 16, 2023
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redissonclient修改
parent
25b5de69
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
50 deletions
+98
-50
RedissonManager.java
...join/amos/boot/module/ymt/biz/config/RedissonManager.java
+21
-19
EquipmentCategoryController.java
...odule/ymt/biz/controller/EquipmentCategoryController.java
+26
-7
EquipmentCategoryServiceImpl.java
...le/ymt/biz/service/impl/EquipmentCategoryServiceImpl.java
+50
-24
application-dev.properties
...ule-ymt-biz/src/main/resources/application-dev.properties
+1
-0
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 @
e5e39d15
...
...
@@ -5,6 +5,7 @@ import org.redisson.Redisson;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -13,39 +14,40 @@ import org.springframework.context.annotation.Configuration;
@Slf4j
public
class
RedissonManager
{
//集群环境使用
// @Value("${spring.redis.cluster.nodes
}")
//
private String clusterNodes;
@Value
(
"${spring.redis.cluster.nodes:default
}"
)
private
String
clusterNodes
;
//通用
@Value
(
"${spring.redis.password}"
)
private
String
password
;
//单机环境使用
@Value
(
"${spring.redis.host}"
)
@Value
(
"${spring.redis.host
:default
}"
)
private
String
host
;
//单机环境使用
@Value
(
"${spring.redis.port}"
)
@Value
(
"${spring.redis.port
:default
}"
)
private
String
port
;
@Bean
@ConditionalOnProperty
(
name
=
"spring.redis.mode"
,
havingValue
=
"cluster"
)
public
RedissonClient
redissonClient
()
{
//集群环境使用
// log.info("clusterNodes{}",clusterNodes);
// log.info("password{}",password);
//
// Config config = new Config();
// config.useClusterServers()
// .addNodeAddress(clusterNodes.split(","))
// .setPassword(password);
// return Redisson.create(config);
//单机打包使用
log
.
info
(
"clusterNodes{}"
,
clusterNodes
);
log
.
info
(
"password{}"
,
password
);
Config
config
=
new
Config
();
config
.
useClusterServers
()
.
addNodeAddress
(
clusterNodes
.
split
(
","
))
.
setPassword
(
password
);
return
Redisson
.
create
(
config
);
}
@Bean
@ConditionalOnProperty
(
name
=
"spring.redis.mode"
,
havingValue
=
"singleton"
)
public
RedissonClient
redissonSingletonClient
()
{
// 单机打包使用
Config
config
=
new
Config
();
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/controller/EquipmentCategoryController.java
View file @
e5e39d15
package
com
.
yeejoin
.
amos
.
boot
.
module
.
ymt
.
biz
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
...
...
@@ -12,7 +11,6 @@ import com.yeejoin.amos.boot.biz.common.utils.Menu;
import
com.yeejoin.amos.boot.biz.common.utils.TreeParser
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.CategoryOtherInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.ImageSizeEnums
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper
;
...
...
@@ -20,14 +18,21 @@ import com.yeejoin.amos.boot.module.ymt.api.service.IEquipmentCategoryService;
import
com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo
;
import
com.yeejoin.amos.boot.module.ymt.biz.service.impl.EquipmentCategoryServiceImpl
;
import
com.yeejoin.amos.boot.module.ymt.biz.utils.ImageUtils
;
import
com.yeejoin.amos.component.robot.BadRequest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
...
...
@@ -35,8 +40,16 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.util.*
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeSet
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -264,7 +277,13 @@ public class EquipmentCategoryController extends BaseController {
return
ResponseHelper
.
buildResponse
(
equipmentCategoryService
.
submit
(
map
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/test/lock"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"一码通八大类设备数据操作接口"
,
notes
=
"一码通八大类设备数据操作接口"
)
public
ResponseModel
<
Object
>
lockTest
()
{
equipmentCategoryServiceImpl
.
lockTest
();
return
ResponseHelper
.
buildResponse
(
"OK~"
);
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
...
...
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 @
e5e39d15
...
...
@@ -10,16 +10,26 @@ import com.google.common.collect.Lists;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.*
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.*
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.ESEquipmentCategoryDto
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.EquInfoDto
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.UseUnitCreditCodeCategoryDto
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.CategoryOtherInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategoryData
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.SupervisoryCodeInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentCategoryEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.*
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryDataMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.SupervisoryCodeInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.service.IEquipmentCategoryService
;
import
com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo
;
import
com.yeejoin.amos.boot.module.ymt.biz.dao.ESEquipmentCategory
;
import
com.yeejoin.amos.boot.module.ymt.biz.utils.JsonUtils
;
import
com.yeejoin.amos.boot.module.ymt.flc.api.feign.IdxFeignService
;
import
com.yeejoin.amos.boot.module.ymt.flc.api.feign.PrivilegeFeginService
;
...
...
@@ -41,7 +51,6 @@ import org.springframework.aop.framework.AopContext;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
import
org.springframework.data.elasticsearch.core.ElasticsearchTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.scheduling.annotation.Async
;
...
...
@@ -60,10 +69,19 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import
java.io.IOException
;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.StringJoiner
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
static
com
.
alibaba
.
fastjson
.
JSON
.
toJSONString
;
...
...
@@ -1046,24 +1064,24 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//生成码
//集群模式使用
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
(
"释放锁"
);
}
//
boolean flag = false;
// if (lock.tryLock(3, 5
, 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"
));
...
...
@@ -1413,4 +1431,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
return
totle
;
}
public
void
lockTest
()
{
RLock
rLock
=
redissonClient
.
getLock
(
LOCK_KEY
);
rLock
.
lock
();
System
.
out
.
println
(
"redissonClient ====> "
);
rLock
.
unlock
();
}
}
\ No newline at end of file
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/resources/application-dev.properties
View file @
e5e39d15
...
...
@@ -27,6 +27,7 @@ spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait
=
-1
spring.redis.lettuce.pool.max-idle
=
10
spring.redis.lettuce.pool.min-idle
=
0
spring.redis.mode
=
singleton
## emqx properties:
emqx.clean-session
=
false
...
...
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