博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
activiti参考5-任务TASK
阅读量:6894 次
发布时间:2019-06-27

本文共 4871 字,大约阅读时间需要 16 分钟。

一、概要

1,设计TASK的表主要是:ACT_RU_TASK,ACT_HI_TASKINST(见参考-activiti表);

2,任务主要有:人工任务(usertask),服务任务(servicetask)等;

3,候选人/候选组(candidate):可以执行任务的一类人或者多个组,候选人/候选组中都可以去签收任务,一旦某人签收,就成为受理人,其他人就不能再签收受理此任务;usertask流程图中,candidate标示候选;候选人涉及的表ACT_RU_IDENTITYLINK;

4,受理人(assignee):有两种情况,一种是候选人/组中有人签收任务后成为受理人,另外一种是流程图中直接指定受理人,但是可以指定一个动态受理人;受理人涉及的表ACT_RU_TASK;

5,持有人(owner):持有人设置主要是存入历史表中,用于历史任务的查询,涉及的表ACT_HI_TASKINST;

二、任务操作

1,创建TASK任务与设置权限:可以使用代码创建任务,但是实际操作中都是绘制流程图。绘制TASK后,在属性可以设置候选人和受理人,一般都是设置候选人,因为固定受理人不太符合程序变动;

候选人设置了deptleader,该值将部署在表ACT_RU_IDENTITYLINK中,查看xml看见:

1
2
3
//设置了候选组
 
<
userTask 
id
=
"deptLeaderAudit" 
name
=
"部门领导审批" 
activiti:candidateGroups
=
"deptLeader"
>
 
</
userTask
>

 

完整的XML(无图形位置信息)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<
process 
id
=
"leave" 
name
=
"请假流程" 
isExecutable
=
"true"
>
    
<
documentation
>请假流程演示</
documentation
>
    
<
startEvent 
id
=
"startevent1" 
name
=
"Start" 
activiti:initiator
=
"applyUserId"
></
startEvent
>
    
<
userTask 
id
=
"deptLeaderAudit" 
name
=
"部门领导审批" 
activiti:candidateGroups
=
"deptLeader"
></
userTask
>
    
<
exclusiveGateway 
id
=
"exclusivegateway5" 
name
=
"Exclusive Gateway"
></
exclusiveGateway
>
    
<
userTask 
id
=
"modifyApply" 
name
=
"调整申请" 
activiti:assignee
=
"${applyUserId}"
>
      
<
extensionElements
>
        
<
activiti:taskListener 
event
=
"complete" 
delegateExpression
=
"${afterModifyApplyContentProcessor}"
></
activiti:taskListener
>
      
</
extensionElements
>
    
</
userTask
>
    
<
userTask 
id
=
"hrAudit" 
name
=
"人事审批" 
activiti:candidateGroups
=
"hr"
></
userTask
>
    
<
exclusiveGateway 
id
=
"exclusivegateway6" 
name
=
"Exclusive Gateway"
></
exclusiveGateway
>
    
<
userTask 
id
=
"reportBack" 
name
=
"销假" 
activiti:assignee
=
"${applyUserId}"
>
      
<
extensionElements
>
        
<
activiti:taskListener 
event
=
"complete" 
delegateExpression
=
"${reportBackEndProcessor}"
></
activiti:taskListener
>
      
</
extensionElements
>
    
</
userTask
>
    
<
endEvent 
id
=
"endevent1" 
name
=
"End"
></
endEvent
>
    
<
exclusiveGateway 
id
=
"exclusivegateway7" 
name
=
"Exclusive Gateway"
></
exclusiveGateway
>
    
<
sequenceFlow 
id
=
"flow2" 
sourceRef
=
"startevent1" 
targetRef
=
"deptLeaderAudit"
></
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow3" 
sourceRef
=
"deptLeaderAudit" 
targetRef
=
"exclusivegateway5"
></
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow4" 
name
=
"不同意" 
sourceRef
=
"exclusivegateway5" 
targetRef
=
"modifyApply"
>
      
<
conditionExpression 
xsi:type
=
"tFormalExpression"
>
<![CDATA[${!deptLeaderPass}]]>
</
conditionExpression
>
    
</
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow5" 
name
=
"同意" 
sourceRef
=
"exclusivegateway5" 
targetRef
=
"hrAudit"
>
      
<
conditionExpression 
xsi:type
=
"tFormalExpression"
>
<![CDATA[${deptLeaderPass}]]>
</
conditionExpression
>
    
</
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow6" 
sourceRef
=
"hrAudit" 
targetRef
=
"exclusivegateway6"
></
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow7" 
name
=
"同意" 
sourceRef
=
"exclusivegateway6" 
targetRef
=
"reportBack"
>
      
<
conditionExpression 
xsi:type
=
"tFormalExpression"
>
<![CDATA[${hrPass}]]>
</
conditionExpression
>
    
</
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow8" 
sourceRef
=
"reportBack" 
targetRef
=
"endevent1"
></
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow9" 
name
=
"不同意" 
sourceRef
=
"exclusivegateway6" 
targetRef
=
"modifyApply"
>
      
<
conditionExpression 
xsi:type
=
"tFormalExpression"
>
<![CDATA[${!hrPass}]]>
</
conditionExpression
>
    
</
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow10" 
name
=
"重新申请" 
sourceRef
=
"exclusivegateway7" 
targetRef
=
"deptLeaderAudit"
>
      
<
conditionExpression 
xsi:type
=
"tFormalExpression"
>
<![CDATA[${reApply}]]>
</
conditionExpression
>
    
</
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow11" 
sourceRef
=
"modifyApply" 
targetRef
=
"exclusivegateway7"
></
sequenceFlow
>
    
<
sequenceFlow 
id
=
"flow12" 
name
=
"结束流程" 
sourceRef
=
"exclusivegateway7" 
targetRef
=
"endevent1"
>
      
<
conditionExpression 
xsi:type
=
"tFormalExpression"
>
<![CDATA[${!reApply}]]>
</
conditionExpression
>
    
</
sequenceFlow
>
  
</
process
>

 

2,查询候选任务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//根据候选组ID查询拥有任务
List<Task> tasks = taskService
                    
.createTaskQuery()
                    
.taskCandidateGroup(groupA.getId())
                    
.list();
for 
(Task task : tasks) 
{System.out.println(task.getName());}  
 
//根据用户ID查询任务
tasks = taskService
        
.createTaskQuery()
        
.taskCandidateUser(user.getId())
        
.list();
for 
(Task task : tasks) 
{System.out.println(task.getName());}
 
//调用taskCandidateGroupIn
List<String> groupIds = 
new 
ArrayList<String>();
    
groupIds.add(groupA.getId());
    
groupIds.add(groupB.getId());
tasks = taskService
        
.createTaskQuery()
        
.taskCandidateGroupIn(groupIds)
        
.list();
for 
(Task task : tasks)
 
{System.out.println(task.getName());}
  
//查询权限数据
List<IdentityLink> links = taskService
                           
.getIdentityLinksForTask(tasks.get(
0
)
                           
.getId());
System.out.println(
"关系数据量: " 
+ links.size());}

 

本文转自二郎三郎博客园博客,原文链接:http://www.cnblogs.com/haore147/p/5213430.html,如需转载请自行联系原作者
你可能感兴趣的文章
Eclipse的基本使用
查看>>
构建之法 第五章 团队和流程
查看>>
(转)如何在eclipse的配置文件里指定jdk路径
查看>>
如何将atom侧边栏显示在右侧
查看>>
Block介绍(一)基础
查看>>
COLORREF的结构和用法
查看>>
《c程序设计语言》读书笔记--统计换行数,空格数,tab数
查看>>
【14】代理模式(Proxy Pattern)
查看>>
Visual Studio 2013 为C#类文件添加版权信息
查看>>
hdu1025(nlon(n)最长上升子序列)
查看>>
将Linux文件清空的几种方法
查看>>
Centos7使用yum快速安装ansible
查看>>
java例程练习(网络编程[简单网络连接试验])
查看>>
使用 console.time() 计算js代码执行时间
查看>>
test2-1
查看>>
Linux 进程间通信 有名管道(fifo)
查看>>
Oracle中SQL查询表字段基本信息、主键、外键(转)
查看>>
Oracle 12C 新特性之 恢复表
查看>>
Cisco交换机里IP和MAC地址互查找出对应端口
查看>>
随机数
查看>>