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.
 
 
 
 
 
 

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