Example #1
0
        public async Task <PagingResponseMessage <HumanInfoSearchResponse> > SearchHumanInfo(UserInfo user, HumanInfoSearchCondition condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            PagingResponseMessage <HumanInfoSearchResponse> pagingResponse = new PagingResponseMessage <HumanInfoSearchResponse>();

            var q = Store.GetQuery().Where(a => !a.IsDeleted);

            if (!string.IsNullOrEmpty(condition?.KeyWord))
            {
                q = q.Where(a => a.Name.Contains(condition.KeyWord) || a.UserID.Contains(condition.KeyWord) || a.IDCard.Contains(condition.KeyWord));
            }
            if (condition?.StaffStatuses?.Count > 0)
            {
                q = q.Where(a => condition.StaffStatuses.Contains(a.StaffStatus));
            }
            if (condition?.BirthdayStart != null)
            {
                q = q.Where(a => condition.BirthdayStart.Value <= a.Birthday);
            }
            if (condition?.BirthdayEnd != null)
            {
                q = q.Where(a => a.Birthday <= condition.BirthdayStart.Value);
            }
            if (!string.IsNullOrEmpty(condition?.DepartmentId))
            {
                q = q.Where(a => a.DepartmentId == condition.DepartmentId);
            }
            pagingResponse.TotalCount = await q.CountAsync(cancellationToken);

            var qlist = await q.Skip(condition.PageIndex *condition.PageSize).Take(condition.PageSize).ToListAsync(cancellationToken);

            var resulte = qlist.Select(a => new HumanInfoSearchResponse
            {
                Id                   = a.Id,
                BaseWages            = a.HumanSalaryStructure.BaseWages,
                BecomeTime           = a.BecomeTime,
                CreateTime           = a.CreateTime,
                CreateUser           = a.CreateUser,
                Name                 = a.Name,
                DepartmentId         = a.DepartmentId,
                OrganizationFullName = a.OrganizationExpansion.FullName,
                Desc                 = a.Desc,
                EntryTime            = a.EntryTime,
                IDCard               = a.IDCard,
                Position             = a.Position,
                Sex                  = a.Sex,
                StaffStatus          = a.StaffStatus,
                PositionName         = a.PositionName,
                UserID               = a.UserID,
                IsSignContracInfo    = a.HumanContractInfo.ContractSignDate != null ? true : false,
                IsHaveSocialSecurity = a.HumanSocialSecurity.IsHave
            });

            pagingResponse.PageIndex = condition.PageIndex;
            pagingResponse.PageSize  = condition.PageSize;
            pagingResponse.Extension = resulte.ToList();
            return(pagingResponse);
        }
Example #2
0
        public async Task <PagingResponseMessage <HumanInfoSearchResponse> > Search(UserInfo User, [FromBody] HumanInfoSearchCondition condition)
        {
            Logger.Trace($"用户{User?.UserName ?? ""}({User?.Id ?? ""})查询人事信息(Search),\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
            var pagingResponse = new PagingResponseMessage <HumanInfoSearchResponse>();

            if (!ModelState.IsValid)
            {
                pagingResponse.Code    = ResponseCodeDefines.ModelStateInvalid;
                pagingResponse.Message = ModelState.GetAllErrors();
                Logger.Warn($"用户{User?.UserName ?? ""}({User?.Id ?? ""})查询人事信息(Search)模型验证失败:\r\n{pagingResponse.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
                return(pagingResponse);
            }
            try
            {
                //if (await _permissionExpansionManager.HavePermission(User.Id, "SEARCH_CONTRACT"))
                //{
                pagingResponse = await _humanInfoManager.SearchHumanInfo(User, condition, HttpContext.RequestAborted);

                //}
                //else
                //{
                //    pagingResponse.Code = ResponseCodeDefines.NotAllow;
                //    pagingResponse.Message = "权限不足";
                //}
            }
            catch (Exception e)
            {
                pagingResponse.Code    = ResponseCodeDefines.ServiceError;
                pagingResponse.Message = "服务器错误:" + e.ToString();
                Logger.Error($"用户{User?.UserName ?? ""}({User?.Id ?? ""})查询人事信息(Search)请求失败:\r\n{pagingResponse.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
            }
            return(pagingResponse);
        }