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
d6986cfa
Commit
d6986cfa
authored
Mar 27, 2025
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.删除可能由于日志打印查询导致的循环判断时间过长问题
parent
aae6f77d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
24 deletions
+16
-24
BaseEquipUsedCheckService.java
...module/jg/biz/service/impl/BaseEquipUsedCheckService.java
+16
-24
No files found.
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/BaseEquipUsedCheckService.java
View file @
d6986cfa
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jg
.
biz
.
service
.
impl
;
import
com.yeejoin.amos.boot.module.jg.api.dto.FlowingEquipRedisKeyDTO
;
import
com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper
;
import
com.yeejoin.amos.boot.module.jg.api.service.IEquipUsedCheck
;
import
com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -23,8 +21,6 @@ import java.util.stream.Collectors;
@Slf4j
public
abstract
class
BaseEquipUsedCheckService
implements
IEquipUsedCheck
{
@Autowired
CommonMapper
commonMapper
;
/**
* 并发校验(页面同时提交或者页面同时打开多个时,某些设备都是为使用状态)校验设备流程在用状态及更新不在用为再使用状态
...
...
@@ -44,26 +40,29 @@ public abstract class BaseEquipUsedCheckService implements IEquipUsedCheck {
RBucket
<
Set
<
String
>>
RBucket
=
getRedisClient
().
getBucket
(
this
.
getFlowingEquipRedisKey
(
companyCode
,
getApplyBizType
()));
Set
<
String
>
equipListOfUsed
=
RBucket
.
get
();
// 查询当前设备在流程中的申请单号列表
List
<
String
>
equipInUseList
=
commonMapper
.
findEquipInUseService
(
record
);
if
(
equipListOfUsed
!=
null
&&
equipListOfUsed
.
contains
(
record
))
{
String
joinedEquipInUse
=
String
.
join
(
","
,
equipInUseList
);
log
.
error
(
"设备已被其他流程使用,不允许重复提交,设备ID:{},在流程中申请单:{}"
,
record
,
joinedEquipInUse
);
log
.
error
(
"设备已被其他流程使用,不允许重复提交,设备ID:{}"
,
record
);
throw
new
BadRequest
(
"设备已被其他流程使用,不允许重复提交,请联系管理员!"
);
}
if
(
equipListOfUsed
==
null
||
equipListOfUsed
.
isEmpty
())
{
equipListOfUsed
=
new
TreeSet
<>();
}
equipListOfUsed
.
add
(
record
);
getRedisClient
().
getBucket
(
this
.
getFlowingEquipRedisKey
(
companyCode
,
getApplyBizType
())).
set
(
equipListOfUsed
);
FlowingEquipRedisContext
.
setRedisKeyInfo
(
new
FlowingEquipRedisKeyDTO
(
this
.
getFlowingEquipRedisKey
(
companyCode
,
getApplyBizType
()),
Collections
.
singletonList
(
record
)));
setUsingData2Redis
(
record
,
companyCode
,
equipListOfUsed
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
(
);
log
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
if
(
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
}
}
}
private
void
setUsingData2Redis
(
String
record
,
String
companyCode
,
Set
<
String
>
equipListOfUsed
)
{
if
(
equipListOfUsed
==
null
||
equipListOfUsed
.
isEmpty
())
{
equipListOfUsed
=
new
TreeSet
<>();
}
equipListOfUsed
.
add
(
record
);
getRedisClient
().
getBucket
(
this
.
getFlowingEquipRedisKey
(
companyCode
,
getApplyBizType
())).
set
(
equipListOfUsed
);
FlowingEquipRedisContext
.
setRedisKeyInfo
(
new
FlowingEquipRedisKeyDTO
(
this
.
getFlowingEquipRedisKey
(
companyCode
,
getApplyBizType
()),
Collections
.
singletonList
(
record
)));
}
@Override
public
void
registrationRepeatUsedCheck
(
String
record
,
String
companyCode
)
{
RLock
lock
=
getRedisClient
().
getLock
(
this
.
getRepeatUsedCheckLockKey
(
companyCode
,
getApplyBizType
(),
record
));
...
...
@@ -76,20 +75,13 @@ public abstract class BaseEquipUsedCheckService implements IEquipUsedCheck {
RBucket
<
Set
<
String
>>
RBucket
=
getRedisClient
().
getBucket
(
this
.
getFlowingEquipRedisKey
(
companyCode
,
getApplyBizType
()));
Set
<
String
>
equipListOfUsed
=
RBucket
.
get
();
// 查询当前设备在用的申请单号列表
List
<
String
>
equipInUseList
=
commonMapper
.
findEquipInUseService
(
record
);
if
(
equipListOfUsed
!=
null
&&
equipListOfUsed
.
contains
(
record
))
{
String
joinedEquipInUse
=
String
.
join
(
","
,
equipInUseList
);
log
.
error
(
"使用登记证已被其他流程使用,不允许重复提交,设备ID:{},在流程中申请单:{}"
,
record
,
joinedEquipInUse
);
log
.
error
(
"使用登记证已被其他流程使用,不允许重复提交,使用登记证ID:{}"
,
record
);
throw
new
BadRequest
(
"使用登记证已被其他流程使用,不允许重复提交,请联系管理员!"
);
}
if
(
equipListOfUsed
==
null
||
equipListOfUsed
.
isEmpty
())
{
equipListOfUsed
=
new
TreeSet
<>();
}
equipListOfUsed
.
add
(
record
);
getRedisClient
().
getBucket
(
this
.
getFlowingEquipRedisKey
(
companyCode
,
getApplyBizType
())).
set
(
equipListOfUsed
);
FlowingEquipRedisContext
.
setRedisKeyInfo
(
new
FlowingEquipRedisKeyDTO
(
this
.
getFlowingEquipRedisKey
(
companyCode
,
getApplyBizType
()),
Collections
.
singletonList
(
record
)));
setUsingData2Redis
(
record
,
companyCode
,
equipListOfUsed
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
(
);
log
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
if
(
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
...
...
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