基于jeecgboot的flowable复杂会签加用户选择流程实现

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介: 基于jeecgboot的flowable复杂会签加用户选择流程实现

    因为flowable流程对于会签流转过程控制都是自动的,但要进行人为中间或后期干预,必须要用到执行监控器,在监控器中进行流程过程与监控,对满足要求进行处理。

1、首先在会签流程进行执行监控器的增加

其中类名 com.nbcio.modules.flowable.listener.MutiInstanceExecutionListener

目前先只实现多实例会签的监控处理

2、在程序里增加相应的执行监控器类

/**
 * 多实例会签审核结果全局监听器
 * @author nbacheng
 * @date 2022-09-22
*/
@Slf4j
@Component("MutiInstanceExecutionListener")
public class MutiInstanceExecutionListener implements ExecutionListener, ApplicationContextAware {
    private static final long serialVersionUID = 1L;
    private static  ApplicationContext applicationContext;

    
    @Override
    public void notify(DelegateExecution execution) {
        // TODO Auto-generated method stub
        RedisUtil redisUtil = applicationContext.getBean(RedisUtil.class);
        FlowNode flowNode = (FlowNode) execution.getCurrentFlowElement();
        if(Objects.nonNull(flowNode)) {
            if(flowNode instanceof UserTask ){
             UserTask userTask = (UserTask) flowNode;
             MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics();
             if (Objects.nonNull(multiInstance)) {
                 if (Objects.nonNull(execution.getVariable("nrOfCompletedInstances"))) {
                     int nrOfCompletedInstances = (int) execution.getVariable("nrOfCompletedInstances");
                     int nrOfInstances = (int) execution.getVariable("nrOfInstances");
                     if(multiInstance.isSequential()) {
                         if((nrOfCompletedInstances + 1) >= nrOfInstances){//结束会签流程前一个节点提示进行用户选择
                             
                             redisUtil.set(CommonConstant.MUTIINSTANCE_NEXT_FINISH + execution.getProcessInstanceId(), execution.getProcessInstanceId());
                         }
                     }
                     else if(multiInstance.getCompletionCondition().equals("${nrOfCompletedInstances>=nrOfInstances}")) {
                         if((nrOfCompletedInstances + 1) >= nrOfInstances){//结束会签流程前一个节点提示进行用户选择
                             redisUtil.set(CommonConstant.MUTIINSTANCE_NEXT_FINISH + execution.getProcessInstanceId(), execution.getProcessInstanceId());
                         }
                     }
                     else if(multiInstance.getCompletionCondition().startsWith("${nrOfCompletedInstances/nrOfInstances>=")) {//后续根据需要实现
                         
                     }
                     /*log.info(execution.getId() + " - " + execution.getProcessInstanceId()
                        + " - " + execution.getEventName()
                        + " - " + execution.getCurrentActivityId()
                        + " - " + execution.getProcessInstanceBusinessKey());
                     log.info("UserExecutionListener会签方式:" + multiInstance.isSequential());
                     log.info("UserExecutionListener会签条件:" + multiInstance.getCompletionCondition());
                    log.info("UserExecutionListener总会签数:" + execution.getVariable("nrOfInstances"));
                    log.info("UserExecutionListener激活的会签数:" + execution.getVariable("nrOfActiveInstances"));
                    log.info("UserExecutionListener已经完成会签数:" + execution.getVariable("nrOfCompletedInstances"));*/
                 }
              }
             
          }    
        }
        
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContextNew) throws BeansException {
        // TODO Auto-generated method stub
        applicationContext = applicationContextNew;
    }
}

上面自己类没办法注入,所以采用ApplicationContextAware方式

同时对下一个任务是进行redis数据读取判断,同时前端也做一下处理

具体流程图与流程流转情况如下:



相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
相关文章
|
5天前
|
前端开发
基于jeecgboot的flowable流程支持退回到发起人节点表单修改功能
基于jeecgboot的flowable流程支持退回到发起人节点表单修改功能
31 0
|
5天前
|
前端开发
基于jeecg-boot的flowable流程自定义业务驳回到发起人的一种处理方式
基于jeecg-boot的flowable流程自定义业务驳回到发起人的一种处理方式
13 0
|
5天前
|
前端开发
基于jeecg-boot的flowable流程增加部门经理审批功能
基于jeecg-boot的flowable流程增加部门经理审批功能
14 0
|
5天前
|
移动开发 前端开发
基于jeecg-boot的flowable流程自定义业务退回撤回或驳回到发起人后的再次流程提交
基于jeecg-boot的flowable流程自定义业务退回撤回或驳回到发起人后的再次流程提交
18 0
|
5天前
基于jeecgboot的flowable流程综合会签功能演示平台已经发布
基于jeecgboot的flowable流程综合会签功能演示平台已经发布
10 0
|
5天前
|
前端开发
基于jeecgboot的flowable流程设计器的用户选择问题修复
基于jeecgboot的flowable流程设计器的用户选择问题修复
10 1
|
5天前
|
前端开发
基于jeecgboot的flowable流程并行审批的bug修复
基于jeecgboot的flowable流程并行审批的bug修复
15 2
|
5天前
Flowable流程中自定义业务表单并行审批的bug修复
Flowable流程中自定义业务表单并行审批的bug修复
12 0
|
5天前
|
前端开发
基于jeecgboot的flowable增加流程节点抄送功能
基于jeecgboot的flowable增加流程节点抄送功能
47 0
|
5天前
|
前端开发
基于jeecgboot的flowable流程任务excel导出功能
基于jeecgboot的flowable流程任务excel导出功能
12 1