基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(三)

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统

1、上一节说到RedisReceiver ,这里有调用了NbcioRedisListener自定义业务监听,如下:

package com.ruoyi.common.redis.listener;import com.ruoyi.common.base.BaseMap;/***  自定义消息监听*  @author nbacheng*  @date 2023-09-20*/public interface NbcioRedisListener {void onMessage(BaseMap message);
}

2、实现这个代码如下:

package com.ruoyi.common.websocket;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;import com.ruoyi.common.base.BaseMap;
import com.ruoyi.common.constant.CommonSendStatus;
import com.ruoyi.common.redis.listener.NbcioRedisListener;import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;/*** 监听消息(采用redis发布订阅方式发送消息)*/
@Slf4j
@Component
public class SocketHandler implements NbcioRedisListener {@Autowiredprivate WebSocketServer webSocket;@Overridepublic void onMessage(BaseMap map) {log.info("【SocketHandler消息】Redis Listerer:" + map.toString());String userId = map.get("userId");String message = map.get("message");if (ObjectUtil.isNotEmpty(userId)) {webSocket.pushMessage(userId, message);//app端消息推送webSocket.pushMessage(userId+CommonSendStatus.APP_SESSION_SUFFIX, message);} else {webSocket.pushMessage(message);}}

       这里进行了websocket的服务器给用户推送,同时之前第一个节里公共类方法也同时往两个表增加数据,以便失败后后续可以进行发送,以确保能真正通知到用户。

3、接下来就是需要在用户提起流程发给审批人进行消息发送了

package com.ruoyi.flowable.listener;import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;import org.apache.commons.lang3.StringUtils;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
import org.flowable.common.engine.api.delegate.event.FlowableEventType;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.stereotype.Component;import com.ruoyi.common.core.service.CommonService;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.model.LoginUser;import javax.annotation.Resource;/*** 全局监听-工作流待办消息提醒** @author nbacheng*/
@Slf4j
@Component
@RequiredArgsConstructor
public class TaskCreateListener implements FlowableEventListener {private final TaskService taskService;@Resourceprivate CommonService commonService;@Resourceprotected RepositoryService repositoryService;@Resourceprotected HistoryService historyService;@Overridepublic void onEvent(FlowableEvent flowableEvent) {FlowableEventType type = flowableEvent.getType();if (type == FlowableEngineEventType.TASK_ASSIGNED) { if(flowableEvent instanceof org.flowable.engine.delegate.event.impl.FlowableEntityEventImpl ) {TaskEntity taskEntity = (TaskEntity) ((org.flowable.engine.delegate.event.impl.FlowableEntityEventImpl) flowableEvent).getEntity();String taskId = taskEntity.getId();String procInsId = taskEntity.getProcessInstanceId();HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(procInsId).singleResult();String businessKey =  historicProcessInstance.getBusinessKey();String deployId = historicProcessInstance.getDeploymentId();String startUserId = historicProcessInstance.getStartUserId();//获取任务接收人String receiver = taskEntity.getAssignee();if (StringUtils.isNotEmpty(receiver)) {//发送提醒消息String category = "";if(taskService.getVariables(taskId).get("category") != null) {category = taskService.getVariables(taskId).get("category").toString();}LoginUser loginUser = commonService.getLoginUser();String taskMessageUrl;if(StringUtils.isNotBlank(businessKey)) {taskMessageUrl = "<a href=" + commonService.getBaseUrl() + "?procInsId=" + procInsId + "&deployId=" + deployId + "&taskId=" + taskId + "&businessKey=" + businessKey + "&category=" + category+ "&finished=true" + ">点击这个进行处理</a>" ;}else {taskMessageUrl = "<a href=" + commonService.getBaseUrl() + "?procInsId=" + procInsId + "&deployId=" + deployId + "&taskId=" + taskId + "&businessKey" + "&category=" + category + "&finished=true" + ">点击这个进行处理</a>" ;}String msgContent = "流程待办通知" + taskMessageUrl;if(!StringUtils.equals(startUserId, receiver) || !StringUtils.equals((loginUser.getUserId()).toString(),receiver)) {//发起人或登录人自己不发送log.info("流程待办通知给:" + receiver);commonService.sendSysNotice(loginUser.getUserId().toString(), receiver, "流程待办通知", msgContent, Constants.MSG_CATEGORY_3);//setMsgCategory=3是待办}}}}	}@Overridepublic boolean isFailOnException() {return false;}@Overridepublic boolean isFireOnTransactionLifecycleEvent() {return false;}@Overridepublic String getOnTransaction() {return null;}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/85223.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

「UG/NX」Block UI 指定方位SpecifyOrientation

✨博客主页何曾参静谧的博客📌文章专栏「UG/NX」BlockUI集合📚全部专栏「UG/NX」NX二次开发「UG/NX」BlockUI集合「VS」Visual Studio「QT」QT5程序设计「C/C+&#

Django系列:Django应用(app)的创建与配置

Django系列 Django应用&#xff08;app&#xff09;的创建与配置 作者&#xff1a;李俊才 &#xff08;jcLee95&#xff09;&#xff1a;https://blog.csdn.net/qq_28550263 邮箱 &#xff1a;291148484163.com 本文地址&#xff1a;https://blog.csdn.net/qq_28550263/article…

Integer使用不当

Integer包装类 Integer 是一个封装类型。它是对应一个 int 类型的包装。 在 Java 里面之所以要提供 Integer 这种基本类型的封装类&#xff0c;是因为 Java 是一个面向对象的语言&#xff0c; 而基本类型不具备对象的特征&#xff0c;所以在基本类型上做了一层对象的包装并且提…

数据结构--排序(1)

文章目录 排序概念直接插入排序希尔排序冒泡排序堆排序选择排序验证不同排序的运行时间 排序概念 排序指的是通过某一特征关键字&#xff08;如信息量大小&#xff0c;首字母等&#xff09;来对一连串的数据进行重新排列的操作&#xff0c;实现递增或者递减的数据排序。 稳定…

【C++】静态成员函数 ( 静态成员函数概念 | 静态成员函数声明 | 静态成员函数访问 | 静态成员函数只能访问静态成员 )

文章目录 一、静态成员函数简介1、静态成员函数概念2、静态成员函数声明3、静态成员函数访问4、静态成员函数只能访问静态成员 二、代码示例 - 静态成员函数 一、静态成员函数简介 1、静态成员函数概念 静态成员函数归属 : 在 C 类中 , 静态成员函数 是一种 特殊的函数 , 该函数…

MFC串口通信控件MSCOMM32.OCX的安装注册

MSCOMM32.OCX是一个与Microsoft Corporation开发的MSComm控件相关联的文件。MSComm控件是软件应用程序用来与调制解调器、条形码读取器和其他串行设备等设备建立串行通信的通信控件。 下载地址1 https://download.csdn.net/download/m0_60352504/88345092 下载地址2 https://ww…

kafka的 ack 应答机制

目录 一 ack 应答机制 二 ISR 集合 一 ack 应答机制 kafka 为用户提供了三种应答级别&#xff1a; all&#xff0c;leader&#xff0c;0 acks &#xff1a;0 这一操作提供了一个最低的延迟&#xff0c;partition的leader接收到消息还没有写入磁盘就已经返回ack&#x…

虚拟机部署linux网络连接配置

1、虚拟机安装linux后&#xff0c;配置网络访问 虚拟机网络设置为NAT模式 linux网络配置好IP&#xff0c;主要是以下网络配置 2、linux没有ifconfig命令&#xff0c;ifconfig命令是在net-tools.x86_64包里 yum install net-tools.x86_64安装

Linus Torvalds接受来自微软的Linux Hyper-V升级

导读微软最近推送了一些变更&#xff0c;旨在改进即将发布的 Linux 内核 6.6 版本对 Hyper-V 的支持。这些改进包括在 Hyper-V 上支持 AMD SEV-SNP guest 和 Intel TDX guest。除了这两项&#xff0c;还有其他一些升级&#xff0c;如改进了 VMBus 驱动程序中的 ACPI&#xff08…

【Vue3 源码解析】ref 全家桶

// 函数重载&#xff0c;以便根据传入的不同参数类型执行不同的处理 export function ref<T extends Ref>(value: T): T export function ref<T>(value: T): Ref<UnwrapRef<T>> export function ref<T any>(): Ref<T | undefined> export…

操作系统:体系结构

1.内核的划分 1.术语解释 时钟管理&#xff1a;利用时钟断实现计时功能。原语是一种特殊的程序,具有原子性。也就是说,这段程序的运行必须一气呵成&#xff0c;不可被“中断”Ubuntu、Centos的开发团队,其主要工作是实现非内核功能&#xff0c;而内核都是用了Linux内核。 内核…

hive数据初始化

mysql版本&#xff1a;3.1.3 hive版本&#xff1a; 8.0.31 hive连接配置 <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://node88:3306/hive?createDatabaseIfNotExisttrue</value> </pr…

算法 滑动窗口最大值-(双指针+队列)

牛客网: BM45 题目: 数组num, 窗口大小size, 所有窗口内的最大值 思路: 用队列作为窗口&#xff0c;窗口内存储数组坐标&#xff0c;left window[0], right从数组0开始遍历完数组&#xff0c;每次新增元素时&#xff0c;(1)先对窗口大小进行收缩到size大小范围&#xff0c;即…

单元测试 —— JUnit 5 参数化测试

JUnit 5参数化测试 目录 设置我们的第一个参数化测试参数来源 ValueSourceNullSource & EmptySourceMethodSourceCsvSourceCsvFileSourceEnumSourceArgumentsSource参数转换参数聚合奖励总结 如果您正在阅读这篇文章&#xff0c;说明您已经熟悉了JUnit。让我为您概括一下…

Java中swing的5种布局方式浅析

在一个传统的java项目中&#xff0c;遇到一个需要调整布局的需求&#xff0c;下面将学习网上大佬的文章&#xff0c;并将过程记录下来。 1、Java swing5种布局方式 1、 边界布局&#xff08;BorderLayout&#xff09;2、流式布局&#xff08;FlowLayout&#xff09;3、网格布局…

王道考研操作系统

王道考研操作系统 计算机系统概述操作系统的概念操作系统的特征操作系统的发展历程操作系统内核中断和异常![在这里插入图片描述](https://img-blog.csdnimg.cn/162452b4c60144e0bd500e180127c447.png)系统调用操作系统结构虚拟机错题 进程与线程进程控制进程通信线程和多线程模…

如何获取美团的热门商品和服务

导语 美团是中国最大的生活服务平台之一&#xff0c;提供了各种各样的商品和服务&#xff0c;如美食、酒店、旅游、电影、娱乐等。如果你想了解美团的热门商品和服务&#xff0c;你可以使用爬虫技术来获取它们。本文将介绍如何使用Python和BeautifulSoup库来编写一个简单的爬虫…

antd+react Hook弹窗改进版

之前写过一个react Hookantd弹窗&#xff0c;虽然功能实现了&#xff0c;但是再使用的时候仍然会有报错&#xff0c;虽然这个报错不影响使用的&#xff0c;但是&#xff0c;作为一个合格的前端切图仔&#xff0c;要再使用中发现问题&#xff0c;改正问题。 问题 多次调用hook…

计算机视觉与深度学习-全连接神经网络-训练过程-批归一化- [北邮鲁鹏]

文章目录 思想批归一化操作批归一化与梯度消失经过BN处理 算法实现 思想 直接对神经元的输出进行批归一化 批归一化&#xff1a;对输出值进行归一化&#xff0c;将归一化结果平移缩放作为输出。 批归一化操作 小批量梯度下降算法回顾&#xff1a;每次迭代时会读入一批数据&am…

反编译之崩溃定位

反编译之崩溃定位 1.背景问题定位1.首先我们需要找崩溃所在的类和方法2.寻找崩溃的代码行数2.1借用反编译工具jadx查看反编译后的内容 1.背景 线上出了个崩溃(量挺大&#x1f62d;)&#xff0c;但是apk是被混淆过的&#xff0c;一时摸不着头脑。崩溃信息如下&#xff1a; 主要…