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 477560d6c..91888de52 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
@@ -60,6 +60,15 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
return View();
}
///
+ /// 通知公告阅读统计
+ ///
+ ///
+ [HttpGet]
+ public ActionResult IndexStatistics()
+ {
+ return View();
+ }
+ ///
/// 通知公告(需要审核)
///
///
@@ -279,6 +288,28 @@ 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
+ {
+ rows = data,
+ total = paginationobj.total,
+ page = paginationobj.page,
+ records = paginationobj.records,
+ };
+ return JsonResult(jsonData);
+ }
+
//public ActionResult GetNoticeCategoryByDepartment(string departmentId)
//{
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..32b6af94f
--- /dev/null
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/IndexStatistics.cshtml
@@ -0,0 +1,54 @@
+@{
+ 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..d62e61b2e
--- /dev/null
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/IndexStatistics.js
@@ -0,0 +1,106 @@
+/*
+ * 版 本 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) {
+ if (!!queryJson.Year && !!queryJson.Month) {
+ queryJson.Year = queryJson.Year;
+ queryJson.Month = Number(queryJson.Month) + 1;
+ }
+ page.search(queryJson);
+ }, 200, 400);
+ // 刷新
+ $('#lr_refresh').on('click', function () {
+ location.reload();
+ });
+ //年度
+ $('#Year').lrselect({
+ url: top.$.rootUrl + '/EducationalAdministration/CdMajor/GenerateNearByYear',
+ value: 'value',
+ text: 'text'
+ });
+ //$('#Year').lrselectSet(Year);
+ //月份
+ $('#Month').lrDataItemSelect({ code: 'MPMonth' });
+
+ $('#F_Departmentid').lrselect({
+ allowSearch: true,
+ url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=classdata',
+ param: { strWhere: " 1=1 and F_EnabledMark=1 and F_deleteMark=0 order by F_SortCode " },
+ value: "id",
+ text: "name"
+ });
+
+ },
+ initGrid: function () {
+ $('#gridtable').jfGrid({
+ url: top.$.rootUrl + '/LR_OAModule/Notice/GetPageListForStatistics',
+ headData: [
+ { label: '职工编号', name: 'F_Account', 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: '完成阅读次数(发起通知7天内)', name: 'rnum', width: 180, align: 'left' },
+ {
+ label: '完成阅读百分比', name: 'ruserid', 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) {
+ param = param || {};
+ $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(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 3b39b96f2..25e2354ce 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
@@ -1484,6 +1484,7 @@
+
@@ -7721,6 +7722,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 d42108a92..3005db410 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
@@ -247,6 +247,20 @@ 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_Account { get; set; }
+ [NotMapped]
+ public string ruserid { 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 eea23e15d..2c3c92ec0 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
@@ -40,6 +40,45 @@ namespace Learun.Application.OA
}
}
}
+
+
+ public IEnumerable GetPageListForStatistics(Pagination pagination, string queryJson)
+ {
+ try
+ {
+ return noticeService.GetPageListForStatistics(pagination, queryJson);
+ }
+ catch (Exception ex)
+ {
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowBusinessException(ex);
+ }
+ }
+ }
+
+ 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 5b322b1aa..599d7faec 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
@@ -20,6 +20,7 @@ namespace Learun.Application.OA
/// 关键词
///
IEnumerable GetPageList(Pagination pagination, string keyword);
+ IEnumerable GetPageListForStatistics(Pagination pagination, string queryJson);
///
/// 公告实体
///
@@ -54,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 b1d08e653..1e4311ca4 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,4 +1,5 @@
-using Learun.DataBase.Repository;
+using Dapper;
+using Learun.DataBase.Repository;
using Learun.Util;
using System;
using System.Collections.Generic;
@@ -51,6 +52,166 @@ namespace Learun.Application.OA
}
}
}
+
+ ///
+ /// 通知公告阅读统计
+ ///
+ ///
+ ///
+ ///
+ public IEnumerable GetPageListForStatistics(Pagination pagination, string queryJson)
+ {
+ try
+ {
+ var queryParam = queryJson.ToJObject();
+ var sql = new StringBuilder(@"select t.*,u.F_Account,u.f_realname,f_departmentid from ");
+ sql.Append("(");
+ sql.Append("select t1.ruserid,isnull(srnum,0) as srnum,isnull(rnum,0) as rnum from (");
+ sql.Append(
+ @"select ruserid,COUNT(1) as srnum from LR_OA_News t left join LR_OA_NewsShouldRead s on s.newsid=t.f_newsid
+left join lr_base_user u on s.RUserId=u.F_UserId
+ WHERE t.F_TypeId = 2 and t.F_DeleteMark=0 and t.F_EnabledMark=1
+ --and u.F_Account like '20%'
+ --and t.F_ReleaseTime>CONVERT(datetime,SUBSTRING(u.F_Account,1,4)+'-08-31',120)
+");
+ if (!queryParam["Year"].IsEmpty() && !queryParam["Month"].IsEmpty())
+ {
+ sql.Append($" and year(t.F_ReleaseTime)='{queryParam["Year"].ToString()}' and month(t.F_ReleaseTime)='{queryParam["Month"].ToString()}'");
+ }
+
+ sql.Append(" group by ruserid ) t1 left join (");
+ sql.Append(
+ @" select ruserid,COUNT(1) as rnum from LR_OA_News t left join LR_OA_NewsRead r on r.newsid=t.f_newsid
+left join lr_base_user u on r.RUserId=u.F_UserId
+ WHERE t.F_TypeId = 2 and t.F_DeleteMark=0 and t.F_EnabledMark=1
+ --and u.F_Account like '20%'
+ --and t.F_ReleaseTime>CONVERT(datetime,SUBSTRING(u.F_Account,1,4)+'-08-31',120)
+ and DATEDIFF(HOUR,t.F_ReleaseTime,r.RTime)<=24*7 ");
+ if (!queryParam["Year"].IsEmpty() && !queryParam["Month"].IsEmpty())
+ {
+ sql.Append($" and year(t.F_ReleaseTime)='{queryParam["Year"].ToString()}' and month(t.F_ReleaseTime)='{queryParam["Month"].ToString()}'");
+ }
+
+ sql.Append(" group by ruserid ) t2 on t1.ruserid=t2.ruserid ");
+ sql.Append(") t");
+ sql.Append(" left join lr_base_user u on t.ruserid=u.f_userid where 1=1 ");
+
+ // 虚拟参数
+ var dp = new DynamicParameters(new { });
+ if (queryParam.HasValues)
+ {
+ if (!queryParam["F_Encode"].IsEmpty())
+ {
+ sql.Append($" AND u.f_encode like '%{queryParam["F_Encode"].ToString()}%' ");
+ }
+ if (!queryParam["F_RealName"].IsEmpty())
+ {
+ sql.Append($" AND u.f_realname like '%{queryParam["F_RealName"].ToString()}%' ");
+ }
+ if (!queryParam["F_Departmentid"].IsEmpty())
+ {
+ sql.Append($" AND f_departmentid = '{queryParam["F_Departmentid"].ToString()}' ");
+ }
+ }
+ var list = this.BaseRepository().FindList(sql.ToString(), pagination);
+
+ return list;
+ }
+ catch (Exception ex)
+ {
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowServiceException(ex);
+ }
+ }
+ }
+
+ ///
+ /// 保存通知公告应读人员
+ ///
+ public void SaveNewsShouldRead()
+ {
+ var db = this.BaseRepository();
+ try
+ {
+ db.BeginTrans();
+
+ 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 distinct Newsid from [dbo].[LR_OA_NewsShouldRead])";
+ var list = db.FindList(sql);
+ foreach (var news in list)
+ {
+ if (string.IsNullOrEmpty(news.F_SendDeptId) && string.IsNullOrEmpty(news.F_SendPostId))
+ {
+ //接收人是全部教师
+ 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 (
+SELECT ruserid from [dbo].[LR_OA_NewsShouldRead] where newsid='{news.F_NewsId}'
+)
+");
+ }
+ else
+ {
+ //接收部门
+ if (!string.IsNullOrEmpty(news.F_SendDeptId))
+ {
+ var deptids = string.Join("','", news.F_SendDeptId.Split(','));
+ db.ExecuteBySql($@"insert into LR_OA_NewsShouldRead
+SELECT newid(),'{news.F_NewsId}',f_userid from lr_base_user where f_description='教师' and F_DepartmentId in ('{deptids}')
+and f_userid not in (
+SELECT ruserid from [dbo].[LR_OA_NewsShouldRead] where newsid='{news.F_NewsId}'
+)");
+ //岗位
+ if (!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_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)
+ {
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowServiceException(ex);
+ }
+ }
+ }
+
///
/// 新闻公告实体
///
@@ -151,7 +312,7 @@ namespace Learun.Application.OA
}
}
-
+
#endregion
#region 扩展数据