update - 统一检查添加日志的 advice 时,是否有正确设置 setAuthenticatedUserId
This commit is contained in:
parent
a59b76513e
commit
d4dd01ff7e
@ -2,6 +2,7 @@ package cn.axzo.workflow.core.engine.cmd;
|
||||
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.AttachmentDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.common.engine.impl.interceptor.Command;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
@ -10,6 +11,7 @@ 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.TaskEntity;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -57,19 +59,29 @@ public class CustomApproveTaskCmd implements Command<Void>, Serializable {
|
||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
validTask((TaskEntity) task, approver);
|
||||
|
||||
addComment(commandContext, task, COMMENT_TYPE_ADVICE, advice);
|
||||
if (StringUtils.hasLength(advice)) {
|
||||
Authentication.setAuthenticatedUserId(approver.buildAssigneeId());
|
||||
addComment(commandContext, task, COMMENT_TYPE_ADVICE, advice);
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(attachmentList)) {
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), taskId, attachmentList, approver);
|
||||
}
|
||||
|
||||
Authentication.setAuthenticatedUserId(approver.buildAssigneeId());
|
||||
addComment(commandContext, task, COMMENT_TYPE_OPERATION_DESC, approver.getAssignerName() + "已通过");
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
|
||||
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
|
||||
if (Objects.nonNull(nextApprover)) {
|
||||
// 主动设置下级审批人
|
||||
runtimeService.setVariable(task.getProcessInstanceId(), INTERNAL_SPECIFY_NEXT_APPROVER,
|
||||
nextApprover);
|
||||
}
|
||||
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), taskId, attachmentList, approver);
|
||||
|
||||
((TaskEntity) task).setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + taskId, APPROVED.getStatus());
|
||||
|
||||
|
||||
if (StringUtils.hasLength(task.getExecutionId())) {
|
||||
// 正常完成流程任务,审批通过
|
||||
taskService.complete(task.getId(), runtimeService.getVariables(task.getExecutionId()));
|
||||
|
||||
@ -87,8 +87,7 @@ public class CustomCommentTaskCmd implements Command<Void>, Serializable {
|
||||
// 创建临时节点
|
||||
taskService.saveTask(task);
|
||||
// 处理该评论节点的评论人
|
||||
buildAndInsertHistoryVariable(processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService(),
|
||||
task, processInstance, processEngineConfiguration);
|
||||
buildAndInsertHistoryVariable(task, processInstance, processEngineConfiguration);
|
||||
|
||||
CommandContextUtil.getEntityCache().findInCache(HistoricTaskInstanceEntity.class).stream()
|
||||
.filter(i -> Objects.equals(i.getId(), task.getId())).findAny()
|
||||
@ -110,9 +109,11 @@ public class CustomCommentTaskCmd implements Command<Void>, Serializable {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void buildAndInsertHistoryVariable(HistoricVariableService historicVariableService, TaskEntity task,
|
||||
private void buildAndInsertHistoryVariable(TaskEntity task,
|
||||
HistoricProcessInstance processInstance,
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration) {
|
||||
HistoricVariableService historicVariableService =
|
||||
processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService();
|
||||
HistoricVariableInstanceEntity historicVariableInstance =
|
||||
historicVariableService.createHistoricVariableInstance();
|
||||
historicVariableInstance.setTaskId(task.getId());
|
||||
|
||||
@ -15,6 +15,7 @@ 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.TaskEntity;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -27,6 +28,10 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ASSIGNEE_SKIP_
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.COUNTERSIGN;
|
||||
import static cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner.buildDummyAssigner;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.batchAddAttachment;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.deleteMultiTask;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.validTask;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.validTaskAssignerDuplicated;
|
||||
|
||||
/**
|
||||
* 自定义的加签用户任务命令实现
|
||||
@ -47,9 +52,9 @@ public class CustomCountersignUserTaskCmd implements Command<Void>, Serializable
|
||||
private final List<BpmnTaskDelegateAssigner> targetTaskAssigneeList;
|
||||
|
||||
public CustomCountersignUserTaskCmd(BpmnCountersignTypeEnum countersignType, String originTaskId,
|
||||
BpmnTaskDelegateAssigner originTaskAssignee, String advice,
|
||||
List<AttachmentDTO> attachmentList,
|
||||
List<BpmnTaskDelegateAssigner> targetTaskAssigneeList) {
|
||||
BpmnTaskDelegateAssigner originTaskAssignee, String advice,
|
||||
List<AttachmentDTO> attachmentList,
|
||||
List<BpmnTaskDelegateAssigner> targetTaskAssigneeList) {
|
||||
this.countersignType = countersignType;
|
||||
this.originTaskId = originTaskId;
|
||||
this.originTaskAssignee = originTaskAssignee;
|
||||
@ -65,14 +70,18 @@ public class CustomCountersignUserTaskCmd implements Command<Void>, Serializable
|
||||
TaskService taskService = processEngineConfiguration.getTaskService();
|
||||
Task task = taskService.createTaskQuery().taskId(originTaskId).singleResult();
|
||||
|
||||
CustomTaskHelper.validTask((TaskEntity) task, originTaskAssignee);
|
||||
validTask((TaskEntity) task, originTaskAssignee);
|
||||
|
||||
List<BpmnTaskDelegateAssigner> taskDelegateAssigners =
|
||||
CustomTaskHelper.validTaskAssignerDuplicated(commandContext, (TaskEntity) task,
|
||||
targetTaskAssigneeList);
|
||||
validTaskAssignerDuplicated(commandContext, (TaskEntity) task, targetTaskAssigneeList);
|
||||
|
||||
resolveOriginTask(taskService, task);
|
||||
|
||||
if (!CollectionUtils.isEmpty(attachmentList)) {
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task.getId(), attachmentList,
|
||||
originTaskAssignee);
|
||||
}
|
||||
|
||||
switch (countersignType) {
|
||||
case FORWARD_COUNTERSIGN:
|
||||
// TODO
|
||||
@ -86,10 +95,9 @@ public class CustomCountersignUserTaskCmd implements Command<Void>, Serializable
|
||||
break;
|
||||
}
|
||||
|
||||
CustomTaskHelper.batchAddAttachment(commandContext, task.getProcessInstanceId(), task.getId(), attachmentList,
|
||||
originTaskAssignee);
|
||||
|
||||
((TaskEntity) task).setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + task.getId(), COUNTERSIGN.getStatus());
|
||||
CustomTaskHelper.deleteMultiTask(commandContext, (TaskEntity) task);
|
||||
deleteMultiTask(commandContext, (TaskEntity) task);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ 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.TaskEntity;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -66,20 +67,21 @@ public class CustomTransferUserTaskCmd implements Command<Void>, Serializable {
|
||||
Task task = taskService.createTaskQuery().taskId(originTaskId).singleResult();
|
||||
validTask((TaskEntity) task, originTaskAssignee);
|
||||
|
||||
validTaskAssignerDuplicated(commandContext, (TaskEntity) task,
|
||||
Lists.newArrayList(targetTaskAssignee));
|
||||
validTaskAssignerDuplicated(commandContext, (TaskEntity) task, Lists.newArrayList(targetTaskAssignee));
|
||||
|
||||
processAssignee(processEngineConfiguration, task);
|
||||
|
||||
resolveOriginTask(taskService, task);
|
||||
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task.getId(), attachmentList,
|
||||
originTaskAssignee);
|
||||
if (!CollectionUtils.isEmpty(attachmentList)) {
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task.getId(), attachmentList,
|
||||
originTaskAssignee);
|
||||
}
|
||||
|
||||
addMultiTask(commandContext, (TaskEntity) task, targetTaskAssignee);
|
||||
((TaskEntity) task).setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + task.getId(), TRANSFER.getStatus());
|
||||
deleteMultiTask(commandContext, (TaskEntity) task);
|
||||
|
||||
((TaskEntity) task).setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + task.getId(), TRANSFER.getStatus());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user