mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-11-28 11:39:26 +08:00
Compare commits
2 Commits
74e3d232f5
...
6b0b7382a6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b0b7382a6 | ||
|
|
c41add355f |
@@ -55,6 +55,7 @@ public class FlowProcessEventHandler {
|
|||||||
* @param flowCode 流程定义编码
|
* @param flowCode 流程定义编码
|
||||||
* @param instance 实例数据
|
* @param instance 实例数据
|
||||||
* @param taskId 任务id
|
* @param taskId 任务id
|
||||||
|
* @param params 上一个任务的办理参数
|
||||||
*/
|
*/
|
||||||
public void processTaskHandler(String flowCode, Instance instance, Long taskId, Map<String, Object> params) {
|
public void processTaskHandler(String flowCode, Instance instance, Long taskId, Map<String, Object> params) {
|
||||||
String tenantId = TenantHelper.getTenantId();
|
String tenantId = TenantHelper.getTenantId();
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import org.dromara.warm.flow.core.listener.GlobalListener;
|
|||||||
import org.dromara.warm.flow.core.listener.ListenerVariable;
|
import org.dromara.warm.flow.core.listener.ListenerVariable;
|
||||||
import org.dromara.warm.flow.core.service.InsService;
|
import org.dromara.warm.flow.core.service.InsService;
|
||||||
import org.dromara.warm.flow.orm.entity.FlowInstance;
|
import org.dromara.warm.flow.orm.entity.FlowInstance;
|
||||||
import org.dromara.warm.flow.orm.entity.FlowTask;
|
|
||||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||||
import org.dromara.workflow.common.constant.FlowConstant;
|
import org.dromara.workflow.common.constant.FlowConstant;
|
||||||
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
||||||
@@ -105,6 +104,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
|||||||
Instance instance = listenerVariable.getInstance();
|
Instance instance = listenerVariable.getInstance();
|
||||||
Definition definition = listenerVariable.getDefinition();
|
Definition definition = listenerVariable.getDefinition();
|
||||||
Task task = listenerVariable.getTask();
|
Task task = listenerVariable.getTask();
|
||||||
|
List<Task> nextTasks = listenerVariable.getNextTasks();
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
FlowParams flowParams = listenerVariable.getFlowParams();
|
FlowParams flowParams = listenerVariable.getFlowParams();
|
||||||
Map<String, Object> variable = new HashMap<>();
|
Map<String, Object> variable = new HashMap<>();
|
||||||
@@ -129,8 +129,10 @@ public class WorkflowGlobalListener implements GlobalListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//发布任务事件
|
//发布任务事件
|
||||||
if (task != null) {
|
if (CollUtil.isNotEmpty(nextTasks)) {
|
||||||
flowProcessEventHandler.processTaskHandler(definition.getFlowCode(), instance, task.getId(), params);
|
for (Task nextTask : nextTasks) {
|
||||||
|
flowProcessEventHandler.processTaskHandler(definition.getFlowCode(), instance, nextTask.getId(), params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNull(flowParams)) {
|
if (ObjectUtil.isNull(flowParams)) {
|
||||||
return;
|
return;
|
||||||
@@ -180,8 +182,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
|||||||
return flowStatus;
|
return flowStatus;
|
||||||
} else {
|
} else {
|
||||||
Long instanceId = instance.getId();
|
Long instanceId = instance.getId();
|
||||||
List<FlowTask> flowTasks = flwTaskService.selectByInstId(instanceId);
|
if (flwTaskService.isTaskEnd(instanceId)) {
|
||||||
if (CollUtil.isEmpty(flowTasks)) {
|
|
||||||
String status = BusinessStatusEnum.FINISH.getStatus();
|
String status = BusinessStatusEnum.FINISH.getStatus();
|
||||||
// 更新流程状态为已完成
|
// 更新流程状态为已完成
|
||||||
instanceService.updateStatus(instanceId, status);
|
instanceService.updateStatus(instanceId, status);
|
||||||
|
|||||||
@@ -165,6 +165,14 @@ public interface IFlwTaskService {
|
|||||||
*/
|
*/
|
||||||
List<FlowTask> selectByInstId(Long instanceId);
|
List<FlowTask> selectByInstId(Long instanceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断流程是否已结束(即该流程实例下是否还有未完成的任务)
|
||||||
|
*
|
||||||
|
* @param instanceId 流程实例ID
|
||||||
|
* @return true 表示任务已全部结束;false 表示仍有任务存在
|
||||||
|
*/
|
||||||
|
boolean isTaskEnd(Long instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务操作
|
* 任务操作
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -574,6 +574,19 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
.eq(FlowTask::getInstanceId, instanceId));
|
.eq(FlowTask::getInstanceId, instanceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断流程是否已结束(即该流程实例下是否还有未完成的任务)
|
||||||
|
*
|
||||||
|
* @param instanceId 流程实例ID
|
||||||
|
* @return true 表示任务已全部结束;false 表示仍有任务存在
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isTaskEnd(Long instanceId) {
|
||||||
|
boolean exists = flowTaskMapper.exists(new LambdaQueryWrapper<FlowTask>()
|
||||||
|
.eq(FlowTask::getInstanceId, instanceId));
|
||||||
|
return !exists;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务操作
|
* 任务操作
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user