package org.springblade.flow.engine.listener;

import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component; import java.io.Serializable; //判断是否一票否决
@Component("multiInstance")
public class MultiInstanceCompleteTask implements Serializable {
/**
* 评估结果判定条件
*
* @param execution 分配执行实例
*/
public boolean accessCondition(DelegateExecution execution) {
//已完成的实例数
int completedInstance = (int) execution.getVariable("nrOfCompletedInstances");
//总实例数
int nrOfInstances = (int) execution.getVariable("nrOfInstances");
//否决判断,一票否决
if (execution.getVariable("pass") != null) {
boolean pass = (boolean) execution.getVariable("pass");
if (!pass) {
//输出方向为拒绝
//一票否决其他实例没必要做,结束
return true;
}
}
//所有实例任务未全部做完则继续其他实例任务
if (completedInstance != nrOfInstances) {
return false;
} else {
//输出方向为赞同
//所有都做完了没被否决,结束
return true;
}
} }
package org.springblade.flow.engine.listener;

import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component; import java.io.Serializable; //多实例任务节点完成条件
@Component("multiInstance")
public class MultiInstance implements Serializable { /**
* 一票否决
* 1、如果有驳回操作,则驳回当前任务节点。
* 2、若已审批人数不等于总人数,则多实例任务继续执行
* 3、若已审批人数等于总人数,则结束当前任务节点,进入下一个任务节点。
* @param execution 分配执行实例
*/
public boolean vetoPower(DelegateExecution execution) {
//已完成的实例数
int completedInstance = (int) execution.getVariable("nrOfCompletedInstances");
//总实例数
int nrOfInstances = (int) execution.getVariable("nrOfInstances");
//否决判断,一票否决
if (execution.getVariable("pass") != null) {
boolean pass = (boolean) execution.getVariable("pass");
if (!pass) {
//输出方向为拒绝
//一票否决其他实例没必要做,结束
return true;
}
}
//所有实例任务未全部做完则继续其他实例任务
if (completedInstance != nrOfInstances) {
return false;
} else {
//输出方向为赞同
//所有都做完了没被否决,结束
return true;
}
} /**
* 一票否决 + 少数服从多数
* 1、如果有驳回操作,则驳回当前任务节点。
* 2、若同意人数比例大于等于0.5,则结束当前任务节点,进入下一个任务节点。
* 3、若不同意人数比例大于0.5,则驳回当前任务节点。
* 4、否则多实例任务继续执行
* @param execution
* @return
*/
public boolean vetoPowerAndObeyMost(DelegateExecution execution) {
//否决判断,一票否决
if (execution.getVariable("pass") != null) {
boolean pass = (boolean) execution.getVariable("pass");
if (!pass) {
//输出方向为拒绝
//一票否决其他实例没必要做,结束
return true;
}
}
//已完成的实例数
int completedInstance = (int) execution.getVariable("nrOfCompletedInstances");
//总实例数
int nrOfInstances = (int) execution.getVariable("nrOfInstances");
//获取不同意的次数
int rejectCount = (int)execution.getVariable("rejectCount");
//获取同意人的次数
int agreeCount = (int)execution.getVariable("agreeCount");
//所有实例任务未全部做完则继续其他实例任务
if (completedInstance != nrOfInstances) {
//不同意的人数大于设置比例*总人数
if (rejectCount*1.00/nrOfInstances>0.5){
execution.setVariable("pass", false);
return true;
}
if (agreeCount*1.00/nrOfInstances>=0.5){
execution.setVariable("pass", true);
return true;
}
return false;
} else {
//输出方向为赞同
//所有都做完了没被否决,结束
return true;
}
} /**
* 少数服从多数
* 1、若同意人数比例大于等于0.5,则结束当前任务节点,进入下一个任务节点。
* 2、若不同意人数比例大于0.5,则驳回当前任务节点。
* 3、否则多实例任务继续执行
* @param execution
* @return
*/
public boolean obeyMost(DelegateExecution execution) {
//已完成的实例数
int completedInstance = (int) execution.getVariable("nrOfCompletedInstances");
//总实例数
int nrOfInstances = (int) execution.getVariable("nrOfInstances");
//获取不同意的次数
int rejectCount = (int)execution.getVariable("rejectCount");
//获取同意人的次数
int agreeCount = (int)execution.getVariable("agreeCount");
//所有实例任务未全部做完则继续其他实例任务
if (completedInstance != nrOfInstances) {
//不同意的人数大于设置比例*总人数
if (rejectCount*1.00/nrOfInstances>0.5){
execution.setVariable("pass", false);
return true;
}
if (agreeCount*1.00/nrOfInstances>=0.5){
execution.setVariable("pass", true);
return true;
}
return false;
} else {
//不同意的人数大于设置比例*总人数
if (rejectCount*1.00/nrOfInstances>0.5){
execution.setVariable("pass", false);
return true;
}
if (agreeCount*1.00/nrOfInstances>=0.5){
execution.setVariable("pass", true);
return true;
}
return true;
}
} public boolean test(DelegateExecution execution,int i,String a){
System.out.println("===========i====="+i);
System.out.println("===========a====="+a);
return false;
} }
package org.springblade.flow.engine.listener.task;

import org.flowable.engine.delegate.TaskListener;
import org.flowable.engine.impl.el.FixedValue;
import org.flowable.task.service.delegate.DelegateTask;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Component; //计算同意和拒绝数量
@Component("countAgreeAndRejectTaskListener")
public class CountAgreeAndRejectTaskListener implements TaskListener { private FixedValue agreeFlagText;
private FixedValue agreeCountText;
private FixedValue rejectCountText; @Override
public void notify(DelegateTask delegateTask) {
Boolean pass = (Boolean) delegateTask.getVariable(Func.toStr(agreeFlagText.getExpressionText(),"pass")); String agreeCountTextVariable = Func.toStr(agreeCountText.getExpressionText(),"agreeCount") ;
// 校验 agreeCountText 是否已经存在
if (!delegateTask.hasVariable(agreeCountTextVariable)) {
delegateTask.setVariable(agreeCountTextVariable, 0);
}
//ExecutionListner类中设置的同意计数变量
int agreeCount = (int) delegateTask.getVariable(agreeCountTextVariable); String rejectCountTextVariable = Func.toStr(rejectCountText.getExpressionText(),"rejectCount") ;
// 校验 rejectCountText 是否已经存在
if (!delegateTask.hasVariable(rejectCountTextVariable)) {
delegateTask.setVariable(rejectCountTextVariable, 0);
}
//ExecutionListner类中设置的拒绝计数变量
int rejectCount = (int) delegateTask.getVariable(rejectCountTextVariable); if (pass){
//同意
delegateTask.setVariable(agreeCountTextVariable, ++agreeCount);
}
else{
//拒绝
delegateTask.setVariable(rejectCountTextVariable, ++rejectCount);
}
}
}
package org.springblade.flow.engine.listener.execution;

import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.flowable.engine.impl.el.FixedValue;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Component; //设置初始值:同意、驳回计数初始化
@Component("initAgreeAndRejectExecutionListener")
public class InitAgreeAndRejectExecutionListener implements ExecutionListener { //页面注入同意计数变量名称
private FixedValue agreeCountText;
//页面注入驳回计数变量名称
private FixedValue rejectCountText; @Override
public void notify(DelegateExecution delegateExecution) {
delegateExecution.setVariable(Func.toStr(agreeCountText.getExpressionText(),"agreeCount"),0);
delegateExecution.setVariable(Func.toStr(rejectCountText.getExpressionText(),"rejectCount"),0);
}
}

flowable中传入审批人是list的更多相关文章

  1. react 不能往组件中传入属性的值为 undefined

    在使用 andt design 的时候遇到个需求,需要清除 Select 组件选中后的值,让它变成什么都没选中,显示 placeholder 刚开始以为设置为 null 即可,结果发现设置为 null ...

  2. 如何向GLSL中传入多个纹理

    http://blog.csdn.net/huawenguang/article/details/41245871 如何向GLSL中传入多个纹理 这几天在研究如何实现用GLSL对多个纹理进行融合处理, ...

  3. Java中传入一个时间范围,取出该时间范围内所有日期的集合

    直接上代码: import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; impor ...

  4. H5_0010:JS动态创建CSS,并向CSS中传入参数值

    1,在html中定义style 2,js中创建css,并添加进入head标签style中 !function(e, t, i) { n.classList && n.classList ...

  5. mapper.xml文件中传入list参数报错 ‘ ’附近有语法错误

    mapper.xml文件中传入list参数,使用foreach循环遍历值,但是在遍历的过程中出错了,具体代码如下所示 mapper.xml <select id="selectByCo ...

  6. Flowable中的Service

    前言 在学习博客[(https://blog.csdn.net/puhaiyang/article/details/79845248)]时,注意到Flowable中的各种Service(如下),进而在 ...

  7. 向shell脚本中传入参数

    写一个 程序名为    test.sh    可带参数为 start 和 stop 执行  test.sh start执行  start 内容的代码 执行 test.sh stop 执行 stop 内 ...

  8. asp.net mvc 强类型视图中传入List 数据到控制器

    问题来源: 在和一位技术老师聊天时,老师问我一个mvc 表单提交的问题,问道:怎样在表单提交的时候,将 带有 List 属性的对象传入控制器? 这时,我有点呆了,以前一直都好像是 单一属性的表单提交, ...

  9. curl javaSSm框架中传入json数组的格式方法

    curl与java结合传入get.post,head请求, 比如: curl的地址: curl -l 127.0.0.1:8080/spacobj/core/do?acid=100 -H " ...

随机推荐

  1. 【对不起】我并不是真的会用spring

    19年12月4日,为了测试另外一个部门的服务在注册到这边zk后能否拿到dubbo代理,在controller草草写了一个http服务请求之,发现所有的dubbo接口都没有被注入代理,排查许久之后,发现 ...

  2. ConvTranspose2d

    nn.ConvTranspose2d的功能是进行反卷积操作 nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=1, p ...

  3. 真香!Python开发工程师都选择这个数据库:因为它免费

    数据库类别 既然我们要使用关系数据库,就必须选择一个关系数据库. 目前广泛使用的关系数据库也就这么几种: 付费的商用数据库: Oracle,典型的高富帅: SQL Server,微软自家产品,Wind ...

  4. charles功能(五)屏蔽web网页的抓包信息(proxy)

    应用场景:屏蔽web网页的抓包信息 proxy-->windows proxy(前面没有对勾,就不会抓到 PC浏览器的包) proxy-->macOS proxy(mac电脑) 最终效果

  5. (四)CPU主频与”性能“

    一.什么是性能 CPU的性能就是就是时间的倒数,简单来说:耗时越少,性能越好,主要包含下面两个指标: 响应时间:程序执行耗时 吞吐率:单位时间处理数据或执行程序的量 缩短响应时间,一定时间内可以执行更 ...

  6. moviepy音视频剪辑:TextClip不支持中文字符以及OSError: magick.exe: unable to read font 仿宋_GB2312.ttf的解决办法

    ☞ ░ 前往老猿Python博文目录 ░ 一.引言 moviepy对中文和多语言环境的支持做得并不好,包括中文文件名以及用于显示文字的TextClip就是典型的中文支持方面存在问题的.对于编解码的问题 ...

  7. 老猿学5G扫盲贴:PDU协议数据单元、PDU连接业务和PDU会话的功能详解

    专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt入门学习 老猿Python博文目录 老猿学5G博文目录 一.PDU 关于PDU在百度百科是这样定义的:协议 ...

  8. 第十一章、Designer中主窗口QMainWindow类

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 一.概述 主窗口对象是在新建窗口对象时,选择main window类型的模板时创建的窗口对象,如图: ...

  9. PyQt(Python+Qt)学习随笔:QAbstractScrollArea的用途

    老猿Python博文目录 老猿Python博客地址 QAbstractScrollArea部件提供了一个带有按需滚动条的滚动区域. QAbstractScrollArea是滚动区域的低级抽象.该区域提 ...

  10. 算法数据结构——数的深搜和广搜(dfs和bfs)

    leetcode104 二叉树的最大深度 https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/ 深度搜索分两种:递归(使用栈) ...