update - 完善流程节点推测功能,仅允许运行中的实例来获取
This commit is contained in:
parent
2f12bfe489
commit
93be14a821
@ -25,6 +25,7 @@ public enum BpmnInstanceRespCode implements IModuleRespCode {
|
||||
PROCESS_INSTANCE_CANT_DELETE("010", "流程实例不能删除"),
|
||||
PROCESS_INSTANCE_CANT_START("011", "流程实例不能启动"),
|
||||
TASK_CANT_COMMENT_INSTANCE_NOT_EXISTS("012", "流程实例【{}】不存在, 不能评论"),
|
||||
RUNNING_INSTANCE_ONLY_FORECAST("013", "仅运行中的实例可以推测"),
|
||||
;
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
@ -111,8 +111,8 @@ import static cn.axzo.workflow.common.enums.BpmnFlowNodeMode.GENERAL;
|
||||
import static cn.axzo.workflow.common.enums.BpmnFlowNodeMode.OR;
|
||||
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_STARTER;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnInstanceRespCode.PROCESS_INSTANCE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnInstanceRespCode.PROCESS_INSTANCE_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnInstanceRespCode.RUNNING_INSTANCE_ONLY_FORECAST;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_IS_SUSPENDED;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_KEY_NOT_EXISTS;
|
||||
@ -780,25 +780,12 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
query.processInstanceTenantId(tenantId);
|
||||
}
|
||||
ProcessInstance instance = query.singleResult();
|
||||
if (Objects.isNull(instance)) {
|
||||
throw new WorkflowEngineException(RUNNING_INSTANCE_ONLY_FORECAST);
|
||||
}
|
||||
List<FlowElement> flowElements = forecastService.performProcessForecasting(processInstanceId, instance);
|
||||
|
||||
String processDefinitionId;
|
||||
boolean skipAllNode;
|
||||
if (Objects.isNull(instance)) {
|
||||
HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
if (Objects.isNull(processInstance)) {
|
||||
throw new WorkflowEngineException(PROCESS_INSTANCE_ID_NOT_EXISTS, processInstanceId);
|
||||
}
|
||||
processDefinitionId = processInstance.getProcessDefinitionId();
|
||||
skipAllNode = true;
|
||||
} else {
|
||||
skipAllNode = false;
|
||||
processDefinitionId = instance.getProcessDefinitionId();
|
||||
}
|
||||
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(instance.getProcessDefinitionId());
|
||||
List<ProcessNodeDetailVO> resultList = new ArrayList<>(flowElements.size());
|
||||
// 发起人节点,也是一个 UserTask 节点, 所以这里默认就包含了发起人节点
|
||||
flowElements.stream()
|
||||
@ -817,19 +804,19 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
node.setNodeMode(GENERAL);
|
||||
node.setId(i.getId()).setName(i.getName());
|
||||
if (i instanceof UserTask) {
|
||||
parseUserTask(processInstanceId, (UserTask) i, node, skipAllNode, nodeDefinitionKeys);
|
||||
parseUserTask(processInstanceId, (UserTask) i, node, nodeDefinitionKeys);
|
||||
} else if (i instanceof ServiceTask) {
|
||||
parseServiceTask(processInstanceId, (ServiceTask) i, node, skipAllNode, nodeDefinitionKeys);
|
||||
parseServiceTask(processInstanceId, (ServiceTask) i, node, nodeDefinitionKeys);
|
||||
}
|
||||
resultList.add(node);
|
||||
});
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private void parseServiceTask(String processInstanceId, ServiceTask i, ProcessNodeDetailVO node, boolean skipAllNode, List<String> skipTaskDefinitionKeys) {
|
||||
private void parseServiceTask(String processInstanceId, ServiceTask i, ProcessNodeDetailVO node, List<String> skipTaskDefinitionKeys) {
|
||||
// ServiceTask 主要作用于抄送
|
||||
node.setId(i.getId()).setName(i.getName());
|
||||
if (skipAllNode || skipTaskDefinitionKeys.contains(i.getId())) {
|
||||
if (skipTaskDefinitionKeys.contains(i.getId())) {
|
||||
return;
|
||||
}
|
||||
getCarbonCopyConfigs(i).ifPresent(carbons ->
|
||||
@ -839,7 +826,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
historicTaskInstanceConverter, serviceVersion))));
|
||||
}
|
||||
|
||||
private void parseUserTask(String processInstanceId, UserTask i, ProcessNodeDetailVO node, boolean skipAllNode, List<String> skipTaskDefinitionKeys) {
|
||||
private void parseUserTask(String processInstanceId, UserTask i, ProcessNodeDetailVO node, List<String> skipTaskDefinitionKeys) {
|
||||
node.setFormKey(i.getFormKey());
|
||||
// 设置审批模式,
|
||||
if (i.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
||||
@ -852,7 +839,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
node.setNodeMode(BpmnFlowNodeMode.GENERAL);
|
||||
}
|
||||
|
||||
if (skipAllNode || skipTaskDefinitionKeys.contains(i.getId())) {
|
||||
if (skipTaskDefinitionKeys.contains(i.getId())) {
|
||||
return;
|
||||
}
|
||||
if (Objects.equals(node.getApprovalMethod(), human)) {
|
||||
|
||||
@ -9,7 +9,6 @@ import org.flowable.bpmn.model.StartEvent;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.ResolvableType;
|
||||
@ -27,7 +26,6 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static cn.axzo.workflow.core.common.code.BpmnInstanceRespCode.PROCESS_INSTANCE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnInstanceRespCode.PROCESS_INSTANCE_NOT_EXISTS;
|
||||
|
||||
|
||||
@ -125,22 +123,8 @@ public class FlowNodeForecastService implements InitializingBean {
|
||||
// .includeProcessVariables()
|
||||
.singleResult();
|
||||
}
|
||||
String processDefinitionId;
|
||||
if (Objects.isNull(instance)) {
|
||||
HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
if (Objects.isNull(processInstance)) {
|
||||
throw new WorkflowEngineException(PROCESS_INSTANCE_ID_NOT_EXISTS, processInstanceId);
|
||||
}
|
||||
processInstanceId = processInstance.getId();
|
||||
processDefinitionId = processInstance.getProcessDefinitionId();
|
||||
} else {
|
||||
processInstanceId = instance.getProcessInstanceId();
|
||||
processDefinitionId = instance.getProcessDefinitionId();
|
||||
}
|
||||
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(instance.getProcessDefinitionId());
|
||||
|
||||
// 保持推测出来的节点执行顺序的容器
|
||||
List<FlowElement> orderedNodes = new ArrayList<>();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user