update - 完善虚拟机器人节点的完成时,重新分配给原审批人

This commit is contained in:
wangli 2024-01-02 16:57:59 +08:00
parent 5a591e44fa
commit 657bc04b68
3 changed files with 11 additions and 17 deletions

View File

@ -8,7 +8,6 @@ import org.flowable.engine.TaskService;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.task.api.Task;
import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity;
import org.springframework.util.CollectionUtils;
import java.io.Serializable;
@ -55,6 +54,8 @@ public class CustomCompleteDummyTaskCmd implements Command<Void>, Serializable {
CustomTaskHelper.addComment(commandContext, task, COMMENT_TYPE_OPERATION_DUMMY_OPERATION_DESC, operationDesc);
taskService.complete(task.getId());
continueProcessingTask(commandContext);
return null;
}
@ -67,17 +68,11 @@ public class CustomCompleteDummyTaskCmd implements Command<Void>, Serializable {
if (CollectionUtils.isEmpty(taskList)) {
return;
}
List<HistoricTaskInstanceEntity> inCache =
CommandContextUtil.getEntityCache().findInCache(HistoricTaskInstanceEntity.class);
taskList.stream().filter(i -> !Objects.equals(i.getTaskDefinitionKey(), DUMMY_ID))
.filter(i -> Objects.nonNull(i.getOwner()))
.forEach(i -> {
i.setAssignee(i.getOwner());
i.setOwner(null);
inCache.stream().filter(cache -> Objects.equals(cache.getId(), i.getId())).findFirst().ifPresent(j -> {
j.setAssignee(i.getOwner());
j.setOwner(null);
});
taskService.setAssignee(i.getId(), i.getOwner());
taskService.setOwner(i.getId(), null);
});
}
}

View File

@ -100,16 +100,10 @@ public class CustomCreateDummyTaskCmd implements Command<String>, Serializable {
CommandContextUtil.getProcessEngineConfiguration(commandContext);
TaskService taskService = processEngineConfiguration.getTaskService();
List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstanceId).active().list();
List<HistoricTaskInstanceEntity> inCache =
CommandContextUtil.getEntityCache().findInCache(HistoricTaskInstanceEntity.class);
if (!CollectionUtils.isEmpty(taskList)) {
taskList.forEach(i -> {
i.setOwner(i.getAssignee());
i.setAssignee(HIDDEN_ASSIGNEE_ID);
inCache.stream().filter(cache -> Objects.equals(cache.getId(), i.getId())).findFirst().ifPresent(j -> {
j.setOwner(j.getAssignee());
j.setAssignee(HIDDEN_ASSIGNEE_ID);
});
taskService.setOwner(i.getId(), i.getAssignee());
taskService.setAssignee(i.getId(), HIDDEN_ASSIGNEE_ID);
});
}
}

View File

@ -17,11 +17,13 @@ import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO;
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ASSIGNEE_SKIP_FLAT;
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_CREATED;
@ -67,6 +69,9 @@ public class RocketMqBpmnTaskEventListener implements BpmnTaskEventListener, Ord
if (log.isDebugEnabled()) {
log.debug("RocketMqBpmnTaskEventListener#onAssigned...{}", delegateTask.getTaskDefinitionKey());
}
if (StringUtils.hasLength(delegateTask.getAssignee()) && delegateTask.getAssignee().contains(TASK_ASSIGNEE_SKIP_FLAT)) {
return;
}
ProcessTaskDTO dto = build(delegateTask, PROCESS_TASK_ASSIGNED);
sendMessageQueue(dto, PROCESS_TASK_ASSIGNED);
if (log.isDebugEnabled()) {