项目地址:https://gitee.com/lwj/flowable.git 分支flowable-base
视频讲解地址
https://space.bilibili.com/485524575/channel/detail?cid=94579
1、演示
2、代码
2.1 查看我发起的流程实例sql
SELECT DISTINCT
t1.ID_ AS processInstanceId,
t1.PROC_DEF_ID_ as processDefinitionId,
t1.NAME_ AS formName,
t1.TENANT_ID_ AS systemSn,
t1.BUSINESS_KEY_ AS businessKey,
t1.START_TIME_ AS startTime,
t1.END_TIME_ AS endTime,
t2.ID_ AS starterId,
t2.FIRST_ as starter
FROM
act_hi_procinst t1
LEFT JOIN act_id_user t2 ON t1.START_USER_ID_ = t2.ID_
<where>
<if test="userCode != null">and t1.START_USER_ID_ = #{userCode}</if>
<if test="userName != null">and t2.FIRST_ like CONCAT('%',#{userName},'%')</if>
<if test="formName != null">and t1.NAME_ like CONCAT('%',#{formName},'%')</if>
</where>
2.2 查看当前的执行人列表
public List<User> getApprovers(String processInstanceId) {
List<User> users = new ArrayList<>();
List<Task> list = taskService.createTaskQuery().processInstanceId(processInstanceId).list();
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(task -> {
if (StringUtils.isNotBlank(task.getAssignee())) {
//1.审批人ASSIGNEE_是用户id
User user = identityService.createUserQuery().userId(task.getAssignee()).singleResult();
if (user != null) {
users.add(user);
}
//2.审批人ASSIGNEE_是组id
List<User> gusers = identityService.createUserQuery().memberOfGroup(task.getAssignee()).list();
if (CollectionUtils.isNotEmpty(gusers)) {
users.addAll(gusers);
}
} else {
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
if (CollectionUtils.isNotEmpty(identityLinks)) {
identityLinks.forEach(identityLink -> {
//3.审批人ASSIGNEE_为空,用户id
if (StringUtils.isNotBlank(identityLink.getUserId())) {
User user = identityService.createUserQuery().userId(identityLink.getUserId()).singleResult();
if (user != null) {
users.add(user);
}
} else {
//4.审批人ASSIGNEE_为空,组id
List<User> gusers = identityService.createUserQuery().memberOfGroup(identityLink.getGroupId()).list();
if (CollectionUtils.isNotEmpty(gusers)) {
users.addAll(gusers);
}
}
});
}
}
});
}
return users;
}