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
58f3af9f
Commit
58f3af9f
authored
Mar 13, 2024
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修改锁释放逻辑
parent
7ff2de81
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
12 deletions
+27
-12
CommonServiceImpl.java
...os/boot/module/jg/biz/service/impl/CommonServiceImpl.java
+6
-4
JgChangeRegistrationNameServiceImpl.java
...biz/service/impl/JgChangeRegistrationNameServiceImpl.java
+13
-3
JgUseRegistrationServiceImpl.java
...ule/jg/biz/service/impl/JgUseRegistrationServiceImpl.java
+8
-5
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/CommonServiceImpl.java
View file @
58f3af9f
...
...
@@ -84,6 +84,7 @@ import java.lang.reflect.Modifier;
import
java.net.URLEncoder
;
import
java.nio.file.Files
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -962,8 +963,8 @@ public class CommonServiceImpl implements ICommonService {
String
assignee
=
map
.
get
(
"assignee"
).
toString
();
String
lockKey
=
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
try
{
boolean
isLocked
=
lock
.
tryLock
(
0
,
180
,
TimeUnit
.
SECONDS
);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
...
...
@@ -1012,13 +1013,14 @@ public class CommonServiceImpl implements ICommonService {
.
nextTaskId
(
nextTaskId
)
.
promoter
(
commonMapper
.
selectPromoterData
(
tableName
,
instanceId
)).
build
());
return
Boolean
.
TRUE
;
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
isLocked
){
if
(
lock
.
isHeldByCurrentThread
()
){
lock
.
unlock
();
}
}
return
Boolean
.
FALSE
;
}
public
void
deleteTaskModel
(
String
id
)
{
...
...
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/JgChangeRegistrationNameServiceImpl.java
View file @
58f3af9f
...
...
@@ -51,6 +51,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -452,7 +453,8 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
public
void
revocation
(
String
instanceId
,
String
taskId
)
{
String
lockKey
=
CommonServiceImpl
.
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
try
{
boolean
isLocked
=
lock
.
tryLock
(
0
,
180
,
TimeUnit
.
SECONDS
);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
...
...
@@ -492,6 +494,14 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
// 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑
jsonObject
.
put
(
"pageType"
,
this
.
getPageTypeByCurrentNode
(
jgChangeRegistrationName
.
getAuditStatus
()));
commonService
.
rollbackTask
(
instanceId
,
jsonObject
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
lock
.
isHeldByCurrentThread
()){
lock
.
unlock
();
}
}
}
private
String
getPageTypeByCurrentNode
(
String
auditStatus
)
{
...
...
@@ -511,8 +521,8 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
public
void
flowExecute
(
Long
id
,
String
instanceId
,
String
operate
,
String
comment
)
{
String
lockKey
=
CommonServiceImpl
.
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
try
{
boolean
isLocked
=
lock
.
tryLock
();
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
...
...
@@ -540,7 +550,7 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
// 更新下一步执行人、创建待办
updateExecuteIds
(
instanceId
,
id
,
operate
,
processTaskDTO
);
}
finally
{
if
(
isLocked
){
if
(
lock
.
isHeldByCurrentThread
()
){
lock
.
unlock
();
}
}
...
...
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/JgUseRegistrationServiceImpl.java
View file @
58f3af9f
...
...
@@ -53,6 +53,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import
javax.servlet.http.HttpServletResponse
;
import
java.time.LocalDate
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
/**
* 服务实现类
...
...
@@ -632,9 +633,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
public
void
flowExecute
(
Long
id
,
String
instanceId
,
String
operate
,
String
comment
,
String
carNumber
,
String
nextTaskId
)
{
String
lockKey
=
CommonServiceImpl
.
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
try
{
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回)
boolean
isLocked
=
lock
.
tryLock
(
0
,
180
,
TimeUnit
.
SECONDS
);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
...
...
@@ -667,8 +668,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
WorkflowResultDto
workflowResultDto
=
resultDto
.
get
(
0
);
updateData
(
jgUseRegistration
.
getSequenceNbr
(),
operate
,
workflowResultDto
,
Boolean
.
FALSE
,
carNumber
);
}
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
isLocked
){
if
(
lock
.
isHeldByCurrentThread
()
){
lock
.
unlock
();
}
}
...
...
@@ -678,8 +681,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
public
void
withdraw
(
String
instanceId
,
String
nextTaskId
)
{
String
lockKey
=
CommonServiceImpl
.
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
try
{
boolean
isLocked
=
lock
.
tryLock
();
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
...
...
@@ -730,7 +733,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// redis流程实时数据更新
commonServiceImpl
.
saveExecuteFlowData2Redis
(
instanceId
,
this
.
buildInstanceRuntimeData
(
data
));
}
finally
{
if
(
isLocked
){
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