记录一下基于jeecg-boot3.0的待办消息移植记录

    因为之前没有记录,所以还要看代码进行寻找,比较费劲,所以今天记录一下:

1、后端

SysAnnouncementController

下面函数增加待办的几个显示内容给前端用

 具体代码如下:

	/*** @功能:补充用户数据,并返回系统消息* @return*/@RequestMapping(value = "/listByUser", method = RequestMethod.GET)public Result<Map<String, Object>> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize) {Result<Map<String,Object>> result = new Result<Map<String,Object>>();LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();String userId = sysUser.getId();// 1.将系统消息补充到用户通告阅读标记表中LambdaQueryWrapper<SysAnnouncement> querySaWrapper = new LambdaQueryWrapper<SysAnnouncement>();querySaWrapper.eq(SysAnnouncement::getMsgType,CommonConstant.MSG_TYPE_ALL); // 全部人员querySaWrapper.eq(SysAnnouncement::getDelFlag,CommonConstant.DEL_FLAG_0.toString());  // 未删除querySaWrapper.eq(SysAnnouncement::getSendStatus, CommonConstant.HAS_SEND); //已发布querySaWrapper.ge(SysAnnouncement::getEndTime, sysUser.getCreateTime()); //新注册用户不看结束通知//update-begin--Author:liusq  Date:20210108 for:[JT-424] 【开源issue】bug处理--------------------querySaWrapper.notInSql(SysAnnouncement::getId,"select annt_id from sys_announcement_send where user_id='"+userId+"'");//update-begin--Author:liusq  Date:20210108  for: [JT-424] 【开源issue】bug处理--------------------List<SysAnnouncement> announcements = sysAnnouncementService.list(querySaWrapper);if(announcements.size()>0) {for(int i=0;i<announcements.size();i++) {//update-begin--Author:wangshuai  Date:20200803  for: 通知公告消息重复LOWCOD-759--------------------//因为websocket没有判断是否存在这个用户,要是判断会出现问题,故在此判断逻辑LambdaQueryWrapper<SysAnnouncementSend> query = new LambdaQueryWrapper<>();query.eq(SysAnnouncementSend::getAnntId,announcements.get(i).getId());query.eq(SysAnnouncementSend::getUserId,userId);SysAnnouncementSend one = sysAnnouncementSendService.getOne(query);if(null==one){SysAnnouncementSend announcementSend = new SysAnnouncementSend();announcementSend.setAnntId(announcements.get(i).getId());announcementSend.setUserId(userId);announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);sysAnnouncementSendService.save(announcementSend);}//update-end--Author:wangshuai  Date:20200803  for: 通知公告消息重复LOWCOD-759------------}}// 2.查询用户未读的系统消息Page<SysAnnouncement> anntMsgList = new Page<SysAnnouncement>(0, pageSize);anntMsgList = sysAnnouncementService.querySysCementPageByUserId(anntMsgList,userId,"1");//通知公告消息Page<SysAnnouncement> sysMsgList = new Page<SysAnnouncement>(0, pageSize);sysMsgList = sysAnnouncementService.querySysCementPageByUserId(sysMsgList,userId,"2");//系统消息Page<SysAnnouncement> todealMsgList = new Page<SysAnnouncement>(0, pageSize);todealMsgList = sysAnnouncementService.querySysCementPageByUserId(todealMsgList,userId,"3");//待办消息Map<String,Object> sysMsgMap = new HashMap<String, Object>();sysMsgMap.put("sysMsgList", sysMsgList.getRecords());sysMsgMap.put("sysMsgTotal", sysMsgList.getTotal());sysMsgMap.put("anntMsgList", anntMsgList.getRecords());sysMsgMap.put("anntMsgTotal", anntMsgList.getTotal());sysMsgMap.put("todealMsgList", todealMsgList.getRecords());sysMsgMap.put("todealMsgTotal", todealMsgList.getTotal());result.setSuccess(true);result.setResult(sysMsgMap);return result;}

2、前端

HeaderNotice.vue 文件

获取系统消息里增加待办内容

 

同时显示的地方做调整,包括样式与内容显示

 

消息通知弹出

 具体代码如下:

<template><a-popovertrigger="click"placement="bottomRight":autoAdjustOverflow="true":arrowPointAtCenter="true"overlayClassName="header-notice-wrapper"@visibleChange="handleHoverChange":overlayStyle="{ width: '400px', top: '50px' }"><template slot="content"><a-spin :spinning="loadding"><a-tabs><a-tab-pane :tab="msg1Title" key="1"><!--<a-list><a-list-item><a-list-item-meta title="你收到了 14 份新周报" description="一年前"><a-avatar style="background-color: white" slot="avatar" src="https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png"/></a-list-item-meta></a-list-item><a-list-item><a-list-item-meta title="你推荐的 IT大牛 已通过第三轮面试" description="一年前"><a-avatar style="background-color: white" slot="avatar" src="https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png"/></a-list-item-meta></a-list-item><a-list-item><a-list-item-meta title="这种模板可以区分多种通知类型" description="一年前"><a-avatar style="background-color: white" slot="avatar" src="https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png"/></a-list-item-meta></a-list-item></a-list>--><a-list><a-list-item :key="index" v-for="(record, index) in announcement1"><div style="margin-left: 5%;width: 50%"><p><a @click="showAnnouncement(record)">{{ record.titile }}</a></p><p style="color: rgba(0,0,0,.45);margin-bottom: 0px">{{ record.createTime }} 发布</p></div><div style="text-align: right"><a-tag @click="showAnnouncement(record)" v-if="record.priority === 'L'" color="blue">一般消息</a-tag><a-tag @click="showAnnouncement(record)" v-if="record.priority === 'M'" color="orange">重要消息</a-tag><a-tag @click="showAnnouncement(record)" v-if="record.priority === 'H'" color="red">紧急消息</a-tag></div></a-list-item><div style="margin-top: 5px;text-align: center"><a-button @click="toMyAnnouncement()" type="dashed" block>查看更多</a-button></div></a-list></a-tab-pane><a-tab-pane :tab="msg2Title" key="2"><a-list><a-list-item :key="index" v-for="(record, index) in announcement2"><div style="margin-left: 5%;width: 50%"><p><a @click="showAnnouncement(record)">{{ record.titile }}</a></p><p style="color: rgba(0,0,0,.45);margin-bottom: 0px">{{ record.createTime }} 发布</p></div><div style="text-align: right"><a-tag @click="showAnnouncement(record)" v-if="record.priority === 'L'" color="blue">一般消息</a-tag><a-tag @click="showAnnouncement(record)" v-if="record.priority === 'M'" color="orange">重要消息</a-tag><a-tag @click="showAnnouncement(record)" v-if="record.priority === 'H'" color="red">紧急消息</a-tag></div></a-list-item><div style="margin-top: 5px;text-align: center"><a-button @click="toMyAnnouncement()" type="dashed" block>查看更多</a-button></div></a-list></a-tab-pane><a-tab-pane :tab="msg3Title" key="3"><a-list><a-list-item :key="index" v-for="(record, index) in announcement3"><div style="margin-left: 5%;width: 50%"><p><a @click="showAnnouncement(record)">{{ record.titile }}</a></p><p style="color: rgba(0,0,0,.45);margin-bottom: 0px">{{ record.createTime }} 发布</p></div><div style="text-align: right"><a-tag @click="showAnnouncement(record)" v-if="record.priority === 'L'" color="blue">一般消息</a-tag><a-tag @click="showAnnouncement(record)" v-if="record.priority === 'M'" color="orange">重要消息</a-tag><a-tag @click="showAnnouncement(record)" v-if="record.priority === 'H'" color="red">紧急消息</a-tag></div></a-list-item><div style="margin-top: 5px;text-align: center"><a-button @click="toMyAnnouncement()" type="dashed" block>查看更多</a-button></div></a-list></a-tab-pane></a-tabs></a-spin></template><span @click="fetchNotice" class="header-notice"><a-badge :count="msgTotal"><a-icon style="font-size: 16px; padding: 4px" type="bell" /></a-badge></span><show-announcement ref="ShowAnnouncement" @ok="modalFormOk"></show-announcement><dynamic-notice ref="showDynamNotice" :path="openPath" :formData="formData"/></a-popover>
</template><script>import { getAction,putAction } from '@/api/manage'import ShowAnnouncement from './ShowAnnouncement'import store from '@/store/'import DynamicNotice from './DynamicNotice'export default {name: "HeaderNotice",components: {DynamicNotice,ShowAnnouncement,},data () {return {loadding: false,url:{listCementByUser:"/sys/annountCement/listByUser",editCementSend:"/sys/sysAnnouncementSend/editByAnntIdAndUserId",queryById:"/sys/annountCement/queryById",},hovered: false,announcement1:[],announcement2:[],announcement3:[],msg1Count:"0",msg2Count:"0",msg3Count:"0",msg1Title:"通知(0)",msg2Title:"",msg3Title:"",stopTimer:false,websock: null,lockReconnect:false,heartCheck:null,formData:{},openPath:''}},computed:{msgTotal () {return parseInt(this.msg1Count)+parseInt(this.msg2Count)+parseInt(this.msg3Count);}},mounted() {this.loadData();//this.timerFun();this.initWebSocket();// this.heartCheckFun();},destroyed: function () { // 离开页面生命周期函数this.websocketOnclose();},methods: {timerFun() {this.stopTimer = false;let myTimer = setInterval(()=>{// 停止定时器if (this.stopTimer == true) {clearInterval(myTimer);return;}this.loadData()},6000)},loadData (){try {// 获取系统消息getAction(this.url.listCementByUser).then((res) => {if (res.success) {this.announcement1 = res.result.anntMsgList;this.msg1Count = res.result.anntMsgTotal;this.msg1Title = "通知(" + res.result.anntMsgTotal + ")";this.announcement2 = res.result.sysMsgList;this.msg2Count = res.result.sysMsgTotal;this.msg2Title = "系统消息(" + res.result.sysMsgTotal + ")";this.announcement3 = res.result.todealMsgList;this.msg3Count = res.result.todealMsgTotal;this.msg3Title = "待办消息(" + res.result.todealMsgTotal + ")";}}).catch(error => {console.log("系统消息通知异常",error);//这行打印permissionName is undefinedthis.stopTimer = true;console.log("清理timer");});} catch (err) {this.stopTimer = true;console.log("通知异常",err);}},fetchNotice () {if (this.loadding) {this.loadding = falsereturn}this.loadding = truesetTimeout(() => {this.loadding = false}, 200)},showAnnouncement(record){putAction(this.url.editCementSend,{anntId:record.id}).then((res)=>{if(res.success){this.loadData();}});this.hovered = false;if(record.openType==='component'){this.openPath = record.openPage;this.formData = {id:record.busId};this.$refs.showDynamNotice.detail(record.openPage);}else{this.$refs.ShowAnnouncement.detail(record);}},toMyAnnouncement(){this.$router.push({path: '/isps/userAnnouncement'});},modalFormOk(){},handleHoverChange (visible) {this.hovered = visible;},initWebSocket: function () {// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于httpsvar userId = store.getters.userInfo.id;var url = window._CONFIG['domianURL'].replace("https://","wss://").replace("http://","ws://")+"/websocket/"+userId;//console.log("url=",url);this.websock = new WebSocket(url);this.websock.onopen = this.websocketOnopen;this.websock.onerror = this.websocketOnerror;this.websock.onmessage = this.websocketOnmessage;this.websock.onclose = this.websocketOnclose;},websocketOnopen: function () {console.log("WebSocket连接成功");//心跳检测重置//this.heartCheck.reset().start();},websocketOnerror: function (e) {console.log("WebSocket连接发生错误");this.reconnect();},websocketOnmessage: function (e) {console.log("-----接收消息-------",e.data);var data = eval("(" + e.data + ")"); //解析对象if(data.cmd == "topic"){//系统通知this.loadData();this.$notification.open({  //websocket消息通知弹出message: 'websocket消息通知',description: data.msgTxt,style: {width: '600px',marginLeft: `${335 - 600}px`,},});}else if(data.cmd == "user"){//用户消息this.loadData();this.$notification.open({message: 'websocket消息通知',description: data.msgTxt,style: {width: '600px',marginLeft: `${335 - 600}px`,},});}//心跳检测重置//this.heartCheck.reset().start();},websocketOnclose: function (e) {console.log("connection closed (" + e + ")");if(e){console.log("connection closed (" + e.code + ")");}this.reconnect();},websocketSend(text) { // 数据发送try {this.websock.send(text);} catch (err) {console.log("send failed (" + err.code + ")");}},openNotification (data) {var text = data.msgTxt;const key = `open${Date.now()}`;this.$notification.open({message: '消息提醒',placement:'bottomRight',description: text,key,btn: (h)=>{return h('a-button', {props: {type: 'primary',size: 'small',},on: {click: () => this.showDetail(key,data)}}, '查看详情')},});},reconnect() {var that = this;if(that.lockReconnect) return;that.lockReconnect = true;//没连接上会一直重连,设置延迟避免请求过多setTimeout(function () {console.info("尝试重连...");that.initWebSocket();that.lockReconnect = false;}, 5000);},heartCheckFun(){var that = this;//心跳检测,每20s心跳一次that.heartCheck = {timeout: 20000,timeoutObj: null,serverTimeoutObj: null,reset: function(){clearTimeout(this.timeoutObj);//clearTimeout(this.serverTimeoutObj);return this;},start: function(){var self = this;this.timeoutObj = setTimeout(function(){//这里发送一个心跳,后端收到后,返回一个心跳消息,//onmessage拿到返回的心跳就说明连接正常that.websocketSend("HeartBeat");console.info("客户端发送心跳");//self.serverTimeoutObj = setTimeout(function(){//如果超过一定时间还没重置,说明后端主动断开了//  that.websock.close();//如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次//}, self.timeout)}, this.timeout)}}},showDetail(key,data){this.$notification.close(key);var id = data.msgId;getAction(this.url.queryById,{id:id}).then((res) => {if (res.success) {var record = res.result;this.showAnnouncement(record);}})},}}
</script><style lang="css">.header-notice-wrapper {top: 50px !important;}
</style>
<style lang="less" scoped>.header-notice{display: inline-block;transition: all 0.3s;span {vertical-align: initial;}}
</style>

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

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

相关文章

由小波变换模极大值重建信号

给定信号&#xff0c; 令小波变换的尺度 则x(t)的二进小波变换为 令为取模极大值时的横坐标&#xff0c;那么就是模极大值。 目标是由坐标、模极大值及最后一级的低频分量重建信号x(t) 为了重建x(t)&#xff0c;假定有一信号集合h(t)&#xff0c;该集合中信号的小波变换和x(…

打印出二进制的奇数位和偶数位

void print(int a) {int i0;printf("奇数位&#xff1a;");for(i30;i>0;i-2){printf("%d ",(a>>i)&1);}printf("\n");printf("偶数位&#xff1a;");for(i31;i>1;i-2){printf("%d ",(a>>i)&1);} …

Linux MQTT智能家居(温度,湿度,环境监测,摄像头等界面布局设置)

文章目录 前言一、温度湿度曲线布局二、环境监测界面布局三、摄像头界面布局总结 前言 本篇文章来完成另外三个界面的布局设置。 这里会使用到 feiyangqingyun的一些控件库。 一、温度湿度曲线布局 TempHumtiy.h: #ifndef TEMPHUMTIY_H #define TEMPHUMTIY_H#include <…

使用Python批量将Word文件转为PDF文件

说明&#xff1a;在使用Minio服务器时&#xff0c;无法对word文件预览&#xff0c;如果有需要的话&#xff0c;可以将word文件转为pdf文件&#xff0c;再存储到Minio中&#xff0c;本文介绍如何批量将word文件&#xff0c;转为pdf格式的文件&#xff1b; 安装库 首先&#xff…

Python系统学习1-9-类一之类语法

一、类之初印象 1、类就是空表格&#xff0c;将变量&#xff08;列名&#xff09;和函数&#xff08;行为&#xff09;结合起来 2、创建对象&#xff0c;表达具体行 3、创建类就是创建数据的模板 --操作数据时有提示 --还能再组合数据的行为 --结构更加清晰 4、类的内存分配…

vue项目根据word模版导出word文件

一、安装依赖 //1、docxtemplaternpm install docxtemplater pizzip -S//2、jszip-utilsnpm install jszip-utils -S//3、pizzipnpm install pizzip -S//4、FileSaver npm install file-saver --save二、创建word模版 也就是编辑一个word文档&#xff0c;文档中需要动态取值的…

【JAVA】数组练习

⭐ 作者&#xff1a;小胡_不糊涂 &#x1f331; 作者主页&#xff1a;小胡_不糊涂的个人主页 &#x1f4c0; 收录专栏&#xff1a;浅谈Java &#x1f496; 持续更文&#xff0c;关注博主少走弯路&#xff0c;谢谢大家支持 &#x1f496; 数组练习 1. 数组转字符串2. 数组拷贝3.…

在vue中使用swiper轮播图(搭配watch和$nextTick())

在组件中使用轮播图展示图片信息&#xff1a; 1.下载swiper,5版本为稳定版本 cnpm install swiper5 2.在组件中引入swiper包和对应样式&#xff0c;若多组件使用swiper&#xff0c;可以把swiper引入到main.js入口文件中&#xff1a; import swiper/css/swiper.css //引入swipe…

SpringBoot系列---【SpringBoot在多个profiles环境中自由切换】

SpringBoot在多个profiles环境中自由切换 1.在resource目录下新建dev&#xff0c;prod两个目录&#xff0c;并分别把dev环境的配置文件和prod环境的配置文件放到对应目录下&#xff0c;可以在配置文件中指定激活的配置文件&#xff0c;也可以默认不指定。 2.在pom.xml中最后位置…

07微服务的事务管理机制

一句话导读 在单体应用程序中&#xff0c;事务通常是在单个数据库或单个操作系统中管理的&#xff0c;而在微服务架构中&#xff0c;事务需要跨越多个服务和数据库&#xff0c;这就使得事务管理变得更加复杂和困难。 目录 一句话导读 一、微服务事务管理的定义和意义 二、微…

Layui列表表头去掉复选框改为选择

效果&#xff1a; 代码&#xff1a; // 表头复选框去掉改为选择 $(".layui-table th[data-field"0"] .layui-table-cell").html("<span>选择</span>");

做好以下几点,可以让我们延长周末体验感,好好放松!!!

工作以后常常容易感到疲于奔命&#xff0c;让我们找到适合自己方式&#xff0c;来让我们度过一个充实放松的周末! 方向一&#xff1a;分享你周末的时间规划 我们可以把每个月当做一个周期&#xff0c;制定一个简单的计划&#xff0c;如&#xff1a;第一周&#xff0c;锻炼身体…

基于Prometheus监控Kubernetes集群

目录 一、环境准备 1.1、主机初始化配置 1.2、部署docker环境 二、部署kubernetes集群 2.1、组件介绍 2.2、配置阿里云yum源 2.3、安装kubelet kubeadm kubectl 2.4、配置init-config.yaml 2.5、安装master节点 2.6、安装node节点 2.7、安装flannel、cni 2.8、部署测…

低成本无刷高速吹风机单片机方案

高速吹风机的转速一般是普通吹风机的5倍左右。一般来说&#xff0c;吹风机的电机转速一般为2-3万转/分钟&#xff0c;而高速吹风机的电机转速一般为10万转/分钟左右。高转速增加了高风速。一般来说&#xff0c;吹风机的风力只有12-17米/秒&#xff0c;而高速吹风机的风力可以达…

使用Docker搭建MySQL主从复制(一主一从)

Docker安装MySQL docker pull mysql:5.7 docker images mysql安装步骤 1.新建主服务器容器实例3307 docker run -p 3307:3306 --name mysql-master -v /usr/local/docker/mysql5.7/data/mysql-master/logs:/var/log/mysql -v /usr/local/docker/mysql5.7/data/mysql-master/…

cve-2016-7193:wwlib 模块堆数据结构溢出

简介 漏洞编号&#xff1a;cve-2016-7193漏洞类型&#xff1a;堆溢出软件名称&#xff1a;Office模块名称&#xff1a;wwlib历史漏洞&#xff1a;较多影响的版本 攻击利用&#xff1a;APT 攻击利器-Word 漏洞 CVE-2016-7193 原理揭秘 操作环境 系统&#xff1a;Win10 1607软…

【Docker报错】docker拉取镜像时报错:no such host

报错信息 [rootSoft soft]# docker pull mysql Using default tag: latest Error response from daemon: Head "https://registry-1.docker.io/v2/library/mysql/manifests/latest": dial tcp: lookup registry-1.docker.io on 192.168.80.2:53: no such host解决方法…

3D模型格式转换工具如何与Parasolid集成?

概述 HOOPS Exchange包括一个 Parasolid 连接器&#xff0c;它允许 Parasolid 开发人员轻松地将 CAD 数据导入到活动的 Parasolid 会话中。如果源数据基于 Parasolid&#xff08;NX、Solid Edge 或 SolidWorks&#xff09;&#xff0c;则数据将按原样导入。 这意味着您可以假…

主数据管理案例-某政务

1、 背景介绍及难点分析 近年来&#xff0c;我国在大数据发展方面持续发力&#xff0c;取得了明显成效。但也要看到&#xff0c;目前我国大数据发展还存在“孤岛化”“碎片化”等问题&#xff0c;无序参与过度与创新参与不足并存&#xff0c;导致大数据资源配置统筹不&#xff…

【C++】list容器

1.list基本概念 2.list构造函数 #include <iostream> using namespace std;#include<list> //链表list容器构造函数//输出list链表 void printList(const list<int>& L) {for (list<int>::const_iterator it L.begin(); it ! L.end(); it){cout &…