From cbf1afd26657c90e2bb5b7a7de8c49a1a569bb6c Mon Sep 17 00:00:00 2001 From: hwh2023 <598694955@qq.com> Date: Sun, 10 Sep 2023 19:32:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=95=B0=E9=87=8F=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/MessageRindController.cs | 27 ++++++++++- .../Controllers/HomeController.cs | 4 +- .../LR_OA_NewsRead/LR_OA_NewsReadBLL.cs | 23 ++++++++++ .../LR_OA_NewsRead/LR_OA_NewsReadService.cs | 26 +++++++++++ .../MessageRind/MessageRindService.cs | 46 +++++++++++++++++++ 5 files changed, 123 insertions(+), 3 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/MessageRindController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/MessageRindController.cs index b10907083..a311c1cb5 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/MessageRindController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/MessageRindController.cs @@ -163,7 +163,8 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers } } } - var readnewslist = newsIBLL.GetList("", userinfo.userId).Where(m => !string.IsNullOrEmpty(m.RNewsId)).Select(m => m.F_NewsId); + //var readnewslist = newsIBLL.GetList("", userinfo.userId).Where(m => !string.IsNullOrEmpty(m.RNewsId)).Select(m => m.F_NewsId); + var readnewslist = readbll.GetListOfSelf().Select(m => m.NewsId).ToList(); int UnreadNews = outnewslist.Count(m => !readnewslist.Contains(m.F_NewsId)); paginationobj.sidx = "SendTime"; int UnreadFile = sys_ReceiveFileIBLL.GetPageListBySenderId(userinfo.userId).Count(); @@ -184,6 +185,7 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers }; return Success(data); } + private static LR_OA_NewsReadBLL readbll = new LR_OA_NewsReadBLL(); /// /// 获取未读的消息 /// @@ -338,11 +340,32 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers else { messageRindIBLL.SaveReadSigns(keyValue); + + + //var loginUserInfo = LoginUserInfo.Get(); + + //var model = messageRindIBLL.GetMessageRemindEntity(keyValue); + ////判断当前用户是否阅读当前通知公告 + //var entity = lR_OA_NewsReadIBLL.GetLR_OA_NewsReadEntityByNewsIdAndUserId(model.InstanceId, loginUserInfo.userId); + //if (entity == null) + //{ + // var lR_OA_NewsRead = new LR_OA_NewsReadEntity() + // { + // NewsId = model.InstanceId, + // RUserId = loginUserInfo.userId, + // RUserName = loginUserInfo.realName, + // RTime = DateTime.Now + // }; + // lR_OA_NewsReadIBLL.SaveEntity("", lR_OA_NewsRead); + + // //修改当前通知公告的浏览量 + // lR_OA_NewsReadIBLL.UpdateNewsPV(model.InstanceId); + //} } } return Success("保存成功!"); } - + private static LR_OA_NewsReadBLL lR_OA_NewsReadIBLL = new LR_OA_NewsReadBLL(); /// /// 更改状态为已读 /// diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs index e71d20ee8..8486ced98 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs @@ -166,13 +166,15 @@ namespace Learun.Application.Web.Controllers } } } - var readnewslist = newsIBLL.GetList("", userinfo.userId).Where(m => !string.IsNullOrEmpty(m.RNewsId)).Select(m => m.F_NewsId); + //var readnewslist = newsIBLL.GetList("", userinfo.userId).Where(m => !string.IsNullOrEmpty(m.RNewsId)).Select(m => m.F_NewsId); + var readnewslist = readbll.GetListOfSelf().Select(m => m.NewsId).ToList(); ViewBag.UnreadNews = outnewslist.Count(m => !readnewslist.Contains(m.F_NewsId)); paginationobj.sidx = "SendTime"; //ViewBag.UnreadFile = sys_ReceiveFileIBLL.GetPageListByUserId(paginationobj, "{}", userinfo.userId).Where(a => a.STypeId == 1).Count(); ViewBag.UnreadFile = sys_ReceiveFileIBLL.GetPageListBySenderId(userinfo.userId); return View(); } + private static LR_OA_NewsReadBLL readbll = new LR_OA_NewsReadBLL(); public ActionResult GoTo() { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/LR_OA_NewsRead/LR_OA_NewsReadBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/LR_OA_NewsRead/LR_OA_NewsReadBLL.cs index 6b00e69f2..3f072909b 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/LR_OA_NewsRead/LR_OA_NewsReadBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/LR_OA_NewsRead/LR_OA_NewsReadBLL.cs @@ -41,6 +41,29 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop } } } + /// + /// 获取页面显示列表数据 + /// + /// 查询参数 + /// + public IEnumerable GetListOfSelf() + { + try + { + return lR_OA_NewsReadService.GetListOfSelf(); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } /// /// 获取LR_OA_NewsRead表实体数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/LR_OA_NewsRead/LR_OA_NewsReadService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/LR_OA_NewsRead/LR_OA_NewsReadService.cs index 7ed3af3d4..56853ed83 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/LR_OA_NewsRead/LR_OA_NewsReadService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/LR_OA_NewsRead/LR_OA_NewsReadService.cs @@ -130,6 +130,32 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop } } } + + public IEnumerable GetListOfSelf() + { + try + { + var userinfo = LoginUserInfo.Get(); + var userId = userinfo.userId; + var deptId = userinfo.departmentId; + var postIds = userinfo.postIds; + var strSql = new StringBuilder(); + strSql.Append("SELECT t.NewsId,t.RUserId FROM LR_OA_NewsRead t "); + strSql.Append(" WHERE t.RUserId = '"+userinfo.userId+"' "); + return this.BaseRepository().FindList(strSql.ToString(), new { }); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/MessageRind/MessageRindService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/MessageRind/MessageRindService.cs index 98b4ffc69..9bd8832c0 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/MessageRind/MessageRindService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/MessageRind/MessageRindService.cs @@ -321,6 +321,27 @@ where t.IsRead = 0 and [Description] = '学生' and a.[state] = 7 and t.Account this.BaseRepository().ExecuteBySql(sql); } } + else if (model.TheTitle == "通知公告") + { + var userInfo = LoginUserInfo.Get(); + var existmodel = this.BaseRepository().FindEntity(c=>c.NewsId==model.InstanceId&&c.RUserId==userInfo.userId); + if (existmodel==null) + { + LR_OA_NewsReadEntity insertmodel = new LR_OA_NewsReadEntity(); + insertmodel.NewsId = model.InstanceId; + insertmodel.RUserId = userInfo.userId; + insertmodel.RUserName = userInfo.realName; + insertmodel.RTime = DateTime.Now; + //插入公告查看日志 + insertmodel.Create(); + this.BaseRepository().Insert(insertmodel); + + var readNum = this.BaseRepository().FindList(x => x.NewsId == model.InstanceId).Count(); + var strSql = "update LR_OA_News set F_PV=" + readNum + " where F_NewsId='" + model.InstanceId + "'"; + this.BaseRepository().ExecuteBySql(strSql); + } + this.BaseRepository().ExecuteBySql(sql); + } else { this.BaseRepository().ExecuteBySql(sql); @@ -347,6 +368,9 @@ where t.IsRead = 0 and [Description] = '学生' and a.[state] = 7 and t.Account { try { + var userInfo = LoginUserInfo.Get(); + string unreadnotice_sql = "select * from MessageRemind where thetitle='通知公告' and receiptid='" + userInfo.userId + "' and readsigns=0"; + var unreadnotice_ = this.BaseRepository().FindList(unreadnotice_sql).ToList(); #region 报修待处理 //查询维修通告中没有处理的id //教师报修 @@ -384,6 +408,28 @@ where t.IsRead = 0 and [Description] = '学生' and a.[state] = 7 and t.Account string sql_e = $"update MessageRemind set ReadSigns=0 where ReceiptId='{userId}' and ReadSigns<>0 and instanceid in ('" + ids_e.Replace(",", "','") + "') and TheTitle='评价通知'"; this.BaseRepository().ExecuteBySql(sql_e); } + + + foreach (var item in unreadnotice_) + { + string updatesql = $"update MessageRemind set ReadSigns=1 where MessageId='{item.MessageId}'"; + LR_OA_NewsReadEntity insertmodel = new LR_OA_NewsReadEntity(); + insertmodel.NewsId = item.InstanceId; + insertmodel.RUserId = userInfo.userId; + insertmodel.RUserName = userInfo.realName; + insertmodel.RTime = DateTime.Now; + //插入公告查看日志 + insertmodel.Create(); + this.BaseRepository().Insert(insertmodel); + + var readNum = this.BaseRepository().FindList(x => x.NewsId == item.InstanceId).Count(); + var strSql = "update LR_OA_News set F_PV=" + readNum + " where F_NewsId='" + item + "'"; + this.BaseRepository().ExecuteBySql(strSql); + + this.BaseRepository().ExecuteBySql(updatesql); + + } + } catch (Exception ex) {