Java Activiti(7)--任務辦理

來源:互聯網
上載者:User
1、具體操作
package com.cloud.wyscha.action;import com.cloud.wyscha.entity.User;import org.activiti.engine.ProcessEngine;import org.activiti.engine.ProcessEngines;import org.activiti.engine.repository.Deployment;import org.activiti.engine.repository.DeploymentBuilder;import org.activiti.engine.runtime.ProcessInstance;import org.activiti.engine.task.Task;import org.activiti.engine.task.TaskQuery;import org.junit.Test;import java.util.HashMap;import java.util.List;import java.util.Map;/** * 任務辦理 * Created by Administrator on 2017/9/18. *///@RunWith(SpringJUnit4ClassRunner.class)//@ContextConfiguration(locations = {"classpath*:/conf/applicationContext.xml","classpath*:/conf/applicationContext_springmvc.xml"})public class ActivitiPersonalTaskTest {    private ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();    //1、部署流程定義    @Test    public void deployLeave() throws Exception {        DeploymentBuilder builder = processEngine.getRepositoryService().createDeployment();        builder.addClasspathResource("flow/grouptask.bpmn");        builder.addClasspathResource("flow/grouptask.png");        builder.name("報銷流程部署");        Deployment deploy = builder.deploy();        System.out.println("deploy.getId()==" + deploy.getId());    }    //2.、動流程執行個體時,添加變數    @Test    public void startProcessInstanceByKey() throws Exception {        String processDefinitionKey = "grouptask";        Map<String, Object> variable = new HashMap<String, Object>();        variable.put("amount", "300元");        variable.put("reason", "出差");        ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey(processDefinitionKey, variable);        System.out.println("processInstance.getId()===" + processInstance.getId());        System.out.println("processInstance.getProcessDefinitionId()===" + processInstance.getProcessDefinitionId());    }    //3、提交申請,辦理個人任務    @Test    public void dealPersonalTask() throws Exception {        String taskId = "60011";        Map<String, Object> variable = new HashMap<String, Object>();        variable.put("amount2", "300元");        variable.put("reason2", "出差");        processEngine.getTaskService().complete(taskId, variable);    }    //3.1、財務審批,查詢組合任務    @Test    public void queryGroupTask() throws Exception {        //查詢誰能辦理        String userId = "jack";        TaskQuery taskQuery = processEngine.getTaskService().createTaskQuery();        taskQuery.taskCandidateUser(userId);        List<Task> list = taskQuery.list();        if(list != null && list.size()>0){        }    }    //3.2、拾取任務並辦理    @Test    public void claimGroupTask() throws Exception {        String taskId = "62504";        String userId = "smith";        processEngine.getTaskService().claim(taskId,userId);        processEngine.getTaskService().complete(taskId);    }    //3.3、退回任務    @Test    public void backGroupTask() throws Exception {        String taskId = "62504";        processEngine.getTaskService().setAssignee(taskId,null);    }}
2、流程檔案
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1505312057485" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">  <process id="grouptask" isClosed="false" isExecutable="true" name="grouptask" processType="None">    <startEvent id="startId" name="start"/>    <endEvent id="endId" name="end"/>    <userTask activiti:assignee="tom" activiti:async="false" activiti:exclusive="true" id="processSubmitId" name="submit application"/>    <userTask activiti:assignee="jack" activiti:candidateUsers="jack,smtih" activiti:exclusive="true" id="processSupervisorId" name="finance approval"/>    <sequenceFlow id="_6" sourceRef="startId" targetRef="processSubmitId"/>    <sequenceFlow id="_7" sourceRef="processSubmitId" targetRef="processSupervisorId"/>    <sequenceFlow id="startId-processSubmitId" sourceRef="startId" targetRef="processSubmitId"/>    <sequenceFlow id="_2" sourceRef="processSupervisorId" targetRef="endId"/>    <sequenceFlow sourceRef="endId" targetRef="endId" id="endId-endId"/>  </process>  <bpmndi:BPMNDiagram documentation="background=#FFFFFF;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">    <bpmndi:BPMNPlane bpmnElement="grouptask">      <bpmndi:BPMNShape bpmnElement="startId" id="Shape-startId">        <omgdc:Bounds height="32.0" width="32.0" x="390.0" y="115.0"/>        <bpmndi:BPMNLabel>          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>        </bpmndi:BPMNLabel>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="endId" id="Shape-endId">        <omgdc:Bounds height="32.0" width="32.0" x="397.0" y="420.0"/>        <bpmndi:BPMNLabel>          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>        </bpmndi:BPMNLabel>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="processSubmitId" id="Shape-processSubmitId">        <omgdc:Bounds height="56.0" width="115.0" x="354.0" y="215.0"/>        <bpmndi:BPMNLabel>          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>        </bpmndi:BPMNLabel>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="processSupervisorId" id="Shape-processSupervisorId">        <omgdc:Bounds height="55.0" width="110.0" x="356.0" y="305.0"/>        <bpmndi:BPMNLabel>          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>        </bpmndi:BPMNLabel>      </bpmndi:BPMNShape>      <bpmndi:BPMNEdge bpmnElement="startId-processSubmitId" id="BPMNEdge_startId-processSubmitId" sourceElement="startId" targetElement="processSubmitId">        <omgdi:waypoint x="406.0" y="147.0"/>        <omgdi:waypoint x="406.0" y="215.0"/>        <bpmndi:BPMNLabel>          <omgdc:Bounds height="-1.0" width="-1.0" x="-1.0" y="-1.0"/>        </bpmndi:BPMNLabel>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="_2" id="BPMNEdge__2" sourceElement="processSupervisorId" targetElement="endId">        <omgdi:waypoint x="416.0" y="360.0"/>        <omgdi:waypoint x="416.0" y="495.0"/>        <bpmndi:BPMNLabel>          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>        </bpmndi:BPMNLabel>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6" sourceElement="startId" targetElement="processSubmitId">        <omgdi:waypoint x="406.0" y="147.0"/>        <omgdi:waypoint x="406.0" y="215.0"/>        <bpmndi:BPMNLabel>          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>        </bpmndi:BPMNLabel>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="processSubmitId" targetElement="processSupervisorId">        <omgdi:waypoint x="410.0" y="270.0"/>        <omgdi:waypoint x="410.0" y="305.0"/>        <bpmndi:BPMNLabel>          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>        </bpmndi:BPMNLabel>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="endId-endId">        <omgdi:waypoint x="413.0" y="436.0"/>        <omgdi:waypoint x="413.0" y="436.0"/>      </bpmndi:BPMNEdge>    </bpmndi:BPMNPlane>  </bpmndi:BPMNDiagram></definitions>

—————————————————————————————————————————————————– java架構師項目實戰,高並發叢集分布式,大資料高可用視頻教程,共760G

下載地址:

https://item.taobao.com/item.htm?id=555888526201

01.進階架構師四十二個階段高
02.Java進階系統培訓架構課程148課時
03.Java進階互連網架構師課程
04.Java互連網架構Netty、Nio、Mina等-視頻教程
05.Java進階架構設計2016整理-視頻教程
06.架構師基礎、進階片
07.Java架構師必修linux營運系列課程
08.Java進階系統培訓架構課程116課時
+
hadoop系列教程,java設計模式與資料結構, Spring Cloud微服務, SpringBoot入門

—————————————————————————————————————————————————–

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.