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 e1d87ec16..4ee1fb573 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 @@ -104,6 +104,16 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers { return View(); } + + /// + /// 通知公告阅读统计 + /// + /// + [HttpGet] + public ActionResult IndexStatistics() + { + return View(); + } #endregion #region 获取数据 @@ -136,6 +146,8 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers public ActionResult GetPageListForStatistics(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); + //添加通知公告应阅读人数 + noticeIBLL.SaveNewsShouldRead(); var data = noticeIBLL.GetPageListForStatistics(paginationobj, queryJson); var jsonData = new { @@ -337,7 +349,7 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers { entity.F_NewsContent = WebHelper.HtmlEncode(entity.F_NewsContent); noticeIBLL.SaveEntity(keyValue, entity); - + return Success("保存成功!"); } @@ -549,7 +561,7 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers noticeIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } - + #endregion diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/IndexStatistics.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/IndexStatistics.cshtml new file mode 100644 index 000000000..097c89a24 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/IndexStatistics.cshtml @@ -0,0 +1,46 @@ +@{ + ViewBag.Title = "通知公告"; + Layout = "~/Views/Shared/_Index.cshtml"; +} +
+
+
+
+
+
+
+
+
+
职工编号
+ +
+
+
姓名
+ +
+
+
部门
+
+
+
+
+
+ @*
+ +
+
+  查询 +
*@ +
+
+
+ +
+
+
+
+
+
+
+@Html.AppendJsFile("/Areas/LR_OAModule/Views/Notice/IndexStatistics.js") + diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/IndexStatistics.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/IndexStatistics.js new file mode 100644 index 000000000..83bea4c3e --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/IndexStatistics.js @@ -0,0 +1,90 @@ +/* + * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) + * Copyright (c) 2013-2018 北京泉江科技有限公司 + * 创建人:陈彬彬 + * 日 期:2017.07.11 + * 描 述:公告通知 + */ +var refreshGirdData; // 更新数据 +var bootstrap = function ($, learun) { + "use strict"; + var page = { + init: function () { + page.initGrid(); + page.bind(); + }, + bind: function () { + $('#multiple_condition_query').lrMultipleQuery(function (queryJson) { + page.search(queryJson); + }, 200, 400); + // 刷新 + $('#lr_refresh').on('click', function () { + location.reload(); + }); + $('#Departmentid').lrselect({ + allowSearch: true, + url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=classdata', + param: { strWhere: "1=1 " }, + value: "id", + text: "name" + }); + }, + initGrid: function () { + $('#gridtable').jfGrid({ + url: top.$.rootUrl + '/LR_OAModule/Notice/GetPageListForStatistics', + headData: [ + { label: '职工编号', name: 'F_Encode', width: 100, align: 'left' }, + { label: '姓名', name: 'F_RealName', width: 100, align: 'left' }, + { + label: '部门', name: 'F_Departmentid', width: 100, align: 'left', + formatterAsync: function (callback, value, row) { + learun.clientdata.getAsync('department', { + key: value, + callback: function (item) { + callback(item.name); + } + }); + } + }, + { label: '应阅读总次数', name: 'srnum', width: 100, align: 'left' }, + { label: '完成阅读次数', name: 'rnum', width: 100, align: 'left' }, + { + label: '完成阅读百分比', name: '', width: 100, align: 'left', + formatter: function (value, row) { + if (!!row.rnum && !!row.srnum) { + return GetPercent(row.rnum, row.srnum); + } else { + return ''; + } + } + }, + + ], + mainId: 'F_Encode', + reloadSelected: true, + isMultiselect: true, + isPage: true, + }); + page.search(); + }, + search: function (param) { + $('#gridtable').jfGridSet('reload', param); + } + }; + // 保存数据后回调刷新 + refreshGirdData = function () { + page.search(); + } + page.init(); +} + +function GetPercent(num, total) { + num = parseFloat(num); + total = parseFloat(total); + if (isNaN(num) || isNaN(total)) { + return '-'; + } + return total <= 0 ? '0%' : Math.round((num / total) * 10000) / 100.0 + '%'; +} + + diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj index 10967a5f4..cc236123a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj @@ -1519,6 +1519,7 @@ + @@ -7963,6 +7964,7 @@ + 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 0da502673..0ef92e14f 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 @@ -248,6 +248,16 @@ namespace Learun.Application.OA #endregion [NotMapped] public string F_Send { get; set; } + [NotMapped] + public string srnum { get; set; } + [NotMapped] + public string rnum { get; set; } + [NotMapped] + public string F_RealName { get; set; } + [NotMapped] + public string F_Departmentid { get; set; } + [NotMapped] + public string F_Encode { get; set; } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs index 34ccd5803..8b81ffc9e 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs @@ -60,6 +60,25 @@ namespace Learun.Application.OA } } + public void SaveNewsShouldRead() + { + try + { + noticeService.SaveNewsShouldRead(); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + /// /// 公告实体 /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs index 7ae6d0371..ef29d06a9 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs @@ -55,6 +55,7 @@ namespace Learun.Application.OA #endregion void ChangeStatusById(string keyValue, int i, string processId); + void SaveNewsShouldRead(); NewsEntity GetEntityByProcessId(string processId); void SaveFormAndSubmit(string keyValue, NewsEntity entity); } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs index 7da1c88eb..efc7ef1b6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs @@ -1,7 +1,9 @@ -using Learun.DataBase.Repository; +using Dapper; +using Learun.DataBase.Repository; using Learun.Util; using System; using System.Collections.Generic; +using System.Data; using System.Text; namespace Learun.Application.OA @@ -57,14 +59,40 @@ namespace Learun.Application.OA { try { - var misdbname = BaseRepository("CollegeMIS").getDbConnection().Database; - var basedbname = BaseRepository().getDbConnection().Database; - - var sql = - @"SELECT case when (F_SendDeptId is null or len(F_SendDeptId)=0) and (F_SendPostId is null or len(F_SendDeptId)=0) then '1' else '' end as F_Send, - F_SendDeptId,F_SendPostId,*FROM LR_OA_News t WHERE t.F_TypeId = 2 and F_DeleteMark = 0 and F_EnabledMark = 1"; - var list = BaseRepository().FindList(sql); - + var sql = new StringBuilder(@"select t.*,u.f_encode,u.f_realname,f_departmentid from ( + select t1.ruserid,isnull(srnum,0) as srnum,isnull(rnum,0) as rnum from ( + select ruserid,COUNT(1) as srnum from LR_OA_News t left join LR_OA_NewsShouldRead s on s.newsid=t.f_newsid + WHERE t.F_TypeId = 2 and t.F_DeleteMark=0 and t.F_EnabledMark=1 group by ruserid + ) t1 + left join ( + select ruserid,COUNT(1) as rnum from LR_OA_News t left join LR_OA_NewsRead r on r.newsid=t.f_newsid + WHERE t.F_TypeId = 2 and t.F_DeleteMark=0 and t.F_EnabledMark=1 and DATEDIFF(HOUR,t.F_ReleaseTime,r.RTime)<=24*7 group by ruserid + ) t2 on t1.ruserid=t2.ruserid + ) t + left join lr_base_user u on t.ruserid=u.f_userid where 1=1 + "); + var queryParam = queryJson.ToJObject(); + // 虚拟参数 + var dp = new DynamicParameters(new { }); + if (queryParam.HasValues) + { + if (!queryParam["F_Encode"].IsEmpty()) + { + dp.Add("F_Encode", "%" + queryParam["F_Encode"].ToString() + "%", DbType.String); + sql.Append(" AND u.f_encode like @F_Encode "); + } + if (!queryParam["F_RealName"].IsEmpty()) + { + dp.Add("F_RealName", "%" + queryParam["F_RealName"].ToString() + "%", DbType.String); + sql.Append(" AND u.f_realname like @F_RealName "); + } + if (!queryParam["F_Departmentid"].IsEmpty()) + { + dp.Add("F_Departmentid", queryParam["F_Departmentid"].ToString(), DbType.String); + sql.Append(" AND f_departmentid like @F_Departmentid "); + } + } + var list = this.BaseRepository().FindList(sql.ToString(), pagination); return list; } @@ -90,19 +118,17 @@ namespace Learun.Application.OA try { db.BeginTrans(); - var misdbname = BaseRepository("CollegeMIS").getDbConnection().Database; - var basedbname = BaseRepository().getDbConnection().Database; var sql = @"SELECT case when (F_SendDeptId is null or len(F_SendDeptId)=0) and (F_SendPostId is null or len(F_SendDeptId)=0) then '1' else '' end as F_Send, F_SendDeptId,F_SendPostId,* FROM LR_OA_News t WHERE t.F_TypeId = 2 and t.F_DeleteMark=0 and t.F_EnabledMark=1 - and t.f_Newsid not in (SELECT Newsid from [dbo].[LR_OA_NewsShouldRead])"; + and t.f_Newsid not in (SELECT distinct Newsid from [dbo].[LR_OA_NewsShouldRead])"; var list = db.FindList(sql); foreach (var news in list) { if (!string.IsNullOrEmpty(news.F_Send) && news.F_Send == "1") { - //全部教师 + //接收人是全部教师 db.ExecuteBySql($@"insert into LR_OA_NewsShouldRead SELECT newid(),'{news.F_NewsId}',f_userid from lr_base_user where f_description='教师' and f_userid not in ( @@ -126,22 +152,31 @@ SELECT ruserid from [dbo].[LR_OA_NewsShouldRead] where newsid='{news.F_NewsId}' { var postids = string.Join("','", news.F_SendPostId.Split(',')); db.ExecuteBySql($@"insert into LR_OA_NewsShouldRead -SELECT newid(),'{news.F_NewsId}',f_userid from lr_base_user t +SELECT newid(),'{news.F_NewsId}',t.f_userid from lr_base_user t join LR_Base_UserRelation r on r.f_category='2' and t.F_UserId=r.f_userid -where t.f_description='教师' and r.f_objectid='{postids}' +where t.f_description='教师' and r.f_objectid in ('{postids}') and t.F_DepartmentId not in ('{deptids}') and t.f_userid not in ( SELECT ruserid from [dbo].[LR_OA_NewsShouldRead] where newsid='{news.F_NewsId}' )"); } } - + //接收部门空 , 接收岗位不为空 if (string.IsNullOrEmpty(news.F_SendDeptId) && !string.IsNullOrEmpty(news.F_SendPostId)) { - + var postids = string.Join("','", news.F_SendPostId.Split(',')); + db.ExecuteBySql($@"insert into LR_OA_NewsShouldRead +SELECT newid(),'{news.F_NewsId}',t.f_userid from lr_base_user t +join LR_Base_UserRelation r on r.f_category='2' and t.F_UserId=r.f_userid +where t.f_description='教师' and r.f_objectid in ('{postids}') +and t.f_userid not in ( +SELECT ruserid from [dbo].[LR_OA_NewsShouldRead] where newsid='{news.F_NewsId}' +)"); } } + } + db.Commit(); } catch (Exception ex) {