Ejemplo n.º 1
0
        public string GetAllWorkState()
        {
            RiskBLL           riskBLL = new RiskBLL();           //安全风险
            SaftyCheckDataBLL saBLL   = new SaftyCheckDataBLL(); //安全检查
            HTBaseInfoBLL     htBLL   = new HTBaseInfoBLL();     //事故隐患
            List <object>     data    = new List <object>();
            OrganizeBLL       orgBll  = new OrganizeBLL();
            DataTable         dt      = orgBll.GetDTList();

            ClassificationBLL classBLL = new ClassificationBLL();

            foreach (DataRow dr in dt.Rows)
            {
                Operator user = new Operator
                {
                    OrganizeId   = dr["orgid"].ToString(),
                    OrganizeCode = dr["encode"].ToString(),
                    DeptCode     = dr["encode"].ToString(),
                    RoleName     = "公司级用户,公司领导"
                };
                decimal[] fxArr = riskBLL.GetHomeStat(user);
                DataTable dtJC  = saBLL.GetCheckStat(user);
                DataTable dtHT  = htBLL.QueryHidWorkList(user); //首页双控工作
                data.Add(new { name = dr[1].ToString(), code = dr[0].ToString(), yjfx = fxArr[1], ejfx = fxArr[2], jccs = dtJC.Rows[0][0].ToString(), ybyh = dtHT.Rows[3][2].ToString(), zdyh1 = dtHT.Rows[1][2].ToString(), zdyh2 = dtHT.Rows[2][2].ToString(), yzgs = dtHT.Rows[0][3].ToString(), wzgs = dtHT.Rows[0][4].ToString(), zgl = dtHT.Rows[0][6].ToString() });
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(data));
        }
Ejemplo n.º 2
0
        public string GetAllRiskSate()
        {
            RiskBLL riskBLL = new RiskBLL();                                //安全风险
            SaftyCheckDataRecordBLL saBLL  = new SaftyCheckDataRecordBLL(); //安全检查
            HTBaseInfoBLL           htBLL  = new HTBaseInfoBLL();           //事故隐患
            List <object>           data   = new List <object>();
            OrganizeBLL             orgBll = new OrganizeBLL();
            DataTable dt = orgBll.GetDTList();

            ClassificationBLL classBLL = new ClassificationBLL();

            foreach (DataRow dr in dt.Rows)
            {
                Operator user = new Operator
                {
                    OrganizeId   = dr["orgid"].ToString(),
                    OrganizeCode = dr["encode"].ToString(),
                    RoleName     = "公司级用户,公司领导"
                };
                //计算事故隐患总得分
                decimal htScore = htBLL.GetHiddenWarning(user, "");
                decimal jcScore = saBLL.GetSafeCheckSumCount(user);
                decimal fxScore = riskBLL.GetRiskValueByTime(user, "");

                List <ClassificationEntity> list = classBLL.GetList(user.OrganizeId).ToList();
                if (list.Count == 0)
                {
                    list = classBLL.GetList("0").ToList();
                }
                data.Add(new { name = dr[1].ToString(), code = dr[0].ToString(), fxScore = fxScore, jcScore = jcScore, htScore = htScore, score = htScore * decimal.Parse(list[0].WeightCoeffcient) + jcScore * decimal.Parse(list[1].WeightCoeffcient) + fxScore * decimal.Parse(list[2].WeightCoeffcient) });
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(data));
        }
Ejemplo n.º 3
0
        public ActionResult GetDepartment(string OrgId)
        {
            OrganizeBLL orgBLL = new OrganizeBLL();

            string organizeId           = OrgId;
            string parentId             = "0";
            IList <SelectDeptData> list = new List <SelectDeptData>();
            //获取当前机构下的所有部门
            OrganizeEntity org  = orgBLL.GetEntity(organizeId);
            SelectDeptData dept = new SelectDeptData();

            dept.deptid     = org.OrganizeId;
            dept.code       = org.EnCode;
            dept.oranizeid  = org.OrganizeId;
            dept.parentcode = "";
            dept.parentid   = parentId;
            dept.name       = org.FullName;
            list.Add(dept);
            List <DepartmentEntity> data = new List <DepartmentEntity>();

            data = departmentBLL.GetList().Where(t => t.OrganizeId == organizeId).OrderBy(t => t.SortCode).ToList();

            foreach (DepartmentEntity entity in data)
            {
                SelectDeptData depts = new SelectDeptData();
                depts.deptid    = entity.DepartmentId;
                depts.code      = entity.EnCode;
                depts.oranizeid = entity.OrganizeId;
                depts.parentid  = entity.ParentId;
                var parentDept = data.Where(p => p.DepartmentId == depts.parentid).FirstOrDefault();
                if (null != parentDept)
                {
                    depts.parentcode = parentDept.EnCode;
                }
                else
                {
                    depts.parentcode = "";
                }
                depts.name = entity.FullName;
                list.Add(depts);
            }

            return(Content(list.ToJson()));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 岗位列表
        /// </summary>
        /// <param name="organizeId">公司Id</param>
        /// <returns></returns>
        public IEnumerable <RoleEntity> GetList(string organizeId, string isOrg)
        {
            var allData = this.GetList(organizeId);
            var data    = allData;

            if (!string.IsNullOrEmpty(organizeId))
            {
                data = data.Where(t => t.OrganizeId == organizeId || t.IsPublic == 1);
            }
            if (isOrg == "true")//这里是选择的是公司
            {
                data = data.Where(t => t.Nature == "厂级");
                if (data.Count() == 0)
                {
                    data = allData.Where(t => t.OrganizeId == organizeId || t.IsPublic == 1);
                }
            }
            else
            {
                //这里选择的是部门
                //DepartmentEntity de = departmentCache.GetEntity(isOrg);
                DepartmentEntity de = isOrg.Length > 32 && isOrg.Contains("-") ? new DepartmentBLL().GetEntity(isOrg) : departmentCache.GetEntityByDeptCode(isOrg);
                if (de == null)
                {
                    var org = new OrganizeBLL().GetEntity(isOrg);
                    if (org != null)
                    {
                        de = new DepartmentEntity {
                            Nature = "厂级", OrganizeId = isOrg
                        };
                    }
                }
                else
                {
                    data = data.Where(t => (t.Nature == de.Nature && t.DeptId == de.DepartmentId));
                    if (data.Count() == 0)
                    {
                        data = allData.Where(t => t.Nature == de.Nature || (t.IsPublic == 1 && t.Nature == de.Nature));
                    }
                }
            }
            return(data);
        }
Ejemplo n.º 5
0
        public static List <string> GetOrgnizeList(string userid)
        {
            if (cache[userid + "organize"] != null)
            {
                return((List <string>)cache[userid + "organize"]);
            }

            DepartmentBLL departmentBLL = new DepartmentBLL();
            OrganizeBLL   organizeBLL   = new OrganizeBLL();
            UserBLL       userBLL       = new UserBLL();

            UserEntity userEntity = new UserBLL().GetEntity(userid);

            if (userEntity == null)
            {
                return(null);
            }

            var orgnizedata = organizeBLL.GetList().ToList();
            List <OrganizeEntity> lstOrg = new List <OrganizeEntity>();

            foreach (OrganizeEntity org in orgnizedata)
            {
                if (org.ManagerId == userEntity.UserId)
                {
                    // operators.LstOrganizeId.Add(org.OrganizeId); //登录用户作为负责人的公司
                    lstOrg = (Reorg(orgnizedata, org.OrganizeId));//登录用户作为负责人的公司及下属
                    lstOrg.Add(org);
                }
            }
            var LstOrganizeId = new List <string>();

            foreach (OrganizeEntity org in lstOrg)
            {
                LstOrganizeId.Add(org.OrganizeId);
            }

            cache.Insert(userid + "organize", LstOrganizeId.Distinct().ToList(), null, DateTime.Now.AddMinutes(10), System.Web.Caching.Cache.NoSlidingExpiration);
            return(LstOrganizeId.Distinct().ToList());;
        }
Ejemplo n.º 6
0
        public string GetIndexWarnValue(string startDate = "", string endDate = "", string orgCode = "", string orgId = "")
        {
            Operator user = OperatorProvider.Provider.Current();
            decimal  totalScore = 0; int count = 0;

            try
            {
                string key   = "WarnScore_" + user.OrganizeCode;
                string score = CacheFactory.Cache().GetCache <string>(key);

                if (string.IsNullOrEmpty(score))
                {
                    if (string.IsNullOrEmpty(startDate) && string.IsNullOrEmpty(endDate))
                    {
                        startDate = DateTime.Now.Year.ToString() + "-01" + "-01";
                        endDate   = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
                    }

                    SafetyAssessedArguments entity = new SafetyAssessedArguments();
                    entity.startDate = startDate;
                    entity.endDate   = endDate;
                    if (user.RoleName.Contains("省级用户") || user.RoleName.Contains("集团用户"))
                    {
                        if (!string.IsNullOrEmpty(orgCode))
                        {
                            entity.orgId   = orgId;
                            entity.orgCode = orgCode;
                            totalScore     = desktopbll.GetSafetyAssessedValue(entity);
                        }
                        else
                        {
                            OrganizeBLL orgBll = new OrganizeBLL();
                            DataTable   dt     = orgBll.GetDTList();
                            foreach (DataRow dr in dt.Rows)
                            {
                                entity.orgId   = dr[2].ToString();
                                entity.orgCode = dr[0].ToString();
                                totalScore    += desktopbll.GetSafetyAssessedValue(entity);
                            }
                            totalScore = totalScore / dt.Rows.Count;
                        }
                    }
                    else
                    {
                        entity.orgId   = user.OrganizeId;
                        entity.orgCode = user.OrganizeCode;
                        totalScore     = desktopbll.GetSafetyAssessedValue(entity);
                    }
                    CacheFactory.Cache().WriteCache <string>(totalScore.ToString(), key, DateTime.Now.AddDays(1));
                }
                else
                {
                    totalScore = decimal.Parse(score);
                }

                string[] scorearr = new string[4];

                DataItemDetailBLL itemBLL = new DataItemDetailBLL();
                string            val     = itemBLL.GetItemValue("基础预警区间分值设置");
                count = 0;
                if (!string.IsNullOrEmpty(val))
                {
                    string[] arr = val.Split('|');
                    for (int i = 0; i < arr.Length; i++)
                    {
                        string[] arrVal = arr[i].Split(',');
                        scorearr[i] = arrVal[1];  //取后一个数字
                    }
                    int j = 0;
                    foreach (string str in arr)
                    {
                        string[] arrVal = str.Split(',');

                        if (totalScore > decimal.Parse(arrVal[0]) && totalScore <= decimal.Parse(arrVal[1]))
                        {
                            count = j;
                            break;
                        }
                        j++;
                    }
                }

                return(Newtonsoft.Json.JsonConvert.SerializeObject(new { score = Math.Round(totalScore, 1), index = count, scorearry = scorearr }));
            }
            catch (Exception ex)
            {
                return(Newtonsoft.Json.JsonConvert.SerializeObject(ex));
            }
        }
Ejemplo n.º 7
0
        public string GetWarnValue(string time = "", string orgCode = "", string orgId = "")
        {
            RiskBLL riskBLL = new RiskBLL();                                      //安全风险
            SaftyCheckDataRecordBLL saBLL        = new SaftyCheckDataRecordBLL(); //安全检查
            HTBaseInfoBLL           htBLL        = new HTBaseInfoBLL();           //事故隐患
            Operator                    user     = OperatorProvider.Provider.Current();
            ClassificationBLL           classBLL = new ClassificationBLL();
            List <ClassificationEntity> list     = classBLL.GetList(user.OrganizeId).ToList();

            if (list.Count == 0)
            {
                list = classBLL.GetList("0").ToList();
            }
            decimal totalScore = 0; int count = 0;

            if (user.RoleName.Contains("省级用户") || user.RoleName.Contains("集团用户"))
            {
                if (!string.IsNullOrEmpty(orgCode))
                {
                    user = new Operator
                    {
                        OrganizeId   = orgId,
                        OrganizeCode = orgCode,
                        RoleName     = "公司级用户,公司领导"
                    };
                    totalScore = desktopbll.GetScore(user, time);
                }
                else
                {
                    OrganizeBLL orgBll = new OrganizeBLL();
                    DataTable   dt     = orgBll.GetDTList();
                    foreach (DataRow dr in dt.Rows)
                    {
                        user = new Operator
                        {
                            OrganizeId   = dr[2].ToString(),
                            OrganizeCode = dr[0].ToString(),
                            RoleName     = "公司级用户,公司领导"
                        };
                        totalScore += desktopbll.GetScore(user, time);
                    }
                    totalScore = totalScore / dt.Rows.Count;
                }
            }
            else
            {
                totalScore = desktopbll.GetScore(user, time);
            }
            DataItemDetailBLL itemBLL = new DataItemDetailBLL();
            string            val     = itemBLL.GetItemValue("基础预警区间分值设置");

            count = 0;
            if (!string.IsNullOrEmpty(val))
            {
                string[] arr = val.Split('|');
                int      j   = 0;
                foreach (string str in arr)
                {
                    string[] arrVal = str.Split(',');
                    if (totalScore > decimal.Parse(arrVal[0]) && totalScore <= decimal.Parse(arrVal[1]))
                    {
                        count = j;
                        break;
                    }
                    j++;
                }
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(new { score = Math.Round(totalScore, 1), index = count }));
        }
Ejemplo n.º 8
0
        public ActionResult GetOccpuationalTreeJson(string Code, int checkMode = 0, int mode = 0, string deptIds = "0")
        {
            DataItemBLL di = new DataItemBLL();
            //先获取到字典项
            DataItemEntity DataItems = di.GetEntityByCode(Code);

            DataItemDetailBLL did = new DataItemDetailBLL();
            //根据字典项获取值
            List <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId).OrderBy(t => t.ItemValue).ToList();


            string      parentId = "0";
            OrganizeBLL orgBLL   = new OrganizeBLL();
            var         treeList = new List <TreeEntity>();

            //获取所有父节点集合
            List <DataItemDetailEntity> parentList = didList.Where(it => it.ItemValue.Length == 3).ToList();

            //获取所有子节点节点集合
            List <DataItemDetailEntity> SunList = didList.Where(it => it.ItemValue.Length > 3).ToList();

            foreach (DataItemDetailEntity oe in parentList)
            {
                treeList.Add(new TreeEntity
                {
                    id              = oe.ItemValue,
                    text            = oe.ItemName,
                    value           = oe.ItemValue,
                    parentId        = "0",
                    isexpand        = true,
                    complete        = true,
                    showcheck       = false,
                    hasChildren     = true,
                    Attribute       = "Sort",
                    AttributeValue  = "Parent",
                    AttributeA      = "manager",
                    AttributeValueA = "" + "," + "" + ",1"
                });
            }

            foreach (DataItemDetailEntity item in SunList)
            {
                int      chkState = 0;
                string[] arrids   = deptIds.Split(',');
                if (arrids.Contains(item.ItemValue))
                {
                    chkState = 1;
                }
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = false;
                tree.id              = item.ItemValue;
                tree.text            = item.ItemName;
                tree.value           = item.ItemValue;
                tree.isexpand        = true;
                tree.complete        = true;
                tree.checkstate      = chkState;
                tree.showcheck       = checkMode == 0 ? false : true;
                tree.hasChildren     = hasChildren;
                tree.parentId        = item.ItemValue.Substring(0, 3);
                tree.Attribute       = "Sort";
                tree.AttributeValue  = "Sun";
                tree.AttributeA      = "manager";
                tree.AttributeValueA = "" + "," + "" + "," + "2";
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson()));
        }
Ejemplo n.º 9
0
        public string ImportLabor()
        {
            LaborprotectionBLL laborprotectionbll = new LaborprotectionBLL();
            PostCache          postCache          = new PostCache();
            PostBLL            postBLL            = new PostBLL();
            DepartmentBLL      departmentBLL      = new DepartmentBLL();
            //获取到已选数据
            List <LaborprotectionEntity> laborlist = laborprotectionbll.GetLaborList();
            var    currUser     = OperatorProvider.Provider.Current();
            string orgId        = OperatorProvider.Provider.Current().OrganizeId;//所属公司
            int    error        = 0;
            string message      = "请选择格式正确的文件再导入!";
            string falseMessage = "";
            int    count        = HttpContext.Request.Files.Count;

            if (count > 0)
            {
                HttpPostedFileBase file = HttpContext.Request.Files[0];
                if (string.IsNullOrEmpty(file.FileName))
                {
                    return(message);
                }
                if (!(file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xls") || file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx")))
                {
                    return(message);
                }
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName));
                Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
                wb.Open(Server.MapPath("~/Resource/temp/" + fileName));
                Aspose.Cells.Cells cells = wb.Worksheets[0].Cells;
                if (cells.MaxDataRow == 0)
                {
                    message = "没有数据,请选择先填写模板在进行导入!";
                    return(message);
                }
                DataTable dt    = cells.ExportDataTable(0, 0, cells.MaxDataRow + 1, cells.MaxColumn + 1, true);
                int       order = 1;

                IList <LaborprotectionEntity> LaborList = new List <LaborprotectionEntity>();

                IEnumerable <DepartmentEntity> deptlist = new DepartmentBLL().GetList();
                OrganizeBLL orgbll = new OrganizeBLL();
                //先获取到原始的一个编号
                string no   = laborprotectionbll.GetNo();
                int    ysno = Convert.ToInt32(no);

                DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();
                var dataitem = dataItemDetailBLL.GetDataItemListByItemCode("'LaborName'").ToList();
                List <LaborprotectionEntity> insertpro  = new List <LaborprotectionEntity>();
                List <LaborinfoEntity>       insertinfo = new List <LaborinfoEntity>();
                //先获取人员
                List <UserEntity> userlist =
                    new UserBLL().GetListForCon(it => it.IsPresence == "1" && it.Account != "System").ToList();
                List <LaborequipmentinfoEntity> eqlist = new List <LaborequipmentinfoEntity>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    order = i;
                    string Name = dt.Rows[i]["名称"].ToString();
                    string Model = dt.Rows[i]["型号"].ToString();
                    string Type = dt.Rows[i]["类型"].ToString();
                    string DeptName = dt.Rows[i]["使用部门"].ToString();
                    string OrgName = dt.Rows[i]["使用单位"].ToString();
                    string PostName = dt.Rows[i]["使用岗位"].ToString().Trim();
                    string Unit = dt.Rows[i]["劳动防护用品单位"].ToString().Trim();
                    string Time = dt.Rows[i]["使用期限"].ToString().Trim();
                    string TimeType = dt.Rows[i]["使用期限单位"].ToString().Trim();
                    string deptId = "", deptCode = "", PostId = "";
                    //---****值存在空验证*****--
                    if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Unit) || string.IsNullOrEmpty(DeptName) || string.IsNullOrEmpty(OrgName) || string.IsNullOrEmpty(PostName))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行值存在空,未能导入.";
                        error++;
                        continue;
                    }

                    //验证机构是不是和自己一个机构
                    DepartmentEntity org = deptlist.Where(it => it.FullName == OrgName).FirstOrDefault();
                    if (org == null)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行使用单位名称不存在,未能导入.";
                        error++;
                        continue;
                    }
                    //如果导入的机构id和本人的机构id不一致
                    if (org.DepartmentId != currUser.OrganizeId)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行使用单位不是导入者的单位,未能导入.";
                        error++;
                        continue;
                    }

                    //验证所填部门是否存在
                    var deptFlag = false;
                    var entity1  = deptlist.Where(x => x.OrganizeId == currUser.OrganizeId && x.FullName == DeptName).FirstOrDefault();
                    if (entity1 == null)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行使用部门不存在,未能导入.";
                        error++;
                        deptFlag = true;
                        break;
                    }
                    else
                    {
                        deptId   = entity1.DepartmentId;
                        deptCode = entity1.EnCode;
                    }

                    //var deptFlag = false;
                    //var array = DeptName.Split('/');
                    //for (int j = 0; j < array.Length; j++)
                    //{
                    //    if (j == 0)
                    //    {
                    //        if (currUser.RoleName.Contains("省级"))
                    //        {
                    //            var entity1 = deptlist.Where(x => x.OrganizeId == currUser.OrganizeId && x.FullName == array[j].ToString()).FirstOrDefault();
                    //            if (entity1 == null)
                    //            {
                    //                falseMessage += "</br>" + "第" + (i + 2) + "行部门不存在,未能导入.";
                    //                error++;
                    //                deptFlag = true;
                    //                break;
                    //            }
                    //            else
                    //            {
                    //                deptId = entity1.DepartmentId;
                    //                deptCode = entity1.EnCode;
                    //            }
                    //        }
                    //        else
                    //        {
                    //            var entity = deptlist.Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "厂级" && x.FullName == array[j].ToString()).FirstOrDefault();
                    //            if (entity == null)
                    //            {
                    //                entity = deptlist.Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "部门" && x.FullName == array[j].ToString()).FirstOrDefault();
                    //                if (entity == null)
                    //                {
                    //                    entity = deptlist.Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "承包商" && x.FullName == array[j].ToString()).FirstOrDefault();
                    //                    if (entity == null)
                    //                    {
                    //                        falseMessage += "</br>" + "第" + (i + 2) + "行部门不存在,未能导入.";
                    //                        error++;
                    //                        deptFlag = true;
                    //                        break;
                    //                    }
                    //                    else
                    //                    {
                    //                        deptId = entity.DepartmentId;
                    //                        deptCode = entity.EnCode;
                    //                    }
                    //                }
                    //                else
                    //                {
                    //                    deptId = entity.DepartmentId;
                    //                    deptCode = entity.EnCode;
                    //                }
                    //            }
                    //            else
                    //            {
                    //                deptId = entity.DepartmentId;
                    //                deptCode = entity.EnCode;
                    //            }
                    //        }
                    //    }
                    //    else if (j == 1)
                    //    {
                    //        var entity1 = deptlist.Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "专业" && x.FullName == array[j].ToString()).FirstOrDefault();
                    //        if (entity1 == null)
                    //        {
                    //            entity1 = deptlist.Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "班组" && x.FullName == array[j].ToString()).FirstOrDefault();
                    //            if (entity1 == null)
                    //            {
                    //                falseMessage += "</br>" + "第" + (i + 2) + "行专业/班组不存在,未能导入.";
                    //                error++;
                    //                deptFlag = true;
                    //                break;
                    //            }
                    //            else
                    //            {
                    //                deptId = entity1.DepartmentId;
                    //                deptCode = entity1.EnCode;
                    //            }
                    //        }
                    //        else
                    //        {
                    //            deptId = entity1.DepartmentId;
                    //            deptCode = entity1.EnCode;
                    //        }

                    //    }
                    //    else
                    //    {
                    //        var entity1 = deptlist.Where(x => x.OrganizeId == currUser.OrganizeId && x.Nature == "班组" && x.FullName == array[j].ToString()).FirstOrDefault();
                    //        if (entity1 == null)
                    //        {
                    //            falseMessage += "</br>" + "第" + (i + 2) + "行班组不存在,未能导入.";
                    //            error++;
                    //            deptFlag = true;
                    //            break;
                    //        }
                    //        else
                    //        {
                    //            deptId = entity1.DepartmentId;
                    //            deptCode = entity1.EnCode;
                    //        }
                    //    }
                    //}
                    if (deptFlag)
                    {
                        continue;
                    }

                    //检验所填岗位是否属于其公司或者部门
                    if (string.IsNullOrEmpty(deptId) || deptId == "undefined")
                    {
                        //所属公司
                        RoleEntity data = postCache.GetList(orgId, "true").OrderBy(x => x.SortCode).Where(a => a.FullName == PostName).FirstOrDefault();
                        if (data == null)
                        {
                            falseMessage += "</br>" + "第" + (i + 2) + "行岗位不属于该公司,未能导入.";
                            error++;
                            continue;
                        }
                    }
                    else
                    {
                        //所属部门
                        //所属公司
                        RoleEntity data = postCache.GetList(orgId, deptId).OrderBy(x => x.SortCode).Where(a => a.FullName == PostName).FirstOrDefault();
                        if (data == null)
                        {
                            falseMessage += "</br>" + "第" + (i + 2) + "行岗位不属于该部门,未能导入.";
                            error++;
                            continue;
                        }
                    }
                    //--**验证岗位是否存在**--


                    RoleEntity re = postBLL.GetList().Where(a => a.FullName == PostName && a.OrganizeId == orgId).FirstOrDefault();
                    if (!(string.IsNullOrEmpty(deptId) || deptId == "undefined"))
                    {
                        re = postBLL.GetList().Where(a => a.FullName == PostName && a.OrganizeId == orgId && a.DeptId == deptId).FirstOrDefault();
                        if (re == null)
                        {
                            re = postBLL.GetList().Where(a =>
                                                         a.FullName == PostName && a.OrganizeId == orgId &&
                                                         a.Nature == departmentBLL.GetEntity(deptId).Nature).FirstOrDefault();
                        }
                    }
                    if (re == null)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行岗位有误,未能导入.";
                        error++;
                        continue;
                    }
                    else
                    {
                        PostId = re.RoleId;
                    }

                    LaborinfoEntity linfo = new LaborinfoEntity();
                    linfo.PostId                 = PostId;
                    linfo.DeptCode               = deptCode;
                    linfo.DeptId                 = deptId;
                    linfo.DeptName               = DeptName;
                    linfo.LaboroPerationTime     = DateTime.Now;
                    linfo.LaboroPerationUserName = currUser.UserName;
                    linfo.Model   = Model;
                    linfo.Name    = Name;
                    linfo.OrgCode = currUser.OrganizeCode;
                    linfo.OrgId   = currUser.OrganizeId;
                    linfo.OrgName = currUser.OrganizeName;
                    linfo.Type    = Type;
                    if (Time == "" || !isInt(Time))
                    {
                        linfo.TimeNum = null;
                    }
                    else
                    {
                        linfo.TimeNum  = Convert.ToInt32(Time);
                        linfo.TimeType = TimeType;
                    }

                    linfo.PostName = PostName;
                    linfo.Unit     = Unit;
                    linfo.Create();
                    //如果已存在物品库中
                    LaborprotectionEntity lp = laborlist.Where(it => it.Name == Name).FirstOrDefault();
                    if (lp != null)
                    {
                        linfo.No  = lp.No;
                        linfo.LId = lp.ID;
                        //如果库里有值 则使用库里的值
                        linfo.Type     = linfo.Type;
                        linfo.TimeNum  = lp.TimeNum;
                        linfo.TimeType = lp.TimeType;
                    }
                    else
                    {
                        LaborprotectionEntity newlp = new LaborprotectionEntity();
                        newlp.Create();
                        newlp.Name = Name;
                        newlp.No   = ysno.ToString();
                        newlp.LaborOperationTime     = DateTime.Now;
                        newlp.LaborOperationUserName = currUser.UserName;
                        newlp.Model    = Model;
                        newlp.Type     = Type;
                        newlp.Unit     = Unit;
                        newlp.TimeNum  = linfo.TimeNum;
                        newlp.TimeType = TimeType;
                        linfo.No       = ysno.ToString();
                        linfo.LId      = newlp.ID;
                        ysno++;
                        insertpro.Add(newlp);
                    }

                    int num = 0;
                    List <UserEntity> ulist = userlist.Where(it => it.DepartmentId == deptId && it.DutyId == PostId).ToList();
                    for (int j = 0; j < ulist.Count; j++)
                    {
                        //添加岗位关联人员
                        LaborequipmentinfoEntity eq = new LaborequipmentinfoEntity();
                        eq.UserName  = ulist[j].RealName;
                        eq.AssId     = linfo.ID;
                        eq.LaborType = 0;
                        eq.ShouldNum = 1;
                        num++;
                        eq.UserId = ulist[j].UserId;
                        if (linfo.Type == "衣服")
                        {
                            eq.Size = "L";
                        }
                        else if (linfo.Type == "鞋子")
                        {
                            eq.Size = "40";
                        }
                        else
                        {
                            eq.Size = "";
                        }
                        eq.Create();
                        eqlist.Add(eq);
                    }

                    linfo.ShouldNum = num;
                    insertinfo.Add(linfo);
                }



                laborinfobll.ImportSaveForm(insertinfo, insertpro, eqlist);

                count    = dt.Rows.Count;
                message  = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条";
                message += "</br>" + falseMessage;
            }

            return(message);
        }
Ejemplo n.º 10
0
        public static List <string> GetUserList(string userid)
        {
            if (cache[userid + "user"] != null)
            {
                return((List <string>)cache[userid + "user"]);
            }

            DepartmentBLL departmentBLL = new DepartmentBLL();
            OrganizeBLL   organizeBLL   = new OrganizeBLL();
            UserBLL       userBLL       = new UserBLL();

            UserEntity userEntity = new UserBLL().GetEntity(userid);

            if (userEntity == null)
            {
                return(null);
            }

            var orgnizedata = organizeBLL.GetList().ToList();
            List <OrganizeEntity> lstOrg = new List <OrganizeEntity>();

            foreach (OrganizeEntity org in orgnizedata)
            {
                if (org.ManagerId == userEntity.UserId)
                {
                    // operators.LstOrganizeId.Add(org.OrganizeId); //登录用户作为负责人的公司
                    lstOrg = (Reorg(orgnizedata, org.OrganizeId));//登录用户作为负责人的公司及下属
                    lstOrg.Add(org);
                }
            }
            var LstOrganizeId = new List <string>();

            foreach (OrganizeEntity org in lstOrg)
            {
                LstOrganizeId.Add(org.OrganizeId);
            }



            var departmentdata             = departmentBLL.GetList().ToList();
            List <DepartmentEntity> lstDep = new List <DepartmentEntity>();

            foreach (DepartmentEntity dep in departmentdata)
            {
                if (dep.ManagerId == userEntity.UserId)
                {
                    // operators.LstOrganizeId.Add(dep.DepartmentId);//登录用户作为负责人的部门
                    lstDep = (Redep(departmentdata, dep.DepartmentId));//登录用户作为负责人的部门及下属
                    lstDep.Add(dep);
                }
            }
            var LstDepartmentId = new List <string>();

            foreach (DepartmentEntity dep in lstDep)
            {
                LstDepartmentId.Add(dep.DepartmentId);
            }

            var userdata = userBLL.GetList().ToList();
            List <UserEntity> lstUser = new List <UserEntity>();

            foreach (UserEntity usr in userdata)
            {
                if (usr.ManagerId == userEntity.UserId)
                {
                    //operators.LstStaffId.Add(usr.UserId);//登录用户上级主管的用户
                    lstUser = (Reusr(userdata, userEntity.UserId));//登录用户作为负责人的部门及下属
                }
            }
            var LstStaffId = new List <string>();

            foreach (UserEntity usr in lstUser)
            {
                LstStaffId.Add(usr.UserId);
            }

            if (LstOrganizeId.Count > 0)
            {//获取公司及下属公司人员
                var depuser1 = userdata.FindAll(a => LstOrganizeId.Contains(Convert.ToString(a.OrganizeId)));

                foreach (var ent in depuser1)
                {
                    LstStaffId.Add(ent.UserId);
                }
            }
            if (LstDepartmentId.Count > 0)
            {//获取部门及下属部门人员
                var depuser2 = userdata.FindAll(a => LstDepartmentId.Contains(Convert.ToString(a.DepartmentId)));
                foreach (var ent in depuser2)
                {
                    LstStaffId.Add(ent.UserId);
                }
            }
            if (LstStaffId.Count > 0)
            {////获取人员及下属人员
                var depuser3 = userdata.FindAll(a => LstStaffId.Contains(Convert.ToString(a.UserId)));
                foreach (var ent in depuser3)
                {
                    LstStaffId.Add(ent.UserId);
                }
            }
            LstStaffId.Add(userid);

            cache.Insert(userid + "user", LstStaffId.Distinct().ToList(), null, DateTime.Now.AddMinutes(10), System.Web.Caching.Cache.NoSlidingExpiration);

            return(LstStaffId.Distinct().ToList());;
        }
Ejemplo n.º 11
0
        public HttpResponseMessage CheckLoginJson(string username, string password)
        {
            try
            {
                RoleBLL       roleBLL       = new RoleBLL();
                DepartmentBLL departmentBLL = new DepartmentBLL();
                OrganizeBLL   organizeBLL   = new OrganizeBLL();
                UserBLL       userBLL       = new UserBLL();

                byte[]        sor    = Encoding.UTF8.GetBytes(password);
                MD5           md5    = MD5.Create();
                byte[]        result = md5.ComputeHash(sor);
                StringBuilder strbul = new StringBuilder(40);
                for (int i = 0; i < result.Length; i++)
                {
                    strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
                }
                password = strbul.ToString();


                UserEntity userEntity = new UserBLL().CheckLogin(username, password);
                if (userEntity == null)
                {
                    return(new HttpResponseMessage {
                        Content = new StringContent("查询失败", Encoding.GetEncoding("UTF-8"), "application/json")
                    });
                }

                UserUrlModel userurlmodel = new UserUrlModel();

                EntityToEntity(userurlmodel, userEntity);

                OrganizeEntity orgent = organizeBLL.GetEntity(userEntity.OrganizeId);
                if (string.IsNullOrEmpty(orgent.ParentId) || orgent.ParentId == "0")
                {
                    userurlmodel.IsTopOrg = true;
                }

                //var orgnizedata = organizeBLL.GetList().ToList();
                //List<OrganizeEntity> lstOrg = new List<OrganizeEntity>();
                Operator operators = new Operator();

                //foreach (OrganizeEntity org in orgnizedata)
                //{
                //    if (org.ManagerId == userurlmodel.UserId)
                //    {
                //        // operators.LstOrganizeId.Add(org.OrganizeId); //登录用户作为负责人的公司
                //        lstOrg=(Reorg(orgnizedata, org.OrganizeId));//登录用户作为负责人的公司及下属
                //    }
                //}
                //operators.LstOrganizeId = new List<string>();
                //foreach (OrganizeEntity org in lstOrg)
                //{
                //    operators.LstOrganizeId.Add(org.OrganizeId);
                //}

                //var departmentdata = departmentBLL.GetList().ToList();
                //List<DepartmentEntity> lstDep = new List<DepartmentEntity>();
                //foreach (DepartmentEntity dep in departmentdata)
                //{
                //    if (dep.DepartmentId == userurlmodel.DepartmentId)
                //    {
                //        userurlmodel.DepartmentName = dep.FullName;
                //    }
                //    if (dep.ManagerId == userurlmodel.UserId)
                //    {
                //       // operators.LstOrganizeId.Add(dep.DepartmentId);//登录用户作为负责人的部门
                //        lstDep=(Redep(departmentdata, dep.DepartmentId));//登录用户作为负责人的部门及下属
                //    }
                //}
                //operators.LstDepartmentId = new List<string>();
                //foreach (DepartmentEntity dep in lstDep)
                //{
                //    operators.LstDepartmentId.Add(dep.DepartmentId);
                //}



                //var userdata = userBLL.GetList().ToList();
                //List<UserEntity> lstUser = new List<UserEntity>();

                //foreach (UserEntity usr in userdata)
                //{
                //    if (usr.ManagerId == userurlmodel.UserId)
                //    {
                //        //operators.LstStaffId.Add(usr.UserId);//登录用户上级主管的用户
                //        lstUser=(Reusr(userdata, userurlmodel.UserId));//登录用户作为负责人的部门及下属
                //    }
                //}
                //operators.LstStaffId = new List<string>();
                //foreach (UserEntity usr in lstUser)
                //{
                //    operators.LstStaffId.Add(usr.UserId);
                //}
                ////var depuser1 = new List<string>();
                ////var depuser2 = new List<UserEntity>();
                ////var depuser3 = new List<UserEntity>();

                //if (operators.LstOrganizeId.Count > 0)
                //{//获取公司及下属公司人员
                //      var  depuser1 = userdata.FindAll(a => operators.LstOrganizeId.Contains(a.OrganizeId.ToString())) ;

                //    foreach(var ent in depuser1)
                //    {
                //        operators.LstStaffId.Add(ent.UserId);
                //    }
                //}
                //if (operators.LstDepartmentId.Count > 0)
                //{//获取部门及下属部门人员
                // var   depuser2 = userdata.FindAll(a => operators.LstDepartmentId.Contains(a.DepartmentId.ToString())) ;
                //    foreach (var ent in depuser2)
                //    {
                //        operators.LstStaffId.Add(ent.UserId);
                //    }
                //}
                //if (operators.LstStaffId.Count > 0)
                //{////获取人员及下属人员
                //  var  depuser3 = userdata.FindAll(a => operators.LstStaffId.Contains(a.UserId.ToString())) ;
                //    foreach (var ent in depuser3)
                //    {
                //        operators.LstStaffId.Add(ent.UserId);
                //    }
                //}

                operators.UserId   = userEntity.UserId;
                operators.UserName = userEntity.RealName;
                operators.Token    = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                operators.LogTime  = DateTime.Now;
                OperatorProvider.Provider.AddCurrent(operators);

                var roledata = roleBLL.GetList();

                foreach (RoleEntity dep in roledata)
                {
                    if (dep.RoleId == userEntity.RoleId)
                    {
                        userurlmodel.RoleName = dep.FullName;
                        userurlmodel.RoleCode = dep.EnCode;
                    }
                }
                CommonMethod.cache.Remove(userEntity.UserId + "organize");
                CommonMethod.cache.Remove(userEntity.UserId + "user");
                CommonMethod.GetUserList(userEntity.UserId);
                CommonMethod.GetOrgnizeList(userEntity.UserId);

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string str             = serializer.Serialize(userurlmodel);
                HttpResponseMessage ut = new HttpResponseMessage {
                    Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                };
                return(ut);
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage {
                    Content = new StringContent(ex.Message, Encoding.GetEncoding("UTF-8"), "application/json")
                });
            }
        }
Ejemplo n.º 12
0
        public ActionResult CheckLogin(string username, string password, string verifycode, int autologin)
        {
            LogEntity logEntity = new LogEntity();

            logEntity.F_CategoryId     = 1;
            logEntity.F_OperateTypeId  = ((int)OperationType.Login).ToString();
            logEntity.F_OperateType    = EnumAttribute.GetDescription(OperationType.Login);
            logEntity.F_OperateAccount = username;
            logEntity.F_OperateUserId  = username;
            logEntity.F_Module         = Config.GetValue("SoftName");

            try
            {
                #region 验证码验证
                if (autologin == 0)
                {
                    verifycode = Md5Helper.MD5(verifycode.ToLower(), 16);
                    if (Session["session_verifycode"].IsEmpty() || verifycode != Session["session_verifycode"].ToString())
                    {
                        throw new Exception("验证码错误,请重新输入");
                    }
                }
                #endregion

                //#region 第三方账户验证
                //AccountEntity accountEntity = accountBLL.CheckLogin(username, password);
                //if (accountEntity != null)
                //{
                //    Operator operators = new Operator();
                //    operators.UserId = accountEntity.AccountId;
                //    operators.Code = accountEntity.MobileCode;
                //    operators.Account = accountEntity.MobileCode;
                //    operators.UserName = accountEntity.FullName;
                //    operators.Password = accountEntity.Password;
                //    operators.IPAddress = Net.Ip;
                //    operators.IPAddressName = IPLocation.GetLocation(Net.Ip);
                //    operators.ObjectId = "";
                //    operators.HeadIcon = "noimg";
                //    operators.LogTime = DateTime.Now;
                //    operators.Token = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                //    operators.IsSystem = true;
                //    AuthorizeDataModel dataAuthorize = new AuthorizeDataModel();
                //    OperatorProvider.Provider.AddCurrent(operators, dataAuthorize);
                //    //在线体验用到
                //    WebHelper.WriteCookie("mobileCode", accountEntity.MobileCode);
                //    //登录限制
                // LoginLimit(username, operators.IPAddress, operators.IPAddressName);
                //    return Success("登录成功。");
                //}
                //#endregion

                #region 内部账户验证
                UserEntity userEntity = new UserBLL().CheckLogin(username, password);
                if (userEntity != null)
                {
                    AuthorizeBLL authorizeBLL = new AuthorizeBLL();
                    Operator     operators    = new Operator();
                    operators.UserId       = userEntity.F_UserId;
                    operators.Code         = userEntity.F_EnCode;
                    operators.Account      = userEntity.F_Account;
                    operators.UserName     = userEntity.F_RealName;
                    operators.Password     = userEntity.F_Password;
                    operators.Secretkey    = userEntity.F_Secretkey;
                    operators.CompanyId    = userEntity.F_OrganizeId;
                    operators.DepartmentId = userEntity.F_DepartmentId;
                    operators.HeadIcon     = userEntity.F_HeadIcon;
                    if (string.IsNullOrEmpty(operators.HeadIcon))
                    {
                        operators.HeadIcon = "noimg";
                    }
                    operators.IPAddress = Net.Ip;
                    //operators.IPAddressName = IPLocation.GetLocation(Net.Ip);
                    operators.ObjectId = new PermissionBLL().GetObjectStr(userEntity.F_UserId);
                    operators.LogTime  = DateTime.Now;
                    operators.Token    = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                    //写入当前用户数据权限
                    //判断是否系统管理员
                    if (userEntity.F_EnCode == "System")
                    {
                        operators.IsSystem = true;
                    }
                    else
                    {
                        OrganizeEntity organize = new OrganizeBLL().GetEntity(userEntity.F_OrganizeId);
                        Session["organize"] = organize;
                        operators.IsSystem  = false;
                    }
                    AuthorizeDataModel dataAuthorize = new AuthorizeDataModel();
                    dataAuthorize.ReadAutorize        = authorizeBLL.GetDataAuthor(operators);
                    dataAuthorize.ReadAutorizeUserId  = authorizeBLL.GetDataAuthorUserId(operators);
                    dataAuthorize.WriteAutorize       = authorizeBLL.GetDataAuthor(operators, true);
                    dataAuthorize.WriteAutorizeUserId = authorizeBLL.GetDataAuthorUserId(operators, true);
                    OperatorProvider.Provider.AddCurrent(operators, dataAuthorize);
                    //在线体验用到
                    if (WebHelper.GetCookie("mobileCode") != "")
                    {
                        username = WebHelper.GetCookie("mobileCode");
                    }
                    //登录限制
                    //LoginLimit(username, operators.IPAddress, operators.IPAddressName);
                    //写入日志
                    logEntity.F_ExecuteResult     = 1;
                    logEntity.F_ExecuteResultJson = "登录成功";
                    logEntity.WriteLog();
                }
                return(Success("登录成功。"));

                #endregion
            }
            catch (Exception ex)
            {
                WebHelper.RemoveCookie("learn_autologin");                  //清除自动登录
                logEntity.F_ExecuteResult     = -1;
                logEntity.F_ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(Error(ex.Message));
            }
        }
Ejemplo n.º 13
0
        public ActionResult GetDeptTreeJson(string Ids, int checkMode = 0, int mode = 0)
        {
            OrganizeBLL             organizeBLL    = new OrganizeBLL();
            Operator                user           = OperatorProvider.Provider.Current();
            List <OrganizeEntity>   organizedata   = new List <OrganizeEntity>();
            List <DepartmentEntity> departmentdata = new List <DepartmentEntity>();
            string roleNames = user.RoleName;

            if (string.IsNullOrEmpty(Ids))
            {
                Ids = departmentBLL.GetRootDepartment().DepartmentId;
            }
            var depts = Ids.Split(',');

            if (user.IsSystem)
            {
                var organizedata1 = CacheFactory.Cache().GetCache <IEnumerable <OrganizeEntity> >(organizeBLL.cacheKey);//organizeCache.GetList();
                if (organizedata1 == null)
                {
                    organizedata1 = organizeBLL.GetList();
                }
                organizedata = organizedata1.ToList();
                var departmentdata1 = CacheFactory.Cache().GetCache <IEnumerable <DepartmentEntity> >(departmentBLL.cacheKey);//departmentCache.GetList();
                if (departmentdata1 == null)
                {
                    departmentdata1 = departmentBLL.GetList();
                }
                departmentdata = departmentdata1.ToList();
            }
            else
            {
                //var organizedata1 = CacheFactory.Cache().GetCache<IEnumerable<OrganizeEntity>>(organizeBLL.cacheKey);//organizeCache.GetList();
                //if (organizedata1 == null)
                //{
                //    organizedata1 = organizeBLL.GetList();
                //}
                //organizedata = organizedata1.ToList();
                if (mode == 1)
                {
                    departmentdata = new DepartmentBLL().GetDepartments(depts);
                }
                else
                {
                    departmentdata = new DepartmentBLL().GetSubDepartments(depts);
                }
            }
            var treeList = new List <TreeEntity>();

            foreach (OrganizeEntity item in organizedata)
            {
                #region 机构
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = organizedata.Count(t => t.ParentId == item.OrganizeId) == 0 ? false : true;
                if (hasChildren == false)
                {
                    hasChildren = departmentdata.Count(t => t.OrganizeId == item.OrganizeId) == 0 ? false : true;
                }
                tree.id              = item.OrganizeId;
                tree.text            = item.FullName;
                tree.value           = item.OrganizeId;
                tree.parentId        = item.ParentId;
                tree.isexpand        = true;
                tree.complete        = true;
                tree.hasChildren     = hasChildren;
                tree.Attribute       = "Sort";
                tree.AttributeValue  = "Organize";
                tree.AttributeA      = "EnCode";
                tree.AttributeValueA = item.EnCode;
                treeList.Add(tree);
                #endregion
            }
            foreach (DepartmentEntity item in departmentdata)
            {
                #region 部门
                TreeEntity tree = new TreeEntity();
                tree.id    = item.DepartmentId;
                tree.text  = item.FullName;
                tree.value = item.DepartmentId;
                if (item.ParentId == "0")
                {
                    tree.parentId = item.OrganizeId;
                }
                else
                {
                    tree.parentId = item.ParentId;
                }
                tree.isexpand    = true;
                tree.complete    = true;
                tree.hasChildren = true;
                if (item.Nature == "班组")
                {
                    tree.Attribute      = "Code";
                    tree.AttributeValue = item.EnCode;
                }
                if (item.Nature == "班组" || item.Nature == "部门")
                {
                    tree.showcheck = checkMode == 0 ? false : true;
                }
                treeList.Add(tree);
                #endregion
            }
            return(Content(treeList.TreeToJson(string.IsNullOrEmpty(Ids) ? "0" : string.Join(",", treeList.FindAll(x => depts.Contains(x.id)).Select(x => x.parentId)))));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 部门列表
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <returns>返回机构+部门树形Json</returns>
        public ActionResult GetOrganizeTreeJson(string keyword)
        {
            var organizedata   = new OrganizeBLL().GetList();//organizeCache.GetList();
            var departmentdata = departmentBLL.GetList();
            var treeList       = new List <TreeEntity>();

            foreach (OrganizeEntity item in organizedata)
            {
                #region 机构
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = organizedata.Count(t => t.ParentId == item.OrganizeId) == 0 ? false : true;
                if (hasChildren == false)
                {
                    hasChildren = departmentdata.Count(t => t.OrganizeId == item.OrganizeId) == 0 ? false : true;
                    //if (hasChildren == false)
                    //{
                    //    continue;
                    //}
                }
                tree.id             = item.OrganizeId;
                tree.text           = item.FullName;
                tree.value          = item.OrganizeId;
                tree.parentId       = item.ParentId;
                tree.isexpand       = true;
                tree.complete       = true;
                tree.hasChildren    = hasChildren;
                tree.Attribute      = "Sort";
                tree.AttributeValue = "Organize";
                treeList.Add(tree);
                #endregion
            }
            foreach (DepartmentEntity item in departmentdata)
            {
                #region 部门
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = departmentdata.Count(t => t.ParentId == item.DepartmentId) == 0 ? false : true;
                tree.id    = item.DepartmentId;
                tree.text  = item.FullName;
                tree.value = item.DepartmentId;
                if (item.ParentId == "0")
                {
                    tree.parentId = item.OrganizeId;
                }
                else
                {
                    tree.parentId = item.ParentId;
                }
                tree.isexpand       = true;
                tree.complete       = true;
                tree.hasChildren    = hasChildren;
                tree.Attribute      = "Sort";
                tree.AttributeValue = "Department";
                treeList.Add(tree);
                #endregion
            }
            if (!string.IsNullOrEmpty(keyword))
            {
                treeList = treeList.TreeWhere(t => t.text.Contains(keyword), "id", "parentId");
            }
            return(Content(treeList.TreeToJson()));
        }