Skip to content

快速开始

songhongtu edited this page Jan 17, 2023 · 4 revisions

4. 快速开始

Step1: 流程

S1.1: 流程设计

有一个五个任务串行执行的流程图demo1

img_3.png

下载文件:demo1.bpmn 放到resouces里面

目录结构如下

img.png

也可以用 http://123.249.93.130/runflow/ 在线设计自己的流程

S1.2: build

目前还没有上传到maven中央仓库,因此需要下载源码 安装到本地仓库

git clone https://github.com/songhongtu/runflow.git

mvn -Dmaven.test.failure.ignore=true clean install

S2.1: 调用流程(jar包方式)

2.1.1: 引入POM文件
<dependency>
    <groupId>com.runflow</groupId>
    <artifactId>runflow-core</artifactId>
    <version>0.0.1-Beta</version>
</dependency>
2.1.2: 调用流程
    ProcessEngineConfigurationImpl conf = new ProcessEngineConfigurationImpl();
RunTimeServiceImpl runTimeService;

    {
        //初始化
        conf.init();
        runTimeService = conf.getRunTimeService();
        //bpmn位置
        conf.addPath("/bpmn/demo1.bpmn");
    }


    @Test
    public void demo1() {
        //a.incrementAndGet()
        AtomicInteger integer = new AtomicInteger(0);
        Map map = new HashMap();
        map.put("a", integer);
        runTimeService.startWorkflow("Process_1671936597549", map);
        System.out.println(integer);
    }

直接运行即可

img_4.png

S3.1: 调用流程(springboot方式)

3.1.1: 引入POM文件
<dependency>
    <groupId>com.runflow</groupId>
    <artifactId>runflow-spring-boot-starters</artifactId>
    <version>0.0.1-Beta</version>
</dependency>
3.1.2: 调用流程
   @Autowired
   RunTimeServiceImpl runTimeService;


    @GetMapping("/demo1")
    public Integer demo1(){
        AtomicInteger integer = new AtomicInteger(0);
        Map map = new HashMap();
        map.put("a", integer);
        runTimeService.startWorkflow("Process_1671936597549",map);
        System.out.println(integer.get());
        return integer.get();
    }
    /**
     * 生成图片
     * @param key
     * @param response
     * @throws IOException
     */
    @GetMapping("/images")
    public void images(String key, HttpServletResponse response) throws IOException {
        InputStream inputStream = runTimeService.generaImages(key);
        IOUtils.copy(inputStream, response.getOutputStream());
    }
Clone this wiki locally