您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關springboot2如何使用activiti6 idea插件的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
Activiti BPMN visualizer插件
import com.alibaba.fastjson.JSON; import com.schinta.util.DateTimeUtil; import lombok.extern.slf4j.Slf4j; import org.activiti.engine.*; import org.activiti.engine.history.*; import org.activiti.engine.impl.identity.Authentication; import org.activiti.engine.repository.Deployment; import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.task.Comment; import org.activiti.engine.task.Task; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.util.CollectionUtils; import java.util.*; //spring boot2 集成activiti6 一系列異常文檔 https://www.jianshu.com/p/77fa5f932f4f @Slf4j @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class WebApplicationTests { @Autowired private ProcessEngine processEngine; private RepositoryService repositoryService; private RuntimeService runtimeService; private TaskService taskService; private HistoryService historyService; @Test public void deployProcess() { //部署模板 Deployment deploy = repositoryService.createDeployment() .addClasspathResource("processes/wh.bpmn20.xml") .deploy(); System.out.println(deploy.getId()); } public void start() { String instanceKey = "wh"; log.info("開啟請假流程..."); Map<String, Object> map = new HashMap<>(); //在wh.bpmn中,填寫請假單的任務辦理人為動態傳入的userId,此處模擬一個id map.put("user1", 1); map.put("user2", 2); Authentication.setAuthenticatedUserId("1"); ProcessInstance instance = runtimeService.startProcessInstanceByKey(instanceKey, map); log.info("啟動流程實例成功:{}", instance); log.info("流程實例ID:{}", instance.getId()); log.info("流程定義ID:{}", instance.getProcessDefinitionId()); public void taskQuery() { //查詢自己發起的全部的審批 //List<HistoricProcessInstance> historicProcessInstanceList = historyService.createHistoricProcessInstanceQuery().startedBy(userId).list(); //根據流程定義的key,負責人assignee來實現 當前用戶的 待辦任務列表查詢 List<Task> list = taskService.createTaskQuery() .processDefinitionKey(instanceKey) .taskAssignee("2") .list(); if (list != null && list.size() > 0) { for (Task task : list) { System.out.println("任務ID:" + task.getId()); System.out.println("任務名稱:" + task.getName()); System.out.println("任務的創建時間:" + task.getCreateTime()); System.out.println("任務的辦理人:" + task.getAssignee()); System.out.println("流程實例ID:" + task.getProcessInstanceId()); System.out.println("執行對象ID:" + task.getExecutionId()); System.out.println("流程定義ID:" + task.getProcessDefinitionId()); System.out.println("getOwner:" + task.getOwner()); System.out.println("getCategory:" + task.getCategory()); System.out.println("getDescription:" + task.getDescription()); System.out.println("getFormKey:" + task.getFormKey()); Map<String, Object> map = task.getProcessVariables(); for (Map.Entry<String, Object> m : map.entrySet()) { System.out.println("key:" + m.getKey() + " value:" + m.getValue()); } for (Map.Entry<String, Object> m : task.getTaskLocalVariables().entrySet()) { } } /** * 審批 */ public void employeeApply() { String instanceId = "130001"; // 執行流程實例id Task task = taskService.createTaskQuery().processInstanceId(instanceId).singleResult(); //是否同意 0 同意, 1 駁回 map.put("status", "0"); taskService.addComment(task.getId(), instanceId, "測試評論34"); taskService.complete(task.getId(), map); log.info("流程推動到下環節"); * 實例詳情 public void queryHistoryTask() { List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery() // 創建歷史活動實例查詢 .processInstanceId(instanceId) // 執行流程實例id .orderByTaskCreateTime() .asc() for (HistoricTaskInstance hai : list) { System.out.println("==================="); System.out.println("活動ID:" + hai.getId()); System.out.println("流程實例ID:" + hai.getProcessInstanceId()); System.out.println("活動名稱:" + hai.getName()); System.out.println("辦理人:" + hai.getAssignee()); System.out.println("開始時間:" + hai.getStartTime()); System.out.println("結束時間:" + hai.getEndTime()); List<Comment> comments = taskService.getTaskComments(hai.getId()); System.out.println("評論內容:" + JSON.toJSONString(comments)); }
感謝各位的閱讀!關于“springboot2如何使用activiti6 idea插件”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。