diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs index 5404b3e1..62a209ad 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs @@ -32,23 +32,24 @@ public class TicketRepository : RepositoryBase, ITicketRepository public List GetAll(TicketSearchModel searchModel) { - var query = _accountContext.Tickets.OrderByDescending(x => x.CreationDate).Select(x => new TicketViewModel() - { - Description = x.Description, - SenderId = x.SenderId, - ContractingPartyName = x.ContractingPartyName, - Id = x.id, - Title = x.Title, - TicketType = x.TicketType, - Status = x.Status, - CreationDateTimeGr = x.CreationDate, - CreationDateTime = x.CreationDate.ToFarsiFull(), - TicketNumber = $"TKC_{x.TicketNumber}", - WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName, - HasTask = _accountContext.Tasks.Include(t => t.Assigns).Any(t => t.TicketId == x.id && t.Assigns.Any(a => !a.IsDone)), - WorkshopId = x.WorkshopId, - RawTicketNumber = x.TicketNumber - }); + var query = _accountContext.Tickets.OrderBy(x => x.Status == "بسته شده").ThenBy(x => x.Status == "پاسخ داده شده") + .ThenBy(x => x.Status == "درحال بررسی").ThenBy(x => "باز").Select(x => new TicketViewModel() + { + Description = x.Description, + SenderId = x.SenderId, + ContractingPartyName = x.ContractingPartyName, + Id = x.id, + Title = x.Title, + TicketType = x.TicketType, + Status = x.Status, + CreationDateTimeGr = x.CreationDate, + CreationDateTime = x.CreationDate.ToFarsiFull(), + TicketNumber = $"TKC_{x.TicketNumber}", + WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName, + HasTask = _accountContext.Tasks.Include(t => t.Assigns).Any(t => t.TicketId == x.id && t.Assigns.Any(a => !a.IsDone)), + WorkshopId = x.WorkshopId, + RawTicketNumber = x.TicketNumber + }); #region Search diff --git a/Company.Domain/RollCallAgg/IRollCallRepository.cs b/Company.Domain/RollCallAgg/IRollCallRepository.cs index 59874d3c..73ab83fb 100644 --- a/Company.Domain/RollCallAgg/IRollCallRepository.cs +++ b/Company.Domain/RollCallAgg/IRollCallRepository.cs @@ -60,8 +60,10 @@ namespace Company.Domain.RollCallAgg RollCallViewModel GetDetails(long rollCallId); - #endregion - long Flag(long employeeId, long workshopId); + TimeSpan GetEmployeeRollCallTimeSpanForDuration(long employeeId, long workshopId, DateTime start, DateTime end); + + #endregion + long Flag(long employeeId, long workshopId); /// /// چک می کند که اگر کارگر به تازگی خروج یا ورود زده است اجازه ثبت مجدد ندهد diff --git a/CompanyManagment.App.Contracts/RollCall/IRollCallApplication.cs b/CompanyManagment.App.Contracts/RollCall/IRollCallApplication.cs index 78eccf8f..f6e326c9 100644 --- a/CompanyManagment.App.Contracts/RollCall/IRollCallApplication.cs +++ b/CompanyManagment.App.Contracts/RollCall/IRollCallApplication.cs @@ -34,10 +34,19 @@ namespace CompanyManagment.App.Contracts.RollCall #region Pooya OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa); + + + /// - /// برای صدور فیش حقوقی + /// برای محسابه ساعت کارکرد هنگام جستجوی پرسنل در بازه زمانی در صفحه سوابق /// - List GetActiveEmployeeRollCallsForDuration(long employeeId, long workshopId, + TimeSpan GetEmployeeRollCallTimeSpanForDuration(long employeeId, long workshopId, string startFa, string endFa); + + + /// + /// برای صدور فیش حقوقی + /// + List GetActiveEmployeeRollCallsForDuration(long employeeId, long workshopId, string startDate, string endDate); diff --git a/CompanyManagment.Application/InsuranceListApplication.cs b/CompanyManagment.Application/InsuranceListApplication.cs index a1e0c34d..fa7836c7 100644 --- a/CompanyManagment.Application/InsuranceListApplication.cs +++ b/CompanyManagment.Application/InsuranceListApplication.cs @@ -565,8 +565,8 @@ public class InsuranceListApplication: IInsuranceListApplication case 6219://ثابت countWorkingDays = 15; break; - case 7897://ثابت - countWorkingDays = 15; + //case 7897://ثابت + // countWorkingDays = 15; break; } #endregion @@ -1509,9 +1509,9 @@ public class InsuranceListApplication: IInsuranceListApplication case 6219://ثابت countWorkingDays = 15; break; - case 7897://ثابت - countWorkingDays = 15; - break; + //case 7897://ثابت + // countWorkingDays = 15; + // break; } ; #endregion diff --git a/CompanyManagment.Application/RollCallApplication.cs b/CompanyManagment.Application/RollCallApplication.cs index 2f9ef4d3..0c7ecc6a 100644 --- a/CompanyManagment.Application/RollCallApplication.cs +++ b/CompanyManagment.Application/RollCallApplication.cs @@ -76,8 +76,21 @@ public class RollCallApplication : IRollCallApplication } - #region Pooya - public OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa) + #region Pooya + public TimeSpan GetEmployeeRollCallTimeSpanForDuration(long employeeId, long workshopId, string startFa, + string endFa) + { + if (startFa.TryToGeorgianDateTime(out DateTime startDateTime) == false) + return TimeSpan.Zero; + if (endFa.TryToGeorgianDateTime(out DateTime endDateTime) == false) + return TimeSpan.Zero; + + if(startDateTime > endDateTime) + return TimeSpan.Zero; + + return _rollCallRepository.GetEmployeeRollCallTimeSpanForDuration(employeeId, workshopId, startDateTime, endDateTime); + } + public OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa) { OperationResult op = new(); var date = dateFa.ToGeorgianDateTime(); @@ -125,7 +138,7 @@ public class RollCallApplication : IRollCallApplication { startDateTimeGr = startDateTime.ToGeorgianDateTime(); endDateTimeGr = endDateTime.ToGeorgianDateTime(); - if (endDateTimeGr <= startDateTimeGr) + if (endDateTimeGr < startDateTimeGr) { return new(); } diff --git a/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs b/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs index 073923ce..552866fa 100644 --- a/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs +++ b/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs @@ -62,8 +62,8 @@ namespace CompanyManagment.Application public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd) { //موقت - //یکتا تجارت گیل - if(workshopId == 108) + //یکتا تجارت گیل 108 - کهن سرویس وارنا 215 + if(workshopId == 108 || workshopId == 215) return false; var service = _rollCallServiceRepository.GetAllServiceByWorkshopId(workshopId); diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 4a53098a..2b29630f 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -19,6 +19,7 @@ using System.Linq; using CompanyManagment.App.Contracts.Fine; using System.Globalization; using System.IO; +using _0_Framework.Domain.CustomizeCheckoutShared.Base; using _0_Framework.Domain.CustomizeCheckoutShared.Enums; using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects; using Microsoft.EntityFrameworkCore; @@ -59,10 +60,18 @@ CreateWorkingHoursTemp command, long leavId) string shiftOver22Minuts = "0"; double ShiftPayResult = 0; int numberOfFridays = 0; - #endregion + #endregion - List rollCallResult = _context.RollCalls.Where(x => + //گرفتن ساعت استراحت پرسنل از تنظیمات + #region breakTime + BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery().FirstOrDefault(x => + x.WorkshopId == workshopId && x.EmployeeId == employeeId); + //اگر ساعت استراحت پرسنل وجود نداشت صفر است + var breakTime = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime; + #endregion + + List rollCallResult = _context.RollCalls.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date && x.StartDate.Value.Date <= contractEnd.Date && x.EndDate != null).Select(x => new RollCallViewModel() { @@ -76,18 +85,20 @@ CreateWorkingHoursTemp command, long leavId) CreationDate = x.Key, ShiftList = x.Select(s => new ShiftList() { Start = s.StartDate!.Value, End = s.EndDate!.Value }).ToList(), HasFriday = x.Any(s => s.StartDate.Value.DayOfWeek == DayOfWeek.Friday || s.EndDate.Value.DayOfWeek == DayOfWeek.Friday), - SumOneDaySpan = new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)), - }).ToList(); + + SumOneDaySpan = new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)) - CalculateBreakTime(breakTime, + new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))), + }).ToList(); numberOfFridays = groupedRollCall.Count(x => x.HasFriday); - //*****کسر ساعاعت استراحت پرسنل از ساعت کار - List rollCallSubtractSpan = groupedRollCall.Select(x => new GroupedRollCalls() - { - CreationDate = x.CreationDate, - AfterSubtractRestSpan = AfterSubtract(command, x.SumOneDaySpan, x.CreationDate), - }).ToList(); - TimeSpan sumSpans = new TimeSpan(rollCallSubtractSpan.Sum(x => x.AfterSubtractRestSpan.Ticks)); + ////*****کسر ساعاعت استراحت پرسنل از ساعت کار + //List rollCallSubtractSpan = groupedRollCall.Select(x => new GroupedRollCalls() + //{ + // CreationDate = x.CreationDate, + // AfterSubtractRestSpan = AfterSubtract(command, x.SumOneDaySpan, x.CreationDate), + //}).ToList(); + TimeSpan sumSpans = new TimeSpan(groupedRollCall.Sum(x => x.SumOneDaySpan.Ticks)); //****افزودن مرخصی پرسنل به مجموع ساعات کار*** @@ -130,7 +141,7 @@ CreateWorkingHoursTemp command, long leavId) }).ToList(); leavingDayCout += afterCheckout.Sum(x => x.DayCounter); Console.WriteLine(leavingDayCout); - TimeSpan workingPerDayAve = sumSpans / rollCallSubtractSpan.Count;//میانگین ساعت کار در روز + TimeSpan workingPerDayAve = sumSpans / groupedRollCall.Count;//میانگین ساعت کار در روز TimeSpan sumLeave = new TimeSpan(); if (workingPerDayAve <= new TimeSpan(7, 20, 0)) { @@ -493,7 +504,20 @@ CreateWorkingHoursTemp command, long leavId) return res; } - public TimeSpan AfterSubtract(CreateWorkingHoursTemp command, TimeSpan sumOneDaySpan, DateTime creationDate) + private TimeSpan CalculateBreakTime(BreakTime breakTime, TimeSpan sumOneDaySpan) + { + if (breakTime.BreakTimeType != BreakTimeType.WithTime) + return TimeSpan.Zero; + + var breakTimeSpan = breakTime.BreakTimeValue.ToTimeSpan(); + + if (breakTimeSpan * 2 >= sumOneDaySpan) + return TimeSpan.Zero; + + return breakTimeSpan; ; + } + + public TimeSpan AfterSubtract(CreateWorkingHoursTemp command, TimeSpan sumOneDaySpan, DateTime creationDate) { #region RestTimes diff --git a/CompanyManagment.EFCore/Repository/RollCallRepository.cs b/CompanyManagment.EFCore/Repository/RollCallRepository.cs index 3e2e83b3..6c7325bf 100644 --- a/CompanyManagment.EFCore/Repository/RollCallRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallRepository.cs @@ -161,7 +161,7 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(), RollCallDateFa = x.Key.Date.ToFarsi(), DateTimeGr = x.Key.Date, - IsSliced = x.Count() > 1 + IsSliced = x.Count() > 2 }; }); @@ -184,6 +184,8 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos } + + public List GetEmployeeRollCallsHistoryAll(long workshopId, long employeeId, DateTime start, DateTime end) { return _context.RollCalls.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.EndDate.Value >= start && @@ -198,9 +200,19 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos } + public TimeSpan GetEmployeeRollCallTimeSpanForDuration(long employeeId, long workshopId, DateTime start, DateTime end) + { - //جستجوی سوابق حضور غیاب بر اساس کارمند - public EmployeeRollCallsByMonthViewModel GetEmployeeRollCallsHistory(long employeeId, long workshopId, + + var rollCalls = _context.RollCalls.Where(x => + x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate != null && x.EndDate != null && x.RollCallModifyType != RollCallModifyType.Undefined && + x.StartDate.Value.Date >= start && x.StartDate.Value.Date <= end).ToList(); + + return new TimeSpan(rollCalls.Sum(x => (x.EndDate - x.StartDate).Value.Ticks)); + + } + //جستجوی سوابق حضور غیاب بر اساس کارمند + public EmployeeRollCallsByMonthViewModel GetEmployeeRollCallsHistory(long employeeId, long workshopId, DateTime? startDateTime, DateTime? endDateTime, DateTime? exactDateTime, DateTime? dateIndex) { @@ -716,7 +728,7 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos #endregion public long Flag(long employeeId, long workshopId) { - var checkDate = DateTime.Now.AddDays(-3); + var checkDate = DateTime.Now.AddDays(-5); var query = _context.RollCalls .Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.CreationDate >= checkDate); if (query.Any()) diff --git a/Query/AdminReports/Handlers/GetWorkshopWithRollCallHandler.cs b/Query/AdminReports/Handlers/GetWorkshopWithRollCallHandler.cs index 2aa9e80e..acb9f899 100644 --- a/Query/AdminReports/Handlers/GetWorkshopWithRollCallHandler.cs +++ b/Query/AdminReports/Handlers/GetWorkshopWithRollCallHandler.cs @@ -29,7 +29,7 @@ namespace Query.AdminReports.Handlers //workshop filter by parameters var rollCallServiceQuery = _companyContext.RollCallServices - .Where(x => x.StartService.Date <= DateTime.Now.Date && x.EndService.Date >= DateTime.Now.Date); + .Where(x => x.StartService <= DateTime.Now && x.EndService >= DateTime.Now); var allWorkshops = _companyContext.Workshops.Select(x => new { x.id, x.WorkshopFullName }); if (!string.IsNullOrWhiteSpace(parameters.WorkshopName)) diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs index 5def93f7..fc7b119c 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs @@ -445,12 +445,12 @@ public class IndexModel : PageModel else { mandatoryCompute = MandatoryHours(workingHours, workshop.WorkshopHolidayWorking, 0); - var hasLeave = _leaveApplication.LeavOnChekout(separation.ContractStartGr, - separation.ContractEndGr, contract.EmployeeId, contract.WorkshopIds); - if (hasLeave != null) - { - //var LeaveCompute = MandatoryHours(workingHours, hasLeave.Id); - } + //var hasLeave = _leaveApplication.LeavOnChekout(separation.ContractStartGr, + // separation.ContractEndGr, contract.EmployeeId, contract.WorkshopIds); + //if (hasLeave != null) + //{ + // //var LeaveCompute = MandatoryHours(workingHours, hasLeave.Id); + //} } diff --git a/ServiceHost/Areas/Camera/Pages/Index.cshtml b/ServiceHost/Areas/Camera/Pages/Index.cshtml index b6d436b0..d7845290 100644 --- a/ServiceHost/Areas/Camera/Pages/Index.cshtml +++ b/ServiceHost/Areas/Camera/Pages/Index.cshtml @@ -52,7 +52,7 @@
-
+ *@ + + + +
+ + در حال آماده سازی... +
+
+