http://topmanopensource.iteye.com/blog/1315341

******************************************************

根据activiti官方提供的 编写 
      1.财务部门填写月财务报告
      2.股东审核月财务审计报告

流程图:

流程配置:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <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">
  3. <process id="financialReport" name="Monthly financial report reminder process">
  4. <startEvent id="startevent1" name="月财务报告审核开始"></startEvent>
  5. <!-- 采用用户组为accountancy编写财务报告  -->
  6. <userTask id="usertask1" name="财务编写月财务报告" activiti:candidateGroups="accountancy"></userTask>
  7. <userTask id="usertask2" name="股东审核月财务审计报告" activiti:candidateGroups="management"></userTask>
  8. <endEvent id="endevent1" name="月财务报告审核结束"></endEvent>
  9. <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
  10. <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
  11. <sequenceFlow id="flow3" name="" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
  12. </process>
  13. <bpmndi:BPMNDiagram id="BPMNDiagram_financialReport">
  14. <bpmndi:BPMNPlane bpmnElement="financialReport" id="BPMNPlane_financialReport">
  15. <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
  16. <omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
  17. </bpmndi:BPMNShape>
  18. <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
  19. <omgdc:Bounds height="55" width="105" x="125" y="190"></omgdc:Bounds>
  20. </bpmndi:BPMNShape>
  21. <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
  22. <omgdc:Bounds height="55" width="105" x="290" y="190"></omgdc:Bounds>
  23. </bpmndi:BPMNShape>
  24. <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
  25. <omgdc:Bounds height="35" width="35" x="455" y="200"></omgdc:Bounds>
  26. </bpmndi:BPMNShape>
  27. <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
  28. <omgdi:waypoint x="65" y="217"></omgdi:waypoint>
  29. <omgdi:waypoint x="125" y="217"></omgdi:waypoint>
  30. </bpmndi:BPMNEdge>
  31. <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
  32. <omgdi:waypoint x="230" y="217"></omgdi:waypoint>
  33. <omgdi:waypoint x="290" y="217"></omgdi:waypoint>
  34. </bpmndi:BPMNEdge>
  35. <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
  36. <omgdi:waypoint x="395" y="217"></omgdi:waypoint>
  37. <omgdi:waypoint x="455" y="217"></omgdi:waypoint>
  38. </bpmndi:BPMNEdge>
  39. </bpmndi:BPMNPlane>
  40. </bpmndi:BPMNDiagram>
  41. </definitions>

编码如下:

  1. package com.easyway.spring.activiti;
  2. import java.util.List;
  3. import org.activiti.engine.HistoryService;
  4. import org.activiti.engine.ProcessEngine;
  5. import org.activiti.engine.ProcessEngineConfiguration;
  6. import org.activiti.engine.RepositoryService;
  7. import org.activiti.engine.RuntimeService;
  8. import org.activiti.engine.TaskService;
  9. import org.activiti.engine.history.HistoricProcessInstance;
  10. import org.activiti.engine.task.Task;
  11. /**
  12. * 根据activiti官方提供的 编写
  13. *     1.财务部门填写月财务报告
  14. *     2.股东审核月财务审计报告
  15. *
  16. *
  17. * activiti提供的财务报告审核
  18. * <!-- 采用用户组为accountancy编写财务报告  -->
  19. *   <userTask id="usertask1" name="财务编写月财务报告" activiti:candidateGroups="accountancy"></userTask>
  20. * <!-- 采用用户组为management编写财务报告  -->
  21. *   <userTask id="usertask2" name="股东审核月财务审计报告" activiti:candidateGroups="management"></userTask>
  22. *
  23. * 备注:
  24. *    默认的两个用户:
  25. *    <pre>
  26. *       用户名   密码         用户组
  27. Table 2.1. The demo users
  28. UserId Password Security roles
  29. kermit kermit admin
  30. gonzo gonzo manager
  31. fozzie fozzie user
  32. *    </pre>
  33. *
  34. * @author longgangbai
  35. *
  36. * 2011-12-18  下午04:08:46
  37. */
  38. public class CustomFinancialReportActiviti {
  39. public static void main(String[] args) {
  40. // Create Activiti process engine
  41. //创建一个流程引擎对象
  42. //          ProcessEngine processEngine = ProcessEngineConfiguration
  43. //            .createStandaloneProcessEngineConfiguration()
  44. //            .buildProcessEngine();
  45. //创建一个流程引擎对象(为了便于多册测试,修改 name="databaseSchemaUpdate" value="create-drop"  默认为ture)
  46. ProcessEngine processEngine=ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
  47. // Get Activiti services
  48. //获取流程相关的服务
  49. RepositoryService repositoryService = processEngine.getRepositoryService();
  50. RuntimeService runtimeService = processEngine.getRuntimeService();
  51. // Deploy the process definition
  52. //部署相关的流程配置
  53. repositoryService.createDeployment()
  54. .addClasspathResource("diagrams/financialReport.bpmn20.xml")
  55. .deploy();
  56. // Start a process instance
  57. //获取流程实例
  58. String procId = runtimeService.startProcessInstanceByKey("financialReport").getId();
  59. // Get the first task
  60. TaskService taskService = processEngine.getTaskService();
  61. //获取accountancy组可能要操作的任务
  62. List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("accountancy").list();
  63. for (Task task : tasks) {
  64. System.out.println("Following task is available for accountancy group: " + task.getName());
  65. //设置fozzie代办 claim it
  66. taskService.claim(task.getId(), "fozzie");
  67. }
  68. // Verify Fozzie can now retrieve the task
  69. //审核fozzie当前的获取的任务数量
  70. tasks = taskService.createTaskQuery().taskAssignee("fozzie").list();
  71. for (Task task : tasks) {
  72. System.out.println("Task for fozzie: " + task.getName());
  73. // Complete the task
  74. //设置forzze完毕
  75. taskService.complete(task.getId());
  76. }
  77. System.out.println("Number of tasks for fozzie: "
  78. + taskService.createTaskQuery().taskAssignee("fozzie").count());
  79. // Retrieve and claim the second task
  80. //管理者审核报告并让kermit代办
  81. tasks = taskService.createTaskQuery().taskCandidateGroup("management").list();
  82. for (Task task : tasks) {
  83. System.out.println("Following task is available for accountancy group: " + task.getName());
  84. taskService.claim(task.getId(), "kermit");
  85. }
  86. // Completing the second task ends the process
  87. //完成报告
  88. for (Task task : tasks) {
  89. taskService.complete(task.getId());
  90. }
  91. // verify that the process is actually finished
  92. //查询流程实例完成事件
  93. HistoryService historyService = processEngine.getHistoryService();
  94. HistoricProcessInstance historicProcessInstance =
  95. historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
  96. System.out.println("Process instance end time: " + historicProcessInstance.getEndTime());
  97. }
  98. }

运行结果如下:

  1. 信息: ProcessEngine default created
  2. 2011-12-18 17:06:00 org.activiti.engine.impl.jobexecutor.JobAcquisitionThread run
  3. 信息: JobAcquisitionThread starting to acquire jobs
  4. 2011-12-18 17:06:00 org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
  5. 信息: Processing resource diagrams/financialReport.bpmn20.xml
  6. 2011-12-18 17:06:01 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
  7. 信息: XMLSchema currently not supported as typeLanguage
  8. 2011-12-18 17:06:01 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
  9. 信息: XPath currently not supported as expressionLanguage
  10. Following task is available for accountancy group:<span style="color: #ff0000;"> 财务编写月财务报告</span>
  11. <span style="color: #ff0000;">Task for fozzie: 财务编写月财务报告</span>
  12. <span style="color: #ff0000;">Number of tasks for fozzie: 0</span>
  13. <span style="color: #ff0000;">Following task is available for accountancy group: 股东审核月财务审计报告</span>
  14. <span style="color: #ff0000;">Process instance end time: Sun Dec 18 17:06:01 CST 2011
  15. </span>

工作流Activiti的学习总结(十二) activiti官方十分钟快速学习 (zhuan)的更多相关文章

  1. 《Django By Example》第十二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第十二章,全书最后一章,终于到这章 ...

  2. SQL注入之Sqli-labs系列第四十一关(基于堆叠注入的盲注)和四十二关四十三关四十四关四十五关

    0x1普通测试方式 (1)输入and1=1和and1=2测试,返回错误,证明存在注入 (2)union select联合查询 (3)查询表名 (4)其他 payload: ,( ,( 0x2 堆叠注入 ...

  3. 第十二课 CSS基本选择器 css学习2

    基础选择器一.标签选择器(元素选择器)标签选择器是指用HTML标签名称作为选择器,按标签名称分类语法:标签名{属性1:属性值1;属性2:属性值2;属性3:属性值3;} 二.类选择器1.类选择器使用&q ...

  4. Redis数据类型简介(十分钟快速学习Redis)

    如何在ubuntu18.04上安装和保护redis 如何连接到Redis数据库 如何管理Redis数据库和Keys 如何在Redis中管理副本和客户端 如何在Redis中管理字符串 如何在Redis中 ...

  5. TensorFlow学习笔记(二)-- MNIST机器学习入门程序学习

    此程序被称为TF的 Hello World,19行代码,给人感觉很简单.第一遍看的时候,不到半个小时,就把程序看完了.感觉有点囫囵吞枣的意思,没理解透彻.现在回过头来看,感觉还可以从中学到更多东西. ...

  6. 第十二章 Net 5.0 快速开发框架 YC.Boilerplate --千万级数据处理解决方案

    在线文档:http://doc.yc-l.com/#/README 在线演示地址:http://yc.yc-l.com/#/login 源码github:https://github.com/linb ...

  7. 30分钟快速学习Shell脚本编程

    什么是Shell脚本 示例 看个例子吧: #!/bin/sh cd ~ mkdir shell_tut cd shell_tut for ((i=0; i<10; i++)); do touch ...

  8. 我的MYSQL学习心得(十二) 触发器

    我的MYSQL学习心得(十二) 触发器 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数 ...

  9. 201521123122 《java程序设计》第十二周学习总结

    ## 201521123122 <java程序设计>第十二周实验总结 ## 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2. 书面作业 将St ...

随机推荐

  1. TYVJ-P1864 守卫者的挑战 题解

    P1864 [Poetize I]守卫者的挑战 时间: 1000ms / 空间: 131072KiB / Java类名: Main 描述 打开了黑魔法师Vani的大门,队员们在迷宫般的路上漫无目的地搜 ...

  2. OpenCV学习(15) 细化算法(3)

          本章我们学习一下Hilditch算法的基本原理,从网上找资料的时候,竟然发现两个有很大差别的算法描述,而且都叫Hilditch算法.不知道那一个才是正宗的,两个算法实现的效果接近,第一种算 ...

  3. Shell学习:grep, sed, awk命令的练习题

    http://www.cnblogs.com/chengmo/archive/2013/01/17/2865479.html 文件:datafileSteve Blenheim:238-923-736 ...

  4. Netbeans配合xdebug调试

    http://xdebug.org/download.php 下载对应的xdebug的dll不知道php文件中的ext文件夹中 并且加入以下配置在php.info 然后重启apche zend_ext ...

  5. Oracle spatial抽稀函数(SDO_UTIL.SIMPLIFY)

    在使用Oracle spatial做空间查询和展示时,经常会遇到展示或者查询过慢,这时候我可以通过空间数据抽稀来优化查询展示效率. 在Oracle spatial中的抽稀函数为:SDO_UTIL.SI ...

  6. 流编辑器sed

    sed与grep一样,都起源于老式的ed编辑器,因其是一个流编辑器(stream editor)而得名.与vi等编辑器不同,sed是一种非交互式编辑器(即用户不必参与编辑过程),它使用预先设定好的编辑 ...

  7. 手动脱UPX 壳实战

    作者:Fly2015 Windows平台的加壳软件还是比較多的,因此有非常多人对于PC软件的脱壳乐此不彼,本人菜鸟一枚,也学习一下PC的脱壳.要对软件进行脱壳.首先第一步就是 查壳.然后才是 脱壳. ...

  8. 自己定义iOS上双击Home键图切换

    假设双击Home.会来到iOS App的switcher页面,在这儿列出了当前系统挂起的App, 上面有每一个App的切屏,相信大家都熟悉这个东东了. 它事实上是每一个App在挂起前,对App后个载屏 ...

  9. QtGui.QPixmap

    A QtGui.QPixmap is one of the widgets used to work with images. It is optimized for showing images o ...

  10. canvas的api

    Canvas API(画布)用于在网页实时生成图像,并且可以操作图像内容,基本上它是一个可以用JavaScript操作的位图(bitmap).使用前,首先需要新建一个canvas网页元素. 1 2 3 ...