Python 官方文档:入门教程 => 点击学习
Activiti BPMN visualizer插件 import com.alibaba.fastJSON.jsON; import com.schinta.util.D
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插件的文章就介绍到这了,更多相关springboot2 activiti6 idea插件内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: springboot2 使用activiti6 idea插件的过程详解
本文链接: https://lsjlt.com/news/144242.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0