activiti7__01Deployment基本用法


使用流程

指定流程key
指定流程名稱
任務指定執行人
上傳bpmn,上傳bpmn和圖片,上傳zip
增刪改查
查詢列表和查詢xml

基本業務代碼的實現

import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.InputStream;
import java.util.List;
import java.util.zip.ZipInputStream;

@SpringBootTest
public class Test01Deployment {

    @Autowired
    private RepositoryService repositoryService;

    /**
     * 使用文件直接發布流程
     */
    @Test
    public void getInfo111() {
        String fileName = "BPMN/part01Deployment.bpmn";
        String pngName = "BPMN/part01Deployment.png";
        //流程發布的時候可以攜帶bpmn文件+縮略圖
        Deployment deployment = repositoryService.createDeployment()
                .addClasspathResource(fileName)
                .addClasspathResource(pngName)
                .name("流程發布定義BPMN")
                .deploy();
        System.out.println(deployment.getName());
    }

    /**
     * 使用壓縮的方式發布流程
     */
    @Test
    public void getInfo222() {
        String path = "BPMN/BPMN_V2.zip";
        InputStream inputStream = this.getClass().getClassLoader()
                .getResourceAsStream(path);
        // 使用壓縮包來發布流程圖 流程圖會被解壓為bpmn文件 png文件
        ZipInputStream zipInputStream = new ZipInputStream(inputStream);
        Deployment deployment = repositoryService.createDeployment()
                .addZipInputStream(zipInputStream)
                .name("流程發布定義BPMNV2")
                .deploy();
        System.out.println(deployment.getName());

    }

    /**
     * 查看發布過的流程
     *
     */
    @Test
    public void getInfo333(){
        List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
        for (int i = 0; i <deployments.size() ; i++) {
            Deployment d = deployments.get(i);
            System.out.println(d.getKey());
            System.out.println(d.getName());
            System.out.println(d.getCategory());
            System.out.println(d.getDeploymentTime());
            System.out.println(d.getId());
        }
    }

}



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM