【流程引擎】---springboot+camunda案例之费用审批流程

一、案例说明

上篇文章介绍了springboot简单集成Camunda,后续以具体案例来介绍Camunda使用。
下面介绍一种简单的“费用审批流程”。该流程会串行的经历三层组织审核,一直到流程结束。
在这里插入图片描述其中,每层组织架构可以输入多个审核人,只要其中任何一个人审核通过,流程进入下一层组织审核。

二、案例说明

2.1、主要代码实现

主要的代码如下

  /**
     *  http://localhost:8033/workflow/deployed-cases
     * 查询已部署的流程定义列表 【包括未启动、启动 的流程】
     */
    @GetMapping("/deployed-cases")
    public List<String> getDeployedCases() {
   
    
    
        // and convert it to a list of WorkflowCase objects
        //来自act_re_procdef表的数据
        List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery()
                .list();
        List<String> reList = list.stream().map(e -> e.getId() + "," + e.getName() + "," + e.getVersion()).collect(Collectors.toList());
        return reList;
    }

    /**
     * 部署流程案例
     * @param file
     * @param name
     * @return
     */
    @PostMapping("/uploadSubmit")
    public String deployCase(@RequestParam("file") MultipartFile file, @RequestParam("name") String name) {
   
    
    
        try (InputStream is = file.getInputStream()) {
   
    
    
            // 获取文件的名称
            String originalFilename = file.getOriginalFilename();

            Deployment deployment = repositoryService.createDeployment()
                    .addInputStream(originalFilename, is)
                    .name(name)
                    .deploy();
            return deployment.getId

猜你喜欢

转载自blog.csdn.net/xunmengyou1990/article/details/132381460