/// <summary> ///获取今日统计数据 /// </summary> public JsonResult GetTodayJob() { var user = OperatorProvider.Provider.Current(); var data = new IndexManageBLL().TodayWorkStatistics(user.DeptId); return(Json(data)); }
/// <summary> ///获取今日班会信息 /// </summary> public JsonResult GetTodayWorkmeet() { var user = OperatorProvider.Provider.Current(); var data = new IndexManageBLL().GetDeptsMeet(user.DeptId); return(Json(data)); }
/// <summary> ///教育培训统计 /// </summary> public JsonResult GetIndexHDCount(string type) { var user = OperatorProvider.Provider.Current(); DateTime now = DateTime.Now.Date; DateTime start = now, end = now; switch (type) { case "1": start = new DateTime(now.Year, now.Month, 1); end = start.AddMonths(1).AddMilliseconds(-1); break; case "2": var monthNum = (now.Month + 2) / 3; start = new DateTime(now.Year, (monthNum - 1) * 3 + 1, 1); end = start.AddMonths(3).AddMilliseconds(-1); break; case "3": start = new DateTime(now.Year, 1, 1); end = start.AddYears(1).AddMilliseconds(-1); break; default: start = new DateTime(now.Year, now.Month, 1); end = start.AddMonths(1).AddMilliseconds(-1); break; } var data = CacheFactory.Cache().GetCache <Dictionary <string, int> >("HDCount_" + type + "_" + user.DeptId); if (data != null) { return(Json(data)); } var deptBll = new DepartmentBLL(); //获取根节点 var dept = deptBll.GetAuthorizationDepartment(user.DeptId); //获取所有班组信息 var depts = deptBll.GetSubDepartments(dept.DepartmentId, ""); data = new IndexManageBLL().GetHDCount(user.UserId, depts, start, end); CacheFactory.Cache().WriteCache <Dictionary <string, int> >(data, "HDCount_" + type + "_" + user.DeptId, DateTime.Now.AddHours(5)); return(Json(data)); }
/// <summary> ///获取隐患趋势 /// </summary> public JsonResult GetIndexHiddenDanger(string year) { var user = OperatorProvider.Provider.Current(); var data = CacheFactory.Cache().GetCache <Dictionary <string, Dictionary <int, int> > >("HiddenDanger_" + year + "_" + user.UserId); if (data != null) { var resultData = data.Select(x => new { name = x.Key, month = x.Value.Select(p => p.Key).ToList(), monthdata = x.Value.Select(p => p.Value).ToList() }).ToList(); return(Json(resultData)); } data = new IndexManageBLL().HiddenDanger(user.UserId, year); CacheFactory.Cache().WriteCache <Dictionary <string, Dictionary <int, int> > >(data, "HiddenDanger_" + year + "_" + user.UserId, DateTime.Now.AddHours(5)); var result = data.Select(x => new { name = x.Key, month = x.Value.Select(p => p.Key).ToList(), monthdata = x.Value.Select(p => p.Value).ToList() }).ToList(); return(Json(result)); }
/// <summary> ///教育培训统计 /// </summary> public JsonResult GetIndexEduManage(string type) { var user = OperatorProvider.Provider.Current(); DateTime now = DateTime.Now.Date; DateTime start = now, end = now; switch (type) { case "1": start = new DateTime(now.Year, now.Month, 1); end = start.AddMonths(1).AddMilliseconds(-1); break; case "2": var monthNum = (now.Month + 2) / 3; start = new DateTime(now.Year, (monthNum - 1) * 3 + 1, 1); end = start.AddMonths(3).AddMilliseconds(-1); break; case "3": start = new DateTime(now.Year, 1, 1); end = start.AddYears(1).AddMilliseconds(-1); break; default: start = new DateTime(now.Year, now.Month, 1); end = start.AddMonths(1).AddMilliseconds(-1); break; } var data = CacheFactory.Cache().GetCache <Dictionary <string, int> >("EduManage_" + type + "_" + user.DeptId); if (data != null) { return(Json(data)); } data = new IndexManageBLL().GetEdCount(user.DeptId, start, end); CacheFactory.Cache().WriteCache <Dictionary <string, int> >(data, "EduManage_" + type + "_" + user.DeptId, DateTime.Now.AddHours(5)); return(Json(data)); }
/// <summary> /// 根据配置获取页面展示 /// </summary> public JsonResult GetActualWarning() { var user = OperatorProvider.Provider.Current(); var traingtype = Config.GetValue("TrainingType"); var CustomerModel = Config.GetValue("CustomerModel"); var data = new List <IndexActualModel>(); data = CacheFactory.Cache().GetCache <List <IndexActualModel> >("ActualWarning_" + user.DeptId); if (data != null) { return(Json(data)); } else { data = new List <IndexActualModel>(); } //获取双控菜单配置 var MenuData = new TerminalDataSetBLL().GetMenuConfigList(1); var RealTimeBool = new bool[] { false, false, false, true, false }; var one = MenuData.Where(x => x.ModuleName == "班前班后会").FirstOrDefault();//班前班后会 if (one != null) { RealTimeBool[0] = true; } var two = MenuData.Where(x => x.ModuleName == "班组活动").FirstOrDefault();//班组活动 if (two != null) { RealTimeBool[1] = true; } var three = MenuData.Where(x => x.ModuleName == traingtype || x.ModuleName == CustomerModel).FirstOrDefault();//人身风险预控 or CustomerModel var ModuleName = string.Empty; if (three != null) { RealTimeBool[2] = true; ModuleName = three.ModuleName; } var five = MenuData.Where(x => x.ModuleName == "教育培训").FirstOrDefault();//教育培训 if (five != null) { RealTimeBool[4] = true; } var DictionaryData = new IndexManageBLL().RealTime(user.DeptId, ModuleName, RealTimeBool, user.UserId); //排序 foreach (var item in DictionaryData) { var One = new IndexActualModel() { name = item.Key, num = item.Value, sort = item.Key.Contains("连续一周") ? 1 : item.Key.Contains("连续两周") ? 2 : item.Key.Contains("今日未开展人身风险预控") ? 3 : item.Key.Contains("14天未开展") ? 4 : item.Key.Contains("未整改违章") ? 5 : item.Key.Contains("未整改隐患") ? 6 : 7, }; data.Add(One); } data = data.OrderBy(x => x.sort).ToList(); CacheFactory.Cache().WriteCache(data, "ActualWarning_" + user.DeptId, DateTime.Now.AddHours(5)); return(Json(data)); }
/// <summary> /// /// </summary> /// <param name="searchDeptId">所查询的指标的部门ID 一般为电厂的Id</param> /// <param name="userId">当前用户的Id 取数据用</param> /// <param name="indexType">指标类型 0管理平台 1安卓终端 2手机APP </param> /// <param name="userDeptId">当前用户的所属的部门Id 取数据用</param> /// <param name="terminalType">查询类型 0月 1季 2年</param> /// <param name="templet">模板 所属的模板 1第一套 2 第二套 以此类推</param> /// <returns></returns> public List <IndexManageModel> GetIndexData(string searchDeptId, string userId, int indexType, string userDeptId, string terminalType, int?templet) { TerminalDataSetBLL terminalDataSetBLL = new TerminalDataSetBLL(); IndexManageBLL indexManageBLL = new IndexManageBLL(); List <TerminalDataSetEntity> entitys = terminalDataSetBLL.GetList().Where(p => p.IsOpen == 1).ToList(); //先取所有的指标 //再取所有的分类 List <IndexManageEntity> manageEntities = indexManageBLL.GetList(searchDeptId, indexType, null, templet).Where(p => p.IsShow == 1).ToList(); //获取分类底下的指标 List <IndexAssocationEntity> indexAssocationEntities = new IIndexAssocationBLL().GetListByTitleId(manageEntities.Select(p => p.Id).ToArray()); //查询并组装指标值的数据 var dataSetIds = indexAssocationEntities.Select(x => x.DataSetId);//所有的指标的Ids Dictionary <string, string> dic = new Dictionary <string, string>(); entitys.Where(x => dataSetIds.Contains(x.Id)).ToList().ForEach(x => { dic.Add(x.Code + "-" + x.Name, terminalType); });//应该要绑定的所有的指标 List <KeyValue> keyValues = FindAllCount(userId, userDeptId, dic); //List<KeyValue> keyValues = FindAllCount(userId, userDeptId, terminalType); List <IndexManageModel> models = new List <IndexManageModel>(); if (manageEntities != null && manageEntities.Count > 0) { manageEntities.ForEach(title => { //生成分类 IndexManageModel model = new IndexManageModel() { TitleId = title.Id, TitleName = title.Title, Srot = title.Sort }; //生成指标 var datasetIds = indexAssocationEntities.Where(p => p.TitleId == title.Id).Select(p => p.DataSetId); List <TerminalDataSetEntity> terminals = entitys.Where(x => datasetIds.Contains(x.Id)).ToList(); List <IndexModel> indexModels = new List <IndexModel>(); terminals.ForEach(terminal => { //组装数据 IndexModel indexModel = new IndexModel() { Key = terminal.Code, Name = terminal.Name, Sort = terminal.Sort, IsBZ = terminal.IsBZ, Unit = terminal.Unint, Icon = string.IsNullOrWhiteSpace(terminal.IconUrl) ? null : Config.GetValue("AppUrl") + terminal.IconUrl, Address = terminal.Address //Value = thisKv == null ? "0" : thisKv.value }; if (terminal.IsBZ == "1" && keyValues != null && keyValues.Count > 0) { var thisKv = keyValues.FirstOrDefault(p => p.key == terminal.Code); indexModel.Value = thisKv == null ? "0" : thisKv.value; } indexModels.Add(indexModel); }); model.AddChilds(indexModels); models.Add(model); }); } return(models); }