Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Skyeye云
Skyeye
提交
293fb1a7
S
Skyeye
项目概览
Skyeye云
/
Skyeye
通知
1435
Star
162
Fork
130
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Skyeye
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
293fb1a7
编写于
12月 19, 2021
作者:
Skyeye云
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
解决获取下一个usertask节点审批人的信息
上级
8bc7ed85
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
115 addition
and
46 deletion
+115
-46
skyeye-activiti/src/main/java/com/skyeye/activiti/cmd/nextusertask/FindNextUserTaskNodeCmd.java
...ye/activiti/cmd/nextusertask/FindNextUserTaskNodeCmd.java
+88
-0
skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/ActivitiProcessServiceImpl.java
...eye/activiti/service/impl/ActivitiProcessServiceImpl.java
+20
-46
skyeye-common/pom.xml
skyeye-common/pom.xml
+7
-0
未找到文件。
skyeye-activiti/src/main/java/com/skyeye/activiti/cmd/nextusertask/FindNextUserTaskNodeCmd.java
0 → 100644
浏览文件 @
293fb1a7
/*******************************************************************************
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package
com.skyeye.activiti.cmd.nextusertask
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.flowable.bpmn.model.*
;
import
org.flowable.common.engine.impl.interceptor.Command
;
import
org.flowable.common.engine.impl.interceptor.CommandContext
;
import
org.flowable.engine.impl.persistence.entity.ExecutionEntity
;
import
org.flowable.engine.impl.util.condition.ConditionUtil
;
import
java.util.List
;
import
java.util.Map
;
/**
* @ClassName: FindNextUserTaskNodeCmd
* @Description: 获取下一个UserTask的信息
* @author: skyeye云系列--卫志强
* @date: 2021/12/18 23:49
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
public
class
FindNextUserTaskNodeCmd
implements
Command
<
UserTask
>
{
private
final
ExecutionEntity
execution
;
private
final
BpmnModel
bpmnModel
;
private
Map
<
String
,
Object
>
vars
;
/**
* 返回下一用户节点
*/
private
UserTask
nextUserTask
;
/**
* @param execution 当前执行实例
* @param bpmnModel 当前执行实例的模型
* @param vars 参与计算流程条件的变量
*/
public
FindNextUserTaskNodeCmd
(
ExecutionEntity
execution
,
BpmnModel
bpmnModel
,
Map
<
String
,
Object
>
vars
)
{
this
.
execution
=
execution
;
this
.
bpmnModel
=
bpmnModel
;
this
.
vars
=
vars
;
}
@Override
public
UserTask
execute
(
CommandContext
commandContext
)
{
// 当前流程节点信息
FlowElement
currentNode
=
bpmnModel
.
getFlowElement
(
execution
.
getActivityId
());
execution
.
setVariables
(
vars
);
// 获取流程曲线走向
List
<
SequenceFlow
>
outgoingFlows
=
((
FlowNode
)
currentNode
).
getOutgoingFlows
();
if
(
CollectionUtils
.
isNotEmpty
(
outgoingFlows
))
{
this
.
findNextUserTaskNode
(
outgoingFlows
,
execution
);
}
return
nextUserTask
;
}
/**
* 下一个任务节点信息,
*
* 如果下一个节点为用户任务则直接返回,
* 如果下一个节点为排他网关, 获取排他网关Id信息, 根据排他网关Id信息和execution获取流程实例排他网关Id为key的变量值,
* 根据变量值分别执行排他网关后线路中的el表达式, 并找到el表达式通过的线路后的用户任务
*
* @param outgoingFlows 曲线走向
* @param execution 执行器,包含form表单参数信息
* @return
*/
void
findNextUserTaskNode
(
List
<
SequenceFlow
>
outgoingFlows
,
ExecutionEntity
execution
)
{
sw:
for
(
SequenceFlow
outgoingFlow
:
outgoingFlows
)
{
if
(
ConditionUtil
.
hasTrueCondition
(
outgoingFlow
,
execution
))
{
if
(
outgoingFlow
.
getTargetFlowElement
()
instanceof
ExclusiveGateway
)
{
// 只有排他网关才继续
ExclusiveGateway
exclusiveGateway
=
(
ExclusiveGateway
)
outgoingFlow
.
getTargetFlowElement
();
findNextUserTaskNode
(
exclusiveGateway
.
getOutgoingFlows
(),
execution
);
}
else
if
(
outgoingFlow
.
getTargetFlowElement
()
instanceof
UserTask
)
{
nextUserTask
=
(
UserTask
)
outgoingFlow
.
getTargetFlowElement
();
// 找到第一个符合条件的userTask就跳出循环
break
sw
;
}
}
}
}
}
skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/ActivitiProcessServiceImpl.java
浏览文件 @
293fb1a7
...
...
@@ -4,6 +4,7 @@
package
com.skyeye.activiti.service.impl
;
import
com.skyeye.activiti.cmd.nextusertask.FindNextUserTaskNodeCmd
;
import
com.skyeye.activiti.cmd.rollback.RollbackCmd
;
import
com.skyeye.activiti.service.ActivitiModelService
;
import
com.skyeye.activiti.service.ActivitiProcessService
;
...
...
@@ -21,13 +22,17 @@ import org.apache.commons.lang3.StringUtils;
import
org.dom4j.Document
;
import
org.dom4j.Element
;
import
org.dom4j.io.SAXReader
;
import
org.flowable.bpmn.model.*
;
import
org.flowable.engine.*
;
import
org.flowable.bpmn.model.BpmnModel
;
import
org.flowable.bpmn.model.UserTask
;
import
org.flowable.engine.ManagementService
;
import
org.flowable.engine.RepositoryService
;
import
org.flowable.engine.RuntimeService
;
import
org.flowable.engine.TaskService
;
import
org.flowable.engine.impl.persistence.entity.ExecutionEntity
;
import
org.flowable.engine.impl.util.condition.ConditionUtil
;
import
org.flowable.engine.repository.Model
;
import
org.flowable.engine.repository.ProcessDefinition
;
import
org.flowable.task.api.Task
;
import
org.nutz.trans.Trans
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -174,7 +179,7 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
String
taskId
=
params
.
get
(
"taskId"
).
toString
();
// 获取表单数据用于排他网关的参数校验
Map
<
String
,
Object
>
map
=
getFormVariable
(
taskId
,
params
);
UserTask
userTask
=
getNextTaskInfo
(
processInstance
Id
,
map
);
UserTask
userTask
=
getNextTaskInfo
(
task
Id
,
map
);
if
(
userTask
!=
null
){
// 1.获取下个节点的所有可选审批人
List
<
Map
<
String
,
Object
>>
user
=
new
ArrayList
<>();
...
...
@@ -241,53 +246,22 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
/**
* 获取下一个用户任务信息
*
* @param
processInstanceId 流程
Id信息
* @param
taskId 任务
Id信息
* @param map 表单数据
* @return 下一个用户任务用户组信息
* @throws Exception
*/
public
UserTask
getNextTaskInfo
(
String
processInstanceId
,
Map
<
String
,
Object
>
map
)
throws
Exception
{
// 获取流程发布Id信息
String
definitionId
=
runtimeService
.
createProcessInstanceQuery
().
processInstanceId
(
processInstanceId
).
singleResult
().
getProcessDefinitionId
();
BpmnModel
bpmnModel
=
repositoryService
.
getBpmnModel
(
definitionId
);
ExecutionEntity
execution
=
(
ExecutionEntity
)
runtimeService
.
createProcessInstanceQuery
().
processInstanceId
(
processInstanceId
).
singleResult
();
execution
.
setVariablesLocal
(
map
);
// 当前流程节点信息
FlowElement
currentNode
=
bpmnModel
.
getFlowElement
(
execution
.
getActivityId
());
// 获取流程曲线走向
List
<
SequenceFlow
>
outgoingFlows
=
((
FlowNode
)
currentNode
).
getOutgoingFlows
();
if
(
CollectionUtils
.
isNotEmpty
(
outgoingFlows
))
{
return
this
.
findNextUserTaskNode
(
outgoingFlows
,
execution
);
public
UserTask
getNextTaskInfo
(
String
taskId
,
Map
<
String
,
Object
>
map
)
throws
Exception
{
try
{
Task
task
=
taskService
.
createTaskQuery
().
taskId
(
taskId
).
singleResult
();
String
executionId
=
task
.
getExecutionId
();
ExecutionEntity
execution
=
(
ExecutionEntity
)
runtimeService
.
createExecutionQuery
().
executionId
(
executionId
).
singleResult
();
BpmnModel
bpmnModel
=
repositoryService
.
getBpmnModel
(
execution
.
getProcessDefinitionId
());
Trans
.
begin
();
return
managementService
.
executeCommand
(
new
FindNextUserTaskNodeCmd
(
execution
,
bpmnModel
,
map
));
}
finally
{
Trans
.
clear
(
true
);
}
return
null
;
}
/**
* 下一个任务节点信息,
*
* 如果下一个节点为用户任务则直接返回,
* 如果下一个节点为排他网关, 获取排他网关Id信息, 根据排他网关Id信息和execution获取流程实例排他网关Id为key的变量值,
* 根据变量值分别执行排他网关后线路中的el表达式, 并找到el表达式通过的线路后的用户任务
*
* @param outgoingFlows 曲线走向
* @param execution 执行器,包含form表单参数信息
* @return
*/
private
UserTask
findNextUserTaskNode
(
List
<
SequenceFlow
>
outgoingFlows
,
ExecutionEntity
execution
)
{
for
(
SequenceFlow
outgoingFlow
:
outgoingFlows
)
{
if
(
ConditionUtil
.
hasTrueCondition
(
outgoingFlow
,
execution
))
{
if
(
outgoingFlow
.
getTargetFlowElement
()
instanceof
ExclusiveGateway
)
{
// 只有排他网关才继续
ExclusiveGateway
exclusiveGateway
=
(
ExclusiveGateway
)
outgoingFlow
.
getTargetFlowElement
();
return
findNextUserTaskNode
(
exclusiveGateway
.
getOutgoingFlows
(),
execution
);
}
else
if
(
outgoingFlow
.
getTargetFlowElement
()
instanceof
UserTask
)
{
UserTask
nextUserTask
=
(
UserTask
)
outgoingFlow
.
getTargetFlowElement
();
// 找到第一个符合条件的userTask就跳出循环
return
nextUserTask
;
}
}
}
return
null
;
}
/**
...
...
skyeye-common/pom.xml
浏览文件 @
293fb1a7
...
...
@@ -23,6 +23,13 @@
<version>
5.5.4
</version>
</dependency>
<!-- Springboot整合Nutz,Nutz可以用于自定义事务,例如:Trans.begin(); -->
<dependency>
<groupId>
org.nutz
</groupId>
<artifactId>
nutz-plugins-spring-boot-starter
</artifactId>
<version>
1.r.66
</version>
</dependency>
<!-- 引入中文拼音的依赖 -->
<dependency>
<groupId>
com.belerweb
</groupId>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录