Пример #1
0
        public async Task <HumanSearchResponse <HumanInfoResponse1> > CreateMonth(UserInfo User, [FromBody] DateTime nextmonth)
        {
            var pagingResponse = new HumanSearchResponse <HumanInfoResponse1>();

            if (!ModelState.IsValid)
            {
                pagingResponse.Code = ResponseCodeDefines.ModelStateInvalid;
                Logger.Warn($"用户{User?.UserName ?? ""}({User?.Id ?? ""})创建月结信息失败:\r\n{pagingResponse.Message ?? ""},\r\n请求参数为:\r\n");
                return(pagingResponse);
            }
            try
            {
                DateTime now  = DateTime.Now;
                var      temp = await _monthManage.GetLastMonth();

                if (temp != null && temp.SettleTime.Value.ToString("Y") == now.ToString("Y"))
                {
                    pagingResponse.Code    = ResponseCodeDefines.ServiceError;
                    pagingResponse.Message = "日期重复";
                    return(pagingResponse);
                }

                if (!await _monthManage.CreateMonth(User, now, HttpContext.RequestAborted))
                {
                    pagingResponse.Code = ResponseCodeDefines.ServiceError;
                }
            }
            catch (Exception e)
            {
                pagingResponse.Code    = ResponseCodeDefines.ServiceError;
                pagingResponse.Message = "服务器错误:" + e.ToString();
                Logger.Error($"用户{User?.UserName ?? ""}({User?.Id ?? ""})创建月结信息失败:\r\n{pagingResponse.Message ?? ""},\r\n请求参数为:\r\n");
            }
            return(pagingResponse);
        }
Пример #2
0
        public virtual async Task <HumanSearchResponse <SalaryInfoResponse> > SearchSalaryInfo(UserInfo user, HumanSearchRequest condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }

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

            string connectstr = " ";

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

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

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

                List <SalaryInfo> result = new List <SalaryInfo>();
                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 <SalaryInfoResponse> >(result);
            }
            catch (Exception e)
            {
                throw;
            }

            return(Response);
        }
Пример #3
0
        public virtual async Task <HumanSearchResponse <RewardPunishmentResponse> > SearchRewardPunishmentInfo(UserInfo user, RewardPunishmentSearchRequest condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }

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

            string connectstr = " ";

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

            if (condition?.CreateDate != null && condition.CreateDate.Year > 2017)
            {
                sql       += connectstr + @"(a.`WorkDate`='" + condition.CreateDate + "'";
                connectstr = " and ";
            }

            try
            {
                var query = _Store.DapperSelect <RewardPunishmentInfo>(sql).ToList();

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

                List <RewardPunishmentInfo> result = new List <RewardPunishmentInfo>();
                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 <RewardPunishmentResponse> >(result);
            }
            catch (Exception e)
            {
                throw;
            }

            return(Response);
        }
Пример #4
0
        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);
        }