add - 新增流程推算执行顺序的节点信息
This commit is contained in:
parent
35cc172cf3
commit
dd0c109633
@ -102,7 +102,7 @@ public interface ProcessInstanceApi {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/api/process/instance/node/calc")
|
||||
CommonResponse<List<ProcessNodeDetailVO>> processInstanceNodeCalc(@NotBlank(message = "流程实例 ID 不能为空") @RequestParam(required = false) String processInstanceId,
|
||||
@Nullable @RequestParam(required = false) String tenantId);
|
||||
@GetMapping("/api/process/instance/node/forecasting")
|
||||
CommonResponse<List<ProcessNodeDetailVO>> processInstanceNodeForecast(@NotBlank(message = "流程实例 ID 不能为空") @RequestParam(required = false) String processInstanceId,
|
||||
@Nullable @RequestParam(required = false) String tenantId);
|
||||
}
|
||||
|
||||
@ -98,5 +98,5 @@ public interface BpmnProcessInstanceService {
|
||||
|
||||
BpmPageResult<HistoricProcessInstanceVO> historicProcessInstancePage(HistoricProcessInstanceSearchDTO dto);
|
||||
|
||||
List<ProcessNodeDetailVO> getProcessNodes(String processInstanceId, @Nullable String tenantId);
|
||||
List<ProcessNodeDetailVO> getProcessInstanceNodeForecast(String processInstanceId, String tenantId);
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import cn.axzo.workflow.core.service.BpmnProcessInstanceService;
|
||||
import cn.axzo.workflow.core.service.converter.BpmnHistoricProcessInstanceConverter;
|
||||
import cn.axzo.workflow.core.service.converter.BpmnProcessInstanceConverter;
|
||||
import cn.axzo.workflow.core.service.converter.BpmnProcessInstancePageItemConverter;
|
||||
import cn.axzo.workflow.core.service.support.FlowNodeForecastService;
|
||||
import cn.axzo.workflow.core.service.support.ProcessGraphicService;
|
||||
import cn.azxo.framework.common.utils.StringUtils;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
@ -107,6 +108,8 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
private ManagementService managementService;
|
||||
@Resource
|
||||
private ProcessGraphicService graphicService;
|
||||
@Resource
|
||||
private FlowNodeForecastService forecastService;
|
||||
|
||||
@Override
|
||||
public HistoricProcessInstance getProcessInstanceByBusinessKey(String businessKey, @Nullable String tenantId,
|
||||
@ -531,7 +534,6 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProcessNodeDetailVO> getProcessNodes(String processInstanceId, @Nullable String tenantId) {
|
||||
HistoricProcessInstance instance =
|
||||
historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||
@ -572,6 +574,43 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProcessNodeDetailVO> getProcessInstanceNodeForecast(String processInstanceId,
|
||||
@Nullable String tenantId) {
|
||||
ProcessInstance instance = runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId).processInstanceTenantId(tenantId).singleResult();
|
||||
if (Objects.isNull(instance)) {
|
||||
throw new WorkflowEngineException(PROCESS_INSTANCE_ID_NOT_EXISTS, processInstanceId);
|
||||
}
|
||||
List<FlowElement> flowElements = forecastService.performProcessForecasting(processInstanceId, instance);
|
||||
|
||||
List<ProcessNodeDetailVO> resultList = new ArrayList<>(flowElements.size() + 1);
|
||||
flowElements.stream().filter(UserTask.class::isInstance).forEach(i -> {
|
||||
UserTask userTask = (UserTask) i;
|
||||
ProcessNodeDetailVO node = new ProcessNodeDetailVO().setId(userTask.getId())
|
||||
.setName(userTask.getName())
|
||||
.setFormKey(userTask.getFormKey());
|
||||
if (userTask.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
||||
MultiInstanceActivityBehavior behavior = (MultiInstanceActivityBehavior) userTask.getBehavior();
|
||||
node.setNodeMode(Objects.equals(AND_SIGN_EXPRESSION, behavior.getCompletionCondition()) ? AND : OR);
|
||||
} else if (userTask.getBehavior() instanceof UserTaskActivityBehavior) {
|
||||
node.setNodeMode(BpmnFlowNodeMode.GENERAL);
|
||||
}
|
||||
resultList.add(node);
|
||||
});
|
||||
|
||||
// 处理发起节点
|
||||
List<FlowElement> startNodes =
|
||||
flowElements.stream().filter(StartEvent.class::isInstance).collect(Collectors.toList());
|
||||
startNodes.forEach(i -> {
|
||||
StartEvent startEvent = (StartEvent) i;
|
||||
ProcessNodeDetailVO node = new ProcessNodeDetailVO()
|
||||
.setId(startEvent.getId())
|
||||
.setName(startEvent.getName())
|
||||
.setFormKey(startEvent.getFormKey())
|
||||
.setNodeMode(BpmnFlowNodeMode.STARTNODE);
|
||||
resultList.add(0, node);
|
||||
});
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -104,16 +105,17 @@ public class FlowNodeForecastService implements InitializingBean {
|
||||
* 已完成的流程可以直接查询流程审批记录就行
|
||||
*
|
||||
* @param processInstanceId 指定运行时的流程实例 ID
|
||||
* @param instance 外部传入流程实例 (与另外一个参数必须二选一)
|
||||
*/
|
||||
public List<FlowElement> performProcessForecasting(String processInstanceId) {
|
||||
if (!StringUtils.hasLength(processInstanceId)) {
|
||||
throw new WorkflowEngineException(PROCESS_INSTANCE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
ProcessInstance instance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId)
|
||||
.includeProcessVariables().singleResult();
|
||||
if (Objects.isNull(instance)) {
|
||||
public List<FlowElement> performProcessForecasting(@Nullable String processInstanceId,
|
||||
@Nullable ProcessInstance instance) {
|
||||
if (Objects.nonNull(instance)) {
|
||||
// nothing to do
|
||||
} else if (!StringUtils.hasLength(processInstanceId)) {
|
||||
throw new WorkflowEngineException(PROCESS_INSTANCE_NOT_EXISTS);
|
||||
} else {
|
||||
instance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId)
|
||||
.includeProcessVariables().singleResult();
|
||||
}
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(instance.getProcessDefinitionId());
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package cn.axzo.workflow.server.controller.web;
|
||||
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.ProcessNodeDetailVO;
|
||||
import cn.axzo.workflow.core.service.BpmnProcessInstanceService;
|
||||
import cn.axzo.workflow.core.service.support.FlowNodeForecastService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.FlowElement;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -29,15 +29,17 @@ public class TestController {
|
||||
@Autowired
|
||||
private FlowNodeForecastService forecastService;
|
||||
@Autowired
|
||||
private HistoryService historyService;
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
private BpmnProcessInstanceService instanceService;
|
||||
@GetMapping("/test")
|
||||
public void test(@RequestParam String processInstanceId) {
|
||||
|
||||
List<FlowElement> flowElements = forecastService.performProcessForecasting(processInstanceId);
|
||||
|
||||
List<FlowElement> flowElements = forecastService.performProcessForecasting(processInstanceId, null);
|
||||
System.out.println("flowElements = " + flowElements);
|
||||
}
|
||||
|
||||
@GetMapping("/test2")
|
||||
public void test2(@RequestParam String processInstanceId) {
|
||||
List<ProcessNodeDetailVO> detailVOS = instanceService.getProcessInstanceNodeForecast(processInstanceId, "296");
|
||||
System.out.println("detailVOS = " + detailVOS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -48,7 +48,6 @@ public class BpmnProcessInstanceController implements ProcessInstanceApi {
|
||||
@Resource
|
||||
private BpmnProcessInstanceService bpmnProcessInstanceService;
|
||||
|
||||
|
||||
/**
|
||||
* 我发起的审批列表
|
||||
*/
|
||||
@ -141,9 +140,10 @@ public class BpmnProcessInstanceController implements ProcessInstanceApi {
|
||||
*/
|
||||
@GetMapping("/node/calc")
|
||||
@Override
|
||||
public CommonResponse<List<ProcessNodeDetailVO>> processInstanceNodeCalc(@NotBlank(message = "流程实例 ID 不能为空") @RequestParam String processInstanceId,
|
||||
@Nullable String tenantId) {
|
||||
return success(bpmnProcessInstanceService.getProcessNodes(processInstanceId, tenantId));
|
||||
public CommonResponse<List<ProcessNodeDetailVO>> processInstanceNodeForecast(@NotBlank(message = "流程实例 ID 不能为空") @RequestParam String processInstanceId,
|
||||
@Nullable String tenantId) {
|
||||
// return success(bpmnProcessInstanceService.getProcessNodes(processInstanceId, tenantId));
|
||||
return success(bpmnProcessInstanceService.getProcessInstanceNodeForecast(processInstanceId, tenantId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user