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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
50 deletions
+65
-50
CommonServiceImpl.java
...os/boot/module/jg/biz/service/impl/CommonServiceImpl.java
+6
-4
JgChangeRegistrationNameServiceImpl.java
...biz/service/impl/JgChangeRegistrationNameServiceImpl.java
+51
-41
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,46 +453,55 @@ 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
();
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
commonService
.
checkForRevocationFlow
(
taskId
,
instanceId
);
// 执行流程
String
taskCode
=
FlowStatusEnum
.
TO_BE_FINISHED
.
getName
();
JgChangeRegistrationName
jgChangeRegistrationName
=
new
JgChangeRegistrationName
();
LambdaQueryWrapper
<
JgChangeRegistrationName
>
lambda
=
new
QueryWrapper
<
JgChangeRegistrationName
>().
lambda
();
lambda
.
eq
(
JgChangeRegistrationName:
:
getInstanceId
,
instanceId
);
jgChangeRegistrationName
=
this
.
getOne
(
lambda
);
List
<
String
>
roleListNext
=
new
ArrayList
<>();
List
<
String
>
roleListAll
=
new
ArrayList
<>();
ProcessTaskDTO
processTaskDTO
=
cmWorkflowService
.
rollBack
(
instanceId
);
String
nextTaskId
=
processTaskDTO
.
getNextTask
().
get
(
0
).
getId
();
this
.
buildRoleList
(
Collections
.
singletonList
(
processTaskDTO
),
roleListNext
,
roleListAll
);
// 待调整
taskCode
=
processTaskDTO
.
getNextTask
().
get
(
0
).
getKey
();
if
(!
FlowStatusEnum
.
TO_BE_FINISHED
.
getName
().
equals
(
taskCode
))
{
jgChangeRegistrationName
.
setAuditStatus
(
WorkFlowStatusEnum
.
getMessage
(
taskCode
).
getRollBack
());
try
{
boolean
isLocked
=
lock
.
tryLock
(
0
,
180
,
TimeUnit
.
SECONDS
);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
commonService
.
checkForRevocationFlow
(
taskId
,
instanceId
);
// 执行流程
String
taskCode
=
FlowStatusEnum
.
TO_BE_FINISHED
.
getName
();
JgChangeRegistrationName
jgChangeRegistrationName
=
new
JgChangeRegistrationName
();
LambdaQueryWrapper
<
JgChangeRegistrationName
>
lambda
=
new
QueryWrapper
<
JgChangeRegistrationName
>().
lambda
();
lambda
.
eq
(
JgChangeRegistrationName:
:
getInstanceId
,
instanceId
);
jgChangeRegistrationName
=
this
.
getOne
(
lambda
);
List
<
String
>
roleListNext
=
new
ArrayList
<>();
List
<
String
>
roleListAll
=
new
ArrayList
<>();
ProcessTaskDTO
processTaskDTO
=
cmWorkflowService
.
rollBack
(
instanceId
);
String
nextTaskId
=
processTaskDTO
.
getNextTask
().
get
(
0
).
getId
();
this
.
buildRoleList
(
Collections
.
singletonList
(
processTaskDTO
),
roleListNext
,
roleListAll
);
// 待调整
taskCode
=
processTaskDTO
.
getNextTask
().
get
(
0
).
getKey
();
if
(!
FlowStatusEnum
.
TO_BE_FINISHED
.
getName
().
equals
(
taskCode
))
{
jgChangeRegistrationName
.
setAuditStatus
(
WorkFlowStatusEnum
.
getMessage
(
taskCode
).
getRollBack
());
}
jgChangeRegistrationName
.
setPromoter
(
RequestContext
.
getExeUserId
());
jgChangeRegistrationName
.
setNextExecutorIds
(
String
.
join
(
","
,
roleListNext
));
jgChangeRegistrationName
.
setNextTaskId
(
nextTaskId
);
List
<
WorkflowResultDto
>
workflowResultDtos
=
commonService
.
buildWorkFlowInfo
(
Collections
.
singletonList
(
processTaskDTO
));
// 更新下一步可执行人
String
nextUserIds
=
workflowResultDtos
.
get
(
0
).
getNextExecutorUserIds
();
jgChangeRegistrationName
.
setNextExecuteUserIds
(
nextUserIds
);
this
.
updateById
(
jgChangeRegistrationName
);
// 删除待办
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
jgChangeRegistrationName
));
jsonObject
.
put
(
"nextExecuteUser"
,
jgChangeRegistrationName
.
getNextExecutorIds
());
jsonObject
.
put
(
"taskType"
,
BusinessTypeEnum
.
JG_NAME_CHANGE_REGISTRATION
.
getCode
());
jsonObject
.
put
(
"flowStatus"
,
this
.
getTaskCodeByName
(
jgChangeRegistrationName
.
getAuditStatus
()));
jsonObject
.
put
(
"flowStatusLabel"
,
jgChangeRegistrationName
.
getAuditStatus
());
jsonObject
.
put
(
"changeCertificate"
,
null
);
// 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑
jsonObject
.
put
(
"pageType"
,
this
.
getPageTypeByCurrentNode
(
jgChangeRegistrationName
.
getAuditStatus
()));
commonService
.
rollbackTask
(
instanceId
,
jsonObject
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
lock
.
isHeldByCurrentThread
()){
lock
.
unlock
();
}
}
jgChangeRegistrationName
.
setPromoter
(
RequestContext
.
getExeUserId
());
jgChangeRegistrationName
.
setNextExecutorIds
(
String
.
join
(
","
,
roleListNext
));
jgChangeRegistrationName
.
setNextTaskId
(
nextTaskId
);
List
<
WorkflowResultDto
>
workflowResultDtos
=
commonService
.
buildWorkFlowInfo
(
Collections
.
singletonList
(
processTaskDTO
));
// 更新下一步可执行人
String
nextUserIds
=
workflowResultDtos
.
get
(
0
).
getNextExecutorUserIds
();
jgChangeRegistrationName
.
setNextExecuteUserIds
(
nextUserIds
);
this
.
updateById
(
jgChangeRegistrationName
);
// 删除待办
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
jgChangeRegistrationName
));
jsonObject
.
put
(
"nextExecuteUser"
,
jgChangeRegistrationName
.
getNextExecutorIds
());
jsonObject
.
put
(
"taskType"
,
BusinessTypeEnum
.
JG_NAME_CHANGE_REGISTRATION
.
getCode
());
jsonObject
.
put
(
"flowStatus"
,
this
.
getTaskCodeByName
(
jgChangeRegistrationName
.
getAuditStatus
()));
jsonObject
.
put
(
"flowStatusLabel"
,
jgChangeRegistrationName
.
getAuditStatus
());
jsonObject
.
put
(
"changeCertificate"
,
null
);
// 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑
jsonObject
.
put
(
"pageType"
,
this
.
getPageTypeByCurrentNode
(
jgChangeRegistrationName
.
getAuditStatus
()));
commonService
.
rollbackTask
(
instanceId
,
jsonObject
);
}
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