4-Springboot集成FLOWABLE之流程驳回

演示地址

效果

在这里插入图片描述

功能

默认驳回到上一节点

后端代码

flowable自带驳回功能, 在源码ProcessInstanceResource.class下已有该功能,不需要自己额外去写

@ApiOperation(value = "Change the state a process instance", tags = { "Process Instances" }, notes = "")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Indicates the process instance was found and change state activity was executed."),
            @ApiResponse(code = 409, message = "Indicates the requested process instance action cannot be executed since the process-instance is already activated/suspended."),
            @ApiResponse(code = 404, message = "Indicates the requested process instance was not found.")
    })
    @PostMapping(value = "/runtime/process-instances/{processInstanceId}/change-state", produces = "application/json")
    public void changeActivityState(@ApiParam(name = "processInstanceId") @PathVariable String processInstanceId,
            @RequestBody ExecutionChangeActivityStateRequest activityStateRequest, HttpServletRequest request) {
        
        if (restApiInterceptor != null) {
            restApiInterceptor.changeActivityState(activityStateRequest);
        }

        if (activityStateRequest.getCancelActivityIds() != null && activityStateRequest.getCancelActivityIds().size() == 1) {
            runtimeService.createChangeActivityStateBuilder()
                .processInstanceId(processInstanceId)
                .moveSingleActivityIdToActivityIds(activityStateRequest.getCancelActivityIds().get(0), activityStateRequest.getStartActivityIds())
                .changeState();
        
        } else if (activityStateRequest.getStartActivityIds() != null && activityStateRequest.getStartActivityIds().size() == 1) {
            runtimeService.createChangeActivityStateBuilder()
                .processInstanceId(processInstanceId)
                .moveActivityIdsToSingleActivityId(activityStateRequest.getCancelActivityIds(), activityStateRequest.getStartActivityIds().get(0))
                .changeState();
        }
        
    }

其中参数 ExecutionChangeActivityStateRequest的
cancelActivityIds指:需要驳回的节点,
startActivityIds指:驳回到的节点
这两个字段对应的是ACT_ID_字段的值。可以做到任意节点驳回。

protected List<String> cancelActivityIds;
protected List<String> startActivityIds;

在这里插入图片描述

补充

1、正在执行的流程的image
ProcessInstanceDiagramResource.class的getProcessInstanceDiagram方法
2、已完结的流程的image
ProcessDefinitionImageResource.class的getModelResource方法

下一篇:会签

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
集成 Flowable 可以让 Spring Boot 应用程序具有工作流功能。下面是在 Spring Boot 中集成 Flowable 的步骤: 1. 添加依赖。在 pom.xml 文件中添加以下依赖: ``` <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-spring-boot-starter</artifactId> <version>6.5.0</version> </dependency> ``` 2. 配置数据源。在 application.properties 文件中添加以下配置: ``` spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/flowable?useUnicode=true&characterEncoding=utf-8 spring.datasource.username=root spring.datasource.password=root ``` 3. 创建流程定义。在 resources 目录下创建一个名为 processes 的目录,然后在该目录下创建一个名为 myprocess.bpmn20.xml 的文件,该文件包含要创建的流程定义。 4. 创建 Service。创建一个名为 MyService 的类,并在该类中添加以下代码: ``` @Service public class MyService { @Autowired private RuntimeService runtimeService; public void startProcess(String processDefinitionKey) { runtimeService.startProcessInstanceByKey(processDefinitionKey); } } ``` 5. 创建 Controller。创建一个名为 MyController 的类,并在该类中添加以下代码: ``` @RestController @RequestMapping("/my") public class MyController { @Autowired private MyService myService; @PostMapping("/start-process") public void startProcess(@RequestParam("processDefinitionKey") String processDefinitionKey) { myService.startProcess(processDefinitionKey); } } ``` 6. 启动应用程序。运行 Spring Boot 应用程序。 现在,您已经成功在 Spring Boot 中集成Flowable,并可以使用工作流功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值