• 大小: 20.54MB
    文件类型: .7z
    金币: 1
    下载: 0 次
    发布日期: 2023-07-08
  • 语言: 其他
  • 标签: Activiti  

资源简介

该代码实现画流程图,申请请假,领导审核,重新申请流程等

资源截图

代码片段和文件信息

package com.activiti;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.activiti.engine.FormService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.form.FormProperty;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.junit.jupiter.api.Test;

public class LeaveTest {

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
 
/**部署流程定义*/  
    @Test  
    public void deploymentProcessDefinition(){  
        RepositoryService repositoryService = processEngine.getRepositoryService();  
        DeploymentBuilder deploymentBuilder=repositoryService.createDeployment(); 
        deploymentBuilder.name(“请假流程“);
        deploymentBuilder.addClasspathResource(“diagrams/LeaveProcess.bpmn“);
        deploymentBuilder.addClasspathResource(“diagrams/LeaveProcess.png“);
        Deployment deployment = deploymentBuilder.deploy();
        //打印我们的流程信息  
        System.out.println(“流程Id:“+deployment.getId());  
        System.out.println(“流程Name:“+deployment.getName());  
        System.out.println(“——————————————————————————————————————————————————“); 
    }
    
    /**启动流程引擎*/  
    @Test  
    public void startProcessInstance(){
     RepositoryService repositoryService = processEngine.getRepositoryService();  
     ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(“LeaveProcess“).singleResult();
     //设置动态表单
     processEngine.getIdentityService().setAuthenticatedUserId(“zhaoliu“);
     Map params = new HashMap();
     SimpleDateFormat  sdt  = new SimpleDateFormat(“yyyy-MM-dd“);
     Calendar calendar = Calendar.getInstance();
     String startDate = sdt.format(calendar.getTime());
     calendar.add(Calendar.DAY_OF_MONTH 2);
     String endDate = sdt.format(calendar.getTime());
     params.put(“startDate“ startDate);
     params.put(“endDate“ endDate);
     params.put(“reason“ “我要休息“);
     FormService formService = processEngine.getFormService();
     ProcessInstance processInstance = formService.submitStartFormData(processDefinition.getId() params);
        System.out.println(“流程实例ID:“+processInstance.getId());  
        System.out.println(“流程定义ID:“+processInstance.getProcessDefinitionId());
        System.out.println(“——————————————————————————————————————————————————“); 
    } 
    
    
    /**部门领导审批通过**/ 
    @Test  
    public void deptLeaderAuditPass(){  
        String assi

评论

共有 条评论