feat(REQ-3769) - 测试流程审批过程中,替换文件变量

This commit is contained in:
wangli 2025-04-11 19:19:41 +08:00
parent 5f34a74b88
commit 1d40dca871
4 changed files with 23 additions and 15 deletions

View File

@ -234,4 +234,5 @@ public interface BpmnConstants {
* 签署人 * 签署人
*/ */
String SIGNATORIES = "[_SIGNATORIES_]"; String SIGNATORIES = "[_SIGNATORIES_]";
String TASK_SUBMIT_FORM_VARIABLE = "[_TASK_SUBMIT_FORM_VARIABLE_]";
} }

View File

@ -43,6 +43,7 @@ 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.COMMENT_TYPE_OPERATION_DESC;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_SPECIFY_NEXT_APPROVER; import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_SPECIFY_NEXT_APPROVER;
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE; import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE;
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_SUBMIT_FORM_VARIABLE;
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.APPROVED; import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.APPROVED;
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.addComment; import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.addComment;
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.batchAddAttachment; import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.batchAddAttachment;
@ -209,6 +210,7 @@ public class CustomApproveTaskWithFormCmd extends AbstractCommand<Void> implemen
.deploymentId(relation.getFormDeploymentId()) .deploymentId(relation.getFormDeploymentId())
.singleResult(); .singleResult();
Authentication.setAuthenticatedUserId(approver.buildAssigneeId()); Authentication.setAuthenticatedUserId(approver.buildAssigneeId());
runtimeService.setVariableLocal(task.getProcessInstanceId(), TASK_SUBMIT_FORM_VARIABLE, formVariables);
taskService.completeTaskWithForm(taskId, formDefinition.getId(), null, formVariables); taskService.completeTaskWithForm(taskId, formDefinition.getId(), null, formVariables);
Authentication.setAuthenticatedUserId(null); Authentication.setAuthenticatedUserId(null);
} else { } else {

View File

@ -2,18 +2,20 @@ package cn.axzo.workflow.core.engine.cmd;
import cn.axzo.workflow.common.exception.WorkflowEngineException; import cn.axzo.workflow.common.exception.WorkflowEngineException;
import org.flowable.common.engine.impl.interceptor.CommandContext; import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.form.api.FormInstance; import org.flowable.form.api.FormInstance;
import org.flowable.form.api.FormService; import org.flowable.form.api.FormService;
import org.flowable.form.engine.FormEngineConfiguration; import org.flowable.form.engine.FormEngineConfiguration;
import org.flowable.form.engine.impl.cmd.GetFormInstanceValuesCmd; import org.flowable.form.engine.impl.cmd.GetFormInstanceValuesCmd;
import org.flowable.form.engine.impl.persistence.entity.FormInstanceEntityManager;
import org.flowable.form.engine.impl.util.CommandContextUtil; import org.flowable.form.engine.impl.util.CommandContextUtil;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
import java.util.Map;
import static cn.axzo.workflow.common.code.FormInstanceRespCode.FORM_INSTANCE_DATA_NOT_FOUND; import static cn.axzo.workflow.common.code.FormInstanceRespCode.FORM_INSTANCE_DATA_NOT_FOUND;
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_SUBMIT_FORM_VARIABLE;
/** /**
* 自定义的获取表单实例数据的命令 * 自定义的获取表单实例数据的命令
@ -44,19 +46,23 @@ public class CustomGetFormInstanceLatestValuesCmd extends GetFormInstanceValuesC
if (StringUtils.hasText(formInstanceId) && !StringUtils.hasText(processInstanceId)) { if (StringUtils.hasText(formInstanceId) && !StringUtils.hasText(processInstanceId)) {
return super.execute(commandContext); return super.execute(commandContext);
} }
FormInstanceEntityManager formInstanceEntityManager = CommandContextUtil.getFormInstanceEntityManager(commandContext); ProcessEngineConfigurationImpl processEngineConfiguration = org.flowable.engine.impl.util.CommandContextUtil.getProcessEngineConfiguration(commandContext);
FormEngineConfiguration formEngineConfiguration = CommandContextUtil.getFormEngineConfiguration(); Map<String, Object> variableLocal = (Map<String, Object>) processEngineConfiguration.getRuntimeService().getVariableLocal(processInstanceId, TASK_SUBMIT_FORM_VARIABLE, Map.class);
if (CollectionUtils.isEmpty(variableLocal)) {
FormService formService = formEngineConfiguration.getFormService(); FormEngineConfiguration formEngineConfiguration = CommandContextUtil.getFormEngineConfiguration();
List<FormInstance> formInstances = formService.createFormInstanceQuery().processInstanceId(processInstanceId) FormService formService = formEngineConfiguration.getFormService();
.orderBySubmittedDate().desc().listPage(0, 1); List<FormInstance> formInstances = formService.createFormInstanceQuery().processInstanceId(processInstanceId)
if (!CollectionUtils.isEmpty(formInstances)) { .orderBySubmittedDate().desc().listPage(0, 1);
return formInstances.get(0).getFormValueBytes(); if (!CollectionUtils.isEmpty(formInstances)) {
} return formInstances.get(0).getFormValueBytes();
if (throwException) { }
throw new WorkflowEngineException(FORM_INSTANCE_DATA_NOT_FOUND, processInstanceId); if (throwException) {
} else { throw new WorkflowEngineException(FORM_INSTANCE_DATA_NOT_FOUND, processInstanceId);
return null; } else {
return null;
}
} }
// TODO 测试会签场景下的表达提交数据 variableLocal 是什么结构
return null;
} }
} }

View File

@ -50,7 +50,6 @@ public class TempFileArchiveActivityEvent_101_Listener extends AbstractBpmnEvent
if (!signConfig.isPresent()) { if (!signConfig.isPresent()) {
return; return;
} }
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
ExtAxProcessSign processSign = extAxProcessSignService.findByProcessInstanceId(execution.getProcessInstanceId()); ExtAxProcessSign processSign = extAxProcessSignService.findByProcessInstanceId(execution.getProcessInstanceId());
processSign.getFileArchive().stream().filter(i -> Objects.equals(i.getFileType(), FileTypeEnum.WORD) processSign.getFileArchive().stream().filter(i -> Objects.equals(i.getFileType(), FileTypeEnum.WORD)