/// <summary>
        /// 考评标准类别修改
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult ClassEdit(string id)
        {
            var bll = new EvaluateBLL();

            var list           = bll.GetAllCategories().ToList();
            var data           = list.Where(t => t.CategoryId == id).LastOrDefault();
            var parentCategory = list.Where(t => t.CategoryId == data.ParentCategoryId).LastOrDefault();

            CategoryModel entity = new CategoryModel();

            if (parentCategory != null)
            {
                ViewData["parentCategory"]   = parentCategory.Category;
                ViewData["parentCategoryId"] = parentCategory.CategoryId;
            }
            else
            {
                ViewData["parentCategory"]   = "";
                ViewData["parentCategoryId"] = "";
            }
            return(View(new CategoryModel()
            {
                Category = data.Category, CategoryId = data.CategoryId, SortCode = data.SortCode
            }));
        }
        /// <summary>
        /// 获取类别
        /// </summary>
        /// <returns></returns>
        public JsonResult GetCategories()
        {
            var bll  = new EvaluateBLL();
            var data = bll.GetAllCategories().ToList();

            return(Json(data.Where(x => x.ParentCategoryId == null).Select(x => new TreeModel {
                id = x.CategoryId, value = x.CategoryId, text = x.Category, isexpand = data.Count(y => y.ParentCategoryId == x.CategoryId) > 0, hasChildren = data.Count(y => y.ParentCategoryId == x.CategoryId) > 0, ChildNodes = GetChildren(data, x.CategoryId)
            }).ToList(), JsonRequestBehavior.AllowGet));
        }
        public JsonResult Import(string id)
        {
            DepartmentBLL dpbll = new DepartmentBLL();
            var           book  = new Workbook(this.Request.Files[0].InputStream);
            var           sheet = book.Worksheets[0];

            var sss        = sheet.Cells[0, 0].StringValue;
            var bll        = new EvaluateBLL();
            var categories = bll.GetAllCategories().ToList();

            var success = true;
            var message = "保存成功";
            var user    = OperatorProvider.Provider.Current();

            var date = DateTime.Now;

            try
            {
                var categoryname  = string.Empty;
                var categoryitems = new List <EvaluateCategoryItemEntity>();
                for (int i = 1; i <= sheet.Cells.MaxRow; i++)
                {
                    var currentcategory = sheet.Cells[i, 0].StringValue;
                    if (!string.IsNullOrWhiteSpace(currentcategory))
                    {
                        categoryname = currentcategory;
                    }

                    var category = categories.Find(x => x.Category == categoryname);
                    if (category == null)
                    {
                        throw new Exception(string.Format("不存在考评要素,行 {0}", i + 1));
                    }

                    var score = 0;
                    if (sheet.Cells[i, 3].Type == CellValueType.IsNumeric)
                    {
                        score = sheet.Cells[i, 3].IntValue;
                    }

                    var itemcontent = sheet.Cells[i, 1].StringValue;
                    if (string.IsNullOrEmpty(itemcontent))
                    {
                        throw new Exception(string.Format("考评内容不能为空,行 {0}", i + 1));
                    }

                    var khbz = sheet.Cells[i, 2].StringValue;
                    if (string.IsNullOrEmpty(khbz))
                    {
                        throw new Exception(string.Format("考评标准不能为空,行 {0}", i + 1));
                    }

                    var deptname = sheet.Cells[i, 5].StringValue;
                    var deptid   = "";
                    if (!string.IsNullOrEmpty(deptname))
                    {
                        if (deptname.Contains(','))
                        {
                            string[] names = deptname.Split(',');
                            foreach (string name in names)
                            {
                                var dept = dpbll.GetList().Where(x => x.FullName == name && x.Nature == "班组").FirstOrDefault();
                                if (dept == null)
                                {
                                    throw new Exception(string.Format("班组{1}不存在,行 {0}", i + 1, deptname));
                                }
                                else
                                {
                                    deptid += dept.DepartmentId + ",";
                                }
                            }
                            if (deptid.EndsWith(","))
                            {
                                deptid = deptid.Substring(0, deptid.Length - 1);
                            }
                        }
                        else
                        {
                            var dept = dpbll.GetList().Where(x => x.FullName == deptname && x.Nature == "班组").FirstOrDefault();
                            if (dept == null)
                            {
                                throw new Exception(string.Format("班组{1}不存在,行 {0}", i + 1, deptname));
                            }
                            else
                            {
                                deptid = dept.DepartmentId;
                            }
                        }
                    }


                    var categoryitem = new EvaluateCategoryItemEntity()
                    {
                        ItemId = Guid.NewGuid().ToString(), CategoryId = category.CategoryId, ItemContent = sheet.Cells[i, 1].StringValue, ItemStandard = sheet.Cells[i, 2].StringValue, EvaluateDept = sheet.Cells[i, 4].StringValue, UseDept = deptname, UseDeptId = deptid, CreateUserId = user.UserId, CreateTime = date.AddSeconds(i), Score = score
                    };
                    categoryitems.Add(categoryitem);
                }

                bll.AddItem(categoryitems);
            }
            catch (Exception ex)
            {
                success = false;
                message = ex.Message;
            }

            return(Json(new AjaxResult {
                type = success ? ResultType.success : ResultType.error, message = HttpUtility.JavaScriptStringEncode(message)
            }));
        }