diff --git a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs index 66d91bd1..988528b6 100644 --- a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs +++ b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using _0_Framework.Domain; using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities; using CompanyManagment.App.Contracts.Contract; @@ -22,4 +23,7 @@ public interface IRollCallMandatoryRepository : IRepository List LateToWorkEarlyExit(List groupedRollCall, ICollection shiftSettings, List leavList); + + Task RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart, + DateTime contractEnd, string shiftwork); } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs b/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs index 4744d8d1..dfacd8d5 100644 --- a/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs +++ b/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using CompanyManagment.App.Contracts.Contract; using CompanyManagment.App.Contracts.WorkingHoursTemp; @@ -8,4 +9,6 @@ public interface IRollCallMandatoryApplication { bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart); ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking); + Task RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart, + DateTime contractEnd, string shiftwork); } \ No newline at end of file diff --git a/CompanyManagment.Application/RollCallMandatoryApplication.cs b/CompanyManagment.Application/RollCallMandatoryApplication.cs index 8850e139..080a7895 100644 --- a/CompanyManagment.Application/RollCallMandatoryApplication.cs +++ b/CompanyManagment.Application/RollCallMandatoryApplication.cs @@ -3,6 +3,7 @@ using CompanyManagment.App.Contracts.Contract; using CompanyManagment.App.Contracts.RollCall; using CompanyManagment.App.Contracts.WorkingHoursTemp; using System; +using System.Threading.Tasks; namespace CompanyManagment.Application; @@ -24,4 +25,10 @@ public class RollCallMandatoryApplication : IRollCallMandatoryApplication { return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking); } + + public async Task RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart, DateTime contractEnd, + string shiftwork) + { + return await _rollCallMandatoryRepository.RotatingShiftReport(workshopId, employeeId, contractStart, contractEnd, shiftwork); + } } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index de84fb74..dd4a9f2d 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -90,6 +90,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos TotalDeductions = x.TotalDeductions, TotalPayment = x.TotalPayment, RewardPay = x.RewardPay, + HasRollCall = x.HasRollCall, + }) .FirstOrDefault(x => x.Id == id); } diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 24ff10d8..8e889dea 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 System.Threading.Tasks; using _0_Framework.Domain.CustomizeCheckoutShared.Base; using _0_Framework.Domain.CustomizeCheckoutShared.Enums; using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects; @@ -30,6 +31,7 @@ using CompanyManagment.App.Contracts.SalaryAid; using Company.Domain.RewardAgg; using CompanyManagment.App.Contracts.Reward.Enums; using static System.Runtime.InteropServices.JavaScript.JSType; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; namespace CompanyManagment.EFCore.Repository; @@ -594,6 +596,106 @@ CreateWorkingHoursTemp command, bool holidayWorking) return res; } + public async Task RotatingShiftReport(long workshopId,long employeeId, DateTime contractStart, DateTime contractEnd, string shiftwork) + { + List rollCallResult =await _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() + { + StartDate = x.StartDate, + EndDate = x.EndDate, + ShiftSpan = (x.EndDate.Value - x.StartDate.Value), + CreationDate = x.ShiftDate, + }).ToListAsync(); + List groupedRollCall = rollCallResult.GroupBy(x => x.CreationDate.Date).Select(x => new GroupedRollCalls() + { + CreationDate = x.Key, + ShiftList = x.Select(s => new ShiftList() { Start = s.StartDate!.Value, End = s.EndDate!.Value }).ToList(), + HasFriday = x.Any(s => s.StartDate != null && s.EndDate != null && (s.StartDate.Value.DayOfWeek == DayOfWeek.Friday || s.EndDate.Value!.DayOfWeek == DayOfWeek.Friday)), + + + + }).OrderBy(x => x.CreationDate).ToList(); + + + //****** نوبت کاری و شب کاری **** + #region RotatingShiftCheckAndNightWorkOver22 + + string shiftPayValue = "0"; + List rotatingResultList = RotatingShiftCheck(groupedRollCall); + var moriningCount = rotatingResultList.Count(x => x.IsMorningShift); + var eveningCount = rotatingResultList.Count(x => x.IsEveningShift); + var nightCount = rotatingResultList.Count(x => x.IsNightShift); + // شبکاری + TimeSpan over22 = new TimeSpan(rotatingResultList.Sum(x => x.NightWorkSpan.Ticks)); + var RotatingfaName = new List(); + if (shiftwork != "1" && shiftwork != "2" && shiftwork != "4")//اگر چرخشی بود و منظم نبود + { + if (moriningCount > 0) + RotatingfaName.Add("صبح"); + if (eveningCount > 0) + RotatingfaName.Add("عصر"); + if (nightCount > 0) + RotatingfaName.Add("شب"); + } + else// اگر منظم و شیفتی بود + { + var totalDays = (int)(contractEnd - contractStart).TotalDays + 1; + int validCount = 0; + if (totalDays <= 7) // زیر 7 روز باید حد اقل 2 تغییر شیفت داشته باشد + { + validCount = 2; + } + else if (totalDays >= 28) // بالای 28 روز حد اقل 8 تغییر شیفت + { + validCount = 8; + } + else + { + // تناسب گیری - اگر برای 28 روز 8 تغییر پس برای ایکس روز چند تغییر لازم است + validCount = (int)((totalDays * 8) / 28); + } + + if (moriningCount >= validCount) + RotatingfaName.Add("صبح"); + if (eveningCount >= validCount) + RotatingfaName.Add("عصر"); + if (nightCount >= validCount) + RotatingfaName.Add("شب"); + + } + + var rotatingFaResult = ""; + if (RotatingfaName.Count > 1)// اگر تعداد شیفت های محاسبه شده بیش از یک بود + { + + for (var rotateNumber = 0; rotateNumber < RotatingfaName.Count; rotateNumber++) + { + if (rotateNumber == 0) + rotatingFaResult = $"{RotatingfaName[rotateNumber]}"; + if (rotateNumber == 1) + rotatingFaResult += $" و {RotatingfaName[rotateNumber]}"; + if (rotateNumber == 2) + rotatingFaResult += $" و {RotatingfaName[rotateNumber]}"; + } + } + else if (RotatingfaName.Count <= 1) + { + rotatingFaResult = "نوبت کاری ندارد"; + + + + } + + return new ComputingViewModel + { + RotatingStatus = rotatingFaResult, + RotatingResultList = rotatingResultList + + }; + + #endregion + } public static TimeSpan CalculateBreakTime(BreakTime breakTime, TimeSpan sumOneDaySpan) { if (breakTime.BreakTimeType != BreakTimeType.WithTime) diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml index 1dad3f2b..5a110205 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml @@ -1323,6 +1323,29 @@ } } + function rotatingShiftReport(id){ + console.log(Number(id)); + var checkoutId=Number(id); + $.ajax({ + + dataType: 'json', + type: 'POST', + url: '@Url.Page("./Index", "RotatngShiftReport")', + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + data: { "checkoutId": checkoutId}, + success: function (response) { + console.log(response); + if (response.isSuccedded) { + + } + + }, + failure: function (response) { + console.log(5, response) + } + }); + } + function deleteCheckout(element, id) { $('.sweet-alert').removeClass("successSwall"); $('.sweet-alert').removeClass("errorSwall"); diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs index 84f27416..fc5b3fce 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs @@ -26,6 +26,7 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.SignalR; using PersianTools.Core; using ServiceHost.Hubs; +using System.Diagnostics.Contracts; namespace ServiceHost.Areas.Admin.Pages.Company.Checkouts; @@ -141,7 +142,38 @@ public class IndexModel : PageModel //chekoutlist = await _checkoutApplication.Search(searchModel); } - public async Task OnGetSearch(CheckoutSearchModel searchModel) + /// + /// گزارش نوبت کاری + /// + /// + /// + + #region RotatngShiftReport + + public async Task OnPostRotatngShiftReport(long checkoutId) + { + var result = new ComputingViewModel(); + var checkout = _checkoutApplication.GetDetails(checkoutId); + var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(checkout.ContractId); + if (checkout.HasRollCall) + { + result = await _rollCallMandatoryApplication.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId,checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork); + } + else + { + + } + + Console.WriteLine("ok"); + return new JsonResult(new + { + isSuccedded = true + }); + } + + #endregion + + public async Task OnGetSearch(CheckoutSearchModel searchModel) { var accountId = _authHelper.CurrentAccountId(); diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml index 92cbf1cd..ca0bdc0b 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml @@ -212,9 +212,13 @@ - + *@ + + diff --git a/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml index 87a96d8a..1fd371eb 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml @@ -324,7 +324,7 @@ } .eye { - z-index: 0; + z-index: 1; position: relative !important; top: 63px !important; display: inline-block !important;