activiti自定义流程之Spring整合activiti-modeler5.16实例(六):启动流程
(2)创建流程模型:activiti自定义流程之Spring整合activiti-modeler5.16实例(二):创建流程模型
(3)流程模型列表展示:activiti自定义流程之Spring整合activiti-modeler5.16实例(三):流程模型列表展示
(4)部署流程定义:activiti自定义流程之Spring整合activiti-modeler5.16实例(四):部署流程定义
(5)流程定义列表:activiti自定义流程之Spring整合activiti-modeler5.16实例(五):流程定义列表
1.启动流程并分配任务是单个流程的正式开始,因此要使用到runtimeService接口,以及相关的启动流程的方法。我习惯于用流程定义的key启动,因为有多个版本的流程定义时,用key启动默认会使用最新版本。同时,因为启动中查询了流程部署时xml文件中流程节点的信息,也用到了repositoryService及相关方法。
2.后台业务代码,
(1)自定义的申请单实体类(为的目的只为了跑通整个流程,因此只定义了一个实体类,按公司标准开发来说,应该是和前台交互一个command类(其实也还是实体类,叫法不一样而已),和数据库交互还有一个实体类),在这里定义了一个申请单的基本信息:
- package model;
- public class applyModel {
- /**
- * 流程定义id
- */
- private String proDefId;
- /**
- * 流程定义的key
- */
- private String key;
- private String name;
- /**
- * 申请人
- */
- private String appPerson;
- /**
- * 原因
- */
- private String cause;
- /**
- * 内容
- */
- private String content;
- /**
- * 处理人,即下一个任务节点的受理人
- */
- private String proPerson;
- public String getKey() {
- return key;
- }
- public void setKey(String key) {
- this.key = key;
- }
- public String getAppPerson() {
- return appPerson;
- }
- public void setAppPerson(String appPerson) {
- this.appPerson = appPerson;
- }
- public String getCause() {
- return cause;
- }
- public void setCause(String cause) {
- this.cause = cause;
- }
- public String getContent() {
- return content;
- }
- public void setContent(String content) {
- this.content = content;
- }
- public String getProPerson() {
- return proPerson;
- }
- public void setProPerson(String proPerson) {
- this.proPerson = proPerson;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getProDefId() {
- return proDefId;
- }
- public void setProDefId(String proDefId) {
- this.proDefId = proDefId;
- }
- @Override
- public String toString() {
- return "applyModel [proDefId=" + proDefId + ", key=" + key + ", name="
- + name + ", appPerson=" + appPerson + ", cause=" + cause
- + ", content=" + content + ", proPerson=" + proPerson + "]";
- }
- }
(2)业务逻辑:
A,这个方法获取流程部署时xml文件里的各个节点相关信息,用来辨别当前是哪个节点,下一节点又是什么,共下边的B方法调用。因为操作部署时的文件,因此使用repositoryService:
- /**
- * @throws XMLStreamException
- * 查询流程节点
- *
- * @author:tuzongxun
- * @Title: findFlow
- * @param @return
- * @return Iterator<FlowElement>
- * @date Mar 21, 2016 9:31:42 AM
- * @throws
- */
- public Iterator<FlowElement> findFlow(String processDefId)
- throws XMLStreamException {
- List<ProcessDefinition> lists = repositoryService
- .createProcessDefinitionQuery()
- .processDefinitionId(processDefId)
- .orderByProcessDefinitionVersion().desc().list();
- ProcessDefinition processDefinition = lists.get(0);
- processDefinition.getCategory();
- String resourceName = processDefinition.getResourceName();
- InputStream inputStream = repositoryService.getResourceAsStream(
- processDefinition.getDeploymentId(), resourceName);
- BpmnXMLConverter converter = new BpmnXMLConverter();
- XMLInputFactory factory = XMLInputFactory.newInstance();
- XMLStreamReader reader = factory.createXMLStreamReader(inputStream);
- BpmnModel bpmnModel = converter.convertToBpmnModel(reader);
- Process process = bpmnModel.getMainProcess();
- Collection<FlowElement> elements = process.getFlowElements();
- Iterator<FlowElement> iterator = elements.iterator();
- return iterator;
- }
B.这里调用上一个方法,一起完成流程的启动及相关信息的设置:
- /**
- * @throws XMLStreamException
- * 启动流程
- *
- * @author:tuzongxun
- * @Title: startProcess
- * @param @return
- * @return Object
- * @date Mar 17, 2016 2:06:34 PM
- * @throws
- */
- @RequestMapping(value = "/startProcess.do", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
- @ResponseBody
- public Object startProcess(@RequestBody applyModel applyModel,
- HttpServletRequest req) throws XMLStreamException {
- Map<String, String> map = new HashMap<String, String>();
- boolean isLogin = this.isLogin(req);
- if (isLogin) {
- if (applyModel != null) {
- String processKey = applyModel.getKey();
- String processDefId = applyModel.getProDefId();
- // //////////////////////////
- Iterator<FlowElement> iterator = this.findFlow(processDefId);
- Map<String, Object> varables = new HashMap<String, Object>();
- int i = 1;
- while (iterator.hasNext()) {
- FlowElement flowElement = iterator.next();
- // 申请人
- if (flowElement.getClass().getSimpleName()
- .equals("UserTask")
- && i == 1) {
- UserTask userTask = (UserTask) flowElement;
- String assignee = userTask.getAssignee();
- int index1 = assignee.indexOf("{");
- int index2 = assignee.indexOf("}");
- varables.put(assignee.substring(index1 + 1, index2),
- applyModel.getAppPerson());
- varables.put("cause", applyModel.getCause());
- varables.put("content", applyModel.getContent());
- varables.put("taskType", applyModel.getName());
- i++;
- // 下一个处理人
- } else if (flowElement.getClass().getSimpleName()
- .equals("UserTask")
- && i == 2) {
- UserTask userTask = (UserTask) flowElement;
- String assignee = userTask.getAssignee();
- int index1 = assignee.indexOf("{");
- int index2 = assignee.indexOf("}");
- varables.put(assignee.substring(index1 + 1, index2),
- applyModel.getProPerson());
- break;
- }
- }
- // ///////////////////////////
- runtimeService.startProcessInstanceByKey(processKey, varables);
- map.put("userName",
- (String) req.getSession().getAttribute("userName"));
- map.put("isLogin", "yes");
- map.put("result", "success");
- } else {
- map.put("result", "fail");
- }
- } else {
- map.put("isLogin", "no");
- }
- return map;
- }
3.angular js前台代码,:
(1)app.js中配置路由:
- $stateProvider
- .state('startProcess', {
- url: "/startProcess",
- views: {
- 'view': {
- templateUrl: 'activi_views/startProcess.html',
- controller: 'startProcessCtr'
- }
- }
- });
(2)逻辑相关代码:
- angular.module('activitiApp')
- .controller('startProcessCtr', ['$rootScope','$scope','$http','$location', function($rootScope,$scope,$http,$location){
- $http.post("createFlush.do").success(function(result){
- if(result.isLogin==="yes"){
- $rootScope.userName=result.userName;
- $scope.process1={"proDefId":"","key":"","appPerson":"","cause":"","content":"","proPerson":"","name":""};
- if($rootScope.process==null||$rootScope.process.key==null){
- $location.path("/processList");
- }else{
- $scope.process1.proDefId=$rootScope.process.id;
- $scope.process1.key=$rootScope.process.key;
- $scope.process1.name=$rootScope.process.name;
- }
- }else{
- $location.path("/login");
- }
- });
- $scope.startProcess=function(process){
- console.log(process);
- $http.post("./startProcess.do",process).success(function(deployResult){
- $location.path("/taskList");
- });
- }
- }])
4.对应的填写相关信息的页面:
- <center>
- <div style="margin-top:20px;margin-left:200px;background-color:#9cc;height:500px;width:50%;font-size:22px;position:relative;float:left;">
- <p style="font-size:28px">新建申请</p>
- 流程定义id:<input type="text" ng-model="process1.proDefId" readonly="readonly" style="background-color:#9dc"/>
- </br>
- </br>
- 流程定义key:<input type="text" ng-model="process1.key" readonly="readonly" style="background-color:#9dc"/>
- </br>
- </br>
- 申请类型:<input type="text" ng-model="process1.name" readonly="readonly" style="background-color:#9dc"/>
- </br>
- </br>
- 申请人:<input type="text" ng-model="process1.appPerson" />
- </br>
- </br>
- 申请原因:<input type="text" ng-model="process1.cause"/>
- </br>
- </br>
- 申请内容:<input type="text" ng-model="process1.content"/>
- </br>
- </br>
- 受理人:<input type="text" ng-model="process1.proPerson"/>
- </br>
- </br>
- <input style="font-size:24px;cursor:pointer" type="button" value="提交申请" ng-click="startProcess(process1);">
- <input style="font-size:24px;cursor:pointer" type="button" value="返回">
- </div>
- </center>
5.成功启动一个流程实例后,会看到act_ru_execution、act_ru_identitylink、act_ru_task、act_ru_variable以及act_hi_actinst、act_hi_detail、act_hi_indentitylink、act_hi_procinst、act_hi_taskinst、act_hi_varinst表中都有了数据。除开variable和varinst中的数据条数是根据对应的流程变量多少来定的,其他都是增加了一条数据。
activiti自定义流程之Spring整合activiti-modeler5.16实例(六):启动流程的更多相关文章
- activiti自定义流程之Spring整合activiti-modeler5.16实例(九):历史任务查询
注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建 (2)创建流程模型:activiti自定义流程之Spring ...
- activiti自定义流程之Spring整合activiti-modeler5.16实例(八):完成个人任务
注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建 (2)创建流程模型:activiti自定义流程之Spring ...
- activiti自定义流程之Spring整合activiti-modeler5.16实例(七):任务列表展示
注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建 (2)创建流程模型:activiti自定义流程之Spring ...
- activiti自定义流程之Spring整合activiti-modeler5.16实例(五):流程定义列表
注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建 (2)创建流程模型:activiti自定义流程之Spring ...
- activiti自定义流程之Spring整合activiti-modeler5.16实例(四):部署流程定义
注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建 (2)创建流程模型:activiti自定义流程之Spring ...
- activiti自定义流程之Spring整合activiti-modeler5.16实例(三):流程模型列表展示
注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建 (2)创建流程模型:activiti自定义流程之Spring ...
- activiti自定义流程之Spring整合activiti-modeler5.16实例(二):创建流程模型
注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建 1.maven导包,这里就没有什么多的好说了,直接代码: <depe ...
- activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建
项目中需要整合activiti-modeler自定义流程,找了很多资料后,终于成功的跳转到activiti-modeler流程设计界面,以下是记录: 一.整合基础:eclipse4.4.1.tomca ...
- activiti自己定义流程之Spring整合activiti-modeler5.16实例(四):部署流程定义
注:(1)环境搭建:activiti自己定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建 (2)创建流程模型:activiti自己定义流程之Spr ...
随机推荐
- php使用redis存储
一.Redis扩展模块 # wget https://codeload.github.com/phpredis/phpredis/zip/develop -O phpredis.zip # unzip ...
- 【P1813】8的倍数
容斥原理,居然没想到……要补一下数论了 原题: 小x最近对数字8很感兴趣,有8进制,2008奥运会之类的.现在小x想知道,在[x,y]区间里,有多少个数能被8整除.小y觉得题目太简单,于是给出n个其他 ...
- apply通过实例理解
测试->运行环境chrom console >var aaa = {a:1,b:2,c:function(){console.log(this.a)}} 运行结果:undefined &g ...
- 大白话系列之C#委托与事件讲解(一)
从序言中,大家应该对委托和事件的重要性有点了解了吧,虽然说我们现在还是能模糊,但是从我的大白话系列中,我会把这些概念说的通俗易懂的.首先,我们还是先说说委托吧,从字面上理解,只要是中国人应该都知道这个 ...
- vb6 判断64位操作系统
Option Explicit Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Priva ...
- python扫描内网banner信息
小菜自己无聊写着玩,主要纪念以前的逗逼学习,可以改IPy import mechanize import cookielib import socket import argparse import ...
- 如何用OCR图文识别软件在文档里复制内容
ABBYY FineReader 12是一款OCR图文识别软件,可从文档中复制文本.图片和表格,粘贴到其他应用程序中.无需识别整个文档(关于ABBYY FineReader识别文档的文章,请参考解析A ...
- 深入浅出Attribute (转载)
原文地址:http://blog.csdn.net/FantasiaX/article/details/1627694 正文: 什么是Attribute?Attribute是干什么使的?Attribu ...
- ASP.NET读取EXCEL文件的三种经典方法
1.方法一:采用OleDB读取EXCEL文件: 把EXCEL文件当做一个数据源来进行数据的读取操作,实例如下: public DataSet ExcelToDS(string Path) { ...
- JavaScript 全选函数的实现
Html代码: <table id="purchase-info" class="table table-bordered table-hover table-st ...