From 78458f24e5ca7eff703f50fabecfa72b1081572f Mon Sep 17 00:00:00 2001 From: mahan Date: Mon, 20 Oct 2025 15:43:59 +0330 Subject: [PATCH] feat: add entry and exit time differences to roll call reports --- 0_Framework/Application/Sms/SmsService.cs | 3 +- .../CaseHistoryRollCallExcelViewModel.cs | 7 ++- .../RollCall/RollCallExcelGenerator.cs | 50 +++++++++++++++++-- .../Repository/RollCallRepository.cs | 4 +- .../Company/RollCall/CaseHistory.cshtml.cs | 4 +- .../PrintAllCaseHistoryWithPersonnel.cshtml | 26 ++++++++-- 6 files changed, 80 insertions(+), 14 deletions(-) diff --git a/0_Framework/Application/Sms/SmsService.cs b/0_Framework/Application/Sms/SmsService.cs index 68207ff0..0de394f7 100644 --- a/0_Framework/Application/Sms/SmsService.cs +++ b/0_Framework/Application/Sms/SmsService.cs @@ -204,8 +204,7 @@ public class SmsService : ISmsService int pageSize = 100; // max: 100 SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa"); var response = await smsIr.GetArchivedReportAsync(pageNumber, pageSize, unixTimestamp, unixTimestamp2); - - + MessageReportResult[] messages = response.Data; foreach (var message in messages) { diff --git a/CompanyManagement.Infrastructure.Excel/RollCall/CaseHistoryRollCallExcelViewModel.cs b/CompanyManagement.Infrastructure.Excel/RollCall/CaseHistoryRollCallExcelViewModel.cs index 68144324..ca7dcfac 100644 --- a/CompanyManagement.Infrastructure.Excel/RollCall/CaseHistoryRollCallExcelViewModel.cs +++ b/CompanyManagement.Infrastructure.Excel/RollCall/CaseHistoryRollCallExcelViewModel.cs @@ -12,9 +12,7 @@ public class CaseHistoryRollCallExcelForEmployeeViewModel public string EmployeeFullName { get; set; } public string TotalWorkingHoursFa { get; set; } public string TotalWorkingTimeSpan { get; set; } - - - + public List RollCalls { get; set; } } @@ -40,7 +38,8 @@ public class RollCallItemForEmployeeExcelViewModel public bool HasLeave { get; set; } public string TotalWorkingHours { get; set; } - + public string EnterTimeDifferences { get; set; } + public string ExitTimeDifferences { get; set; } } public class RollCallTimeExcelViewModel diff --git a/CompanyManagement.Infrastructure.Excel/RollCall/RollCallExcelGenerator.cs b/CompanyManagement.Infrastructure.Excel/RollCall/RollCallExcelGenerator.cs index 4d10e241..b7455351 100644 --- a/CompanyManagement.Infrastructure.Excel/RollCall/RollCallExcelGenerator.cs +++ b/CompanyManagement.Infrastructure.Excel/RollCall/RollCallExcelGenerator.cs @@ -113,11 +113,12 @@ public class RollCallExcelGenerator : ExcelGenerator worksheet.Cells[i + row + 1, 1].Value = i + 1; worksheet.Cells[i + row + 1, 2].Value = rollCall.DayOfWeekFa; worksheet.Cells[i + row + 1, 3].Value = rollCall.DateFa; - worksheet.Cells[i + row + 1, 4].Value = "-"; + worksheet.Cells[i + row + 1, 4].Value = rollCall.EnterTimeDifferences; worksheet.Cells[i + row + 1, 5].Value = rollCall.StartsItems; worksheet.Cells[i + row + 1, 6].Value = rollCall.EndsItems; - worksheet.Cells[i + row + 1, 7].Value = "-"; - worksheet.Cells[i + row + 1, 8].Value = rollCall.TotalWorkingHours == string.Empty ? "ندارد" : rollCall.TotalWorkingHours; + worksheet.Cells[i + row + 1, 7].Value = rollCall.ExitTimeDifferences; + worksheet.Cells[i + row + 1, 8].Value = rollCall.TotalWorkingHours == string.Empty + ? "ندارد" : rollCall.TotalWorkingHours; // Style data cells for (int j = 1; j <= 8; j++) @@ -307,6 +308,49 @@ public class RollCallExcelGenerator : ExcelGenerator return package.GetAsByteArray(); } + private string CalculateExitMinuteDifference(TimeSpan early, TimeSpan late) + { + if (early == TimeSpan.Zero && late == TimeSpan.Zero) + { + return "-"; + } + else if (late != TimeSpan.Zero) + { + var minutes = late.TotalMinutes > 999 ? "999" : late.TotalMinutes.ToString(); + return $"{minutes}+"; + } + else if (early != TimeSpan.Zero) + { + var minutes = early.TotalMinutes > 999 ? "999" : early.TotalMinutes.ToString(); + return $"{minutes}-"; + } + else + { + return $""; + } + } + + private string CalculateEntryMinuteDifference(TimeSpan early, TimeSpan late) + { + if (early == TimeSpan.Zero && late == TimeSpan.Zero) + { + return "-"; + } + else if (late != TimeSpan.Zero) + { + var minutes = late.TotalMinutes > 999 ? "999" : late.TotalMinutes.ToString(); + return $"{minutes}-"; + } + else if (early != TimeSpan.Zero) + { + var minutes = early.TotalMinutes > 999 ? "999" : early.TotalMinutes.ToString(); + return $"{minutes}+"; + } + else + { + return $""; + } + } } diff --git a/CompanyManagment.EFCore/Repository/RollCallRepository.cs b/CompanyManagment.EFCore/Repository/RollCallRepository.cs index 2f83995b..27b00e72 100644 --- a/CompanyManagment.EFCore/Repository/RollCallRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallRepository.cs @@ -1517,7 +1517,9 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos StartDate = y.StartDate.Value.ToString("HH:mm"), EndDate = y.EndDate!.Value.ToString("HH:mm"), StartDateGr = y.StartDate.Value, - EndDateGr = y.EndDate.Value + EndDateGr = y.EndDate.Value, + EntryTimeDifferences = CalculateEntryTimeDifferences( y.EarlyEntryDuration, y.LateEntryDuration), + ExitTimeDifferences = CalculateExitTimeDifferences(y.EarlyExitDuration, y.LateExitDuration) }), TotalWorkingHoursSpan = new TimeSpan(rollCallsList.Where(y => x.Date == y.ShiftDate.Date) .Sum(y => (y.EndDate!.Value - y.StartDate.Value).Ticks)), diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml.cs index eb238115..04e0d1b0 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml.cs @@ -382,7 +382,9 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall IsAbsent = x.IsAbsent, TotalWorkingHours = x.TotalWorkingHours, StartsItems = string.Join(Environment.NewLine, x.RollCallTimesList.Select(tr=>tr.StartDate)), - EndsItems= string.Join(Environment.NewLine, x.RollCallTimesList.Select(tr=>tr.EndDate)) + EndsItems= string.Join(Environment.NewLine, x.RollCallTimesList.Select(tr=>tr.EndDate)), + EnterTimeDifferences = string.Join(Environment.NewLine, x.RollCallTimesList.Select(tr=>tr.EntryTimeDifferences)), + ExitTimeDifferences = string.Join(Environment.NewLine, x.RollCallTimesList.Select(tr=>tr.ExitTimeDifferences)) }).ToList() }; diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/PrintAllCaseHistoryWithPersonnel.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/PrintAllCaseHistoryWithPersonnel.cshtml index 48e2f6f8..fef64ebe 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/PrintAllCaseHistoryWithPersonnel.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/PrintAllCaseHistoryWithPersonnel.cshtml @@ -17,7 +17,7 @@
پرینت حضور و غیاب انفرادی @Model.PersianMonthName ماه @Model.PersianYear
- +```````