当前位置: 首页 > news >正文

静态网站开发课程相关新闻购物网站推广方案

静态网站开发课程相关新闻,购物网站推广方案,网站建设设计设计,山东咕果做网站怎么样flowable流程结束触发监听器 | flowable流程结束获取结束节点 | flowable流程结束事件响应监听器 下面代码是该监听器是对每个到达结束事件后执行的。 原本的流程定义是如果其中任意某个节点进行了驳回,则直接结束流程。 所以在每个节点的驳回对应的排他网关都设…

flowable流程结束触发监听器 | flowable流程结束获取结束节点 | flowable流程结束事件响应监听器

下面代码是该监听器是对每个到达结束事件后执行的。

原本的流程定义是如果其中任意某个节点进行了驳回,则直接结束流程。

所以在每个节点的驳回对应的排他网关都设置了EndEvent


import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.EndEvent;
import org.flowable.bpmn.model.FlowNode;
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.event.impl.FlowableEntityEventImpl;
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.springframework.stereotype.Component;import java.util.List;/*** @description 全局监听器,判断流程是不是运行到了最后一个EndEvent* @since 2024/1/15*/
@Slf4j
@Component
public class ProcessEndListener implements FlowableEventListener {@Overridepublic void onEvent(FlowableEvent event) {log.info("ProcessEndListener:{}", JSON.toJSONString(event.getType()));TaskService taskService = SpringUtil.getBean(TaskService.class);RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);FlowableEntityEventImpl flowableEntityEvent = ((FlowableEntityEventImpl) event);ProcessInstance pi = (ProcessInstance) flowableEntityEvent.getEntity();List<Task> tasks = taskService.createTaskQuery().active().processInstanceId(pi.getId()).list();Task t = tasks.get(0);String bizKey = pi.getBusinessKey();log.info("ProcessEndListener#bizKey:{}", bizKey);String procDefId = pi.getProcessDefinitionId();List<Execution> exes = runtimeService.createExecutionQuery().processInstanceId(pi.getProcessInstanceId()).processDefinitionId(procDefId).executionId(t.getExecutionId()).list();String curActId = exes.get(0).getActivityId();//获得当前执行器的活动IDBpmnModel bm = ProcessDefinitionUtil.getBpmnModel(t.getProcessDefinitionId());FlowNode flowNode = (FlowNode) bm.getFlowElement(curActId);//获得当前节点if (flowNode instanceof EndEvent) {//判断当前节点是否为结束事件if (flowNode.getId().equals("end")) {//end是自定义的EndEvent节点的ID//todo 通知回调log.info("当前节点是结束节点:{}!!", JSON.toJSONString(flowNode));}}}@Overridepublic boolean isFailOnException() {return false;}@Overridepublic boolean isFireOnTransactionLifecycleEvent() {return false;}@Overridepublic String getOnTransaction() {return null;}}

百度关于该问题答案出来的几乎清一色全是同一个答案,给了三种方法,但是每个方法的代码都有他自定义的部分,是不完整的东西。
下面是网上找的东西,里面的flowableService是这个比玩意自定义的。

下面这段代码是被转载多次的代码, 它监听的是指向结束事件的上一个节点。
也就是他的当前节点可能是最后一岗。
然后最后一岗—>EndEvent

@Component
public class ProcessEndListener implements FlowableEventListener {@AutowiredFlowableService flowableService;@Overridepublic void onEvent(FlowableEvent event) {// 当前节点任务实体,TaskEntity taskEntity = (TaskEntity) ((FlowableEntityEventImpl) event).getEntity();String taskId = taskEntity.getId();String curActId = flowableService.getNodeId(taskId);String procDefId = ProcUtils.getProcessDefinitionByTaskId(taskEntity.getId()).getId();Process process = ProcessDefinitionUtil.getProcess(procDefId);//遍历整个process,找到endEventId是什么,与当前taskId作对比List<FlowElement> flowElements = (List<FlowElement>) process.getFlowElements();for (FlowElement flowElement : flowElements) {if (flowElement instanceof SequenceFlow) {SequenceFlow flow = (SequenceFlow) flowElement;FlowElement sourceFlowElement = flow.getSourceFlowElement();FlowElement targetFlowElement = flow.getTargetFlowElement();//如果当前边的下一个节点是endEvent,那么获取当前边if(targetFlowElement instanceof EndEvent && sourceFlowElement.getId().equals(curActId)){System.out.println("下一个是结束节点!!");}}}}@Overridepublic boolean isFailOnException() {return false;}@Overridepublic boolean isFireOnTransactionLifecycleEvent() {return false;}@Overridepublic String getOnTransaction() {return null;}
}

用我上面的代码实现示例这个b的代码

    @Overridepublic void onEvent(FlowableEvent event) {log.info("ProcessEndListener:{}", JSON.toJSONString(event.getType()));TaskService taskService = SpringUtil.getBean(TaskService.class);RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);FlowableEntityEventImpl flowableEntityEvent = ((FlowableEntityEventImpl) event);ProcessInstance pi = (ProcessInstance) flowableEntityEvent.getEntity();List<Task> tasks = taskService.createTaskQuery().active().processInstanceId(pi.getId()).list();Task t = tasks.get(0);String bizKey = pi.getBusinessKey();log.info("ProcessEndListener#bizKey:{}", bizKey);String procDefId = pi.getProcessDefinitionId();List<Execution> exes = runtimeService.createExecutionQuery().processInstanceId(pi.getProcessInstanceId()).processDefinitionId(procDefId).executionId(t.getExecutionId()).list();String curActId = exes.get(0).getActivityId();BpmnModel bm = ProcessDefinitionUtil.getBpmnModel(t.getProcessDefinitionId());FlowNode flowNode = (FlowNode) bm.getFlowElement(curActId);//如果当前节点是最后一岗List<SequenceFlow> outFlows = flowNode.getOutgoingFlows(); //此处需要获取他的下一个节点是否为EndEventfor (SequenceFlow sequenceFlow : outFlows) { //遍历outFlowssequenceFlow.getTargetFlowElement();//用该flow节点与EndEvent进行对比判断,也就是当前节点的下一个节点和EndEvent判断是否一致,是则说明当前节点就是最后一岗,且它的下一个节点就是结束事件}}
http://www.mmbaike.com/news/99920.html

相关文章:

  • 做网站 写脚本是什么中国旺旺(00151) 股吧
  • 淘宝客网站可以做百度推广百度代运营推广
  • 省住房城乡建设厅网站百度搜索指数1000是什么
  • 滕州做网站哪家好seo平台是什么意思
  • ueeshop外贸建站公司汕头seo外包公司
  • 1万流量网站 服务器配置搜索引擎网站优化推广
  • tp框架做购物网站开发培训方案
  • 葫芦岛网站建设seo高手培训
  • 手机网站如何建立上海网站快速排名优化
  • 网站建设设计说明石家庄今天最新新闻头条
  • 上什么网站做会计教育俄罗斯搜索引擎入口
  • 网站开发的未来发展趋势短视频广告投放平台
  • 怎么把淘宝店放到自己做的网站去站长之家
  • 台湾做网站中国十大新闻网站排名
  • 制作自己的网站需要什么软件好上海网站seo公司
  • 佛山小网站建设营销型网站建设方案
  • 做外贸网站平台有哪些营销目标分为三个方面
  • 谁有南安石井镇做妓的网站黄冈网站推广策略
  • wordpress对的密码无法登录seo百度贴吧
  • 网站建设pdf下载磁力猫引擎
  • 互联网网站建设水平seo有什么作用
  • 网站建设公司 未来站外推广方式有哪些
  • 如何黑网站免费发布信息不收费的网站
  • 网站营销怎么做2022当下社会热点话题
  • 大连百度推广seo广州网站营销seo费用
  • 已经有网站了 怎么做app运营推广计划怎么写
  • 政府网站内容建设百度首页网址是多少
  • 电商网站搜索引擎怎么做百度网页游戏
  • 苏州沧浪做网站哪家好手机百度账号申请注册
  • 建设银行交学费网站bing搜索 国内版