activiti任务TASK
生活随笔
收集整理的這篇文章主要介紹了
activiti任务TASK
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、概要
- 設計TASK的表主要是:ACT_RU_TASK,ACT_HI_TASKINST(見參考-activiti表);
- 任務主要有:人工任務(usertask),服務任務(servicetask)等;
- 候選人/候選組(candidate):可以執行任務的一類人或者多個組,候選人/候選組中都可以去簽收任務,一旦某人簽收,就成為受理人,其他人就不能再簽收受理此任務;usertask流程圖中,candidate標示候選;候選人涉及的表ACT_RU_IDENTITYLINK;
- 受理人(assignee):有兩種情況,一種是候選人/組中有人簽收任務后成為受理人,另外一種是流程圖中直接指定受理人,但是可以指定一個動態受理人;受理人涉及的表ACT_RU_TASK;
- 持有人(owner):持有人設置主要是存入歷史表中,用于歷史任務的查詢,涉及的表ACT_HI_TASKINST;
二、任務操作
- 創建TASK任務與設置權限:可以使用代碼創建任務,但是實際操作中都是繪制流程圖。繪制TASK后,在屬性可以設置候選人和受理人,一般都是設置候選人,因為固定受理人不太符合程序變動;
? ? ? ? ? 候選人設置了deptleader,該值將部署在表ACT_RU_IDENTITYLINK中,查看xml看見:
//設置了候選組<userTask id="deptLeaderAudit" name="部門領導審批" activiti:candidateGroups="deptLeader"></userTask>
?完整的XML(無圖形位置信息)
<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.查詢候選任務
//根據候選組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());
}//調用taskCandidateGroupInList<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());}
?
轉載于:https://www.cnblogs.com/firebata/p/5253021.html
總結
以上是生活随笔為你收集整理的activiti任务TASK的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 镇魂街网剧版有么
- 下一篇: ArrayList Iterator r