/// <summary>
        /// 导出到Excel
        /// </summary>
        /// <param name="queryJson"></param>
        /// <returns></returns>
        public ActionResult Excel(string queryJson)
        {
            DepartmentBLL departmentBLL = new DepartmentBLL();


            string   sqlwhere = "Account!='System' and us is not null";
            Operator user     = ERCHTMS.Code.OperatorProvider.Provider.Current();

            if (user.IsSystem)
            {
                sqlwhere = "1=1 and us is not null";
            }
            else
            {
                var queryParam = queryJson.ToJObject();
                if (queryParam["datatype"].IsEmpty())
                {
                    string where = new AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value, "departmentcode", "organizecode");
                    if (!string.IsNullOrEmpty(where) && (queryParam["code"].IsEmpty() || !queryJson.Contains("code")))
                    {
                        sqlwhere += " and " + where;
                    }
                }
            }



            var data = new HazardfactoruserBLL().GetPageList(sqlwhere, queryJson);

            foreach (DataRow dr in data.Rows)
            {
                if (dr["nature"].ToString() == "专业" || dr["nature"].ToString() == "班组")
                {
                    DataTable dt = departmentBLL.GetDataTable(string.Format("select fullname from BASE_DEPARTMENT where encode=(select encode from BASE_DEPARTMENT t where instr('{0}',encode)=1 and nature='{1}' and organizeid='{2}') or encode='{0}' order by deptcode", dr["DEPARTMENTCODE"], "部门", dr["organizeid"]));
                    if (dt.Rows.Count > 0)
                    {
                        string name = "";
                        foreach (DataRow dr1 in dt.Rows)
                        {
                            name += dr1["fullname"].ToString() + "/";
                        }
                        dr["deptname"] = name.TrimEnd('/');
                    }
                }
            }

            for (int i = 0; i < data.Rows.Count; i++)
            {
                data.Rows[i][0] = i + 1;
            }
            string FileUrl = @"\Resource\ExcelTemplate\接触职业危害因素人员_导出模板.xlsx";

            AsposeExcelHelper.ExecuteResult(data, FileUrl, "接触职业危害因素人员清单", "接触职业危害因素人员列表");

            return(Success("导出成功。"));
        }
示例#2
0
        public object GetInfo([FromBody] JObject json)
        {
            try
            {
                string  res          = json.Value <string>("json");
                dynamic dy           = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId       = dy.userid;
                string  id           = dy.data.uid;
                bool    IsPermission = false;             //是否有权限
                OperatorProvider.AppUserId = userId;      //设置当前用户
                var user = userBll.GetUserInfoEntity(id); //获取用户基本信息

                DataItemDetailBLL itemBll = new DataItemDetailBLL();
                string            path    = itemBll.GetItemValue("imgUrl");
                var cert   = new ERCHTMS.Busines.PersonManage.CertificateBLL().GetList(id).Select(t => new { t.CertName, t.CertNum, SendDate = t.SendDate.Value.ToString("yyyy-MM-dd"), t.Years, t.SendOrgan, FilePath = path + t.FilePath }).ToList(); //获取人员证书信息
                var wzInfo = new DesktopBLL().GetWZInfoByUserId(id);                                                                                                                                                                                    //违章信息
                var health = new ERCHTMS.Busines.OccupationalHealthManage.OccupationalstaffdetailBLL().GetUserTable(id);                                                                                                                                //职业病信息
                //20190326 fwz 新增查询个人接触职业危害因素
                string Hazardfactor = "";
                //判断是否是本人\厂领导\EHS部与人力资源部的人
                if (userId == id)
                {
                    IsPermission = true;
                }
                //获取当前操作用户
                var Appuser = userBll.GetUserInfoEntity(userId);   //获取用户基本信息
                //EHS部与人力资源部配置在字典中 通过字典查找
                var Perdeptname = Appuser.DepartmentCode;
                DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();
                var data = dataItemDetailBLL.GetDataItemListByItemCode("'SelectDept'").ToList();
                if (data != null)
                {
                    foreach (var Peritem in data)
                    {
                        string   value  = Peritem.ItemValue;
                        string[] values = value.Split('|');
                        for (int i = 0; i < values.Length; i++)
                        {
                            if (values[i] == Perdeptname) //如果部门编码对应则是有权限的人
                            {
                                IsPermission = true;
                                break;
                            }
                        }
                    }
                }

                //如果是厂领导也有权限
                if (Appuser.RoleName.Contains("厂级部门用户") && Appuser.RoleName.Contains("公司领导"))
                {
                    IsPermission = true;
                }

                if (IsPermission)
                {
                    Hazardfactor = new HazardfactoruserBLL().GetUserHazardfactor(user.Account);
                }

                var    work        = new WorkRecordBLL().GetList(id).Select(t => new { EnterDate = t.EnterDate.ToString().Contains("0001") ? "" : t.EnterDate.ToString("yyyy-MM-dd"), LeaveTime = t.LeaveTime.ToString().Contains("0001") ? "" : t.LeaveTime.ToString("yyyy-MM-dd"), t.DeptName, t.PostName, t.OrganizeName, t.JobName }).ToList();//工作记录
                string deptname    = new TransferBLL().GetDeptName(user.DepartmentId);
                string projectName = "";
                if (!string.IsNullOrEmpty(user.ProjectId))
                {
                    OutsouringengineerEntity entity = new OutsouringengineerBLL().GetEntity(user.ProjectId);
                    if (entity != null)
                    {
                        projectName = entity.ENGINEERNAME;
                    }
                }

                string photo = "";
                if (!string.IsNullOrEmpty(user.HeadIcon))
                {
                    if (!string.IsNullOrEmpty(path))
                    {
                        photo = path + user.HeadIcon;
                    }
                }
                int score = 100;
                var item  = itemBll.GetEntity("csjf");
                if (item != null)
                {
                    score = int.Parse(item.ItemValue);
                }

                int    point    = 0;
                string argValue = new DataItemDetailBLL().GetItemValue("Point");
                if (!string.IsNullOrEmpty(argValue) && argValue == "point")
                {
                    dynamic pointdata = UpdatePoint(user.Account);
                    if (pointdata != null && pointdata.Qualitydata.Count > 0)
                    {
                        point = pointdata.Qualitydata[0].point;
                    }
                }


                //2019-03-08 Fwz修改 加入职务字段 部门显示改为层级显示
                return(new { Code = 0, Count = 1, Info = "获取数据成功", data = new { realname = user.RealName, point = point, sex = user.Gender, identifyid = user.IdentifyID, deptname = deptname, postname = user.DutyName, dutyname = user.PostName, organizename = user.OrganizeName, native = user.Native, nation = user.Nation, isSpecial = user.IsSpecial, isSpecialEqu = user.IsSpecialEqu, isBlack = user.IsBlack, mobile = user.Mobile, usertype = user.UserType, isEpiboly = user.isEpiboly, enterDate = user.EnterTime == null ? "" : user.EnterTime.Value.ToString("yyyy-MM-dd"), leaveTime = user.DepartureTime == null ? "" : user.DepartureTime.Value.ToString("yyyy-MM-dd"), isPresence = user.isPresence, score = new UserScoreBLL().GetUserScore(user.UserId, DateTime.Now.Year.ToString()) + score, projectName = projectName, faceUrl = photo, CertInfo = cert, IllInfo = health, Hazardfactor = Hazardfactor, IsPermission = IsPermission, WorkInfo = work, IllegalInfo = wzInfo, isfourperson = user.IsFourPerson, fourpersontype = user.FourPersonType } });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }