activiti 6 遍历流程任务

       XMLInputFactory xif = XMLInputFactory.newInstance();
        List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().latestVersion().list();
        for (ProcessDefinition definition : list) {
            log.info(definition.getName());
            log.info(definition.getKey());
            log.info(definition.getId());
            log.info(definition.getDeploymentId());

            InputStream bpmnStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName());
            InputStreamReader in = new InputStreamReader(bpmnStream, StandardCharsets.UTF_8);
            XMLStreamReader xtr = xif.createXMLStreamReader(in);
            BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
            Process mainProcess = bpmnModel.getMainProcess();
            Collection<FlowElement> flowElements = mainProcess.getFlowElements();


            flowElements.stream().filter(r->r instanceof UserTask||r instanceof ServiceTask).forEach((x)-> {
                log.info(x.getClass().toString());
                log.info(x.getId());
                log.info(x.getName());
                log.info(x.getDocumentation());
            });
        }
posted @ 2023-02-20 18:13  大哥超帅  阅读(48)  评论(0编辑  收藏  举报