update - 工作流的主要动作添加异步接口支持

This commit is contained in:
wangli 2024-04-15 21:07:43 +08:00
parent 79c717d8cc
commit 01fc2eee8b
2 changed files with 20 additions and 3 deletions

View File

@ -54,14 +54,16 @@ public class CustomApproveTaskCmd implements Command<Void>, Serializable {
* 下级节点的审批,可为空
*/
private final BpmnTaskDelegateAssigner nextApprover;
private final Boolean async;
public CustomApproveTaskCmd(String taskId, String advice, List<AttachmentDTO> attachmentList,
BpmnTaskDelegateAssigner approver, BpmnTaskDelegateAssigner nextApprover) {
BpmnTaskDelegateAssigner approver, BpmnTaskDelegateAssigner nextApprover, Boolean async) {
this.taskId = taskId;
this.advice = advice;
this.attachmentList = attachmentList;
this.approver = approver;
this.nextApprover = nextApprover;
this.async = async;
}
public CustomApproveTaskCmd(String taskId, String advice, String operationDesc, List<AttachmentDTO> attachmentList,
BpmnTaskDelegateAssigner approver, BpmnTaskDelegateAssigner nextApprover) {
@ -71,6 +73,7 @@ public class CustomApproveTaskCmd implements Command<Void>, Serializable {
this.attachmentList = attachmentList;
this.approver = approver;
this.nextApprover = nextApprover;
this.async = false;
}
@Override
@ -110,6 +113,15 @@ public class CustomApproveTaskCmd implements Command<Void>, Serializable {
((TaskEntity) task).setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + taskId, APPROVED.getStatus());
if (async) {
} else {
executeSynchronous(task, taskService, runtimeService);
}
return null;
}
private void executeSynchronous(Task task, TaskService taskService, RuntimeService runtimeService) {
if (StringUtils.hasLength(task.getExecutionId())) {
// 正常完成流程任务审批通过
taskService.complete(task.getId(), runtimeService.getVariables(task.getExecutionId()));
@ -117,6 +129,11 @@ public class CustomApproveTaskCmd implements Command<Void>, Serializable {
// 特殊的完成单独创建的任务
taskService.complete(task.getId());
}
return null;
}
private void executeAsynchronous() {
}
}

View File

@ -291,7 +291,7 @@ public class BpmnProcessTaskServiceImpl implements BpmnProcessTaskService {
public void approveTask(BpmnTaskAuditDTO dto) {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
commandExecutor.execute(new CustomApproveTaskCmd(dto.getTaskId(), dto.getAdvice(), dto.getAttachmentList(),
dto.getApprover(), dto.getNextApprover()));
dto.getApprover(), dto.getNextApprover(), dto.getAsync()));
}
@Override