工作流Activiti的学习总结(十二) activiti官方十分钟快速学习 (zhuan)
http://topmanopensource.iteye.com/blog/1315341
******************************************************
根据activiti官方提供的 编写
1.财务部门填写月财务报告
2.股东审核月财务审计报告
流程图:

流程配置:
- <?xml version="1.0" encoding="UTF-8"?>
- <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20">
- <process id="financialReport" name="Monthly financial report reminder process">
- <startEvent id="startevent1" name="月财务报告审核开始"></startEvent>
- <!-- 采用用户组为accountancy编写财务报告 -->
- <userTask id="usertask1" name="财务编写月财务报告" activiti:candidateGroups="accountancy"></userTask>
- <userTask id="usertask2" name="股东审核月财务审计报告" activiti:candidateGroups="management"></userTask>
- <endEvent id="endevent1" name="月财务报告审核结束"></endEvent>
- <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
- <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
- <sequenceFlow id="flow3" name="" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
- </process>
- <bpmndi:BPMNDiagram id="BPMNDiagram_financialReport">
- <bpmndi:BPMNPlane bpmnElement="financialReport" id="BPMNPlane_financialReport">
- <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
- <omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
- <omgdc:Bounds height="55" width="105" x="125" y="190"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
- <omgdc:Bounds height="55" width="105" x="290" y="190"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
- <omgdc:Bounds height="35" width="35" x="455" y="200"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
- <omgdi:waypoint x="65" y="217"></omgdi:waypoint>
- <omgdi:waypoint x="125" y="217"></omgdi:waypoint>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
- <omgdi:waypoint x="230" y="217"></omgdi:waypoint>
- <omgdi:waypoint x="290" y="217"></omgdi:waypoint>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
- <omgdi:waypoint x="395" y="217"></omgdi:waypoint>
- <omgdi:waypoint x="455" y="217"></omgdi:waypoint>
- </bpmndi:BPMNEdge>
- </bpmndi:BPMNPlane>
- </bpmndi:BPMNDiagram>
- </definitions>
编码如下:
- package com.easyway.spring.activiti;
- import java.util.List;
- import org.activiti.engine.HistoryService;
- import org.activiti.engine.ProcessEngine;
- import org.activiti.engine.ProcessEngineConfiguration;
- import org.activiti.engine.RepositoryService;
- import org.activiti.engine.RuntimeService;
- import org.activiti.engine.TaskService;
- import org.activiti.engine.history.HistoricProcessInstance;
- import org.activiti.engine.task.Task;
- /**
- * 根据activiti官方提供的 编写
- * 1.财务部门填写月财务报告
- * 2.股东审核月财务审计报告
- *
- *
- * activiti提供的财务报告审核
- * <!-- 采用用户组为accountancy编写财务报告 -->
- * <userTask id="usertask1" name="财务编写月财务报告" activiti:candidateGroups="accountancy"></userTask>
- * <!-- 采用用户组为management编写财务报告 -->
- * <userTask id="usertask2" name="股东审核月财务审计报告" activiti:candidateGroups="management"></userTask>
- *
- * 备注:
- * 默认的两个用户:
- * <pre>
- * 用户名 密码 用户组
- Table 2.1. The demo users
- UserId Password Security roles
- kermit kermit admin
- gonzo gonzo manager
- fozzie fozzie user
- * </pre>
- *
- * @author longgangbai
- *
- * 2011-12-18 下午04:08:46
- */
- public class CustomFinancialReportActiviti {
- public static void main(String[] args) {
- // Create Activiti process engine
- //创建一个流程引擎对象
- // ProcessEngine processEngine = ProcessEngineConfiguration
- // .createStandaloneProcessEngineConfiguration()
- // .buildProcessEngine();
- //创建一个流程引擎对象(为了便于多册测试,修改 name="databaseSchemaUpdate" value="create-drop" 默认为ture)
- ProcessEngine processEngine=ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
- // Get Activiti services
- //获取流程相关的服务
- RepositoryService repositoryService = processEngine.getRepositoryService();
- RuntimeService runtimeService = processEngine.getRuntimeService();
- // Deploy the process definition
- //部署相关的流程配置
- repositoryService.createDeployment()
- .addClasspathResource("diagrams/financialReport.bpmn20.xml")
- .deploy();
- // Start a process instance
- //获取流程实例
- String procId = runtimeService.startProcessInstanceByKey("financialReport").getId();
- // Get the first task
- TaskService taskService = processEngine.getTaskService();
- //获取accountancy组可能要操作的任务
- List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("accountancy").list();
- for (Task task : tasks) {
- System.out.println("Following task is available for accountancy group: " + task.getName());
- //设置fozzie代办 claim it
- taskService.claim(task.getId(), "fozzie");
- }
- // Verify Fozzie can now retrieve the task
- //审核fozzie当前的获取的任务数量
- tasks = taskService.createTaskQuery().taskAssignee("fozzie").list();
- for (Task task : tasks) {
- System.out.println("Task for fozzie: " + task.getName());
- // Complete the task
- //设置forzze完毕
- taskService.complete(task.getId());
- }
- System.out.println("Number of tasks for fozzie: "
- + taskService.createTaskQuery().taskAssignee("fozzie").count());
- // Retrieve and claim the second task
- //管理者审核报告并让kermit代办
- tasks = taskService.createTaskQuery().taskCandidateGroup("management").list();
- for (Task task : tasks) {
- System.out.println("Following task is available for accountancy 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());
- }
- }
运行结果如下:
- 信息: ProcessEngine default created
- 2011-12-18 17:06:00 org.activiti.engine.impl.jobexecutor.JobAcquisitionThread run
- 信息: JobAcquisitionThread starting to acquire jobs
- 2011-12-18 17:06:00 org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
- 信息: Processing resource diagrams/financialReport.bpmn20.xml
- 2011-12-18 17:06:01 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
- 信息: XMLSchema currently not supported as typeLanguage
- 2011-12-18 17:06:01 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
- 信息: XPath currently not supported as expressionLanguage
- Following task is available for accountancy group:<span style="color: #ff0000;"> 财务编写月财务报告</span>
- <span style="color: #ff0000;">Task for fozzie: 财务编写月财务报告</span>
- <span style="color: #ff0000;">Number of tasks for fozzie: 0</span>
- <span style="color: #ff0000;">Following task is available for accountancy group: 股东审核月财务审计报告</span>
- <span style="color: #ff0000;">Process instance end time: Sun Dec 18 17:06:01 CST 2011
- </span>
工作流Activiti的学习总结(十二) activiti官方十分钟快速学习 (zhuan)的更多相关文章
- 《Django By Example》第十二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第十二章,全书最后一章,终于到这章 ...
- SQL注入之Sqli-labs系列第四十一关(基于堆叠注入的盲注)和四十二关四十三关四十四关四十五关
0x1普通测试方式 (1)输入and1=1和and1=2测试,返回错误,证明存在注入 (2)union select联合查询 (3)查询表名 (4)其他 payload: ,( ,( 0x2 堆叠注入 ...
- 第十二课 CSS基本选择器 css学习2
基础选择器一.标签选择器(元素选择器)标签选择器是指用HTML标签名称作为选择器,按标签名称分类语法:标签名{属性1:属性值1;属性2:属性值2;属性3:属性值3;} 二.类选择器1.类选择器使用&q ...
- Redis数据类型简介(十分钟快速学习Redis)
如何在ubuntu18.04上安装和保护redis 如何连接到Redis数据库 如何管理Redis数据库和Keys 如何在Redis中管理副本和客户端 如何在Redis中管理字符串 如何在Redis中 ...
- TensorFlow学习笔记(二)-- MNIST机器学习入门程序学习
此程序被称为TF的 Hello World,19行代码,给人感觉很简单.第一遍看的时候,不到半个小时,就把程序看完了.感觉有点囫囵吞枣的意思,没理解透彻.现在回过头来看,感觉还可以从中学到更多东西. ...
- 第十二章 Net 5.0 快速开发框架 YC.Boilerplate --千万级数据处理解决方案
在线文档:http://doc.yc-l.com/#/README 在线演示地址:http://yc.yc-l.com/#/login 源码github:https://github.com/linb ...
- 30分钟快速学习Shell脚本编程
什么是Shell脚本 示例 看个例子吧: #!/bin/sh cd ~ mkdir shell_tut cd shell_tut for ((i=0; i<10; i++)); do touch ...
- 我的MYSQL学习心得(十二) 触发器
我的MYSQL学习心得(十二) 触发器 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数 ...
- 201521123122 《java程序设计》第十二周学习总结
## 201521123122 <java程序设计>第十二周实验总结 ## 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2. 书面作业 将St ...
随机推荐
- 对 getaddrinfo Android 返回错误 EAI_BADFLAGS
我们尝试使用 getaddrinfo 对 Android API 14 及以上 (在 c + + 代码使用 NDK r12) 从 IPV4 获得合成的 IPV6 地址 address .这是在 IPV ...
- linux 网络设备驱动
linux 网络驱动 谨以此文纪念过往的岁月 一.前言在linux中网络驱动也是一个大头,如何去理解网络驱动是作为一个linux驱动工程师必备的技能.不过同样的设备,在不同人的手中会有不同的效果,其原 ...
- mysql之子查询
所谓子查询,就是指在一个查询之中嵌套了其他的若干查询,通过子查询可以实现多表查询,该查询语句中可能包含IN,ANY,ALL和EXISTS等关键字,除此之外还可以包含比较运算符,子查询经常出现在WHER ...
- TextView文字横向自己主动滚动
效果截图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjI4Nj ...
- [React + Functional Programming ADT] Create Redux Middleware to Dispatch Actions with the Async ADT
We would like the ability to group a series of actions to be dispatched with single dispatching func ...
- Wifidog及认证过程初分析
Wifidog初分析 一.综述 wifidog是搭建无线热点认证系统的解决方案之一,他比nocat.nodog更适合互联网营销思路.常见的使用在openwrt系统上,它实现了路由器和认证服务器的数据交 ...
- Microjs: 超棒的迷你框架和迷你类库搜罗工具
你可以按条件方便的搜索需要的类库或者框架,以下为条件 基础框架 模板引擎 DOM操作 CSS动画 Javascript动画 数据操作 更多 阅读原文:Microjs: 超棒的迷你框架和迷你类库搜罗工具
- Python 数据驱动工具:DDT
背景 python 的unittest 没有自带数据驱动功能. 所以如果使用unittest,同时又想使用数据驱动,那么就可以使用DDT来完成. DDT是 “Data-Driven Tests”的缩写 ...
- HTTP请求头 If-Modified-Since
来自:http://www.jm47.com/g/91174.htm 一直以来没有留意过HTTP请求头的IMS(If-Modified-Since)标签. 最近在分析Squid的access.log日 ...
- OSG 集群渲染 cluster render 支持 Cave 和 powerwall 模式
写了几天.用OSG,实现了集群渲染,感觉还不错,线性加速比还算能够.採用KDTree .八叉树管理场景.场景数据通过UDP和TCP. 不用复制文件,直接在线读取(主节点向渲染节点同步模型数据).效率基 ...