/// <summary>
        /// 新增修改
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveForm(SelfEvaluateEntity entity)
        {
            var userNow = OperatorProvider.Provider.Current();

            var bll = new SelfEvaluateBLL();

            try
            {
                if (string.IsNullOrEmpty(entity.Id)) //新增自我评估
                {
                    entity.Id = Guid.NewGuid().ToString();
                }
                entity.CreateUser   = userNow.UserName;
                entity.CreateUserId = userNow.UserId;
                entity.DeptCode     = userNow.DeptCode;
                entity.DeptId       = userNow.DeptId;
                entity.DeptName     = userNow.DeptName;
                if (string.IsNullOrEmpty(entity.A.Id)) //新增自我评估
                {
                    entity.A.Id = Guid.NewGuid().ToString();
                }
                if (string.IsNullOrEmpty(entity.B.Id)) //新增自我评估
                {
                    entity.B.Id = Guid.NewGuid().ToString();
                }
                if (string.IsNullOrEmpty(entity.C.Id)) //新增自我评估
                {
                    entity.C.Id = Guid.NewGuid().ToString();
                }
                if (string.IsNullOrEmpty(entity.D.Id)) //新增自我评估
                {
                    entity.D.Id = Guid.NewGuid().ToString();
                }
                if (string.IsNullOrEmpty(entity.E.Id)) //新增自我评估
                {
                    entity.E.Id = Guid.NewGuid().ToString();
                }
                entity.A.EvaId = entity.Id;
                entity.B.EvaId = entity.Id;
                entity.C.EvaId = entity.Id;
                entity.D.EvaId = entity.Id;
                entity.E.EvaId = entity.Id;
                if (entity.IsSubmit == "1")
                {
                    entity.IsFill = "1";
                }
                bll.SaveForm(entity);
                return(Success("操作完成"));
            }
            catch (Exception ex)
            {
                return(Error("操作失败:" + ex.Message));
            }
        }
Example #2
0
 public void SaveForm(SelfEvaluateEntity entity)
 {
     service.SaveForm(entity);
 }
Example #3
0
        public object GetSelfEvaluateList([FromBody] JObject json)
        {
            try
            {
                var     bll = new SelfEvaluateBLL();
                string  res = json.Value <string>("json");
                dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res);
                int     page = Convert.ToInt32(dy.data.pageNum), rows = Convert.ToInt32(dy.data.pageSize);
                string  type     = dy.data.type;
                string  name     = dy.data.name;
                string  userid   = dy.userid;
                string  keyword  = dy.data.keyword;
                string  year     = dy.data.year;
                string  deptcode = dy.data.deptcode;
                string  state    = dy.data.state;
                string  month    = dy.data.month;
                OperatorProvider.AppUserId = userid;  //设置当前用户
                Operator curUser = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!", data = new object() });
                }
                var list = new List <SelfEvaluateEntity>();
                if (string.IsNullOrEmpty(deptcode))
                {
                    list     = bll.GetList("", curUser.DeptCode, keyword, year, month).ToList();
                    deptcode = curUser.DeptCode;
                }
                else
                {
                    list = bll.GetList("", deptcode, keyword, year, month).ToList();
                }
                if (type == "my")
                {
                    list = list.Where(x => x.CreateUserId == curUser.UserId).ToList();
                }
                else
                {
                    if (state != "已填报")
                    {
                        var           allUser         = new UserBLL().GetList().Where(x => x.IsPresence == "1");
                        List <string> submituserids   = list.Where(x => x.IsSubmit == "1").Select(x => x.CreateUserId).ToList();                                                                                      //该部门下已提交人的人的Id
                        List <string> submitUserNames = allUser.Where(p => submituserids.Contains(p.UserId) && p.IsPresence == "1").Select(p => p.RealName).ToList();                                                 //已提交的人
                        List <Entity.BaseManage.UserEntity> notSubmitUserNames = allUser.Where(p => p.DepartmentCode != null && p.DepartmentCode.StartsWith(deptcode) && !submituserids.Contains(p.UserId)).ToList(); //未提交的人
                        if (state == "未填报")
                        {
                            list.Clear();
                        }
                        var yearNum  = Convert.ToInt32(year);
                        var monthNum = Convert.ToInt32(month);
                        var dayTime  = new DateTime(yearNum, monthNum, 1);
                        notSubmitUserNames.ForEach(x =>
                        {
                            var model        = new SelfEvaluateEntity();
                            model.CreateUser = x.RealName;
                            model.CreateDate = dayTime;
                            model.DeptId     = x.DepartmentId;
                            model.DeptCode   = x.DepartmentCode;
                            model.IsSubmit   = "1";
                            list.Add(model);
                        });
                    }
                    list = list.Where(x => x.IsSubmit == "1").ToList();
                }

                if (!string.IsNullOrEmpty(name))
                {
                    list = list.Where(x => x.CreateUser.Contains(name)).ToList();
                }
                int count = list.Count();
                list = list.Skip((page - 1) * rows).Take(rows).OrderBy(p => p.IsFill).OrderByDescending(x => x.IsSubmit).ThenByDescending(p => p.CreateDate).ToList();
                var deptbll = new DepartmentBLL();
                var allDept = deptbll.GetList();
                list.ForEach(x =>
                {
                    var dept      = string.Empty;
                    var go        = true;
                    var getDept   = allDept.FirstOrDefault(p => p.DepartmentId == x.DeptId);
                    var parDeptId = getDept.ParentId;
                    if (getDept.Nature == "班组" || getDept.Nature == "专业")
                    {
                        dept = getDept.FullName;
                        while (go)
                        {
                            var parDept = deptbll.GetEntity(parDeptId);
                            if (parDept == null)
                            {
                                go = false;
                                break;
                            }
                            if (parDept.Nature == "部门")
                            {
                                if (string.IsNullOrEmpty(dept))
                                {
                                    dept = parDept.FullName;
                                }
                                else
                                {
                                    dept = parDept.FullName + "/" + dept;
                                }
                                go = false;
                            }
                            else
                            {
                                parDeptId = parDept.ParentId;
                            }
                        }
                    }
                    else
                    {
                        dept = getDept.FullName;
                    }
                    x.DeptName = dept;
                });
                return(new { code = 0, count = count, info = "获取成功", data = list });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = "获取数据失败:" + ex.Message, data = new object() });
            }
        }
Example #4
0
        public object SaveSelfEvaluate()
        {
            try
            {
                var     bll    = new SelfEvaluateBLL();
                string  res    = HttpContext.Current.Request["json"];
                dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userid = dy.userid;
                OperatorProvider.AppUserId = userid;  //设置当前用户
                Operator curUser = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!", data = new object() });
                }
                string             dataJson = JsonConvert.SerializeObject(dy.data);
                SelfEvaluateEntity entity   = JsonConvert.DeserializeObject <SelfEvaluateEntity>(dataJson);
                if (string.IsNullOrEmpty(entity.Id)) //新增自我评估
                {
                    entity.Id = Guid.NewGuid().ToString();
                }
                entity.CreateUser   = curUser.UserName;
                entity.CreateUserId = curUser.UserId;
                entity.DeptCode     = curUser.DeptCode;
                entity.DeptId       = curUser.DeptId;
                entity.DeptName     = curUser.DeptName;


                if (string.IsNullOrEmpty(entity.A.Id)) //新增自我评估
                {
                    entity.A.Id = Guid.NewGuid().ToString();
                }
                if (string.IsNullOrEmpty(entity.B.Id)) //新增自我评估
                {
                    entity.B.Id = Guid.NewGuid().ToString();
                }
                if (string.IsNullOrEmpty(entity.C.Id)) //新增自我评估
                {
                    entity.C.Id = Guid.NewGuid().ToString();
                }
                if (string.IsNullOrEmpty(entity.D.Id)) //新增自我评估
                {
                    entity.D.Id = Guid.NewGuid().ToString();
                }
                if (string.IsNullOrEmpty(entity.E.Id)) //新增自我评估
                {
                    entity.E.Id = Guid.NewGuid().ToString();
                }
                entity.A.EvaId = entity.Id;
                entity.B.EvaId = entity.Id;
                entity.C.EvaId = entity.Id;
                entity.D.EvaId = entity.Id;
                entity.E.EvaId = entity.Id;
                if (entity.IsSubmit == "1")
                {
                    entity.IsFill = "1";
                }
                bll.SaveForm(entity);
                return(new { code = 0, count = 0, info = "获取成功", data = 0 });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = "获取数据失败:" + ex.Message, data = new object() });
            }
        }