You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

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