update - 完善业务节点由业务指定审批人的逻辑,并自测通过

This commit is contained in:
wangli 2023-12-22 18:06:32 +08:00
parent cce18515ec
commit 931c812cae
3 changed files with 33 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil;
@ -18,6 +19,7 @@ import java.util.List;
import java.util.Objects;
import static cn.axzo.workflow.common.constant.BpmnConstants.DUMMY_ASSIGNEE_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT;
import static cn.axzo.workflow.core.common.code.BpmnTaskRespCode.ACTIVITY_BIZ_SET_ASSIGNEE_ERROR;
import static cn.axzo.workflow.core.common.code.BpmnTaskRespCode.ACTIVITY_CANT_SET_ASSIGNEE;
@ -46,21 +48,44 @@ public class CustomBizSpecifyAssigneeToTaskCmd implements Command<Boolean>, Seri
Task task = taskService.createTaskQuery().executionId(executionId)
.taskAssignee(DUMMY_ASSIGNEE_ID)
.singleResult();
validTask(task);
changeAssigneeSnapshot(commandContext, task);
addAssignee(commandContext, taskService, task);
return true;
}
private void changeAssigneeSnapshot(CommandContext commandContext, Task task) {
ProcessEngineConfigurationImpl processEngineConfiguration =
CommandContextUtil.getProcessEngineConfiguration(commandContext);
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
List<BpmnTaskDelegateAssigner> originAssingeeList = runtimeService.getVariable(task.getProcessInstanceId(),
INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + task.getTaskDefinitionKey(), List.class);
for (BpmnTaskDelegateAssigner assigner : originAssingeeList) {
if (Objects.equals(assigner.buildAssigneeId(), DUMMY_ASSIGNEE_ID)) {
originAssingeeList.remove(assigner);
break;
}
}
originAssingeeList.addAll(addedAssigners);
runtimeService.setVariable(task.getProcessInstanceId(),
INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + task.getTaskDefinitionKey(),
originAssingeeList);
}
private void addAssignee(CommandContext commandContext, TaskService taskService, Task task) {
if (CollectionUtils.isEmpty(addedAssigners)) {
return;
}
addedAssigners.forEach(i -> {
if (Objects.equals(task.getAssignee(), DUMMY_ASSIGNEE_ID)) {
task.setAssignee(i.buildAssigneeId());
taskService.saveTask(task);
taskService.setAssignee(task.getId(), i.buildAssigneeId());
} else {
CustomTaskHelper.addMultiTask(commandContext, (TaskEntity) task, i);
}

View File

@ -22,7 +22,7 @@ public @interface RepeatSubmit {
/**
* 间隔时间(ms)小于此时间视为重复提交
*/
int interval() default 30000;
int interval() default 3000;
TimeUnit timeUnit() default TimeUnit.MILLISECONDS;

View File

@ -26,6 +26,7 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static cn.axzo.workflow.common.constant.BpmnConstants.DUMMY_ASSIGNEE_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT;
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ASSIGNEE_SKIP_FLAT;
@ -59,6 +60,10 @@ public class MessagePushTaskEventListener implements BpmnTaskEventListener, Orde
pendingComplete(delegateTask);
return;
}
if (Objects.equals(DUMMY_ASSIGNEE_ID, delegateTask.getAssignee())) {
// 业务指定审批人, 不用发待办
return;
}
pendingPush(delegateTask);
if (log.isDebugEnabled()) {
log.debug("MessagePushTaskEventListener#onAssigned...end: {}", delegateTask.getTaskDefinitionKey());