feat(REQ-3769) - 测试流程审批过程中,替换文件变量
This commit is contained in:
parent
5f34a74b88
commit
1d40dca871
@ -234,4 +234,5 @@ public interface BpmnConstants {
|
||||
* 签署人
|
||||
*/
|
||||
String SIGNATORIES = "[_SIGNATORIES_]";
|
||||
String TASK_SUBMIT_FORM_VARIABLE = "[_TASK_SUBMIT_FORM_VARIABLE_]";
|
||||
}
|
||||
|
||||
@ -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.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_SUBMIT_FORM_VARIABLE;
|
||||
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.batchAddAttachment;
|
||||
@ -209,6 +210,7 @@ public class CustomApproveTaskWithFormCmd extends AbstractCommand<Void> implemen
|
||||
.deploymentId(relation.getFormDeploymentId())
|
||||
.singleResult();
|
||||
Authentication.setAuthenticatedUserId(approver.buildAssigneeId());
|
||||
runtimeService.setVariableLocal(task.getProcessInstanceId(), TASK_SUBMIT_FORM_VARIABLE, formVariables);
|
||||
taskService.completeTaskWithForm(taskId, formDefinition.getId(), null, formVariables);
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
} else {
|
||||
|
||||
@ -2,18 +2,20 @@ package cn.axzo.workflow.core.engine.cmd;
|
||||
|
||||
import cn.axzo.workflow.common.exception.WorkflowEngineException;
|
||||
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.FormService;
|
||||
import org.flowable.form.engine.FormEngineConfiguration;
|
||||
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.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
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.constant.BpmnConstants.TASK_SUBMIT_FORM_VARIABLE;
|
||||
|
||||
/**
|
||||
* 自定义的获取表单实例数据的命令
|
||||
@ -44,19 +46,23 @@ public class CustomGetFormInstanceLatestValuesCmd extends GetFormInstanceValuesC
|
||||
if (StringUtils.hasText(formInstanceId) && !StringUtils.hasText(processInstanceId)) {
|
||||
return super.execute(commandContext);
|
||||
}
|
||||
FormInstanceEntityManager formInstanceEntityManager = CommandContextUtil.getFormInstanceEntityManager(commandContext);
|
||||
FormEngineConfiguration formEngineConfiguration = CommandContextUtil.getFormEngineConfiguration();
|
||||
|
||||
FormService formService = formEngineConfiguration.getFormService();
|
||||
List<FormInstance> formInstances = formService.createFormInstanceQuery().processInstanceId(processInstanceId)
|
||||
.orderBySubmittedDate().desc().listPage(0, 1);
|
||||
if (!CollectionUtils.isEmpty(formInstances)) {
|
||||
return formInstances.get(0).getFormValueBytes();
|
||||
}
|
||||
if (throwException) {
|
||||
throw new WorkflowEngineException(FORM_INSTANCE_DATA_NOT_FOUND, processInstanceId);
|
||||
} else {
|
||||
return null;
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration = org.flowable.engine.impl.util.CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
||||
Map<String, Object> variableLocal = (Map<String, Object>) processEngineConfiguration.getRuntimeService().getVariableLocal(processInstanceId, TASK_SUBMIT_FORM_VARIABLE, Map.class);
|
||||
if (CollectionUtils.isEmpty(variableLocal)) {
|
||||
FormEngineConfiguration formEngineConfiguration = CommandContextUtil.getFormEngineConfiguration();
|
||||
FormService formService = formEngineConfiguration.getFormService();
|
||||
List<FormInstance> formInstances = formService.createFormInstanceQuery().processInstanceId(processInstanceId)
|
||||
.orderBySubmittedDate().desc().listPage(0, 1);
|
||||
if (!CollectionUtils.isEmpty(formInstances)) {
|
||||
return formInstances.get(0).getFormValueBytes();
|
||||
}
|
||||
if (throwException) {
|
||||
throw new WorkflowEngineException(FORM_INSTANCE_DATA_NOT_FOUND, processInstanceId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// TODO 测试会签场景下的表达提交数据 variableLocal 是什么结构
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +50,6 @@ public class TempFileArchiveActivityEvent_101_Listener extends AbstractBpmnEvent
|
||||
if (!signConfig.isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
|
||||
ExtAxProcessSign processSign = extAxProcessSignService.findByProcessInstanceId(execution.getProcessInstanceId());
|
||||
processSign.getFileArchive().stream().filter(i -> Objects.equals(i.getFileType(), FileTypeEnum.WORD)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user