mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 10:13:28 +08:00
update 调整流程执行非空校验,调整任务节点执行
This commit is contained in:
parent
5bb3f65bae
commit
afb2c67022
@ -2,8 +2,6 @@ package org.dromara.workflow.flowable.config;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
||||
import org.dromara.workflow.flowable.strategy.FlowEventStrategy;
|
||||
import org.dromara.workflow.flowable.strategy.FlowTaskEventHandler;
|
||||
import org.flowable.bpmn.model.BoundaryEvent;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.bpmn.model.FlowElement;
|
||||
@ -12,11 +10,9 @@ import org.flowable.common.engine.impl.cfg.TransactionState;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.Execution;
|
||||
import org.flowable.engine.task.Comment;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -44,16 +40,12 @@ public class GlobalFlowableListener implements FlowableEventListener {
|
||||
@Lazy
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Autowired
|
||||
private FlowEventStrategy flowEventStrategy;
|
||||
|
||||
@Override
|
||||
public void onEvent(FlowableEvent flowableEvent) {
|
||||
if (flowableEvent instanceof FlowableEngineEvent flowableEngineEvent) {
|
||||
FlowableEngineEventType engineEventType = (FlowableEngineEventType) flowableEvent.getType();
|
||||
switch (engineEventType) {
|
||||
case JOB_EXECUTION_SUCCESS -> jobExecutionSuccess((FlowableEngineEntityEvent) flowableEngineEvent);
|
||||
case TASK_COMPLETED -> taskCompleted((FlowableEngineEntityEvent) flowableEngineEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,21 +88,4 @@ public class GlobalFlowableListener implements FlowableEventListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理任务办理监听
|
||||
*
|
||||
* @param event 事件
|
||||
*/
|
||||
protected void taskCompleted(FlowableEngineEntityEvent event) {
|
||||
TaskEntity entity = (TaskEntity) event.getEntity();
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(entity.getProcessDefinitionId()).singleResult();
|
||||
String processDefinitionKey = processDefinition.getKey();
|
||||
String taskDefinitionKey = entity.getTaskDefinitionKey();
|
||||
String key = processDefinitionKey + "_" + taskDefinitionKey;
|
||||
FlowTaskEventHandler handler = flowEventStrategy.getTaskHandler(key);
|
||||
if (handler != null) {
|
||||
handler.handleTask(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package org.dromara.workflow.flowable.strategy;
|
||||
|
||||
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
import org.flowable.task.api.Task;
|
||||
|
||||
/**
|
||||
* 流程任务监听
|
||||
@ -13,7 +13,7 @@ public interface FlowTaskEventHandler {
|
||||
/**
|
||||
* 执行办理任务监听
|
||||
*
|
||||
* @param taskEntity 任务
|
||||
* @param task 任务
|
||||
*/
|
||||
void handleTask(TaskEntity taskEntity);
|
||||
void handleTask(Task task);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package org.dromara.workflow.listener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.workflow.annotation.FlowListenerAnnotation;
|
||||
import org.dromara.workflow.flowable.strategy.FlowTaskEventHandler;
|
||||
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@ -18,7 +18,7 @@ import org.springframework.stereotype.Component;
|
||||
public class TestCustomTaskHandler implements FlowTaskEventHandler {
|
||||
|
||||
@Override
|
||||
public void handleTask(TaskEntity taskEntity) {
|
||||
log.info("任务名称:" + taskEntity.getName());
|
||||
public void handleTask(Task task) {
|
||||
log.info("任务名称:" + task.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,7 +370,9 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||
runtimeService.updateBusinessStatus(processInvalidBo.getProcessInstanceId(), BusinessStatusEnum.INVALID.getStatus());
|
||||
runtimeService.deleteProcessInstance(processInvalidBo.getProcessInstanceId(), deleteReason);
|
||||
FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(historicProcessInstance.getProcessDefinitionKey());
|
||||
processHandler.handleProcess(historicProcessInstance.getId(), BusinessStatusEnum.INVALID.getStatus());
|
||||
if (processHandler != null) {
|
||||
processHandler.handleProcess(historicProcessInstance.getId(), BusinessStatusEnum.INVALID.getStatus());
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -501,7 +503,9 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||
}
|
||||
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.CANCEL.getStatus());
|
||||
FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(processInstance.getProcessDefinitionKey());
|
||||
processHandler.handleProcess(processInstanceId, BusinessStatusEnum.CANCEL.getStatus());
|
||||
if (processHandler != null) {
|
||||
processHandler.handleProcess(processInstanceId, BusinessStatusEnum.CANCEL.getStatus());
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -23,6 +23,7 @@ import org.dromara.workflow.domain.vo.TaskVo;
|
||||
import org.dromara.workflow.flowable.strategy.FlowEventStrategy;
|
||||
import org.dromara.workflow.flowable.cmd.*;
|
||||
import org.dromara.workflow.flowable.strategy.FlowProcessEventHandler;
|
||||
import org.dromara.workflow.flowable.strategy.FlowTaskEventHandler;
|
||||
import org.dromara.workflow.service.IActTaskService;
|
||||
import org.dromara.workflow.utils.WorkflowUtils;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
@ -152,6 +153,11 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
return true;
|
||||
}
|
||||
runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.WAITING.getStatus());
|
||||
String key = processInstance.getProcessDefinitionKey() + "_" + task.getTaskDefinitionKey();
|
||||
FlowTaskEventHandler taskHandler = flowEventStrategy.getTaskHandler(key);
|
||||
if (taskHandler != null) {
|
||||
taskHandler.handleTask(task);
|
||||
}
|
||||
//办理意见
|
||||
taskService.addComment(completeTaskBo.getTaskId(), task.getProcessInstanceId(), TaskStatusEnum.PASS.getStatus(), StringUtils.isBlank(completeTaskBo.getMessage()) ? "同意" : completeTaskBo.getMessage());
|
||||
//办理任务
|
||||
@ -165,7 +171,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
UpdateBusinessStatusCmd updateBusinessStatusCmd = new UpdateBusinessStatusCmd(task.getProcessInstanceId(), BusinessStatusEnum.FINISH.getStatus());
|
||||
managementService.executeCommand(updateBusinessStatusCmd);
|
||||
FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(processInstance.getProcessDefinitionKey());
|
||||
processHandler.handleProcess(processInstance.getId(), BusinessStatusEnum.FINISH.getStatus());
|
||||
if (processHandler != null) {
|
||||
processHandler.handleProcess(processInstance.getId(), BusinessStatusEnum.FINISH.getStatus());
|
||||
}
|
||||
} else {
|
||||
sendMessage(list, processInstance.getName(), completeTaskBo.getMessageType(), null);
|
||||
}
|
||||
@ -437,7 +445,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
}
|
||||
runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.TERMINATION.getStatus());
|
||||
FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(historicProcessInstance.getProcessDefinitionKey());
|
||||
processHandler.handleProcess(historicProcessInstance.getId(), BusinessStatusEnum.TERMINATION.getStatus());
|
||||
if (processHandler != null) {
|
||||
processHandler.handleProcess(historicProcessInstance.getId(), BusinessStatusEnum.TERMINATION.getStatus());
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
@ -617,7 +627,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
}
|
||||
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.BACK.getStatus());
|
||||
FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(processInstance.getProcessDefinitionKey());
|
||||
processHandler.handleProcess(processInstanceId, BusinessStatusEnum.BACK.getStatus());
|
||||
if (processHandler != null) {
|
||||
processHandler.handleProcess(processInstanceId, BusinessStatusEnum.BACK.getStatus());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user