diff --git a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs index 06dbe04c..a1ec3262 100644 --- a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs +++ b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs @@ -18,7 +18,7 @@ public interface IRollCallMandatoryRepository : IRepository List RotatingShiftCheck(List rollCallList); - List ConvertStaticHouresToRollCall(CreateWorkingHoursTemp command, bool workshopHolidyWorking); + List ConvertStaticHourseToRollCall(CreateWorkingHoursTemp command, bool workshopHolidyWorking); CustomizeCheckoutMandatoryViewModel CustomizeCheckoutMandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd); List LateToWorkEarlyExit(List groupedRollCall, diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index a60d8d1b..64de1270 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -114,7 +114,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll command.EmployeeId = employeeId; command.ContractStartGr = contractStart; command.ContractEndGr = contractEnd; - rollCallResult = ConvertStaticHouresToRollCall(command, holidayWorking); + rollCallResult = ConvertStaticHourseToRollCall(command, holidayWorking); groupedRollCall = rollCallResult.GroupBy(x => x.ShiftDate.Date).Select(x => new GroupedRollCalls() { CreationDate = x.Key, @@ -1237,7 +1237,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll } - public List ConvertStaticHouresToRollCall(CreateWorkingHoursTemp command, bool workshopHolidyWorking) + public List ConvertStaticHourseToRollCall(CreateWorkingHoursTemp command, bool workshopHolidyWorking) { var rollCallList = new List(); #region Entities @@ -1255,6 +1255,20 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll var d1 = new PersianDateTime(syear, smonth, sday); var d2 = new PersianDateTime(eyear, emonth, eday); + //بدست آوردن مرخصی + LeaveSearchModel leaveSearch = new LeaveSearchModel() + { + EmployeeId = command.EmployeeId, + WorkshopId = command.WorkshopId, + + StartLeaveGr = command.ContractStartGr, + EndLeaveGr = command.ContractEndGr, + IsAccepted = true, + }; + var leaveSearchResult = _leaveRepository.search(leaveSearch); + //بدس آوردن تعطیلات رسمی + var holidayList = _holidayItemRepository.GetHolidayItem(sdate.Substring(0, 4)); + bool isHoliday = false; #endregion @@ -1430,23 +1444,64 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll } + + #endregion + + #region 12-24 + + if (command.ShiftWork == "5") //12-24 + { + 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)) + { + + if (end.TimeOfDay < start.TimeOfDay) + end = end.AddDays(1); + var currentDateFa = $"{da}"; + + string startComplex = start.ToString("HH:mm"); + string endComplex = end.ToString("HH:mm"); + DateTime currntDateGr = currentDateFa.ToGeorgianDateTime(); + if (da == startContract) + { + var res = FindStaticShiftsStatus( + startComplex, + endComplex, + null, + null, currntDateGr, TimeSpan.Zero, leaveSearchResult); + if (res.Count > 0) + rollCallList.AddRange(res); + } + else + { + + + + + var res = FindStaticShiftsStatus( + startComplex, + endComplex, + null, + null, currntDateGr, TimeSpan.Zero, leaveSearchResult); + if (res.Count > 0) + rollCallList.AddRange(res); + } + + var endCal = end - start; + var nextStart = start.AddHours(36); + end = nextStart.Add(endCal); + + } + } + #endregion - //بدست آوردن مرخصی - LeaveSearchModel leaveSearch = new LeaveSearchModel() - { - EmployeeId = command.EmployeeId, - WorkshopId = command.WorkshopId, - - StartLeaveGr = command.ContractStartGr, - EndLeaveGr = command.ContractEndGr, - IsAccepted = true, - }; - var leaveSearchResult = _leaveRepository.search(leaveSearch); - //بدس آوردن تعطیلات رسمی - var holidayList = _holidayItemRepository.GetHolidayItem(sdate.Substring(0, 4)); - bool isHoliday = false; #region ShiftWork4Compute @@ -1465,10 +1520,10 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll var w6 = 0; var currentDateFa = $"{da}"; DateTime currntDateGr = currentDateFa.ToGeorgianDateTime(); - //if (!workshopHolidyWorking) - //{ - // isHoliday = holidayList.Any(x => x == currentDateFa); - //} + if (!workshopHolidyWorking) + { + isHoliday = holidayList.Any(x => x == currentDateFa); + } switch (FirstDayOfMonth.DayOfWeek) { case "شنبه":