示例#1
0
        public static ApplyDetailDto <Q> ToDetaiDto <T, Q>(this T model, UserVacationInfoVDto info, Q request, ApplicationDbContext context) where T : IAppliable, IHasGuidId where Q : IApplyRequestBase
        {
            if (model == null || context == null)
            {
                return(null);
            }
            var b = new ApplyDetailDto <Q>()
            {
                Base                    = model.BaseInfo.From.ToSummaryDto(),
                Company                 = model.BaseInfo.Company,
                Create                  = model.Create,
                Duties                  = model.BaseInfo.Duties,
                RequestInfo             = request,
                Response                = model.Response.Select(r => r.ToResponseDto()),
                NowStep                 = model?.NowAuditStep?.ToDtoModel(),
                Steps                   = model?.ApplyAllAuditStep?.Select(a => a.ToDtoModel()),
                AuditSolution           = model?.ApplyAuditStreamSolutionRule?.Solution?.Name ?? "已失效的审批流程",
                Id                      = model.Id,
                Social                  = model.BaseInfo.Social,
                Status                  = model.Status,
                AuditLeader             = model.AuditLeader,
                ExecuteStatus           = model.ExecuteStatus,
                MainStatus              = model.MainStatus,
                RecallId                = model.RecallId,
                ExecuteStatusId         = model.ExecuteStatusDetailId,
                UserVacationDescription = info
            };

            if (model.Status == AuditStatus.Withdrew)
            {
                b.RequestInfo = default;
            }
            return(b);
        }
示例#2
0
 public static string VacationDescription(this UserVacationInfoVDto info)
 {
     return($"全年假期{info?.YearlyLength}天,已休{info.NowTimes}次,{info.YearlyLength - info.LeftLength}天,剩余{info.LeftLength}天。其中可休路途{info.MaxTripTimes}次,已休{info.OnTripTimes}次");
 }
        private UserVacationInfoVDto VacationInfoInRange(IEnumerable <Apply> applies, double yearlyLength)
        {
            var userAdditions = new List <VacationAdditional>();
            var maxOnTripTimeGainForRecall = 0;            //应召回而增加路途次数
            var description = "";
            int nowLength   = 0;
            int delayLength = 0;
            int nowTimes    = 0;
            int onTripTime  = 0;
            var f           = applies.All <DAL.Entities.ApplyInfo.Apply>(a =>
            {
                nowLength += a.RequestInfo.VacationLength;
                if (a.RequestInfo.OnTripLength > 0)
                {
                    onTripTime++;
                }
                nowTimes++;
                userAdditions.AddRange(a.RequestInfo.AdditialVacations);

                // 处理被召回的假期
                if (a.RecallId != null)
                {
                    //不论用户是否休路途,均应该增加一次路途
                    maxOnTripTimeGainForRecall++;
                    var order = _context.RecallOrders.Find(a.RecallId);
                    if (order == null)
                    {
                        throw new ActionStatusMessageException(ActionStatusMessage.ApplyMessage.RecallMessage.IdRecordButNoData);
                    }
                    // 归还天数=应归队 - 召回应归队
                    var recallMiniusDay = a.RequestInfo.StampReturn.Value.Subtract(order.ReturnStamp).Days;
                    nowLength          -= recallMiniusDay;
                    // 判断召回应归队到应归队之间的福利假天数
                    var benefitDuringRecallAndStampReturn = _vacationCheckServices.GetVacationDates(order.ReturnStamp, recallMiniusDay, true).Sum(v => v.Length);
                    if (benefitDuringRecallAndStampReturn > 0)
                    {
                        nowLength += benefitDuringRecallAndStampReturn;
                    }
                }
                // 处理推迟的假期
                else if (((int)a.ExecuteStatus & (int)ExecuteStatus.Delay) > 0 && a.ExecuteStatusDetailId != null)
                {
                    var order = _context.ApplyExcuteStatus.Find(a.ExecuteStatusDetailId);

                    var length   = order.ReturnStamp.Subtract(a.RequestInfo.StampReturn.Value).Days;
                    delayLength += length;
                }
                return(true);
            });

            if (maxOnTripTimeGainForRecall > 0)
            {
                description = $"因期间被召回{maxOnTripTimeGainForRecall}次,全年可休路途次数相应增加。";
            }
            if (delayLength > 0)
            {
                description = $"{description}因期间归队时间推迟{delayLength}天,全年可休假天数相应减少";
            }
            var vacationInfo = new UserVacationInfoVDto()
            {
                LeftLength   = (int)Math.Floor(yearlyLength - nowLength - delayLength),
                MaxTripTimes = maxOnTripTimeGainForRecall,
                NowTimes     = nowTimes,
                OnTripTimes  = onTripTime,
                YearlyLength = (int)Math.Round(yearlyLength, 0),
                Description  = description,
                Additionals  = userAdditions
            };

            if (vacationInfo.LeftLength < 0)
            {
                vacationInfo.LeftLength = 0;
            }
            return(vacationInfo);
        }