update - 调试自动过审的功能

This commit is contained in:
wangli 2024-03-26 18:42:47 +08:00
parent a29c75140d
commit 6a9237c0c6
4 changed files with 41 additions and 16 deletions

View File

@ -38,14 +38,25 @@ public class CustomApproveTaskCmd implements Command<Void>, Serializable {
private final String taskId;
private final String advice;
/**
* 不传,默认"已通过"
*/
private final String operationDesc;
/**
* 附件, 可为空
*/
private final List<AttachmentDTO> attachmentList;
private final BpmnTaskDelegateAssigner approver;
/**
* 下级节点的审批,可为空
*/
private final BpmnTaskDelegateAssigner nextApprover;
public CustomApproveTaskCmd(String taskId, String advice, List<AttachmentDTO> attachmentList,
public CustomApproveTaskCmd(String taskId, String advice, String operationDesc, List<AttachmentDTO> attachmentList,
BpmnTaskDelegateAssigner approver, BpmnTaskDelegateAssigner nextApprover) {
this.taskId = taskId;
this.advice = advice;
this.operationDesc = operationDesc;
this.attachmentList = attachmentList;
this.approver = approver;
this.nextApprover = nextApprover;
@ -72,8 +83,9 @@ public class CustomApproveTaskCmd implements Command<Void>, Serializable {
batchAddAttachment(commandContext, task.getProcessInstanceId(), taskId, attachmentList, approver);
Authentication.setAuthenticatedUserId(approver.buildAssigneeId());
addComment(commandContext, task, COMMENT_TYPE_OPERATION_DESC, "已通过");
Authentication.setAuthenticatedUserId(Objects.nonNull(approver) ? approver.buildAssigneeId() : null);
addComment(commandContext, task, COMMENT_TYPE_OPERATION_DESC, StringUtils.hasText(operationDesc) ?
operationDesc : "已通过");
Authentication.setAuthenticatedUserId(null);
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();

View File

@ -289,7 +289,8 @@ public class BpmnProcessTaskServiceImpl implements BpmnProcessTaskService {
@Transactional(rollbackFor = Exception.class)
public void approveTask(BpmnTaskAuditDTO dto) {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
commandExecutor.execute(new CustomApproveTaskCmd(dto.getTaskId(), dto.getAdvice(), dto.getAttachmentList(),
commandExecutor.execute(new CustomApproveTaskCmd(dto.getTaskId(), dto.getAdvice(), null,
dto.getAttachmentList(),
dto.getApprover(), dto.getNextApprover()));
}

View File

@ -2,6 +2,7 @@ package cn.axzo.workflow.server.controller.listener.task;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.engine.cmd.CustomApproveTaskCmd;
import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
import lombok.AllArgsConstructor;
@ -9,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.UserTask;
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
@ -23,6 +25,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@ -58,7 +61,7 @@ import static cn.axzo.workflow.core.common.enums.BpmnProcessTaskResultEnum.REJEC
public class AutoOperatorEventListener implements BpmnTaskEventListener, Ordered {
@Override
public int getOrder() {
return Integer.MIN_VALUE + 102;
return Integer.MIN_VALUE + 103;
}
private final TaskService taskService;
@ -251,15 +254,24 @@ public class AutoOperatorEventListener implements BpmnTaskEventListener, Ordered
private void autoPass(DelegateTask delegateTask) {
if (log.isDebugEnabled()) {
log.debug("AutoOperatorEventListener#autoPass...{}", delegateTask.getTaskDefinitionKey());
}
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), COMMENT_TYPE_OPERATION_DESC,
"自动通过");
delegateTask.setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + delegateTask.getId(), APPROVED.getStatus());
taskService.complete(delegateTask.getId(), runtimeService.getVariables(delegateTask.getExecutionId()));
if (log.isDebugEnabled()) {
log.debug("AutoOperatorEventListener#autoPass...end: {}", delegateTask.getTaskDefinitionKey());
}
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
commandExecutor.execute(new CustomApproveTaskCmd(delegateTask.getId(), null, "自动通过",
Collections.emptyList(), null, null));
// if (log.isDebugEnabled()) {
// log.debug("AutoOperatorEventListener#autoPass...{}", delegateTask.getTaskDefinitionKey());
// }
// taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(),
// COMMENT_TYPE_OPERATION_DESC,
// "自动通过");
// delegateTask.setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + delegateTask.getId(), APPROVED
// .getStatus());
// taskService.complete(delegateTask.getId(), runtimeService.getVariables(delegateTask.getExecutionId
// ()));
// if (log.isDebugEnabled()) {
// log.debug("AutoOperatorEventListener#autoPass...end: {}", delegateTask.getTaskDefinitionKey());
// }
}
}

View File

@ -50,7 +50,7 @@ import static cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEventType.ADD
public class MessagePushTaskEventListener implements BpmnTaskEventListener, Ordered {
@Override
public int getOrder() {
return Integer.MIN_VALUE + 103;
return Integer.MIN_VALUE + 104;
}
private final RuntimeService runtimeService;