This commit is contained in:
xd 2024-04-28 09:53:41 +08:00
parent 3985b78ba3
commit 115e610fbe
7 changed files with 78 additions and 21 deletions

View File

@ -137,7 +137,9 @@ public class SysNoticeController extends BaseController
{ {
String userName = getLoginUser().getUsername();//当前登陆者 String userName = getLoginUser().getUsername();//当前登陆者
String noticeType = sysNoticeUser.getNoticeType();//消息类型 String noticeType = sysNoticeUser.getNoticeType();//消息类型
List<SysNoticeUser> list = noticeService.navbarNoticeMorelist(userName,noticeType); sysNoticeUser.setCurrentUserName(userName);
sysNoticeUser.setNoticeType(noticeType);
List<SysNoticeUser> list = noticeService.navbarNoticeMorelist(sysNoticeUser);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();

View File

@ -1,9 +1,11 @@
package com.ruoyi.system.domain; package com.ruoyi.system.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
public class SysNoticeUser { public class SysNoticeUser extends BaseEntity {
private Long noticeId; private Long noticeId;
private String noticeTitle; private String noticeTitle;
@ -14,6 +16,8 @@ public class SysNoticeUser {
private String sendUser; private String sendUser;
private Date sendTime; private Date sendTime;
private String currentUserName;//当前用户
public Long getNoticeId() { public Long getNoticeId() {
return noticeId; return noticeId;
} }
@ -51,4 +55,8 @@ public class SysNoticeUser {
public void setSendTime(Date sendTime) { this.sendTime = sendTime; } public void setSendTime(Date sendTime) { this.sendTime = sendTime; }
public String getSendTimeFormat() { return new SimpleDateFormat("yyyy-MM-dd").format(sendTime); } public String getSendTimeFormat() { return new SimpleDateFormat("yyyy-MM-dd").format(sendTime); }
public String getCurrentUserName() { return currentUserName; }
public void setCurrentUserName(String currentUserName) { this.currentUserName = currentUserName; }
} }

View File

@ -70,11 +70,10 @@ public interface SysNoticeMapper
/** /**
* 导航面板 消息通知-更多 * 导航面板 消息通知-更多
* @param userName * @param sysNoticeUser
* @param noticeType
* @return * @return
*/ */
List<SysNoticeUser> navbarNoticeMorelist(@Param("userName") String userName,@Param("noticeType") String noticeType); List<SysNoticeUser> navbarNoticeMorelist(SysNoticeUser sysNoticeUser);
/** /**
* 批量插入消息-用户 中间表 * 批量插入消息-用户 中间表

View File

@ -69,11 +69,10 @@ public interface ISysNoticeService
/** /**
* 导航面板 消息通知-更多 * 导航面板 消息通知-更多
* @param userName * @param sysNoticeUser
* @param noticeType
* @return * @return
*/ */
List<SysNoticeUser> navbarNoticeMorelist(String userName, String noticeType); List<SysNoticeUser> navbarNoticeMorelist(SysNoticeUser sysNoticeUser);
/** /**
* 批量插入消息-用户 中间表 * 批量插入消息-用户 中间表

View File

@ -126,13 +126,12 @@ public class SysNoticeServiceImpl implements ISysNoticeService
/** /**
* 导航面板 消息通知-更多 * 导航面板 消息通知-更多
* @param userName * @param sysNoticeUser
* @param noticeType
* @return * @return
*/ */
@Override @Override
public List<SysNoticeUser> navbarNoticeMorelist(String userName, String noticeType) { public List<SysNoticeUser> navbarNoticeMorelist(SysNoticeUser sysNoticeUser) {
return noticeMapper.navbarNoticeMorelist(userName,noticeType); return noticeMapper.navbarNoticeMorelist(sysNoticeUser);
} }
/** /**

View File

@ -92,10 +92,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
inner join sys_user_notice b on a.notice_id = b.noticeId inner join sys_user_notice b on a.notice_id = b.noticeId
<where> <where>
and b.userId = #{userName} and b.userId = #{userName}
and CONVERT(date, a.create_time) = CONVERT(date, GETDATE()) and CONVERT(date, b.sendTime) = CONVERT(date, GETDATE())
and a.status = '0' and b.isRead = '0' and a.status = '0' and b.isRead = '0'
</where> </where>
order by create_time desc order by b.sendTime desc
</select> </select>
<select id="navbarNoticeMorelist" resultType="SysNoticeUser"> <select id="navbarNoticeMorelist" resultType="SysNoticeUser">
@ -103,12 +103,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sys_notice a from sys_notice a
inner join sys_user_notice b on a.notice_id = b.noticeId inner join sys_user_notice b on a.notice_id = b.noticeId
<where> <where>
and b.userId = #{userName} and b.userId = #{currentUserName}
and a.notice_type = #{noticeType} and a.notice_type = #{noticeType}
and CONVERT(date, a.create_time) = CONVERT(date, GETDATE())
and a.status = '0' and a.status = '0'
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and datediff(d, b.sendTime, #{params.beginTime}) <![CDATA[<=]]> 0
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and datediff(d, b.sendTime, #{params.endTime}) <![CDATA[>=]]> 0
</if>
<if test="(params.beginTime == null or params.beginTime == '') and (params.endTime == null or params.endTime == '')"><!-- 结束时间检索 -->
and CONVERT(date, b.sendTime) = CONVERT(date, GETDATE())
</if>
</where> </where>
order by create_time desc order by b.sendTime desc
</select> </select>
<insert id="insertNoticeUserBatch"> <insert id="insertNoticeUserBatch">

View File

@ -62,13 +62,31 @@
<el-dialog class="noteMore" :title="noteMoreTitle" :visible.sync="noteMoreVisible" width="780px" append-to-body> <el-dialog class="noteMore" :title="noteMoreTitle" :visible.sync="noteMoreVisible" width="780px" append-to-body>
<div class="block"> <div class="block">
<el-form :model="form" ref="queryForm" size="small" :inline="true" label-width="80px">
<el-form-item label="消息时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-timeline> <el-timeline>
<el-timeline-item :timestamp="item.date" placement="top" v-for="(item,index) in noteMore" :key="index"> <el-timeline-item :timestamp="item.date" placement="top" v-for="(item,index) in noteMore" :key="index">
<el-card v-for="(item,index) in item.data" :key="index" :style="index==0?'': 'margin-top :10px'"> <el-card v-for="(item,index) in item.data" :key="index" :style="index==0?'': 'margin-top :10px'">
<h3>{{item.noticeTitle}}</h3> <h3>{{item.noticeTitle}}</h3>
<p>{{item.sendUser}} 提交于 {{parseTime(item.sendTime, '{y}-{m}-{d} {h}:{i}:{s}')}}</p> <span>{{item.sendUser}} 提交于 {{parseTime(item.sendTime, '{y}-{m}-{d} {h}:{i}:{s}')}}</span>
<el-button class="mb5" size="mini" :style="item.isRead==0?'float :right;background-color :#ffba00;border-color: #ffba00;': 'float :right;background-color :#c0c4cc;border-color: #c0c4cc;'" type="info">{{item.isRead=='1'?'已读':'未读'}}</el-button>
<div style="width:100%;height:1px;margin:0px auto;padding:0px;overflow:hidden;background-color: #c0c4ccab"></div> <div style="width:100%;height:1px;margin:0px auto;padding:0px;overflow:hidden;background-color: #c0c4ccab"></div>
<el-link :underline="false" @click="clickNote(item)" style="color:#46a6ff;margin-top :10px">详情</el-link> <el-link :underline="false" @click="clickMoreNote(item)" style="color:#46a6ff;margin-top :10px">详情</el-link>
</el-card> </el-card>
</el-timeline-item> </el-timeline-item>
</el-timeline> </el-timeline>
@ -121,7 +139,10 @@
// //
form: {}, form: {},
// //
queryParams:{} queryParams:{},
//
dateRange: [],
} }
}, },
mounted() { mounted() {
@ -162,14 +183,35 @@
}, },
/** 显示更多消息 */ /** 显示更多消息 */
moreNote(noticeType){ moreNote(noticeType){
this.noteMore = [];
this.queryParams.noticeType = noticeType; this.queryParams.noticeType = noticeType;
navbarNoticeMorelist(this.queryParams).then(response => { navbarNoticeMorelist(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
console.log(response) console.log(response)
this.noteMoreTitle = noticeType=='1'?"系统通知消息":noticeType=='2'?"系统公告消息":"业务通知消息"; this.noteMoreTitle = noticeType=='1'?"系统通知消息":noticeType=='2'?"系统公告消息":"业务通知消息";
this.noteMoreVisible = true this.noteMoreVisible = true
this.noteMore = response this.noteMore = response
}); });
}, },
/** 搜索按钮操作 */
handleQuery() {
this.moreNote(this.queryParams.noticeType)
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.handleQuery();
},
/**获取更多消息中详情*/
clickMoreNote(data) {
getNavbarNotice(data.noticeId).then(response => {
this.form = response.data;
this.noteTitle = "消息详情"
this.noteVisible = true
this.moreNote(data.noticeType)
this.getList()
});
},
initWebSocket() { initWebSocket() {
var userName = this.$store.state.user.name; var userName = this.$store.state.user.name;