一、從建立表到辦理完成任務
public class LeaveActionTest { private ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); //1.1、建立表 public static void createTabelAuto(){ //建立對象 ProcessEngineConfiguration conf = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration(); String driver = PropertiesUtil.getValue("jdbc_driver", "conf/jdbc.properties"); String url = PropertiesUtil.getValue("jdbc_url", "conf/jdbc.properties"); String username = PropertiesUtil.getValue("jdbc_username", "conf/jdbc.properties"); String password = PropertiesUtil.getValue("jdbc_password", "conf/jdbc.properties"); //設定資料庫 conf.setJdbcDriver(driver); conf.setJdbcUrl(url); conf.setJdbcUsername(username); conf.setJdbcPassword(password); //自動建表 conf.setDatabaseSchemaUpdate("true"); //建立引擎 ProcessEngine processEngine = conf.buildProcessEngine(); } //1.2、建立表,processEngineConfiguration為資料庫實體bean public static void createTabelByXML(){ //建立對象 String resource = "activiti-context2.xml"; String beanName = "processEngineConfiguration"; ProcessEngineConfiguration conf = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(resource, beanName); //建立引擎 ProcessEngine processEngine = conf.buildProcessEngine(); } //2、部署流程定義 @Test public void deployLeave() throws Exception { DeploymentBuilder builder = processEngine.getRepositoryService().createDeployment(); builder.addClasspathResource("flow/leave.bpmn"); builder.addClasspathResource("flow/leave.png"); Deployment deploy = builder.deploy(); System.out.println("deploy.getId()==" + deploy.getId()); } //3、獲得流程定義的id @Test public void queryFinition() throws Exception { ProcessDefinitionQuery query = processEngine.getRepositoryService().createProcessDefinitionQuery(); //添加過濾條件 query.processDefinitionKey("leaveFlow"); //添加排序 query.orderByProcessDefinitionVersion().desc(); //分頁 query.listPage(0, 10); List<ProcessDefinition> processDefinitions = query.list(); for (ProcessDefinition p : processDefinitions) { System.out.println("p.getId()===" +p.getId()); } } @Test public void querys() throws Exception { List<ProcessDefinition> processDefinitions = processEngine.getRepositoryService().createProcessDefinitionQuery().list(); List<Deployment> deployments = processEngine.getRepositoryService().createDeploymentQuery().list(); List<ProcessInstance> processInstances = processEngine.getRuntimeService().createProcessInstanceQuery().list(); List<Task> tasks = processEngine.getTaskService().createTaskQuery().list(); } //4、根據流程定義的id獲得流程執行個體的id @Test public void getProcessInstance() throws Exception { String processDefinitionId = "leaveFlow:1:4"; ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitionId); System.out.println("processInstance.getId()===" + processInstance.getId()); } //5、根據流程執行個體,查詢工作清單 ,說明一個流程定義對應多個流程執行個體,一個流程執行個體對應多個工作清單 @Test public void getProcessTask() throws Exception { String processInstanceId = "5001"; //1 //String assignee = "tom"; //2 //String assignee = "jack"; //3 String assignee = "smith"; //工作清單 TaskQuery taskQuery = processEngine.getTaskService().createTaskQuery(); //查詢tom的工作清單 taskQuery.taskAssignee(assignee); List<Task> tasks = taskQuery.list(); for (Task task: tasks){ System.out.println(task.getId() + ":" + task.getName()); } } //6、辦理任務,辦理完成後,第三步就找不到tom的這個任務了,跑到下個jack的任務中了,5與6是相互重複的 @Test public void dealProcessTask() throws Exception { String taskId = ""; processEngine.getTaskService().complete(taskId); }}
二、資料庫配置
jdbc_driver=com.microsoft.sqlserver.jdbc.SQLServerDriverjdbc_url=jdbc:sqlserver://localhost:1433;DatabaseName=activitijdbc_username=sajdbc_password=sa
三、流程檔案leave.xml
<?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="leaveFlow" isClosed="false" isExecutable="true" name="leaveFlow" 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="提交請假申請"/> <userTask activiti:assignee="jack" activiti:exclusive="true" id="processSupervisorId" name="專案經理審批"/> <sequenceFlow id="_6" sourceRef="startId" targetRef="processSubmitId"/> <sequenceFlow id="_7" sourceRef="processSubmitId" targetRef="processSupervisorId"/> <userTask activiti:assignee="smith" activiti:exclusive="true" id="processManagerId" name="部門經理審批"/> <sequenceFlow id="_10" sourceRef="processSupervisorId" targetRef="processManagerId"/> <sequenceFlow id="_11" sourceRef="processManagerId" targetRef="endId"/> <sequenceFlow sourceRef="startId" targetRef="processSubmitId" id="startId-processSubmitId"/> </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="leaveFlow"> <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="400.0" y="495.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="55.0" width="85.0" x="370.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="85.0" x="365.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:BPMNShape bpmnElement="processManagerId" id="Shape-processManagerId"> <omgdc:Bounds height="55.0" width="85.0" x="370.0" y="405.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <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="_11" id="BPMNEdge__11" sourceElement="processManagerId" targetElement="endId"> <omgdi:waypoint x="416.0" y="460.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="_10" id="BPMNEdge__10" sourceElement="processSupervisorId" targetElement="processManagerId"> <omgdi:waypoint x="410.0" y="360.0"/> <omgdi:waypoint x="410.0" y="405.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="startId-processSubmitId"> <omgdi:waypoint x="406.0" y="131.0"/> <omgdi:waypoint x="412.5" y="242.5"/> </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入門
—————————————————————————————————————————————————–