public JsonResult GetWorkersInfo(QueryWorkersDto dto, int searchMode)
        {
            var datas = ArchiveService.ArchivesManager.FindWorkers(dto, searchMode);

            RebuildDepartmentContent(datas);
            return(Json(datas, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据部门载入班别信息
        /// </summary>
        /// <param name="department"></param>
        /// <returns></returns>
        public List <AttendClassTypeModel> LoadDatasBy(string department, string workerId = null, string classType = null)
        {
            List <AttendClassTypeModel> getDatas = new List <AttendClassTypeModel>();

            try
            {
                QueryWorkersDto qry = new QueryWorkersDto()
                {
                    Department = department, WorkerId = workerId
                };
                //在档案中载入部门数据
                List <ArWorkerInfo> workers = workerId == null?ArchiveService.ArchivesManager.FindWorkers(qry, 1) : ArchiveService.ArchivesManager.FindWorkers(qry, 2);

                //在班别设置中载入部门班别数据信息
                List <AttendClassTypeModel> classTypes = GetClassTypeDatas(department, workerId, classType);
                AttendClassTypeModel        mdl        = null;
                //合并数据
                workers.ForEach(w =>
                {
                    mdl    = new AttendClassTypeModel();
                    var ct = classTypes.FirstOrDefault(c => c.WorkerId == w.WorkerId);
                    if (ct != null)
                    {
                        //根据部门信息添加数据
                        getDatas.Add(ct);
                        //移除要搜索的数据,减少查询时间
                        classTypes.Remove(ct);
                    }
                    else
                    {
                        mdl.WorkerId   = w.WorkerId;
                        mdl.WorkerName = w.Name;
                        mdl.Department = w.Department;
                        mdl.ClassType  = w.ClassType;
                        getDatas.Add(mdl);
                    }
                });
                //清空班别设置中离职人员数据信息
                if (classTypes != null && classTypes.Count > 0)
                {
                    classTypes.ForEach(c =>
                    {
                        var item = workers.FirstOrDefault(e => e.WorkerId == c.WorkerId);
                        //人员信息列表中已经找不到此数据,则清空
                        if (item == null)
                        {
                            this.irep.Delete(d => d.WorkerId == c.WorkerId);
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            getDatas = getDatas.OrderBy(e => e.WorkerId).ToList();
            return(getDatas);
        }