記錄一下基于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.pswp.cn/news/40970.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/40970.shtml
英文地址,請注明出處:http://en.pswp.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);} …

人臉圖像處理

1,人臉圖像與特征基礎 人臉圖像的特點 規律性: 人的兩只眼睛總是對稱分布在人臉的上半部分,鼻子和嘴唇中心點的連線基本與兩眼之間的連線垂直,嘴絕對不會超過眼鏡的兩端點(雙眼為d,則雙眼到嘴巴的垂直距離一般在0.8-1.25) 唯一性 非侵擾與便利性 可擴展性 人臉圖像的應用 身份…

Linux MQTT智能家居(溫度,濕度,環境監測,攝像頭等界面布局設置)

文章目錄 前言一、溫度濕度曲線布局二、環境監測界面布局三、攝像頭界面布局總結 前言 本篇文章來完成另外三個界面的布局設置。 這里會使用到 feiyangqingyun的一些控件庫。 一、溫度濕度曲線布局 TempHumtiy.h: #ifndef TEMPHUMTIY_H #define TEMPHUMTIY_H#include <…

pprof 三把刀

pprof 三把刀 看內存 go tool pprof http://127.0.0.1:6060/debug/pprof/heap?seconds30 看cpu go tool pprof http://127.0.0.1:6060/debug/pprof/profile?seconds30 看協程 go tool pprof http://localhost:6060/debug/pprof/goroutine 端口是自定義的&#xff0c;看看…

Golang原生實現JA3指紋修改,并支持Proxy代理

起因 抓取某個HTTPS網站的時候 開啟charles代理能夠抓取成功,關閉被風控 通過檢測,懷疑可能是tls的時候有區別 嘗試 golang的http中,Transport.TLSClientConfig是可以自定義設置的 但起初通過隨意設置并不能繞過風控 困難 使用golang的http客戶端,修改DialTLSContext函數的…

使用Python批量將Word文件轉為PDF文件

說明&#xff1a;在使用Minio服務器時&#xff0c;無法對word文件預覽&#xff0c;如果有需要的話&#xff0c;可以將word文件轉為pdf文件&#xff0c;再存儲到Minio中&#xff0c;本文介紹如何批量將word文件&#xff0c;轉為pdf格式的文件&#xff1b; 安裝庫 首先&#xff…

神經網絡基礎-神經網絡補充概念-12-向量化邏輯回歸的梯度輸出

代碼實現 import numpy as npdef sigmoid(z):return 1 / (1 np.exp(-z))def compute_loss(X, y, theta):m len(y)h sigmoid(X.dot(theta))loss (-1/m) * np.sum(y * np.log(h) (1 - y) * np.log(1 - h))return lossdef compute_gradient(X, y, theta):m len(y)h sigmoi…

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.…

arm-linux-gnueabihf-g++ gcc編譯、優化命令 匯總

gcc優化選項&#xff0c;可在編譯時間&#xff0c;目標文件長度&#xff0c;執行效率三個維度&#xff0c;進行不同的取舍和平衡。 gcc 常用編譯選項 arm-linux-gnueabihf-g -O3 -marcharmv7-a -mcpucortex-a9 -ftree-vectorize -mfpuneon -mfpuvfpv3-fp16 -mfloat-abihard -…

js的FileSaver.saveAs()方法:監聽保存進度,進度條等方法

在使用FileSaver.saveAs保存表格到本地時&#xff0c;如果想要獲取導出/保存進度可以如下操作 FileSaver.js的saveAs()方法是一個異步操作&#xff0c;它將文件保存到用戶設備上。在調用saveAs()方法后&#xff0c;可以通過使用回調函數、Promise、或監聽相關事件來確定saveAs(…

在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、部署測…

Go 1.21新增的內置函數(built-in functions)詳解

Go 1.21新增的內置函數分別是 min、max 和 clear&#xff0c;接下來看下這幾個函數的用途和使用示例。 在編程過程中&#xff0c;需要知道一組值中的最大或最小值的場景是很常見的&#xff0c;比如排序、統計等場景。之前都需要自己寫代碼來實現這個功能&#xff0c;現在 Go 1…