activiti自己定义流程之Spring整合activiti-modeler实例(七):任务列表展示
1.通过上一节的操作,能够知道流程启动以后会同一时候生成一个流程实例和用户任务。这个用户任务保存在act_ru_task和act_hi_task表中,从表明能够看出ru是runtime,hi是history。可是须要注意的是,和操作流程使用的service不同。操作正在发生任务不是使用runtimeService,而是专门的taskService。
2.后台业务代码,
(1)自己定义的任务实体类
- package model;
- import java.util.Date;
- public class TaskModel {
- private String id;
- private String name;
- private String processInstanceId;
- private String assignee;
- private Date createTime;
- private String nextPerson;
- private String cause;
- private String content;
- private String taskType;
- private String processKey;
- private String processDefId;
- public String getTaskType() {
- return taskType;
- }
- public void setTaskType(String taskType) {
- this.taskType = taskType;
- }
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getProcessInstanceId() {
- return processInstanceId;
- }
- public void setProcessInstanceId(String processInstanceId) {
- this.processInstanceId = processInstanceId;
- }
- public String getAssignee() {
- return assignee;
- }
- public void setAssignee(String assignee) {
- this.assignee = assignee;
- }
- public Date getCreateTime() {
- return createTime;
- }
- public void setCreateTime(Date createTime) {
- this.createTime = createTime;
- }
- public String getNextPerson() {
- return nextPerson;
- }
- public void setNextPerson(String nextPerson) {
- this.nextPerson = nextPerson;
- }
- 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 getProcessKey() {
- return processKey;
- }
- public void setProcessKey(String processKey) {
- this.processKey = processKey;
- }
- public String getProcessDefId() {
- return processDefId;
- }
- public void setProcessDefId(String processDefId) {
- this.processDefId = processDefId;
- }
- @Override
- public String toString() {
- return "TaskModel [id=" + id + ", name=" + name
- + ", processInstanceId=" + processInstanceId + ", assignee="
- + assignee + ", createTime=" + createTime + ", nextPerson="
- + nextPerson + ", cause=" + cause + ", content=" + content
- + ", taskType=" + taskType + ", processKey=" + processKey
- + ", processDefId=" + processDefId + "]";
- }
- }
(2)业务逻辑:查询任务使用taskService调用相关的方法来完毕,能够依据特定的条件,也能够不加条件查询全部。能够返回task为元素的list。也能够返回单独的task对象,可是须要注意的是,假设要返回单独的task对象。则必须确定返回值是唯一的对象,否则就会抛出异常。下边的样例中。我是依据当前登陆的username来查询出相应的全部task:
- /**
- * @throws XMLStreamException
- * 查询个人任务
- *
- * @author:tuzongxun
- * @Title: findTask
- * @param @return
- * @return Object
- * @date Mar 17, 2016 2:44:11 PM
- * @throws
- */
- @RequestMapping(value = "/findTask.do", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
- @ResponseBody
- public Object findTask(HttpServletRequest req) throws XMLStreamException {
- Map<String, Object> map = new HashMap<String, Object>();
- boolean isLogin = this.isLogin(req);
- if (isLogin) {
- List<TaskModel> taskList = new ArrayList<TaskModel>();
- HttpSession session = req.getSession();
- String assginee = (String) session.getAttribute("userName");
- List<Task> taskList1 = taskService.createTaskQuery()
- .taskAssignee(assginee).list();
- if (taskList1 != null && taskList1.size() > 0) {
- for (Task task : taskList1) {
- TaskModel taskModel = new TaskModel();
- taskModel.setAssignee(task.getAssignee());
- taskModel.setCreateTime(task.getCreateTime());
- taskModel.setId(task.getId());
- taskModel.setName(task.getName());
- taskModel.setProcessInstanceId(task.getProcessInstanceId());
- taskModel.setProcessDefId(task.getProcessDefinitionId());
- // 获取流程变量
- Map<String, Object> variables = runtimeService
- .getVariables(task.getProcessInstanceId());
- Set<String> keysSet = variables.keySet();
- Iterator<String> keySet = keysSet.iterator();
- while (keySet.hasNext()) {
- String key = keySet.next();
- if (key.endsWith("cause")) {
- taskModel.setCause((String) variables.get("cause"));
- } else if (key.endsWith("content")) {
- taskModel.setContent((String) variables
- .get("content"));
- } else if (key.endsWith("taskType")) {
- taskModel.setTaskType((String) variables
- .get("taskType"));
- } else if (!assginee.equals(variables.get(key))) {
- // 想办法查询是否还有下一个任务节点
- 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 (assginee.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);
- taskModel.setNextPerson(ToolUtils
- .isEmpty(assignee23));
- }
- }
- }
- }
- // //////////
- }
- }
- taskList.add(taskModel);
- }
- }
- map.put("isLogin", "yes");
- map.put("userName",
- (String) req.getSession().getAttribute("userName"));
- map.put("result", "success");
- map.put("data", taskList);
- } else {
- map.put("isLogin", "no");
- }
- return map;
- }
3.angular js前台代码(前台仅仅是做简单的展示,不多讲):
(1)app.js中配置路由:
- $stateProvider
- .state('taskList', {
- url: "/taskList",
- views: {
- 'view': {
- templateUrl: 'activi_views/taskList.html',
- controller: 'taskCtr'
- }
- }
- });
(2)逻辑相关代码:
- angular.module('activitiApp')
- .controller('taskCtr', ['$rootScope','$scope','$http','$location','$state', function($rootScope,$scope,$http,$location,$state){
- $scope.init=function(){
- $http.post("./findTask.do").success(function(result) {
- if(result.isLogin==="yes"){
- console.log(result.data);
- $rootScope.userName=result.userName;
- $scope.taskList=result.data;
- }else{
- $location.path("/login");
- }
- });
- }
- $scope.completeTaskTo=function(task){
- console.log(task);
- $rootScope.task=task;
- //$location.path("/completeTaskTo");
- $location.path("/completeTaskTo1");
- }
- }])
4.相应的填写相关信息的页面:
- <div id="logdiv1" ng-init="init();">
- <p style="font-size:22px;margin-top:10px">当前任务列表</p>
- <center>
- <table border="1px" style="width:87%;font-size:14px;text-align:center;margin-top:1px;margin-left:2px;position:relative;float:left;" cellSpacing="0px" cellPadding="0px">
- <tr style="background-color:#ccc">
- <td>类型</td>
- <td>ID</td>
- <td>NAME</td>
- <td>ProcessIntanceId</td>
- <td>ProcessDefId</td>
- <td>创建时间</td>
- <td>申请人</td>
- <td>受理人</td>
- <td>申请原因</td>
- <td>申请内容
activiti自己定义流程之Spring整合activiti-modeler实例(七):任务列表展示的更多相关文章
- activiti自己定义流程之Spring整合activiti-modeler5.16实例(四):部署流程定义
注:(1)环境搭建:activiti自己定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建 (2)创建流程模型:activiti自己定义流程之Spr ...
- activiti自己定义流程之Spring整合activiti-modeler实例(一):环境搭建
项目中须要整合activiti-modeler自己定义流程,找了非常多资料后,最终成功的跳转到activiti-modeler流程设计界面.下面是记录: 一.整合基础:eclipse4.4.1.tom ...
- activiti自己定义流程之Spring整合activiti-modeler实例(六):启动流程
1.启动流程并分配任务是单个流程的正式開始,因此要使用到runtimeService接口.以及相关的启动流程的方法.我习惯于用流程定义的key启动,由于有多个版本号的流程定义时,用key启动默认会使用 ...
- 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 ...
随机推荐
- hdu 3038 并查集
题意:给出多个区间的和,判断数据矛盾的区间有几个,比方说[1,5] = 10 ,[6.10] = 10, [1, 10] = 30,这明显第三个与前面两个矛盾. 链接:点我 水题了,val代表到根的 ...
- 在活动中使用菜单(Menu)
任务名称:在活动使用菜单 任务现象:打开程序后,点击菜单按钮会出现2个选项,点击选项时会跳出相对应的提示框 步骤 1.创建一个项目,详细参考:http://8c925c9a.wiz03.com/sha ...
- bzoj1798 维护序列
Description 老师交给小可可一个维护数列的任务,现在小可可希望你来帮他完成. 有长为N的数列,不妨设为a1,a2,…,aN .有如下三种操作形式: (1)把数列中的一段数全部乘一个值; (2 ...
- Linux下路由表调试工具traceroute
在做静态路由表或者路由表分配时,比较直接的调试工具是traceroute,可以跟踪访问一个IP所到达的路由层级,从而知道经过哪些链路. 参考: http://man.linuxde.net/trace ...
- Spring SetFactoryBean实例
SetFactoryBean 类为开发者提供了一种可在 Spring bean 配置文件创建一个具体的Set集合(HashSet 和 TreeSet). 这里有一个 ListFactoryBean.例 ...
- cadence学习(1)常规封装的建立
1.建立焊盘. (1)首先要获得datasheet(或可用pcb matrix ipc-7531标准的可查询封装软件)中元器件的封装信息. (2)建立.pad文件.打开PCB Editor Utili ...
- Percona-Toolkit学习之安装和配置
http://blog.chinaunix.net/uid-26446098-id-3390779.html
- CocoaAsyncSocket 与 Java服务 交互
注意:向客户端写数据时最后需要加上\n,不然很久都不会得到服务端的返回. 上面为普通的socket服务端,最近项目采用apache mina框架建后台的socket服务端,采用上面的asyncSock ...
- xheditor
完整按钮表 |:分隔符 /:强制换行 Cut:剪切 Copy:复制 Paste:粘贴 Pastetext:文本粘贴 Blocktag:段落标签 Fontface:字体 FontSize:字体大小 Bo ...
- iOS:转载:IOS谓词--NSPredicate
IOS谓词--NSPredicate 分类: IOS应用2013-02-19 17:24 6792人阅读 评论(1) 收藏 举报 Cocoa 提供了NSPredicate 用于指定过滤条件,谓词是指在 ...
