美文网首页
Activiti 7.x 流程定义的挂起与激活

Activiti 7.x 流程定义的挂起与激活

作者: MaJiT | 来源:发表于2020-03-01 10:58 被阅读0次

1.全部流程实例的挂起与激活

        //1.得到ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

        //2.得到RepositoryService
        RepositoryService repositoryService = processEngine.getRepositoryService();

        //3.查询流程定义的对象
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
                .processDefinitionKey("holiday").singleResult();

        //4.得到当前流程定义的实例是否都为暂停状态
        boolean suspended = processDefinition.isSuspended();

        String processDefinitionId = processDefinition.getId();
        //5.判断
        if(suspended){
            //说明是暂停,就可以激活操作
            repositoryService.activateProcessDefinitionById(processDefinitionId,true
            ,null);
            System.out.println("流程定义:"+processDefinitionId+"激活");
        }else{
            repositoryService.suspendProcessDefinitionById(processDefinitionId,true,null);
            System.out.println("流程定义:"+processDefinitionId+"挂起");
        }

2.单个流程实例的挂起与激活

        //1.得到ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

        //2.得到RuntimeService
        RuntimeService runtimeService = processEngine.getRuntimeService();

        //3.查询流程实例对象
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
                .processInstanceId("2501").singleResult();

        //4.得到当前流程定义的实例是否都为暂停状态
        boolean suspended = processInstance.isSuspended();

       String processInstanceId = processInstance.getId();
        //5.判断
        if(suspended){
            //说明是暂停,就可以激活操作
            runtimeService.activateProcessInstanceById(processInstanceId);
            System.out.println("流程:"+processInstanceId+"激活");
        }else{
            runtimeService.suspendProcessInstanceById(processInstanceId);
            System.out.println("流程定义:"+processInstanceId+"挂起");
        }

相关文章

网友评论

      本文标题:Activiti 7.x 流程定义的挂起与激活

      本文链接:https://www.haomeiwen.com/subject/trztkhtx.html