Example #1
0
        public IActionResult Ask([ModelBinder(BinderType = typeof(HumanSearchBinder))] HumanSearchRequest humanSearchRequest)
        {
            var targetPlace = logroñoGuide
                              .GetPlacesOfInterest()
                              .FirstOrDefault(s => s.Search(humanSearchRequest.Search));

            string moodMessage = humanSearchRequest.Mood == MoodStatus.Happy
                ? "Nos alegra que este contento, " :
                                 humanSearchRequest.Mood == MoodStatus.Unhappy ?
                                 "Vamos a intentar animarle,"
                                           : string.Empty;


            return(Ok(
                       $"{moodMessage} le recomendamos {targetPlace.Name} en {targetPlace.Address.AddressLine}"
                       ));
        }
        public async Task <ResponseMessage <HumanSearchResponse <BlackInfoResponse> > > GetBlackList(UserInfo User, [FromBody] HumanSearchRequest searchinfo)
        {
            var Response = new ResponseMessage <HumanSearchResponse <BlackInfoResponse> >();

            if (!ModelState.IsValid)
            {
                Response.Code = ResponseCodeDefines.ModelStateInvalid;
                Logger.Warn($"用户{User?.UserName ?? ""}({User?.Id ?? ""})查询薪酬条件(PostCustomerListSaleMan)模型验证失败:\r\n{Response.Message ?? ""},\r\n请求参数为:\r\n" + (searchinfo != null ? JsonHelper.ToJson(searchinfo) : ""));
                return(Response);
            }

            try
            {
                Response.Extension = await _blackManage.SearchBlackInfo(User, searchinfo, HttpContext.RequestAborted);
            }
            catch (Exception e)
            {
                Response.Code    = ResponseCodeDefines.ServiceError;
                Response.Message = "服务器错误:" + e.ToString();
                Logger.Error("error");
            }
            return(Response);
        }
        public virtual async Task <HumanSearchResponse <HumanInfoResponse1> > SearchHumanInfo(UserInfo user, HumanSearchRequest condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }

            var Response = new HumanSearchResponse <HumanInfoResponse1>();
            var sql      = @"SELECT a.* from XYH_HU_HUMANMANAGE as a where";

            if (condition?.CheckStatu > 0)
            {
                sql = @"SELECT a.* from XYH_HU_HUMANMANAGE as a LEFT JOIN XYH_HU_MODIFY as b ON a.`RecentModify`=b.`ID` where";
            }

            string connectstr = " ";

            if (!string.IsNullOrEmpty(condition?.KeyWord))
            {
                sql       += connectstr + @"LOCATE('" + condition.KeyWord + "', a.`Name`)>0";
                connectstr = " and ";
            }
            else if (condition?.KeyWord != null)
            {
                sql       += connectstr + @"a.`ID`!=''";
                connectstr = " and ";
            }

            if (condition?.HumanType > 0)//0不限 1未入职 2在职 3离职 4黑名单
            {
                switch (condition?.HumanType)
                {
                case 1:
                {
                    sql       += connectstr + @"a.`StaffStatus`=0";
                    connectstr = " and ";
                }
                break;

                case 2:
                {
                    sql       += connectstr + @"a.`StaffStatus`>1";
                    connectstr = " and ";
                }
                break;

                case 3:
                {
                    sql       += connectstr + @"a.`StaffStatus`=1";
                    connectstr = " and ";
                }
                break;

                case 4:
                {
                    sql       += connectstr + @"a.`StaffStatus`=-1";
                    connectstr = " and ";
                }
                break;
                }
            }

            if (condition?.SearchTimeType > 0)
            {
                switch (condition?.SearchTimeType)
                {
                case 1:
                {
                    sql       += connectstr + @"(a.`CreateTime`<='" + condition.CreateDateStart.Value + "'";
                    connectstr = " and ";
                    sql       += connectstr + @"a.`CreateTime`>='" + condition.CreateDateEnd.Value + "')";
                }
                break;

                case 2:
                {
                    sql       += connectstr + @"(a.`EntryTime`<='" + condition.CreateDateStart.Value + "'";
                    connectstr = " and ";
                    sql       += connectstr + @"a.`EntryTime`>='" + condition.CreateDateEnd.Value + "')";
                }
                break;

                case 3:
                {
                    sql       += connectstr + @"(a.`BecomeTime`<='" + condition.CreateDateStart.Value + "'";
                    connectstr = " and ";
                    sql       += connectstr + @"a.`BecomeTime`>='" + condition.CreateDateEnd.Value + "')";
                }
                break;

                case 4:
                {
                    sql       += connectstr + @"(a.`LeaveTime`<='" + condition.CreateDateStart.Value + "'";
                    connectstr = " and ";
                    sql       += connectstr + @"a.`LeaveTime`>='" + condition.CreateDateEnd.Value + "')";
                }
                break;

                default:
                    break;
                }
            }

            if (condition?.CheckStatu > 0)
            {
                string head = "(", tail = ")";
                if ((condition?.CheckStatu & 0x01) > 0)//1 2 4 8 未提交 审核中 通过 驳回
                {
                    sql       += connectstr + head + @"b.`ExamineStatus`=0";
                    connectstr = " or ";
                    head       = "";
                }
                if ((condition?.CheckStatu & 0x02) > 0)
                {
                    sql       += connectstr + head + @"b.`ExamineStatus`=1";
                    connectstr = " or ";
                    head       = "";
                }
                if ((condition?.CheckStatu & 0x04) > 0)
                {
                    sql       += connectstr + head + @"b.`ExamineStatus`=8";
                    connectstr = " or ";
                    head       = "";
                }
                if ((condition?.CheckStatu & 0x08) > 0)
                {
                    sql       += connectstr + head + @"b.`ExamineStatus`=16";
                    connectstr = " or ";
                    head       = "";
                }

                sql       += tail;
                connectstr = " and ";
            }

            if (condition?.AgeCondition > 0)
            {
                if (condition?.AgeCondition == 1)
                {
                    sql       += connectstr + @"a.`Age`>=20";
                    connectstr = " and ";
                }
                else if (condition?.AgeCondition == 2)
                {
                    sql       += connectstr + @"a.`Age`>=30";
                    connectstr = " and ";
                }
                else if (condition?.AgeCondition == 3)
                {
                    sql       += connectstr + @"a.`Age`>=40";
                    connectstr = " and ";
                }
            }

            if (condition?.OrderRule == 0 || condition?.OrderRule == null)
            {
                sql += @" ORDER BY a.`Name`";
            }
            else if (condition?.OrderRule == 1)
            {
                sql += @" ORDER BY a.`ID`";
            }

            try
            {
                List <HumanInfo> query = new List <HumanInfo>();
                var sqlinfo            = _Store.DapperSelect <HumanInfo>(sql).ToList();

                if (!string.IsNullOrEmpty(condition?.Organizate) && condition.LstChildren.Count > 0)
                {
                    foreach (var item in sqlinfo)
                    {
                        if (condition.LstChildren.Contains(item.DepartmentId))
                        {
                            query.Add(item);
                        }
                    }
                }
                else
                {
                    query = sqlinfo;
                }

                Response.ValidityContractCount = query.Count;
                Response.TotalCount            = query.Count;

                List <HumanInfo> result = new List <HumanInfo>();
                var begin = (condition.pageIndex) * condition.pageSize;
                var end   = (begin + condition.pageSize) > query.Count ? query.Count : (begin + condition.pageSize);

                for (; begin < end; begin++)
                {
                    result.Add(query.ElementAt(begin));
                }

                Response.PageIndex = condition.pageIndex;
                Response.PageSize  = condition.pageSize;
                Response.Extension = _mapper.Map <List <HumanInfoResponse1> >(result);

                foreach (var item in Response.Extension)
                {
                    var tf = await _Store.GetStationAsync(a => a.Where(b => b.ID == item.Position));

                    if (tf != null)
                    {
                        item.PositionName = tf.PositionName;
                    }
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(Response);
        }
Example #4
0
        public virtual async Task <HumanSearchResponse <BlackInfoResponse> > SearchBlackInfo(UserInfo user, HumanSearchRequest condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }

            var Response = new HumanSearchResponse <BlackInfoResponse>();
            var sql      = @"SELECT a.* from xyh_hu_blacklist as a where";

            string connectstr = " ";

            if (!string.IsNullOrEmpty(condition?.KeyWord))
            {
                sql       += connectstr + @"LOCATE('" + condition.KeyWord + "', a.`Name`)>0";
                connectstr = " and ";
            }
            else if (condition?.KeyWord != null)
            {
                sql       += connectstr + @"a.`IDCard`!=''";
                connectstr = " and ";
            }
            else if (condition?.KeyWord == null)
            {
                sql       += connectstr + @"a.`IDCard`!=''";
                connectstr = " and ";
            }

            if (condition?.OrderRule == 0 || condition?.OrderRule == null)
            {
                sql += @" ORDER BY a.`Name`";
            }

            try
            {
                var query = _Store.DapperSelect <BlackInfo>(sql).ToList();
                Response.ValidityContractCount = query.Count;
                Response.TotalCount            = query.Count;

                List <BlackInfo> result = new List <BlackInfo>();
                var begin = (condition.pageIndex) * condition.pageSize;
                var end   = (begin + condition.pageSize) > query.Count ? query.Count : (begin + condition.pageSize);

                for (; begin < end; begin++)
                {
                    result.Add(query.ElementAt(begin));
                }
                Response.PageIndex = condition.pageIndex;
                Response.PageSize  = condition.pageSize;
                Response.Extension = _mapper.Map <List <BlackInfoResponse> >(result);
            }
            catch (Exception e)
            {
                throw;
            }

            return(Response);
        }