您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章给大家分享的是有关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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。