feat(REQ-5865) - 测试 trigger 问题
This commit is contained in:
parent
d452465750
commit
fbe3bfd836
@ -46,39 +46,6 @@ public class CustomActivityTriggerAsyncCmd extends AbstractCommand<String> imple
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String execute(CommandContext commandContext) {
|
public String execute(CommandContext commandContext) {
|
||||||
// ProcessEngineConfigurationImpl processEngineConfiguration =
|
|
||||||
// CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
|
||||||
// RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
|
|
||||||
// List<Execution> list = runtimeService.createExecutionQuery().executionId(dto.getTriggerId()).list();
|
|
||||||
// log.info("execution list size: {}, executionId: {}, id: {}", list.size(), dto.getTriggerId(), org.springframework.util.StringUtils.collectionToCommaDelimitedString(list.stream().map(Execution::getId).collect(Collectors.toSet())));
|
|
||||||
//
|
|
||||||
// if (list.size() == 1) {
|
|
||||||
// HistoricProcessInstance instance = processEngineConfiguration.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(list.get(0).getProcessInstanceId()).singleResult();
|
|
||||||
// log.info("instance business status : {}", Objects.nonNull(instance) ? instance.getBusinessStatus() : "未找到实例");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// List<Task> tasks = processEngineConfiguration.getTaskService().createTaskQuery()
|
|
||||||
// .executionId(dto.getTriggerId()).list();
|
|
||||||
// if (CollectionUtils.isEmpty(tasks)) {
|
|
||||||
// log.info("未通过 triggerId 找到任务集合,无法继续触发,executionId: {}", dto.getTriggerId());
|
|
||||||
// throw new WorkflowEngineException(ACTIVITY_TRIGGER_NOT_EXISTS, dto.getTriggerId());
|
|
||||||
// }
|
|
||||||
// if (org.springframework.util.StringUtils.hasText(dto.getActivityId())) {
|
|
||||||
// tasks = tasks.stream()
|
|
||||||
// .filter(task -> Objects.equals(task.getTaskDefinitionKey(), dto.getActivityId()))
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// TaskEntity task = (TaskEntity) findLatestByCreateTime(tasks).orElse(null);
|
|
||||||
// if (Objects.isNull(task)) {
|
|
||||||
// log.info("未找到对应的任务,无法继续触发,executionId: {}, activityId: {}", dto.getTriggerId(), dto.getActivityId());
|
|
||||||
// throw new WorkflowEngineException(ACTIVITY_TRIGGER_NOT_EXISTS, dto.getTriggerId());
|
|
||||||
// }
|
|
||||||
// if (!validateActivityConfig((task))) {
|
|
||||||
// log.info("业务节点唤醒时,发现节点已经修改配置,无法继续唤醒,processInstanceId:{}, taskDefinitionKey={}", task.getProcessInstanceId(), task.getTaskDefinitionKey());
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
ProcessEngineConfigurationImpl processEngineConfiguration =
|
ProcessEngineConfigurationImpl processEngineConfiguration =
|
||||||
CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
||||||
TaskQuery taskQuery = processEngineConfiguration.getTaskService().createTaskQuery()
|
TaskQuery taskQuery = processEngineConfiguration.getTaskService().createTaskQuery()
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import org.flowable.engine.RuntimeService;
|
|||||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||||
import org.flowable.task.api.Task;
|
|
||||||
import org.flowable.task.api.TaskQuery;
|
import org.flowable.task.api.TaskQuery;
|
||||||
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -20,10 +19,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.ACTIVITY_TRIGGER_NOT_EXISTS;
|
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.ACTIVITY_TRIGGER_NOT_EXISTS;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_OPERATION_DESC;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_OPERATION_DESC;
|
||||||
@ -52,44 +48,6 @@ public class CustomActivityTriggerCmd extends AbstractCommand<Void> implements S
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void execute(CommandContext commandContext) {
|
public Void execute(CommandContext commandContext) {
|
||||||
// ProcessEngineConfigurationImpl processEngineConfiguration =
|
|
||||||
// CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
|
||||||
// RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
|
|
||||||
// List<Execution> list = runtimeService.createExecutionQuery().executionId(dto.getTriggerId()).list();
|
|
||||||
// log.info("execution list size: {}, executionId: {}, id: {}", list.size(), dto.getTriggerId(), org.springframework.util.StringUtils.collectionToCommaDelimitedString(list.stream().map(Execution::getId).collect(Collectors.toSet())));
|
|
||||||
//
|
|
||||||
// if (list.size() == 1) {
|
|
||||||
// HistoricProcessInstance instance = processEngineConfiguration.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(list.get(0).getProcessInstanceId()).singleResult();
|
|
||||||
// log.info("instance business status : {}", Objects.nonNull(instance) ? instance.getBusinessStatus() : "未找到实例");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// List<Task> tasks = processEngineConfiguration.getTaskService().createTaskQuery()
|
|
||||||
// .executionId(dto.getTriggerId()).list();
|
|
||||||
// if (CollectionUtils.isEmpty(tasks)) {
|
|
||||||
// log.info("未通过 triggerId 找到任务集合,无法继续触发,executionId: {}", dto.getTriggerId());
|
|
||||||
// throw new WorkflowEngineException(ACTIVITY_TRIGGER_NOT_EXISTS, dto.getTriggerId());
|
|
||||||
// }
|
|
||||||
// if (StringUtils.hasText(dto.getActivityId())) {
|
|
||||||
// tasks = tasks.stream()
|
|
||||||
// .filter(task -> Objects.equals(task.getTaskDefinitionKey(), dto.getActivityId()))
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// TaskEntity task = (TaskEntity) findLatestByCreateTime(tasks).orElse(null);
|
|
||||||
// if (Objects.isNull(task)) {
|
|
||||||
// log.info("未找到对应的任务,无法继续触发,executionId: {}, activityId: {}", dto.getTriggerId(), dto.getActivityId());
|
|
||||||
// throw new WorkflowEngineException(ACTIVITY_TRIGGER_NOT_EXISTS, dto.getTriggerId());
|
|
||||||
// }
|
|
||||||
// if (!validateActivityConfig((task))) {
|
|
||||||
// log.info("业务节点唤醒时,发现节点已经修改配置,无法继续唤醒,processInstanceId:{}, taskDefinitionKey={}", task.getProcessInstanceId(), task.getTaskDefinitionKey());
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// addComment(commandContext, task, COMMENT_TYPE_OPERATION_DESC, "已同意");
|
|
||||||
// runtimeService.trigger(dto.getTriggerId());
|
|
||||||
// return null;
|
|
||||||
|
|
||||||
ProcessEngineConfigurationImpl processEngineConfiguration =
|
ProcessEngineConfigurationImpl processEngineConfiguration =
|
||||||
CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
||||||
|
|
||||||
@ -114,16 +72,6 @@ public class CustomActivityTriggerCmd extends AbstractCommand<Void> implements S
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<Task> findLatestByCreateTime(List<Task> tasks) {
|
|
||||||
if (tasks == null || tasks.isEmpty()) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
return tasks.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(t -> t.getCreateTime() != null)
|
|
||||||
.max(Comparator.comparing(Task::getCreateTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean validateActivityConfig(TaskEntity task) {
|
public static boolean validateActivityConfig(TaskEntity task) {
|
||||||
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(task.getProcessDefinitionId());
|
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(task.getProcessDefinitionId());
|
||||||
FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
|
FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user