update - 任务事件中添加任务的处理状态

This commit is contained in:
wangli 2023-12-07 18:57:16 +08:00
parent dd1abd11cf
commit 575164d738
2 changed files with 8 additions and 1 deletions

View File

@ -316,12 +316,12 @@ public class BpmnProcessTaskServiceImpl implements BpmnProcessTaskService {
Authentication.setAuthenticatedUserId(null); Authentication.setAuthenticatedUserId(null);
} }
if (Objects.nonNull(dto.getNextApprover())) { if (Objects.nonNull(dto.getNextApprover())) {
// 主动设置下级审批人
runtimeService.setVariable(task.getProcessInstanceId(), INTERNAL_SPECIFY_NEXT_APPROVER, runtimeService.setVariable(task.getProcessInstanceId(), INTERNAL_SPECIFY_NEXT_APPROVER,
dto.getNextApprover()); dto.getNextApprover());
} }
saveAttachment(dto.getAttachmentList(), instance.getId(), task.getId()); saveAttachment(dto.getAttachmentList(), instance.getId(), task.getId());
// 主动设置下级审批人
// 完成任务审批通过 // 完成任务审批通过
if (StringUtil.isNotEmpty(task.getExecutionId())) { if (StringUtil.isNotEmpty(task.getExecutionId())) {
taskService.complete(task.getId(), runtimeService.getVariables(task.getExecutionId())); taskService.complete(task.getId(), runtimeService.getVariables(task.getExecutionId()));

View File

@ -2,6 +2,7 @@ package cn.axzo.workflow.server.controller.listener.task;
import cn.axzo.framework.rocketmq.Event; import cn.axzo.framework.rocketmq.Event;
import cn.axzo.framework.rocketmq.EventProducer; import cn.axzo.framework.rocketmq.EventProducer;
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
import cn.axzo.workflow.common.enums.ProcessTaskEventEnum; import cn.axzo.workflow.common.enums.ProcessTaskEventEnum;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner; import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.common.model.response.mq.ProcessTaskDTO; import cn.axzo.workflow.common.model.response.mq.ProcessTaskDTO;
@ -19,9 +20,12 @@ import org.springframework.core.Ordered;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Objects;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR; import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO_SNAPSHOT; import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO_SNAPSHOT;
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE;
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.APPROVED;
import static cn.axzo.workflow.common.enums.ProcessTaskEventEnum.PROCESS_TASK_ASSIGNED; import static cn.axzo.workflow.common.enums.ProcessTaskEventEnum.PROCESS_TASK_ASSIGNED;
import static cn.axzo.workflow.common.enums.ProcessTaskEventEnum.PROCESS_TASK_COMPLETED; import static cn.axzo.workflow.common.enums.ProcessTaskEventEnum.PROCESS_TASK_COMPLETED;
import static cn.axzo.workflow.common.enums.ProcessTaskEventEnum.PROCESS_TASK_CREATED; import static cn.axzo.workflow.common.enums.ProcessTaskEventEnum.PROCESS_TASK_CREATED;
@ -121,6 +125,9 @@ public class RocketMqBpmnTaskEventListener implements BpmnTaskEventListener, Ord
.setStartTime(delegateTask.getCreateTime()) .setStartTime(delegateTask.getCreateTime())
.setTenantId(delegateTask.getTenantId()); .setTenantId(delegateTask.getTenantId());
BpmnMetaParserHelper.getNoticeConfig(mainProcess).ifPresent(dto::setNoticeConf); BpmnMetaParserHelper.getNoticeConfig(mainProcess).ifPresent(dto::setNoticeConf);
BpmnProcessInstanceResultEnum resultEnum = runtimeService.getVariable(delegateTask.getExecutionId(),
TASK_COMPLETE_OPERATION_TYPE + delegateTask.getId(), BpmnProcessInstanceResultEnum.class);
dto.setTaskResult(Objects.nonNull(resultEnum) ? resultEnum : APPROVED);
return dto; return dto;
} }