flowable 实现多实例-会签-动态配置人员 参考demo

会签 即多人执行当前任务 设置判断数 通过 例如:设置了是半数通过即可通过当前节点 如果当前是4人那就是2人即通过 如果是6人那就是三人即通过 如果是5人 即三人通过 看各位的判断值是如何书写 这个值是根据各位需求改变的
以下是xml



  
    测试flowable多实例
    
    
         
        4
        ${nrOfCompletedInstances/nrOfInstances >= 0.50}
      
    
    
    
    
    
    
  
  
    
      
        
      
      
        
      
      
        
      
      
        
      
      
        
        
      
      
        
        
      
      
        
        
      
    
  

${nrOfCompletedInstances/nrOfInstances >= 0.50}

>=0.50  即通过数是>=人员数的50%

flowable:collection=“assigneeList” ${assigneeList}即取的人员列表名称

以下是java代码

		//主体流程的开始
		//创建数据库链接信息
		ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration()
		.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/自库名?characterEncoding=UTF-8")
		.setJdbcUsername("账号")
		.setJdbcPassword("密码")
		.setJdbcDriver("com.mysql.jdbc.Driver")
		.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE);
		// 通过数据库链接信息         创建Flowable流程引擎 Create Flowable process engine
		ProcessEngine processEngine = cfg.buildProcessEngine();
		// 获取Flowable服务 Get Flowable repositoryService
		RepositoryService repositoryService = processEngine.getRepositoryService();
		// 获取Flowable服务 Get Flowable runtimeService
		RuntimeService runtimeService = processEngine.getRuntimeService();
		// 获取taskService对象 Get the first task
		TaskService taskService = processEngine.getTaskService();
		//获取fromserver对象  操作from表单的东西
		FormService formService = processEngine.getFormService();
		
		
		Deployment deploy = repositoryService.createDeployment().addClasspathResource("/MoreLiving.bpmn20.xml").deploy();
		System.out.println(deploy.getId());
		
        HashMap map = new HashMap<>();
        //定义的人员列表4人
        String[] v = { "shareniu1", "shareniu2", "shareniu3", "shareniu4" };
        map.put("per", "bbb");
        map.put("money", "1111");
        map.put("assigneeList", Arrays.asList(v));
		ProcessInstance pi = runtimeService.startProcessInstanceByKey("living",map);
		
		List list = taskService.createTaskQuery().processInstanceId(pi.getId()).list();
		System.out.println(list.size());
		int  i=0;
		
		for (Task task : list) {
			i=i+1;
			System.out.println("==========================所有节点name is =  "+task.getName());
			System.out.println("==========================所有节点id is =  "+task.getId());
			System.out.println("============ i ="+i);
            //变相判断已经二人提交 之后人员不提交
			if (i<3) {
				System.out.println("================== 提交 节点 id is="+task.getId());
				taskService.complete(task.getId());
			}
		}
        //判断值为 50% 所以提交人达到2人 会签节点即可通过
		Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
		System.out.println("====================================================================================");
        //验证是否已通过
		System.out.println("===================task id is="+task.getId());
		System.out.println("===================task name is="+task.getName());

我的判断值为 50% 所以提交人达到2人 会签节点即可通过

你可能感兴趣的:(Flowable,Flowable)