Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

311 рядки
10 KiB

  1. using Learun.Application.Base.SystemModule;
  2. using Learun.Application.WorkFlow;
  3. using Learun.Util;
  4. using Learun.Util.Operat;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web.Mvc;
  8. using static Learun.Util.WebHelper;
  9. namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创建人:陈彬彬
  15. /// 日 期:2017.04.01
  16. /// 描 述:系统日志
  17. /// </summary>
  18. public class LogController : MvcControllerBase
  19. {
  20. #region 视图功能
  21. /// <summary>
  22. /// 日志管理
  23. /// </summary>
  24. /// <returns></returns>
  25. [HttpGet]
  26. public ActionResult Index()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 清空
  32. /// </summary>
  33. /// <returns></returns>
  34. [HttpGet]
  35. public ActionResult Form()
  36. {
  37. return View();
  38. }
  39. /// <summary>
  40. /// 详情页面
  41. /// </summary>
  42. /// <returns></returns>
  43. [HttpGet]
  44. public ActionResult DetailForm()
  45. {
  46. return View();
  47. }
  48. /// <summary>
  49. /// 系统使用统计页面
  50. /// <summary>
  51. /// <returns></returns>
  52. [HttpGet]
  53. public ActionResult UseStatistics()
  54. {
  55. return View();
  56. }
  57. /// <summary>
  58. /// 在线人员页面
  59. /// <summary>
  60. /// <returns></returns>
  61. [HttpGet]
  62. public ActionResult OnlineUserIndex()
  63. {
  64. return View();
  65. }
  66. #endregion
  67. #region 获取数据
  68. /// <summary>
  69. /// 分页查询
  70. /// </summary>
  71. /// <param name="pagination">分页参数</param>
  72. /// <param name="queryJson">查询条件函数</param>
  73. /// <returns></returns>
  74. [HttpGet]
  75. [AjaxOnly]
  76. public ActionResult GetPageList(string pagination, string queryJson)
  77. {
  78. Pagination paginationobj = pagination.ToObject<Pagination>();
  79. var data = LogBLL.GetPageList(paginationobj, queryJson, "");
  80. var jsonData = new
  81. {
  82. rows = data,
  83. total = paginationobj.total,
  84. page = paginationobj.page,
  85. records = paginationobj.records,
  86. };
  87. return JsonResult(jsonData);
  88. }
  89. /// <summary>
  90. /// 分页查询(本人数据)
  91. /// </summary>
  92. /// <param name="pagination"></param>
  93. /// <param name="queryJson"></param>
  94. /// <returns></returns>
  95. [HttpGet]
  96. [AjaxOnly]
  97. public ActionResult GetPageListByMy(string pagination, string queryJson)
  98. {
  99. Pagination paginationobj = pagination.ToObject<Pagination>();
  100. UserInfo userInfo = LoginUserInfo.Get();
  101. var data = LogBLL.GetPageList(paginationobj, queryJson, userInfo.userId);
  102. var jsonData = new
  103. {
  104. rows = data,
  105. total = paginationobj.total,
  106. page = paginationobj.page,
  107. records = paginationobj.records,
  108. };
  109. return JsonResult(jsonData);
  110. }
  111. #endregion
  112. #region 提交数据
  113. /// <summary>
  114. /// 清空日志
  115. /// </summary>
  116. /// <param name="categoryId">日志分类Id</param>
  117. /// <param name="keepTime">保留时间段内</param>
  118. /// <returns></returns>
  119. [HttpPost]
  120. [ValidateAntiForgeryToken]
  121. [AjaxOnly]
  122. public ActionResult SaveRemoveLog(int categoryId, string keepTime)
  123. {
  124. LogBLL.RemoveLog(categoryId, keepTime);
  125. return Success("清空成功。");
  126. }
  127. #endregion
  128. #region 接收访问日志信息
  129. /// <summary>
  130. /// 访问功能
  131. /// </summary>
  132. /// <param name="moduleId">功能Id</param>
  133. /// <param name="moduleName">功能模块</param>
  134. /// <param name="moduleUrl">访问路径</param>
  135. /// <returns></returns>
  136. [AjaxOnly]
  137. [HttpPost]
  138. public ActionResult VisitModules(string moduleName, string moduleUrl)
  139. {
  140. LogEntity logEntity = new LogEntity();
  141. var userInfo = LoginUserInfo.Get();
  142. logEntity.F_CategoryId = 2;
  143. logEntity.F_OperateTypeId = ((int)OperationType.Visit).ToString();
  144. logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Visit);
  145. logEntity.F_OperateAccount = userInfo.account + "(" + userInfo.realName + ")";
  146. logEntity.F_OperateUserId = userInfo.userId;
  147. logEntity.F_Module = moduleName;
  148. logEntity.F_ExecuteResult = 1;
  149. logEntity.F_ExecuteResultJson = "访问地址:" + moduleUrl;
  150. logEntity.F_Description = "PC端";
  151. logEntity.WriteLog();
  152. return Success("");
  153. }
  154. #endregion
  155. #region 接收操作日志信息
  156. #endregion
  157. #region 扩展数据
  158. /// <summary>
  159. /// 获取报表数据
  160. /// </summary>
  161. /// <param name="queryJson">查询条件函数</param>
  162. /// <returns></returns>
  163. [HttpGet]
  164. [AjaxOnly]
  165. public ActionResult GetUseList(string queryJson, int CategoryId)
  166. {
  167. var data = LogBLL.GetList(queryJson, false);
  168. var jsonData = data.Where(x => x.F_CategoryId == CategoryId).GroupBy(x => new { x.Department, x.F_Description }).Select(x => new
  169. {
  170. category = CategoryId,
  171. department = x.Key.Department,
  172. source = x.Key.F_Description,
  173. total = x.Select(y => y.F_OperateUserId).Distinct().Count()
  174. });
  175. return JsonResult(jsonData);
  176. }
  177. /// <summary>
  178. /// 获取图表数据
  179. /// </summary>
  180. /// <param name="queryJson"></param>
  181. /// <returns></returns>
  182. public ActionResult GetUseChartList(string queryJson)
  183. {
  184. var categorydata = new List<YearGrade>();
  185. categorydata.Add(new YearGrade { value = "1", text = "登录记录" });
  186. categorydata.Add(new YearGrade { value = "2", text = "操作记录" });
  187. var categorydata2 = new List<YearGrade>();
  188. categorydata2.Add(new YearGrade { value = "1", text = "PC端" });
  189. categorydata2.Add(new YearGrade { value = "2", text = "移动端" });
  190. var usedata = LogBLL.GetList(queryJson, false).ToList();
  191. var usedataOfYear = LogBLL.GetList(queryJson, true).ToList();
  192. var aa = usedata.Where(x => x.F_CategoryId == 1 && x.F_Description != null).GroupBy(x => x.F_Description).Select(x => new WfSchemeReportModelOfPie()
  193. {
  194. name = x.Key,
  195. value = x.Select(y => y.F_OperateUserId).Distinct().Count()
  196. });
  197. var aa2 = usedata.Where(x => x.F_CategoryId == 2 && x.F_Description != null).GroupBy(x => x.F_Description).Select(x => new WfSchemeReportModelOfPie()
  198. {
  199. name = x.Key,
  200. value = x.Select(y => y.F_OperateUserId).Distinct().Count()
  201. });
  202. var bb = usedataOfYear.Where(x => x.F_OperateTime.HasValue).GroupBy(x => new { x.F_CategoryId, x.F_OperateTime.Value.Month }).Select(x => new
  203. {
  204. name = x.Key.F_CategoryId.ToString(),
  205. month = x.Key.Month,
  206. value = x.Select(y => y.F_OperateUserId).Distinct().Count()
  207. });
  208. //饼图项
  209. var legendData = new List<string>();
  210. //登录记录饼图数据
  211. var seriesData = new List<WfSchemeReportModelOfPie>();
  212. //访问记录饼图数据
  213. var seriesData2 = new List<WfSchemeReportModelOfPie>();
  214. foreach (var item in categorydata2)
  215. {
  216. legendData.Add(item.text);
  217. var model = new WfSchemeReportModelOfPie()
  218. {
  219. value = aa.FirstOrDefault(x => x.name == item.text) == null ? 0 : aa.FirstOrDefault(x => x.name == item.text).value,
  220. name = item.text
  221. };
  222. seriesData.Add(model);
  223. var model2 = new WfSchemeReportModelOfPie()
  224. {
  225. value = aa2.FirstOrDefault(x => x.name == item.text) == null ? 0 : aa.FirstOrDefault(x => x.name == item.text).value,
  226. name = item.text
  227. };
  228. seriesData2.Add(model2);
  229. }
  230. //柱状图项
  231. var legendDataOfLine = new List<string>();
  232. //柱状图数据
  233. var seriesLineData = new List<WfSchemeReportModelOfLine>();
  234. //x轴数据
  235. var xAxis = new List<string>();
  236. for (int i = 0; i < 12; i++)
  237. {
  238. xAxis.Add(string.Format("{0}月", i + 1));
  239. }
  240. foreach (var item in categorydata)
  241. {
  242. legendDataOfLine.Add(item.text);
  243. var monthData = new List<int>();
  244. for (int i = 0; i < 12; i++)
  245. {
  246. monthData.Add(0);
  247. }
  248. var linemodel = new WfSchemeReportModelOfLine()
  249. {
  250. name = item.text,
  251. type = "line",
  252. stack = "人数",
  253. data = monthData
  254. };
  255. var bbb = bb.Where(x => x.name == item.value);
  256. if (bbb.Any())
  257. {
  258. foreach (var bbbb in bbb)
  259. {
  260. linemodel.data[bbbb.month - 1] = bbbb.value;
  261. }
  262. }
  263. seriesLineData.Add(linemodel);
  264. }
  265. var jsonData = new
  266. {
  267. legendData = legendData,
  268. seriesData = seriesData,
  269. seriesData2 = seriesData2,
  270. legendDataOfLine = legendDataOfLine,
  271. seriesLineData = seriesLineData,
  272. xAxis = xAxis
  273. };
  274. return Success(jsonData);
  275. }
  276. /// <summary>
  277. /// 获取在线人员
  278. /// </summary>
  279. /// <param name="queryJson">查询条件函数</param>
  280. /// <returns></returns>
  281. [HttpGet]
  282. [AjaxOnly]
  283. public ActionResult GetOnlineUserList()
  284. {
  285. var data = LogBLL.GetOnlineUserList();
  286. return JsonResult(data);
  287. }
  288. #endregion
  289. }
  290. }