From 0f18d973e747ce8e928489d2497bbd417bdbee8b Mon Sep 17 00:00:00 2001 From: dyy <807692433@qq.com> Date: Fri, 24 Nov 2023 15:25:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=85=AC=E5=91=8A=E4=B8=8B?= =?UTF-8?q?=E5=8F=91=E6=B7=BB=E5=8A=A0=E4=B8=AA=E4=BA=BA=20=E6=9C=AA?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DTListController.cs | 38 ++++----- .../Controllers/NoticeController.cs | 83 +++++++++++-------- .../LR_OAModule/Views/Notice/Form.cshtml | 14 ++-- .../Areas/LR_OAModule/Views/Notice/Form.js | 1 + .../UserRelation/UserRelationBLL.cs | 24 ++++++ .../UserRelation/UserRelationIBLL.cs | 6 ++ .../UserRelation/UserRelationService.cs | 28 +++++++ .../Learun.Application.OA/News/NewsEntity.cs | 17 +++- .../NodeMethod/OA_NewsMethod.cs | 2 +- 9 files changed, 151 insertions(+), 62 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/DTListController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/DTListController.cs index 6dd7932ba..d554f284a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/DTListController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/DTListController.cs @@ -65,7 +65,7 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers Pagination paginationobj = pagination.ToObject(); var data = dTListIBLL.GetPageList(paginationobj, queryJson); - + if (paginationobj == null) { return JsonResult(data); @@ -200,11 +200,20 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers dtnew = reqDataTable.Clone(); for (int i = 0; i < reqDataTable.Rows.Count; i++) { - if (reqDataTable.Rows[i]["F_SendPostId"] != null && reqDataTable.Rows[i]["F_SendPostId"].ToString() != "") + if (reqDataTable.Rows[i]["ReceiverUserId"] != null && reqDataTable.Rows[i]["ReceiverUserId"].ToString() != "") + { + if (reqDataTable.Rows[i]["ReceiverUserId"].ToString().Contains(loginUserInfo.userId)) + { + //todo:需要继续验证岗位和部门,必须三者都一致才行,否则后下角消息通知和桌面通知不一致???测试人为admin; + if (dtnew.Rows.Count < 5) + dtnew.Rows.Add(reqDataTable.Rows[i].ItemArray); + } + } + else { - if (!string.IsNullOrEmpty(loginUserInfo.postIds)) + if (reqDataTable.Rows[i]["F_SendPostId"] != null && reqDataTable.Rows[i]["F_SendPostId"].ToString() != "") { - if (loginUserInfo.postIds.Contains(",")) + if (!string.IsNullOrEmpty(loginUserInfo.postIds)) { foreach (var postid in loginUserInfo.postIds.Split(',')) { @@ -219,33 +228,24 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers } } } - else + } + else + { + if (reqDataTable.Rows[i]["F_SendDeptId"] != null && reqDataTable.Rows[i]["F_SendDeptId"].ToString() != "") { - if (reqDataTable.Rows[i]["F_SendPostId"].ToString().Contains(loginUserInfo.postIds)) + if (reqDataTable.Rows[i]["F_SendDeptId"].ToString().Contains(loginUserInfo.departmentId)) { if (dtnew.Rows.Count < 5) dtnew.Rows.Add(reqDataTable.Rows[i].ItemArray); } } - } - } - else - { - if (reqDataTable.Rows[i]["F_SendDeptId"] != null && reqDataTable.Rows[i]["F_SendDeptId"].ToString() != "") - { - if (reqDataTable.Rows[i]["F_SendDeptId"].ToString().Contains(loginUserInfo.departmentId)) + else { if (dtnew.Rows.Count < 5) dtnew.Rows.Add(reqDataTable.Rows[i].ItemArray); } } - else - { - if (dtnew.Rows.Count < 5) - dtnew.Rows.Add(reqDataTable.Rows[i].ItemArray); - } } - } var jsonData = new { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs index 6cb224487..aac3c8c58 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs @@ -366,6 +366,10 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers { entity.F_NewsContent = WebHelper.HtmlEncode(entity.F_NewsContent); noticeIBLL.SaveFormAndSubmit(keyValue, entity); + if (!string.IsNullOrEmpty(keyValue)) + { + entity = noticeIBLL.GetEntity(keyValue); + } //推送通知 //读取信息推送管理-通知公告推送(01)的配置 var informationPushEntity = sys_InformationPushIBLL.GetEntityByPushItem("01"); @@ -390,60 +394,54 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers } Task DoWeixinPush(NewsEntity entity) { - //微信推送 try { var allteacherlist = userIbll.GetAllList().Where(m => m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师"); - var userralationlist = userRelationIBLL.GetUserIdList("2"); + var userralationlist = userRelationIBLL.GetUserIdListByCategory("2"); var needpostuserlist = new List(); - if (!string.IsNullOrEmpty(entity.F_SendDeptId)) + //接收部门,下的接收岗位,下的接收人,才是需要发送消息的用户。 + if (!string.IsNullOrEmpty(entity.F_SendDeptId))//部门 { - if (!entity.F_SendDeptId.Contains(",")) + foreach (var senddeptid in entity.F_SendDeptId.Split(',')) { - var departteacherlist = allteacherlist.Where(m => entity.F_SendDeptId == m.F_DepartmentId); + var departteacherlist = allteacherlist.Where(m => senddeptid == m.F_DepartmentId); needpostuserlist.AddRange(departteacherlist.ToList()); - if (!string.IsNullOrEmpty(entity.F_SendPostId)) + } + if (!string.IsNullOrEmpty(entity.F_SendPostId))//岗位 + { + var newpostuserlist = new List(); + foreach (var uuitem in needpostuserlist.Distinct()) { - var newpostuserlist = new List(); - foreach (var uuitem in needpostuserlist) + var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId)); + if (postids > 0) { - var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId)); - if (postids > 0) - { - newpostuserlist.Add(uuitem); - } + newpostuserlist.Add(uuitem); } + } + if (!string.IsNullOrEmpty(entity.ReceiverUserId))//人 + { + var intersectUserIdList = newpostuserlist.Select(x => x.F_UserId).Intersect(entity.ReceiverUserId.Split(',')); + needpostuserlist = newpostuserlist.Where(x => intersectUserIdList.Contains(x.F_UserId)).ToList(); + } + else + { needpostuserlist = newpostuserlist; } } else { - foreach (var senddeptid in entity.F_SendDeptId.Split(',')) + if (!string.IsNullOrEmpty(entity.ReceiverUserId))//人 { - var departteacherlist = allteacherlist.Where(m => senddeptid == m.F_DepartmentId); - needpostuserlist.AddRange(departteacherlist.ToList()); - if (!string.IsNullOrEmpty(entity.F_SendPostId)) - { - var newpostuserlist = new List(); - foreach (var uuitem in needpostuserlist) - { - var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId)); - if (postids > 0) - { - newpostuserlist.Add(uuitem); - } - } - needpostuserlist = newpostuserlist; - } + var intersectUserIdList = needpostuserlist.Select(x => x.F_UserId).Intersect(entity.ReceiverUserId.Split(',')); + needpostuserlist = needpostuserlist.Where(x => intersectUserIdList.Contains(x.F_UserId)).ToList(); } } } else { - if (!string.IsNullOrEmpty(entity.F_SendPostId)) + if (!string.IsNullOrEmpty(entity.F_SendPostId))//岗位 { - //岗位下发 var newpostuserlist = new List(); foreach (var uuitem in allteacherlist) { @@ -453,14 +451,31 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers newpostuserlist.Add(uuitem); } } - needpostuserlist = newpostuserlist; + if (!string.IsNullOrEmpty(entity.ReceiverUserId))//人 + { + var intersectUserIdList = newpostuserlist.Select(x => x.F_UserId).Intersect(entity.ReceiverUserId.Split(',')); + needpostuserlist = newpostuserlist.Where(x => intersectUserIdList.Contains(x.F_UserId)).ToList(); + } + else + { + needpostuserlist = newpostuserlist; + } } else { - //全员下发 - needpostuserlist = allteacherlist.ToList(); + if (!string.IsNullOrEmpty(entity.ReceiverUserId))//人 + { + var intersectUserIdList = allteacherlist.Select(x => x.F_UserId).Intersect(entity.ReceiverUserId.Split(',')); + needpostuserlist = allteacherlist.Where(x => intersectUserIdList.Contains(x.F_UserId)).ToList(); + } + else + { + //全员下发 + needpostuserlist = allteacherlist.ToList(); + } } } + //微信推送 PushWeixin(needpostuserlist, entity.F_FullHead); //消息提醒表 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.cshtml index 0bb56eee5..4d1eb9d60 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.cshtml @@ -24,19 +24,23 @@
来源地址
-
+
接收部门
-
+
接收岗位
-
+ +
+
接收人
+
+
下发飞星
-
+
标题图片
@@ -45,7 +49,7 @@
公告内容
@**@ + *@
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.js index 2ad166355..4cb38e3bc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.js @@ -28,6 +28,7 @@ var bootstrap = function ($, learun) { $('#F_IsSendFX').lrDataItemSelect({ code: 'YesOrNoBit' }); $('#F_SendDeptId').lrDepartmentSelect({ type: 'treemultiple' }); $('#F_SendPostId').lrPostSelect({ type: 'treemultiple' }); + $('#ReceiverUserId').lrUserSelect({ type: '1' }); //内容编辑器 ue = UE.getEditor('editor'); }, diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationBLL.cs index 4a7153c0b..54cd85a22 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationBLL.cs @@ -171,6 +171,30 @@ namespace Learun.Application.Base.AuthorizeModule } } } + + /// + /// 获取用户主键列表信息 + /// + /// 分类:1-角色2-岗位 + /// + public IEnumerable GetUserIdListByCategory(string category) + { + try + { + return userRelationService.GetUserIdListByCategory(category); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationIBLL.cs index 36bde65fe..7f1701005 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationIBLL.cs @@ -43,6 +43,12 @@ namespace Learun.Application.Base.AuthorizeModule IEnumerable GetUserIdList(List objectIdList); IEnumerable GetEntityNameByUserId(string keyValue); + /// + /// 获取用户主键列表信息 + /// + /// 分类:1-角色2-岗位 + /// + IEnumerable GetUserIdListByCategory(string category); #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationService.cs index cb22bf055..93b814ab8 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Base/AuthorizeModule/UserRelation/UserRelationService.cs @@ -154,6 +154,34 @@ namespace Learun.Application.Base.AuthorizeModule } } } + + /// + /// 获取用户主键列表信息 + /// + /// 分类:1-角色2-岗位 + /// + public IEnumerable GetUserIdListByCategory(string category) + { + try + { + var strSql = new StringBuilder(); + strSql.Append(" SELECT "); + strSql.Append(fieldSql); + strSql.Append(" FROM LR_Base_UserRelation t WHERE t.F_Category = @category"); + return this.BaseRepository().FindList(strSql.ToString(), new { category = category }); + } + 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.OA/News/NewsEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs index bf6aa1937..e62142570 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs @@ -174,13 +174,24 @@ namespace Learun.Application.OA [Column("F_NEWSIMAGE")] public string F_NewsImage { get; set; } - + /// + /// 接收部门 + /// [Column("F_SENDDEPTID")] public string F_SendDeptId { get; set; } - + /// + /// 接收岗位 + /// [Column("F_SENDPOSTID")] public string F_SendPostId { get; set; } - + /// + /// 接收人 + /// + [Column("RECEIVERUSERID")] + public string ReceiverUserId { get; set; } + /// + /// 下发飞星 + /// [Column("F_ISSENDFX")] public bool? F_IsSendFX { get; set; } /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/NodeMethod/OA_NewsMethod.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/NodeMethod/OA_NewsMethod.cs index 8afd64804..0857ee0c4 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/NodeMethod/OA_NewsMethod.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/NodeMethod/OA_NewsMethod.cs @@ -68,7 +68,7 @@ namespace Learun.Application.WorkFlow { var allteacherlist = userIbll.GetAllList().Where(m => m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师"); - var userralationlist = userRelationIBLL.GetUserIdList("2"); + var userralationlist = userRelationIBLL.GetUserIdListByCategory("2"); var needpostuserlist = new List(); if (!string.IsNullOrEmpty(entity.F_SendDeptId)) {