Exemplo n.º 1
0
        private bool[] getMenu()
        {
            var user      = OperatorProvider.Provider.Current();
            var dept      = new DepartmentBLL().GetList();
            var root      = dept.FirstOrDefault(x => x.ParentId == "0");
            var get       = dept.Where(x => x.ParentId == root.DepartmentId).OrderBy(x => x.EnCode).First();
            var dyresultS = MywebClient("MenuConfig/GetMenuList",
                                        "{'userid':'" + user.UserId + "','data':{'id':'" + get.DepartmentId + "','platform':1,'themetype':0}}");

            bool[] IsMenu = new bool[2];
            if (dyresultS.Contains("人脸签到"))
            {
                IsMenu[0] = true;
            }
            else
            {
                IsMenu[0] = false;
            }
            if (dyresultS.Contains("考勤签到"))
            {
                IsMenu[1] = true;
            }
            else
            {
                IsMenu[1] = false;
            }

            return(IsMenu);
        }
Exemplo n.º 2
0
        public ActionResult GetWarningCardCount(FormCollection form)
        {
            try
            {
                var user = OperatorProvider.Provider.Current();
                List <DepartmentEntity> allDeptList = new DepartmentBLL().GetList().ToList();
                //1、获取页面上要显示的部门(当前用户所在的部门的下级部门)
                List <DepartmentEntity>     showDepts      = new List <DepartmentEntity>();
                List <string>               searchDeptIds  = new List <string>();
                List <HseKeyValueParameter> serchParameter = new List <HseKeyValueParameter>();//搜索用参数
                var userDept = allDeptList.FirstOrDefault(p => p.DepartmentId.Equals(user.DeptId));
                if (userDept == null)
                {
                    return(Json(new { Code = -1, Message = "找不到当前用户的部门" }));
                }
                if (userDept.Nature == "班组")
                {
                    //如果改用户是班组级用户则查上级部门下的所有班组
                    showDepts = allDeptList.Where(p => p.ParentId == userDept.ParentId).ToList();
                    showDepts.ForEach(p =>
                    {
                        serchParameter.Add(new HseKeyValueParameter()
                        {
                            RootId   = p.DepartmentId,
                            RootName = p.FullName,
                            DeptIds  = new List <string>()
                            {
                                p.DepartmentId
                            }
                        });
                    });
                }
                else
                {
                    //如果不是班组级的话 ,则查当前用户部门的下级部门即可,预警指标卡数据根据Encode模糊查询出的部门的去做匹配
                    if (userDept.IsOrg == 1)
                    {
                        //厂级部门查全厂的数据
                        showDepts = allDeptList.Where(p => p.ParentId == userDept.OrganizeId).ToList();
                    }
                    else
                    {
                        //非厂级部门查 本子部门的数据
                        showDepts = allDeptList.Where(p => p.ParentId == userDept.DepartmentId).ToList();
                    }

                    showDepts.ForEach(p =>
                    {
                        serchParameter.Add(new HseKeyValueParameter()
                        {
                            RootId   = p.DepartmentId,
                            RootName = p.FullName,
                            DeptIds  = allDeptList.Where(x => x.EnCode.StartsWith(p.EnCode)).Select(m => m.DepartmentId).ToList()
                        });
                    });
                }
                var bll = new WarningCardBLL();
                List <HseKeyValue> dataCount = bll.GetWarningCardCount(serchParameter.SelectMany(p => p.DeptIds).ToList(), form["start"], form["end"]);
                List <HseKeyValue> data      = new List <HseKeyValue>();
                var allUser = new UserBLL().GetList().Where(p => p.IsPresence == "1").ToList();
                serchParameter.ForEach(p =>
                {
                    HseKeyValue keyValue = new HseKeyValue();
                    keyValue.Key         = p.RootName;
                    var matchData        = dataCount.Where(x => p.DeptIds.Contains(x.DeptId)).ToList();
                    keyValue.Num1        = matchData.Sum(m => m.Num1);
                    keyValue.Num3        = matchData.Sum(m => m.Num3);
                    keyValue.Num4        = matchData.Sum(m => m.Num4);
                    keyValue.Num5        = (keyValue.Num3 + keyValue.Num4) == 0 ? 0 : Math.Round(keyValue.Num3 / (keyValue.Num3 + keyValue.Num4) * 100, 2);
                    int userCount        = allUser.Count(u => u.DepartmentId == p.RootId || p.DeptIds.Contains(u.DepartmentId)); //本子部门的用户的数量
                    keyValue.Num2        = userCount == 0 ? 0 : Math.Round(keyValue.Num1 / userCount, 2);                        //如果没有用户 ,默认0
                    data.Add(keyValue);
                });



                return(Json(new { Code = 0, Data = data }));
            }
            catch (Exception ex)
            {
                return(Json(new { Code = -1, ex.Message }));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取列表数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetTableData(FormCollection form)
        {
            try
            {
                dynamic queryJson = JsonConvert.DeserializeObject <ExpandoObject>(Request["queryJson"]);
                var     user      = OperatorProvider.Provider.Current();
                //先找到当前用户所在的电厂
                var       searchDept = new DepartmentBLL().GetList().Where(p => p.EnCode.StartsWith(user.OrganizeCode)).OrderBy(x => x.EnCode).ToList();//当前电厂底下的部门数据。分组组装数据用
                var       parentCode = user.OrganizeCode;
                DataTable dt         = new SelfEvaluateBLL().GetChartsData(queryJson.year, queryJson.month, user.DeptCode);
                var       userList   = new UserBLL().GetList();

                var treeList = new List <TreeGridEntity>();
                if (searchDept != null && searchDept.Count > 0)
                {
                    //组装各个部门的数据
                    searchDept.ForEach(p =>
                    {
                        TreeGird treeGird = new TreeGird()
                        {
                            Id       = p.DepartmentId,
                            Name     = p.FullName,
                            ParentId = p.ParentId,
                            DeptId   = p.DepartmentId,
                            DeptCode = p.DeptCode,
                            Nature   = p.Nature
                        };
                        decimal userCount       = userList.Count(x => x.DepartmentCode.StartsWith(p.EnCode) && x.IsPresence == "1"); //总人数
                        treeGird.AllUserCount   = userCount.ToString();;
                        decimal allCount        = 0;
                        var drItem              = dt.Select(" DEPTCODE LIKE '" + p.EnCode + "%'");
                        decimal sbumitUserCount = 0;
                        foreach (DataRow dr in drItem)
                        {
                            allCount        += dr["COUNT"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["COUNT"]);         //已提交总数
                            sbumitUserCount += dr["USERCOUNT"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["USERCOUNT"]); //已提交总人数
                        }
                        treeGird.SubmitCount    = allCount.ToString();
                        treeGird.NotSubmitCount = ((userCount - sbumitUserCount) < 0 ? 0 : (userCount - sbumitUserCount)).ToString();
                        if (userCount < 1)
                        {
                            treeGird.CYD = "0%";
                        }
                        else
                        {
                            treeGird.CYD = Math.Round(allCount / userCount * 100, 2).ToString() + "%";//百分比 参与度=已提交/应提交*100%
                        }


                        TreeGridEntity treeGridEntity = new TreeGridEntity()
                        {
                            parentId    = treeGird.ParentId,
                            entityJson  = JsonConvert.SerializeObject(treeGird),
                            expanded    = false,
                            hasChildren = true,
                            id          = treeGird.Id,
                            text        = treeGird.Name,
                            code        = treeGird.CYD
                        };
                        treeList.Add(treeGridEntity);
                    });
                }
                var FristDpetDetail = searchDept.FirstOrDefault(x => x.EnCode == parentCode);
                if (FristDpetDetail != null && !user.IsSystem)
                {
                    var FristDpet = treeList.FirstOrDefault(x => x.id == FristDpetDetail.DepartmentId);
                    if (FristDpet != null)
                    {
                        FristDpet.parentId = "0";
                    }
                }

                return(Content(treeList.TreeJson()));
            }
            catch (Exception ex)
            {
                return(Error("查询失败:" + ex.Message));
            }
        }