Flowable入门系列文章23 - 基本的Flowable概念四

1、代码概述

结合前面文章中的介绍整理的代码。代码考虑到您可能已经通过Flowable应用程序UI启动了一些流程实例。它检索一个任务列表,而不是一个任务,所以它始终工作:

public class TenMinuteTutorial {
    public static void main(String[] args) {
// Create Flowable process engine
        ProcessEngine processEngine = ProcessEngineConfiguration
                .createStandaloneProcessEngineConfiguration()
                .buildProcessEngine();
// Get Flowable services
        RepositoryService repositoryService = processEngine.getRepositoryService();
        RuntimeService runtimeService = processEngine.getRuntimeService();
// Deploy the process definition
        repositoryService.createDeployment()
                .addClasspathResource("FinancialReportProcess.bpmn20.xml")
                .deploy();
// Start a process instance
        String procId = runtimeService.startProcessInstanceByKey("financialReport").getId();
// Get the first task
        TaskService taskService = processEngine.getTaskService();
        List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("accountancy").list();
        for (Task task : tasks) {
            System.out.println("Following task is available for accountancy group: " + task.getName());
// claim it
            taskService.claim(task.getId(), "fozzie");
        }
// Verify Fozzie can now retrieve the task
        tasks = taskService.createTaskQuery().taskAssignee("fozzie").list();
        for (Task task : tasks) {
            System.out.println("Task for fozzie: " + task.getName());
// Complete the task
            taskService.complete(task.getId());
        }
        System.out.println("Number of tasks for fozzie: "
                + taskService.createTaskQuery().taskAssignee("fozzie").count());
// Retrieve and claim the second task
        tasks = taskService.createTaskQuery().taskCandidateGroup("management").list();
        for (Task task : tasks) {
            System.out.println("Following task is available for management group: " + task.getName());
            taskService.claim(task.getId(), "kermit");
        }
// Completing the second task ends the process
        for (Task task : tasks) {
            taskService.complete(task.getId());
        }
// verify that the process is actually finished
        HistoryService historyService = processEngine.getHistoryService();
        HistoricProcessInstance historicProcessInstance =
                historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
        System.out.println("Process instance end time: " + historicProcessInstance.getEndTime());
    }
}

2、未来的增强

很容易看出,这个业务流程太简单了,不能在现实中使用。但是,当您正在浏览Flowable中的BPMN 2.0结构时,您将能够通过以下方式增强业务流程:

  • 定义网关使管理者可以决定拒绝该财务报告,并重新对会计的任务,下面接受报告时相比,不同的路径。
  • 声明和使用变量来存储或引用报告,以便在窗体中可视化。
  • 在流程结束时定义服务任务,将报告发送给每个股东。
  • 等等

上面文章来自盘古BPM研究院:http://vue.pangubpm.com/
文章翻译提交:https://github.com/qiudaoke/flowable-userguide
了解更多文章可以关注微信公众号:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值