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

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