mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-10-20 08:53:48 +08:00
Compare commits
3 Commits
ef39ad7107
...
b50904c6ff
Author | SHA1 | Date | |
---|---|---|---|
|
b50904c6ff | ||
|
70aa14ecf8 | ||
|
c37b92978a |
@@ -177,9 +177,6 @@ springdoc:
|
||||
api-docs:
|
||||
# 是否开启接口文档
|
||||
enabled: true
|
||||
# swagger-ui:
|
||||
# # 持久化认证数据
|
||||
# persistAuthorization: true
|
||||
info:
|
||||
# 标题
|
||||
title: '标题:RuoYi-Vue-Plus多租户管理系统_接口文档'
|
||||
|
@@ -27,10 +27,20 @@ public class ProcessCreateTaskEvent implements Serializable {
|
||||
private String flowCode;
|
||||
|
||||
/**
|
||||
* 审批节点编码
|
||||
* 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 流程节点编码
|
||||
*/
|
||||
private String nodeCode;
|
||||
|
||||
/**
|
||||
* 流程节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
|
@@ -33,7 +33,22 @@ public class ProcessEvent implements Serializable {
|
||||
private String businessId;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 流程节点编码
|
||||
*/
|
||||
private String nodeCode;
|
||||
|
||||
/**
|
||||
* 流程节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 流程状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
|
@@ -30,7 +30,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Swagger 文档配置
|
||||
* 接口文档配置
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
@@ -27,16 +27,27 @@ public class FlowProcessEventHandler {
|
||||
*
|
||||
* @param flowCode 流程定义编码
|
||||
* @param businessId 业务id
|
||||
* @param status 状态
|
||||
* @param nodeType 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
* @param nodeCode 流程节点编码
|
||||
* @param nodeName 流程节点名称
|
||||
* @param status 流程状态
|
||||
* @param params 办理参数
|
||||
* @param submit 当为true时为申请人节点办理
|
||||
*/
|
||||
public void processHandler(String flowCode, String businessId, String status, Map<String, Object> params, boolean submit) {
|
||||
public void processHandler(String flowCode, String businessId, Integer nodeType, String nodeCode, String nodeName,
|
||||
String status, Map<String, Object> params, boolean submit) {
|
||||
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
log.info("发布流程事件,租户ID: {}, 流程状态: {}, 流程编码: {}, 业务ID: {}, 是否申请人节点办理: {}", tenantId, status, flowCode, businessId, submit);
|
||||
log.info("【流程事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}, 状态: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 是否申请人节点: {}, 参数: {}",
|
||||
tenantId, flowCode, businessId, status, nodeType, nodeCode, nodeName, submit, params);
|
||||
|
||||
ProcessEvent processEvent = new ProcessEvent();
|
||||
processEvent.setTenantId(tenantId);
|
||||
processEvent.setFlowCode(flowCode);
|
||||
processEvent.setBusinessId(businessId);
|
||||
processEvent.setNodeType(nodeType);
|
||||
processEvent.setNodeCode(nodeCode);
|
||||
processEvent.setNodeName(nodeName);
|
||||
processEvent.setStatus(status);
|
||||
processEvent.setParams(params);
|
||||
processEvent.setSubmit(submit);
|
||||
@@ -47,17 +58,22 @@ public class FlowProcessEventHandler {
|
||||
* 执行创建任务监听
|
||||
*
|
||||
* @param flowCode 流程定义编码
|
||||
* @param nodeCode 审批节点编码
|
||||
* @param nodeType 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
* @param nodeCode 流程节点编码
|
||||
* @param nodeName 流程节点名称
|
||||
* @param taskId 任务id
|
||||
* @param businessId 业务id
|
||||
*/
|
||||
public void processCreateTaskHandler(String flowCode, String nodeCode, Long taskId, String businessId) {
|
||||
public void processCreateTaskHandler(String flowCode, Integer nodeType, String nodeCode, String nodeName, Long taskId, String businessId) {
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
log.info("发布流程任务事件, 租户ID: {}, 流程编码: {}, 节点编码: {}, 任务ID: {}, 业务ID: {}", tenantId, flowCode, nodeCode, taskId, businessId);
|
||||
log.info("发布流程任务事件, 租户ID: {}, 流程编码: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 任务ID: {}, 业务ID: {}",
|
||||
tenantId, flowCode, nodeType, nodeCode, nodeName, taskId, businessId);
|
||||
ProcessCreateTaskEvent processCreateTaskEvent = new ProcessCreateTaskEvent();
|
||||
processCreateTaskEvent.setTenantId(tenantId);
|
||||
processCreateTaskEvent.setFlowCode(flowCode);
|
||||
processCreateTaskEvent.setNodeType(nodeType);
|
||||
processCreateTaskEvent.setNodeCode(nodeCode);
|
||||
processCreateTaskEvent.setNodeName(nodeName);
|
||||
processCreateTaskEvent.setTaskId(taskId);
|
||||
processCreateTaskEvent.setBusinessId(businessId);
|
||||
SpringUtils.context().publishEvent(processCreateTaskEvent);
|
||||
|
@@ -1,22 +1,16 @@
|
||||
package org.dromara.workflow.handler;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.enums.TaskAssigneeEnum;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.warm.flow.core.dto.FlowParams;
|
||||
import org.dromara.warm.flow.core.handler.PermissionHandler;
|
||||
import org.dromara.warm.flow.core.service.impl.TaskServiceImpl;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 办理人权限处理器
|
||||
@@ -36,28 +30,7 @@ public class WorkflowPermissionHandler implements PermissionHandler {
|
||||
*/
|
||||
@Override
|
||||
public List<String> permissions() {
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 使用一个流来构建权限列表
|
||||
return Stream.of(
|
||||
// 角色权限前缀
|
||||
loginUser.getRoles().stream()
|
||||
.map(role -> TaskAssigneeEnum.ROLE.getCode() + role.getRoleId()),
|
||||
|
||||
// 岗位权限前缀
|
||||
Stream.ofNullable(loginUser.getPosts())
|
||||
.flatMap(Collection::stream)
|
||||
.map(post -> TaskAssigneeEnum.POST.getCode() + post.getPostId()),
|
||||
|
||||
// 用户和部门权限
|
||||
Stream.of(String.valueOf(loginUser.getUserId()),
|
||||
TaskAssigneeEnum.DEPT.getCode() + loginUser.getDeptId()
|
||||
)
|
||||
)
|
||||
.flatMap(stream -> stream)
|
||||
.collect(Collectors.toList());
|
||||
return Collections.singletonList(LoginHelper.getUserIdStr());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -52,7 +52,8 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
Task task = listenerVariable.getTask();
|
||||
if (task != null && BusinessStatusEnum.WAITING.getStatus().equals(flowStatus)) {
|
||||
// 判断流程状态(发布审批中事件)
|
||||
flowProcessEventHandler.processCreateTaskHandler(definition.getFlowCode(), task.getNodeCode(), task.getId(), businessId);
|
||||
flowProcessEventHandler.processCreateTaskHandler(definition.getFlowCode(), task.getNodeType(),
|
||||
task.getNodeCode(), task.getNodeName(), task.getId(), businessId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +84,6 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
public void finish(ListenerVariable listenerVariable) {
|
||||
Instance instance = listenerVariable.getInstance();
|
||||
Definition definition = listenerVariable.getDefinition();
|
||||
String businessId = instance.getBusinessId();
|
||||
String flowStatus = instance.getFlowStatus();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
FlowParams flowParams = listenerVariable.getFlowParams();
|
||||
if (ObjectUtil.isNotNull(flowParams)) {
|
||||
@@ -96,20 +95,21 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
params.put("message", flowParams.getMessage());
|
||||
}
|
||||
// 判断流程状态(发布:撤销,退回,作废,终止,已完成事件)
|
||||
String status = determineFlowStatus(instance, flowStatus);
|
||||
String status = determineFlowStatus(instance);
|
||||
if (StringUtils.isNotBlank(status)) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), businessId, status, params, false);
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance.getBusinessId(), instance.getNodeType(),
|
||||
instance.getNodeCode(), instance.getNodeName(), status, params, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程实例和当前流程状态确定最终状态
|
||||
* 根据流程实例确定最终状态
|
||||
*
|
||||
* @param instance 流程实例
|
||||
* @param flowStatus 流程实例当前状态
|
||||
* @param instance 流程实例
|
||||
* @return 流程最终状态
|
||||
*/
|
||||
private String determineFlowStatus(Instance instance, String flowStatus) {
|
||||
private String determineFlowStatus(Instance instance) {
|
||||
String flowStatus = instance.getFlowStatus();
|
||||
if (StringUtils.isNotBlank(flowStatus) && BusinessStatusEnum.initialState(flowStatus)) {
|
||||
log.info("流程实例当前状态: {}", flowStatus);
|
||||
return flowStatus;
|
||||
|
@@ -162,7 +162,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
Definition definition = defService.getById(flowTask.getDefinitionId());
|
||||
// 检查流程状态是否为草稿、已撤销或已退回状态,若是则执行流程提交监听
|
||||
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), ins.getBusinessId(), ins.getFlowStatus(), null, true);
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), ins.getBusinessId(), ins.getNodeType(),
|
||||
ins.getNodeCode(), ins.getNodeName(), ins.getFlowStatus(), null, true);
|
||||
}
|
||||
// 设置弹窗处理人
|
||||
Map<String, Object> assigneeMap = setPopAssigneeMap(completeTaskBo.getAssigneeMap(), ins.getVariableMap());
|
||||
|
Reference in New Issue
Block a user