REQ-2924-添加附件设置到任务本地变量
This commit is contained in:
parent
4174e4f451
commit
3a826d8fa6
@ -28,7 +28,6 @@ import java.util.Objects;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_ADVICE;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_OPERATION_DESC;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_SPECIFY_NEXT_APPROVER;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ATTACHMENTS_VAR_NAME;
|
||||
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.core.engine.cmd.helper.CustomTaskHelper.addComment;
|
||||
@ -128,7 +127,7 @@ public class CustomApproveTaskCmd extends AbstractCommand<Void> implements Seria
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
}
|
||||
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), taskId, attachmentList, approver);
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task, attachmentList, approver);
|
||||
|
||||
Authentication.setAuthenticatedUserId(Objects.nonNull(approver) ? approver.buildAssigneeId() : null);
|
||||
addComment(commandContext, task, COMMENT_TYPE_OPERATION_DESC, operationDesc);
|
||||
@ -141,7 +140,6 @@ public class CustomApproveTaskCmd extends AbstractCommand<Void> implements Seria
|
||||
nextApprover);
|
||||
}
|
||||
task.setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + taskId, APPROVED.getStatus());
|
||||
task.setTransientVariableLocal(TASK_ATTACHMENTS_VAR_NAME, attachmentList);
|
||||
executeSynchronous(task, taskService, runtimeService);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class CustomBackTaskCmd extends AbstractCommand<Void> implements Serializ
|
||||
if (!BpmnModelUtils.isReachable(process, (FlowNode) targetFlowElement, (FlowNode) sourceFlowElement)) {
|
||||
throw new WorkflowEngineException(BACK_NODE_CANNOT_REACHABLE, dto.getToActivityId());
|
||||
}
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), dto.getTaskId(), dto.getAttachmentList(), dto.getApprover());
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task, dto.getAttachmentList(), dto.getApprover());
|
||||
|
||||
Authentication.setAuthenticatedUserId(dto.getApprover().buildAssigneeId());
|
||||
addComment(commandContext, task, COMMENT_TYPE_ADVICE, dto.getAdvice());
|
||||
|
||||
@ -125,7 +125,7 @@ public class CustomCommentTaskCmd extends AbstractCommand<Void> implements Seria
|
||||
addComment(commandContext, task, COMMENT_TYPE_COMMENT_EXT, JSONUtil.toJsonStr(commentExt));
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
// 处理附件
|
||||
batchAddAttachment(commandContext, processInstanceId, task.getId(), attachmentList, operator);
|
||||
batchAddAttachment(commandContext, processInstanceId, task, attachmentList, operator);
|
||||
|
||||
// 设置快照信息
|
||||
task.setTransientVariable(INTERNAL_TASK_RELATION_ASSIGNEE_INFO + task.getId(), operator.toJson());
|
||||
|
||||
@ -98,7 +98,7 @@ public class CustomCountersignUserTaskCmd extends AbstractCommand<Void> implemen
|
||||
|
||||
resolveOriginTask(commandContext, extAxHiTaskInstService, taskService, task);
|
||||
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task.getId(), attachmentList,
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task, attachmentList,
|
||||
originTaskAssignee);
|
||||
|
||||
switch (countersignType) {
|
||||
@ -142,7 +142,7 @@ public class CustomCountersignUserTaskCmd extends AbstractCommand<Void> implemen
|
||||
}
|
||||
|
||||
private void resolveOriginTask(CommandContext commandContext, ExtAxHiTaskInstService extAxHiTaskInstService,
|
||||
TaskService taskService, Task task) {
|
||||
TaskService taskService, TaskEntity task) {
|
||||
// 构建评论内容
|
||||
StringBuilder message = new StringBuilder("添加");
|
||||
int end = Math.min(targetTaskAssigneeList.size(), COUNTERSIGN_ASSIGNER_SHOW_NUMBER);
|
||||
@ -156,7 +156,7 @@ public class CustomCountersignUserTaskCmd extends AbstractCommand<Void> implemen
|
||||
message.append("等").append(targetTaskAssigneeList.size()).append("人进行审批");
|
||||
Task virtualTask = createVirtualTask(commandContext, extAxHiTaskInstService, task.getProcessInstanceId(), task.getName(),
|
||||
task.getTaskDefinitionKey(), advice, originTaskAssignee, COUNTERSIGN.getStatus(), new AddComment(message.toString()));
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task.getId(), attachmentList, originTaskAssignee);
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task, attachmentList, originTaskAssignee);
|
||||
completeVirtualTask(commandContext, virtualTask);
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_END_USER_I
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_END_USER_NAME;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_PROCESS_DELETE_REASON;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_PROCESS_TYPE_REJECT;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ATTACHMENTS_VAR_NAME;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.DELETED;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.REJECTED;
|
||||
@ -104,15 +103,14 @@ public class CustomRejectionTaskCmd extends AbstractCommand<Void> implements Ser
|
||||
validTask(historicTaskInstance, task, approver, nodeTypes);
|
||||
|
||||
task.setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + task.getId(), DELETED.getStatus());
|
||||
Task virtualTask = createVirtualTask(commandContext, extAxHiTaskInstService, task.getProcessInstanceId(), task.getName(),
|
||||
task.getTaskDefinitionKey(), advice,
|
||||
Objects.equals(operationDesc, "自动驳回") ? null : approver, REJECTED.getStatus(),
|
||||
new AddComment(operationDesc));
|
||||
TaskEntity virtualTask = createVirtualTask(commandContext, extAxHiTaskInstService, task.getProcessInstanceId(), task.getName(),
|
||||
task.getTaskDefinitionKey(), advice,
|
||||
Objects.equals(operationDesc, "自动驳回") ? null : approver, REJECTED.getStatus(),
|
||||
new AddComment(operationDesc));
|
||||
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), virtualTask.getId(), attachmentList, approver);
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), virtualTask, attachmentList, approver);
|
||||
completeVirtualTask(commandContext, virtualTask);
|
||||
|
||||
task.setTransientVariableLocal(TASK_ATTACHMENTS_VAR_NAME, attachmentList);
|
||||
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
|
||||
finishProcessInstance(commandContext, runtimeService, task, advice);
|
||||
return null;
|
||||
@ -129,7 +127,7 @@ public class CustomRejectionTaskCmd extends AbstractCommand<Void> implements Ser
|
||||
runtimeService.setVariables(task.getProcessInstanceId(), variables);
|
||||
CommandContextUtil.getAgenda(commandContext)
|
||||
.planOperation(new DeleteProcessInstanceOperation(commandContext, task.getProcessInstanceId(),
|
||||
extAxHiTaskInstService, REJECTED));
|
||||
extAxHiTaskInstService, REJECTED));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class CustomTransferUserTaskCmd extends AbstractCommand<Void> implements
|
||||
|
||||
// 对被转交的任务进行建议和附件的处理
|
||||
resolveOriginTask(commandContext, taskService, task);
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task.getId(), attachmentList,
|
||||
batchAddAttachment(commandContext, task.getProcessInstanceId(), task, attachmentList,
|
||||
originTaskAssignee);
|
||||
|
||||
// 生成转交任务
|
||||
|
||||
@ -55,6 +55,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_R
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.NO_ASSIGNEE;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.OLD_INTERNAL_TASK_RELATION_ASSIGNEE_INFO_SNAPSHOT;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ATTACHMENTS_VAR_NAME;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE;
|
||||
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_EMPTY;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
|
||||
@ -220,10 +221,10 @@ public class CustomTaskHelper {
|
||||
*
|
||||
* @param commandContext
|
||||
* @param processInstanceId
|
||||
* @param taskId
|
||||
* @param task
|
||||
* @param attachmentList
|
||||
*/
|
||||
public static void batchAddAttachment(CommandContext commandContext, String processInstanceId, String taskId,
|
||||
public static void batchAddAttachment(CommandContext commandContext, String processInstanceId, TaskEntity task,
|
||||
List<AttachmentDTO> attachmentList, BpmnTaskDelegateAssigner assigner) {
|
||||
if (CollectionUtils.isEmpty(attachmentList)) {
|
||||
return;
|
||||
@ -233,10 +234,11 @@ public class CustomTaskHelper {
|
||||
TaskService taskService = processEngineConfiguration.getTaskService();
|
||||
Authentication.setAuthenticatedUserId(assigner.buildAssigneeId());
|
||||
attachmentList.forEach(dto -> {
|
||||
Attachment attachment = taskService.createAttachment(dto.getType().getType(), taskId, processInstanceId,
|
||||
Attachment attachment = taskService.createAttachment(dto.getType().getType(), task.getId(), processInstanceId,
|
||||
dto.getName(), dto.getDescription(), dto.getUrl());
|
||||
taskService.saveAttachment(attachment);
|
||||
});
|
||||
task.setTransientVariableLocal(TASK_ATTACHMENTS_VAR_NAME, attachmentList);
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
}
|
||||
|
||||
@ -320,7 +322,7 @@ public class CustomTaskHelper {
|
||||
* @param extTaskInstStatus 节点状态
|
||||
* @return
|
||||
*/
|
||||
public static Task createVirtualTask(CommandContext commandContext, ExtAxHiTaskInstService extAxHiTaskInstService
|
||||
public static TaskEntity createVirtualTask(CommandContext commandContext, ExtAxHiTaskInstService extAxHiTaskInstService
|
||||
, String processInstanceId, String nodeName, String taskDefinitionKey, String advice,
|
||||
BpmnTaskDelegateAssigner assigner,
|
||||
String extTaskInstStatus, AddComment addComment) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user