diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 5fd09cac..818d281e 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -1447,17 +1447,25 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll #endregion - #region 12-24 - - if (command.ShiftWork == "5") //12-24 + #region Complex + //[12-24 : 5] [24-24 : 6] [12-36 : 7] [24-48 : 8] + if (command.ShiftWork is "5" or "6" or "7" or "8") { + int addHourse = command.ShiftWork switch + { + "5" => 36, + "6" => 48, + "7" => 48, + "8" => 72, + _ => 0 + }; var start = Convert.ToDateTime(command.StartComplex); var end = Convert.ToDateTime(command.EndComplex); var startDateAndTime = new PersianDateTime(syear, smonth, sday, start.Hour, start.Minute); var startContract = new PersianDateTime(syear, smonth, sday, start.Hour, start.Minute); var endContract = new PersianDateTime(eyear, emonth, eday, 23, 59); - for (var da = startDateAndTime; da <= endContract; da = da.AddHours(36)) + for (var da = startDateAndTime; da <= endContract; da = da.AddHours(addHourse)) { @@ -1476,23 +1484,30 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll var endComplex = new DateTime(end.Year, end.Month, end.Day, end.Hour, end.Minute, end.Second); Console.WriteLine($"{currentDateFa} - {currentDateGr.Date} - start : {startComplex} end : {endComplex}"); - DateTime currntDateGr = currentDateFa.ToGeorgianDateTime(); - - var res = FindStaticShiftsStatus( - startComplex.ToString("HH:mm"), - endComplex.ToString("HH:mm"), - null, - null, currntDateGr, TimeSpan.Zero, leaveSearchResult); - if (res.Count > 0) - rollCallList.AddRange(res); - - + + rollCallList.Add(new RollCallViewModel() + { + StartDate = startComplex, + EndDate = endComplex, + ShiftSpan = (endComplex - startComplex), + ShiftDate = currentDateGr, + }); + var endCal = end - start; - start = startComplex.AddHours(36); + start = startComplex.AddHours(addHourse); end = start.Add(endCal); } + + int countLeveSearch = leaveSearchResult.Count(x => x.PaidLeaveType == "روزانه"); + if (countLeveSearch > 0) + { + int countRollCall = rollCallList.Count(); + int takRollCall = countLeveSearch < countRollCall ? (countRollCall - countLeveSearch) : 0; + rollCallList = rollCallList.Take(takRollCall).ToList(); + } + } #endregion @@ -2136,6 +2151,8 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll return result; } + + #endregion #region CustomizeCheckout