Activiti 流程框架——基本操作

xiaoxiao2021-02-28  9

public class TestActivti { @Test //配置引擎 public void creatTable(){ ProcessEngineConfiguration configuration=ProcessEngineConfiguration .createProcessEngineConfigurationFromResource("activti.cfg.xml"); ProcessEngine processEngine=configuration.buildProcessEngine(); System.out.println(processEngine); // creatdeploy(processEngine); // startproc(processEngine); // creatGroup(processEngine); // creatuser(processEngine); // queryTask(processEngine); // completeTask(processEngine); } //部署流程 public void creatdeploy(ProcessEngine processEngine){ processEngine.getRepositoryService().createDeployment().name("请假流程") .category("人事").tenantId("1001").addClasspathResource("aa.bpmn").deploy(); //启动流程 public void startproc (ProcessEngine processEngine){ RuntimeService runtimeService=processEngine.getRuntimeService(); runtimeService.startProcessInstanceByKeyAndTenantId("leave","1001"); } public void creatuser(ProcessEngine processEngine){ IdentityService identityService = processEngine.getIdentityService(); User user = identityService.newUser("3"); user.setFirstName("张三"); user.setPassword("123456"); user.setEmail("zhangsan@126.com"); identityService.saveUser(user); identityService.createMembership("3","1001"); User user1 = identityService.newUser("4"); user1.setEmail("lisi@126.com"); user1.setFirstName("李四"); user1.setPassword("123456"); identityService.saveUser(user1); identityService.createMembership("4","1002"); } public void creatGroup(ProcessEngine processEngine){ IdentityService identityService = processEngine.getIdentityService(); Group group = identityService.newGroup("1002"); group.setName("主管"); group.setType("leader"); identityService.saveGroup(group); Group group1 = identityService.newGroup("1001"); group1.setName("员工"); group1.setType("user"); identityService.saveGroup(group1); } //查看user下面的人的流程任务 public void queryTask(ProcessEngine processEngine){ TaskService taskService = processEngine.getTaskService(); List<Task> zhangsanlist = taskService.createTaskQuery().taskAssignee("zhangsan").list(); System.out.println("zhangsan ====="+zhangsanlist.size()); List<Task> lisilist = taskService.createTaskQuery().taskAssignee("lisi").list(); System.out.println("lisilist ====="+lisilist.size()); } //处理流程 public void completeTask(ProcessEngine processEngine){ TaskService taskService = processEngine.getTaskService(); List<Task> taskList = taskService.createTaskQuery().taskCandidateOrAssigned("zhangsan").list(); for (Task task : taskList) { System.out.println(task.getId()); taskService.complete(task.getId()); } }
转载请注明原文地址: https://www.6miu.com/read-2350130.html

最新回复(0)