(5)流程定义列表:activiti自定义流程之Spring整合activiti-modeler5.16实例(五):流程定义列表
(6)启动流程:activiti自定义流程之Spring整合activiti-modeler5.16实例(六):启动流程
(7)任务列表展示:activiti自定义流程之Spring整合activiti-modeler5.16实例(七):任务列表展示
上边所说的正确调用是指,如果当前任务的下一个任务设有个人任务变量或者组任务变量,那么提交的时候必须有对应的变量数据,否则会抛出异常,完成任务失败。(但是,如果下一个任务没有设置这些,提交时依旧填了流程变量是不会出错的)
下边的例子中,之所以还查询了流程节点的信息,并做了相关的处理,是为了实现针对任意数量任务的流程都能正常运行,否则不需要这么麻烦。
/** * @throws XMLStreamException * 完成个人任务 * * @author:tuzongxun * @Title: completeTask * @param @return * @return Object * @date Mar 17, 2016 4:55:31 PM * @throws */ @RequestMapping(value = "/completeTask.do", method = RequestMethod.POST, produces = "application/json;charset=utf-8") @ResponseBody public Object completeTask(@RequestBody TaskModel taskModel, HttpServletRequest req) throws XMLStreamException { boolean isLogin = this.isLogin(req); if (isLogin) { String taskId = taskModel.getId(); // 1、查task Task task = taskService.createTaskQuery().taskId(taskId) .singleResult(); // 2、查variables Map<String, Object> variables = runtimeService.getVariables(task .getProcessInstanceId()); Set<String> keysSet = variables.keySet(); Iterator<String> keySet = keysSet.iterator(); Map<String, Object> variables1 = new HashMap<String, Object>(); String assignee = task.getAssignee(); // 判断之后是否还有任务 // //////////////// while (keySet.hasNext()) { String key = keySet.next(); if (key.equals("cause") || key.equals("content") || key.equals("taskType")) { continue; } else if (!(assignee.equals(variables.get(key)))) { // 3、查flowElement Iterator<FlowElement> iterator = this.findFlow(task .getProcessDefinitionId()); while (iterator.hasNext()) { FlowElement flowElement = iterator.next(); String classNames = flowElement.getClass() .getSimpleName(); if (classNames.equals("UserTask")) { UserTask userTask = (UserTask) flowElement; String assginee11 = userTask.getAssignee(); String assginee12 = assginee11.substring( assginee11.indexOf("{") + 1, assginee11.indexOf("}")); String assignee13 = (String) variables .get(assginee12); if (assignee.equals(assignee13)) { // 看下下一个节点是什么 iterator.next(); FlowElement flowElement2 = iterator.next(); String classNames1 = flowElement2.getClass() .getSimpleName(); // 设置下一个任务人 if (!(classNames1.equals("EndEvent"))) { UserTask userTask2 = (UserTask) flowElement2; String assginee21 = userTask2.getAssignee(); String assginee22 = assginee21.substring( assginee21.indexOf("{") + 1, assginee21.indexOf("}")); // String assignee23 = (String) variables // .get(assginee22); String assignee23 = taskModel .getNextPerson(); variables1.put(assginee22, assignee23); } } } } } } taskService.complete(taskId, variables1); } return null; }
$stateProvider .state('completeTaskTo', { url: "/completeTaskTo", views: { 'view': { templateUrl: 'activi_views/completeTask.html', controller: 'completeTaskCtr' } } });
angular.module('activitiApp') .controller('completeTaskCtr', ['$rootScope','$scope','$http','$location','$state', function($rootScope,$scope,$http,$location,$state){ $http.post("createFlush.do").success(function(result){ if(result.isLogin==="yes"){ $rootScope.userName=result.userName; if($rootScope.task==null||$rootScope.task.id==null){ $location.path("/taskList"); }else{ $scope.task=$rootScope.task; } }else{ $location.path("/login"); } }); $scope.completeTask=function(task){ console.log(task); $rootScope.task=task; $http.post("./completeTask.do",task).success(function(taskResult){ $location.path("/taskList"); }); } }])
<div style="margin-top:20px;margin-left:200px;background-color:#ccf;height:550px;width:50%;font-size:18px;position:relative;float:left;"> <center> <p style="font-size:24px;margin-top:10px">处理当前任务</p> 类 型:<input ng-model="task.taskType" readonly="readonly" style="background-color:#9cf"></input> </br> </br> NAME :<input ng-model="task.name" readonly="readonly" style="background-color:#9cf"></input> </br> </br> 任 务 ID :<input ng-model="task.id" readonly="readonly" style="background-color:#9cf"></input> </br> </br> ProcessIntanceId:<input ng-model="task.processInstanceId" readonly="readonly" style="background-color:#9cf"></input> </br> </br> ProcessDefId :<input ng-model="task.processDefId" readonly="readonly" style="background-color:#9cf"></input> </br> </br> 创 建 时 间 :<input ng-model="task.createTime" readonly="readonly" style="background-color:#9cf"></input> </br> </br> 申 请 人 :<input ng-model="task.assignee" readonly="readonly" style="background-color:#9cf"></input> </br> </br> 受 理 人 :<input ng-model="task.nextPerson"></input> </br> </br> 申 请 原 因 :<input ng-model="task.cause"></input> </br> </br> 申 请 内 容 :<input ng-model="task.content"></input> </br> </br> <input style="font-size:22px;cursor:pointer" type="button" value="处理任务" ng-click="completeTask(task);"> <input style="font-size:22px;cursor:pointer" type="button" value="返回"> </center> </div>