From 247e2f206964187b82d454455a3fea93a55aa49f Mon Sep 17 00:00:00 2001 From: SamSys Date: Sun, 27 Apr 2025 21:22:11 +0330 Subject: [PATCH 1/8] RotatingShitReport - RollCall --- .../IRollCallMandatoryRepository.cs | 4 + .../RollCall/IRollCallMandatoryApplication.cs | 3 + .../RollCallMandatoryApplication.cs | 7 ++ .../Repository/CheckoutRepository.cs | 2 + .../Repository/RollCallMandatoryRepository.cs | 102 ++++++++++++++++++ .../Pages/Company/Checkouts/Index.cshtml | 23 ++++ .../Pages/Company/Checkouts/Index.cshtml.cs | 34 +++++- .../Pages/Company/Checkouts/MainSearch.cshtml | 8 +- .../Company/InstitutionContracts/Index.cshtml | 2 +- 9 files changed, 181 insertions(+), 4 deletions(-) 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; From 7f9a2ac597920033a6bc984dbd6e3ac3bcfeda38 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 28 Apr 2025 18:48:19 +0330 Subject: [PATCH 2/8] add partial --- .../Repository/CheckoutRepository.cs | 11 +- .../Pages/Company/Checkouts/Index.cshtml | 1 + .../Pages/Company/Checkouts/Index.cshtml.cs | 30 ++++- .../Pages/Company/Checkouts/MainSearch.cshtml | 3 +- .../Checkouts/RotatingShiftReport.cshtml | 121 ++++++++++++++++++ 5 files changed, 155 insertions(+), 11 deletions(-) create mode 100644 ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index dd4a9f2d..f3f93596 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -91,8 +91,15 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos TotalPayment = x.TotalPayment, RewardPay = x.RewardPay, HasRollCall = x.HasRollCall, - - }) + EmployeeId = x.EmployeeId, + WorkshopId = x.WorkshopId, + ContractId = x.ContractId, + ContractStartGr = x.ContractStart, + ContractEndGr = x.ContractEnd, + ContractStart = x.ContractStart.ToFarsi(), + ContractEnd = x.ContractEnd.ToFarsi() + + }) .FirstOrDefault(x => x.Id == id); } diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml index 5a110205..eace4adc 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml @@ -1324,6 +1324,7 @@ } function rotatingShiftReport(id){ + console.log(Number(id)); var checkoutId=Number(id); $.ajax({ diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs index fc5b3fce..86115f89 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs @@ -150,10 +150,10 @@ public class IndexModel : PageModel #region RotatngShiftReport - public async Task OnPostRotatngShiftReport(long checkoutId) + public async Task OnGetRotatngShiftReport(long id) { var result = new ComputingViewModel(); - var checkout = _checkoutApplication.GetDetails(checkoutId); + var checkout = _checkoutApplication.GetDetails(id); var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(checkout.ContractId); if (checkout.HasRollCall) { @@ -161,14 +161,30 @@ public class IndexModel : PageModel } else { - + var ConvertYear = checkout.ContractStart.Substring(0, 4); + var ConvertMonth = checkout.ContractStart.Substring(5, 2); + + var contract = _contractApplication.GetDetails(checkout.ContractId); + var workshop = _workshopApplication.GetDetails(contract.WorkshopIds); + var separation = _contractApplication.contractSeparation(ConvertYear, ConvertMonth, + contract.ContractStartGr, contract.ContractEndGr, contract.EmployeeId, contract.WorkshopIds); + workingHours.ContractStartGr = separation.ContractStartGr; + workingHours.ContractEndGr = separation.ContractEndGr; + workingHours.ContarctStart = separation.ContarctStart; + workingHours.ContractEnd = separation.ContractEnd; + workingHours.GetWorkDate = contract.GetWorkDate; + workingHours.GetWorkDateHide = contract.GetWorkDate; + workingHours.WorkshopId = contract.WorkshopIds; + workingHours.EmployeeId = contract.EmployeeId; + + result = MandatoryHours(workingHours, workshop.WorkshopHolidayWorking, 0); + + + } Console.WriteLine("ok"); - return new JsonResult(new - { - isSuccedded = true - }); + return Partial("./RotatingShiftReport", result); } #endregion diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml index ca0bdc0b..bad2aab5 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml @@ -216,8 +216,7 @@ href="#showmodal=@Url.Page("./Index", "CustomSet", new { item.Id })"> *@ - + diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml new file mode 100644 index 00000000..19267e32 --- /dev/null +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml @@ -0,0 +1,121 @@ +@model CompanyManagment.App.Contracts.Contract.ComputingViewModel +@{ + +} + + + + \ No newline at end of file From edc017b4d4d47926f2ca97c9fb38b963878440b1 Mon Sep 17 00:00:00 2001 From: MahanCh Date: Mon, 28 Apr 2025 19:12:58 +0330 Subject: [PATCH 3/8] Left work bug fixed --- ...ustomizeWorkshopGroupSettingsRepository.cs | 7 +++-- .../Repository/RollCallEmployeeRepository.cs | 27 ++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/CustomizeWorkshopGroupSettingsRepository.cs b/CompanyManagment.EFCore/Repository/CustomizeWorkshopGroupSettingsRepository.cs index c73d2a44..a986ba2c 100644 --- a/CompanyManagment.EFCore/Repository/CustomizeWorkshopGroupSettingsRepository.cs +++ b/CompanyManagment.EFCore/Repository/CustomizeWorkshopGroupSettingsRepository.cs @@ -123,15 +123,18 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont public bool HasAnyEmployeeWithoutGroup(long workshopId) { var dateNow = DateTime.Now.Date; + var leftWork = _companyContext.LeftWorkList.Where(x => + x.WorkshopId == workshopId && x.StartWorkDate <= dateNow && x.LeftWorkDate >= dateNow); - var rollCallEmployeesWithoutCWS = _companyContext.RollCallEmployees + var rollCallEmployeesWithoutCWS = _companyContext.RollCallEmployees .Include(x => x.EmployeesStatus) .Where( x => x.WorkshopId == workshopId && x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) && - x.HasUploadedImage == "true") + x.HasUploadedImage == "true"&& + leftWork.Any(l => l.EmployeeId == x.EmployeeId && l.WorkshopId == x.WorkshopId)) .GroupJoin(_companyContext.CustomizeWorkshopEmployeeSettings .AsSplitQuery() .Include(x => x.CustomizeWorkshopGroupSettings) diff --git a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs index 7b8b4a79..37e836f4 100644 --- a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs @@ -145,7 +145,7 @@ public class RollCallEmployeeRepository : RepositoryBase ? "true" : "false", HasUploadedImage = joinedRollCall == null ? "false" : joinedRollCall.HasUploadedImage, - CreatedByClient = clientTemp != null || (employee.workshopTemp != null &&employee.workshopTemp.LeftWorkType == LeftWorkTempType.StartWork) + CreatedByClient = clientTemp != null || (employee.workshopTemp != null && employee.workshopTemp.LeftWorkType == LeftWorkTempType.StartWork) }; @@ -272,8 +272,15 @@ public class RollCallEmployeeRepository : RepositoryBase public List GetActivePersonnelByWorkshopId(long workshopId) { var dateNow = DateTime.Now.Date; - var rollCallEmployeesQuery = _context.RollCallEmployees.Include(x => x.EmployeesStatus).Where(x => x.WorkshopId == workshopId - && x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) && x.HasUploadedImage == "true"); + + var leftWork = _context.LeftWorkList.Where(x => + x.WorkshopId == workshopId && x.StartWorkDate <= dateNow && x.LeftWorkDate >= dateNow); + + var rollCallEmployeesQuery = _context.RollCallEmployees.Include(x => x.EmployeesStatus) + .Where(x => x.WorkshopId == workshopId + && x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) + && x.HasUploadedImage == "true" &&leftWork.Any(l=>l.EmployeeId == x.EmployeeId && l.WorkshopId == x.WorkshopId)); + var personnel = _context.PersonnelCodeSet.Where(x => x.WorkshopId == workshopId && rollCallEmployeesQuery.Any(y => y.EmployeeId == x.EmployeeId && y.WorkshopId == x.WorkshopId)) @@ -300,15 +307,15 @@ public class RollCallEmployeeRepository : RepositoryBase { var personnelCodes = _context.PersonnelCodeSet.Where(x => x.WorkshopId == workshopId); - var rollCallEmployeesQuery = _context.RollCallEmployees.Include(x=>x.EmployeesStatus) - .Where(x => x.WorkshopId == workshopId && x.EmployeesStatus.Any() && personnelCodes.Any(y=>y.EmployeeId == x.EmployeeId)); + var rollCallEmployeesQuery = _context.RollCallEmployees.Include(x => x.EmployeesStatus) + .Where(x => x.WorkshopId == workshopId && x.EmployeesStatus.Any() && personnelCodes.Any(y => y.EmployeeId == x.EmployeeId)); var res = rollCallEmployeesQuery.Select(x => new RollCallEmployeeViewModel - { - RollCallEmployeeId = x.id, - EmployeeId = x.EmployeeId, - EmployeeFullName = x.EmployeeFullName - }) + { + RollCallEmployeeId = x.id, + EmployeeId = x.EmployeeId, + EmployeeFullName = x.EmployeeFullName + }) .ToList(); return res; From cd83ca4379dc19c9020ed15ead332a1b08ac7a1e Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 28 Apr 2025 19:20:10 +0330 Subject: [PATCH 4/8] RotatingShiftReport Modal --- .../Checkouts/RotatingShiftReport.cshtml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml index 19267e32..1defe4f4 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml @@ -1,6 +1,16 @@ @model CompanyManagment.App.Contracts.Contract.ComputingViewModel @{ + + + + خروجی EXCEL + + + diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/Grouping.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/Grouping.cshtml.cs index 004626e2..1d6eadc1 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/Grouping.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/Grouping.cshtml.cs @@ -14,6 +14,8 @@ using _0_Framework.Domain.CustomizeCheckoutShared.Enums; using _0_Framework.Infrastructure; using CompanyManagment.App.Contracts.RollCallEmployee; using Company.Domain.EmployeeAgg; +using CompanyManagement.Infrastructure.Excel.CWS; +using CompanyManagement.Infrastructure.Excel.EmployeeBankInfo; namespace ServiceHost.Areas.Client.Pages.Company.RollCall { @@ -29,12 +31,12 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall private readonly IHttpContextAccessor _contextAccessor; private readonly IAuthHelper _authHelper; public bool GroupedAllEmployees; - private readonly long _workshopId; - public string WorkshopFullName; + private readonly long _workshopId; + public string WorkshopFullName; public CustomizeWorkshopSettingsViewModel RollCallWorkshopSettings; public List RollCallEmployeeList; - public GroupingModel(IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication, ICustomizeWorkshopSettingsApplication rollCallWorkshopSettingsApplication, IEmployeeApplication employeeApplication, IHttpContextAccessor contextAccessor, IAuthHelper authHelper, IRollCallEmployeeApplication rollCallEmployeeApplication) + public GroupingModel(IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication, ICustomizeWorkshopSettingsApplication rollCallWorkshopSettingsApplication, IEmployeeApplication employeeApplication, IHttpContextAccessor contextAccessor, IAuthHelper authHelper, IRollCallEmployeeApplication rollCallEmployeeApplication) { _passwordHasher = passwordHasher; _workshopApplication = workshopApplication; @@ -47,29 +49,29 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall _workshopId = _passwordHasher.SlugDecrypt(workshopHash); if (_workshopId < 1) - throw new InvalidDataException("اختلال در کارگاه"); - } + throw new InvalidDataException("اختلال در کارگاه"); + } public bool IrregularWorkshopHaveGroupedAllPersonnelValidation(long workshopId) { - //var isWorkshopIrregular = _customizeWorkshopSettingsApplication - // .GetWorkshopSettingsDetails(workshopId).WorkshopShiftStatus == WorkshopShiftStatus.Irregular; + //var isWorkshopIrregular = _customizeWorkshopSettingsApplication + // .GetWorkshopSettingsDetails(workshopId).WorkshopShiftStatus == WorkshopShiftStatus.Irregular; - //if (isWorkshopIrregular == false) - // return true; - var employeesWithoutGroup = _customizeWorkshopSettingsApplication.HasAnyEmployeeWithoutGroup(workshopId); - if (employeesWithoutGroup) - return false; - return true; - } + //if (isWorkshopIrregular == false) + // return true; + var employeesWithoutGroup = _customizeWorkshopSettingsApplication.HasAnyEmployeeWithoutGroup(workshopId); + if (employeesWithoutGroup) + return false; + return true; + } public IActionResult OnGet() { - //if (_workshopId != 11) - // return Redirect("/Client/Company/RollCall"); + //if (_workshopId != 11) + // return Redirect("/Client/Company/RollCall"); - RollCallEmployeeList = _rollCallEmployeeApplication.GetEmployeeRollCalls(_workshopId); + RollCallEmployeeList = _rollCallEmployeeApplication.GetEmployeeRollCalls(_workshopId); - var account = _authHelper.CurrentAccountInfo(); + var account = _authHelper.CurrentAccountInfo(); GroupedAllEmployees = IrregularWorkshopHaveGroupedAllPersonnelValidation(_workshopId); var workshop = _workshopApplication.GetWorkshopInfo(_workshopId); @@ -77,18 +79,18 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall RollCallWorkshopSettings = _customizeWorkshopSettingsApplication.GetWorkshopSettingsByWorkshopId(_workshopId, account); if (RollCallWorkshopSettings.Id == 0) - { - return Redirect("/Client/Company/RollCall"); - } + { + return Redirect("/Client/Company/RollCall"); + } return Page(); } public IActionResult OnGetWorkshopSettingsDataAjax() { - var account = _authHelper.CurrentAccountInfo(); + var account = _authHelper.CurrentAccountInfo(); - var result = _customizeWorkshopSettingsApplication.GetWorkshopSettingsByWorkshopId(_workshopId, account); + var result = _customizeWorkshopSettingsApplication.GetWorkshopSettingsByWorkshopId(_workshopId, account); return new JsonResult(new { isSuccedded = true, @@ -107,16 +109,16 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall } public IActionResult OnGetEmployeesGroupSettingsByEmployeeId(long employeeId) - { - var result = _customizeWorkshopSettingsApplication.GetEmployeesGroupSettingsByEmployeeId(employeeId, _workshopId); - return new JsonResult(new - { - success = true, - data = result - }); + { + var result = _customizeWorkshopSettingsApplication.GetEmployeesGroupSettingsByEmployeeId(employeeId, _workshopId); + return new JsonResult(new + { + success = true, + data = result + }); } - public IActionResult OnGetCreateGroup(long workshopSettingId) + public IActionResult OnGetCreateGroup(long workshopSettingId) { var command = new CreateCustomizeWorkshopGroupSettings { @@ -127,7 +129,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall public IActionResult OnPostCreateGroup(CreateCustomizeWorkshopGroupSettings command) { - command.Salary = "0"; + command.Salary = "0"; OperationResult result = _customizeWorkshopSettingsApplication.CreateGroupSettingsByRollCallWorkshopSettingId(command); return new JsonResult(new @@ -139,35 +141,35 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall public IActionResult OnGetEditGroup(long groupId) { - var command = _customizeWorkshopSettingsApplication.GetCustomizeWorkshopGroupSettingsDetails(groupId); - - command.IsShiftChanged = _customizeWorkshopSettingsApplication - .GetEmployeeSettingsByGroupSettingsId(groupId) - .Any(x => x.IsSettingChanged == true); - return Partial("ModalEditGroup", command); - } + var command = _customizeWorkshopSettingsApplication.GetCustomizeWorkshopGroupSettingsDetails(groupId); + + command.IsShiftChanged = _customizeWorkshopSettingsApplication + .GetEmployeeSettingsByGroupSettingsId(groupId) + .Any(x => x.IsSettingChanged == true); + return Partial("ModalEditGroup", command); + } public IActionResult OnPostEditGroup(EditCustomizeWorkshopGroupSettings command) { - var result = _customizeWorkshopSettingsApplication.EditSimpleRollCallGroupSetting(command); + var result = _customizeWorkshopSettingsApplication.EditSimpleRollCallGroupSetting(command); - return new JsonResult(new - { + return new JsonResult(new + { success = result.IsSuccedded, message = result.Message - }); + }); } public IActionResult OnGetEmployeeIsChangeList(long groupId) { - var result = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByGroupSettingsId(groupId) - .Where(x => x.IsSettingChanged).ToList(); - return new JsonResult(new - { - success = true, - data = result - }); - } + var result = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByGroupSettingsId(groupId) + .Where(x => x.IsSettingChanged).ToList(); + return new JsonResult(new + { + success = true, + data = result + }); + } public IActionResult OnPostDeleteGroup(long groupId) { @@ -179,7 +181,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall }); } - public IActionResult OnGetEmployeeGroupAjax(long rollCallWorkshopSettingId) + public IActionResult OnGetEmployeeGroupAjax(long rollCallWorkshopSettingId) { var result = _customizeWorkshopSettingsApplication.GetEmployeesWithoutGroup(rollCallWorkshopSettingId); return new JsonResult(new @@ -202,8 +204,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall public IActionResult OnPostCreateEmployee(CreateCustomizeEmployeeSettings command) { - command.WorkshopId = _workshopId; - OperationResult result = _customizeWorkshopSettingsApplication.CreateEmployeeSettings(command); + command.WorkshopId = _workshopId; + OperationResult result = _customizeWorkshopSettingsApplication.CreateEmployeeSettings(command); return new JsonResult(new { success = result.IsSuccedded, @@ -223,29 +225,29 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall public IActionResult OnGetEditEmployee(long groupId, List employeeId) { - var employee = _customizeWorkshopSettingsApplication.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(_workshopId, employeeId.First()); + var employee = _customizeWorkshopSettingsApplication.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(_workshopId, employeeId.First()); var command = new EditCustomizeEmployeeSettings() { - Id = employee.Id, + Id = employee.Id, EmployeeIds = employeeId, EmployeeFullName = employee.EmployeeFullName, Salary = employee.Salary.ToMoney(), NameGroup = employee.Name, - ShiftViewModel = employee.RollCallWorkshopShifts, + ShiftViewModel = employee.RollCallWorkshopShifts, BreakTime = employee.BreakTime, WorkshopShiftStatus = employee.WorkshopShiftStatus, IrregularShift = employee.IrregularShift, FridayWork = employee.FridayWork, HolidayWork = employee.HolidayWork, CustomizeRotatingShifts = employee.CustomizeRotatingShiftsViewModels - }; + }; return Partial("ModalEditEmployeeFromGroup", command); } public IActionResult OnPostChangeEditEmployee(EditCustomizeEmployeeSettings command) { - command.WorkshopId = _workshopId; - OperationResult result = _customizeWorkshopSettingsApplication.EditSimpleRollCallEmployeeSetting(command); + command.WorkshopId = _workshopId; + OperationResult result = _customizeWorkshopSettingsApplication.EditSimpleRollCallEmployeeSetting(command); return new JsonResult(new { success = result.IsSuccedded, @@ -253,43 +255,113 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall }); } - // public IActionResult OnGetGroupingSetting(long groupId) - // { - // var command = _customizeWorkshopSettingsApplication.GetCustomizeWorkshopGroupSettingsDetails(groupId); + public IActionResult OnGetDownloadExcel() + { + var groupData = _customizeWorkshopSettingsApplication.GetWorkshopSettingsByWorkshopIdForAdmin(_workshopId); - // return Partial("ModalSettingGroup", command); - //} + var data = groupData.GroupSettings.Select(x => new CustomizeWorkshopGroupExcelViewModel() + { + Name = x.GroupName, + Salary = ((int)x.Salary).ToString(), + ShiftType = x.WorkshopShiftStatus switch + { + WorkshopShiftStatus.Irregular => "مختلط", + WorkshopShiftStatus.Regular => "منظم", + WorkshopShiftStatus.Rotating => "گردشی", + _ => throw new ArgumentOutOfRangeException() + }, + Shifts = x.WorkshopShiftStatus switch + { + WorkshopShiftStatus.Irregular => x.IrregularShift.WorkshopIrregularShifts switch + { + WorkshopIrregularShifts.None => "نامشخص", + WorkshopIrregularShifts.TwelveThirtySix => "12/36", + WorkshopIrregularShifts.TwelveTwentyFour => "12/24", + WorkshopIrregularShifts.TwentyFourTwentyFour => "24/24", + _ => throw new ArgumentOutOfRangeException() + }, + WorkshopShiftStatus.Regular => string.Join(Environment.NewLine, + x.RollCallWorkshopShifts.Select(s => s.StartTime.ToString() + " - " + s.EndTime).ToList()), + WorkshopShiftStatus.Rotating => string.Join(Environment.NewLine, + x.CustomizeRotatingShiftsViewModels.Select(s => s.StartTime.ToString() + " - " + s.EndTime) + .ToList()), + _ => throw new ArgumentOutOfRangeException() + }, + EmployeeSettings = x.RollCallWorkshopEmployeesSettings.Select(e => new CustomizeWorkshopEmployeeExcelViewModel + { + Shifts = e.WorkshopShiftStatus switch + { + WorkshopShiftStatus.Irregular => e.IrregularShift.WorkshopIrregularShifts switch + { + WorkshopIrregularShifts.None => "نامشخص", + WorkshopIrregularShifts.TwelveThirtySix => "12/36", + WorkshopIrregularShifts.TwelveTwentyFour => "12/24", + WorkshopIrregularShifts.TwentyFourTwentyFour => "24/24", + _ => throw new ArgumentOutOfRangeException() + }, + WorkshopShiftStatus.Regular => string.Join(Environment.NewLine, + e.RollCallWorkshopShifts.Select(s => s.StartTime.ToString() + " - " + s.EndTime).ToList()), + WorkshopShiftStatus.Rotating => string.Join(Environment.NewLine, + e.CustomizeRotatingShiftsViewModels.Select(s => s.StartTime.ToString() + " - " + s.EndTime) + .ToList()), + _ => throw new ArgumentOutOfRangeException() + }, + Salary = ((int)e.Salary).ToString(), + ShiftType = e.WorkshopShiftStatus switch + { + WorkshopShiftStatus.Irregular => "مختلط", + WorkshopShiftStatus.Regular => "منظم", + WorkshopShiftStatus.Rotating => "گردشی", + _ => throw new ArgumentOutOfRangeException() + }, + LeavePermitted = e.LeavePermittedDays, + Name = e.Name + }).ToList(), + }).ToList(); - // public IActionResult OnPostGroupingSetting(EditCustomizeWorkshopGroupSettings command) - // { - // command.EmployeeIds = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByGroupSettingsId(command.Id).Select(x => x.EmployeeId).ToList(); - // OperationResult result = _customizeWorkshopSettingsApplication.EditRollCallGroupSetting(command); + var bytes = CustomizeWorkshopGroupSettingExcelGenerator.Generate(data); + return File(bytes, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + $"اطلاعات گروهبندی.xlsx"); + } - // return new JsonResult(new - // { - // isSuccess = result.IsSuccedded, - // message = result.Message - // }); - //} + // public IActionResult OnGetGroupingSetting(long groupId) + // { + // var command = _customizeWorkshopSettingsApplication.GetCustomizeWorkshopGroupSettingsDetails(groupId); - //public IActionResult OnGetGroupingEmployeeSetting(long customizeEmployeeId, List employeeId) - // { - // var command = _customizeWorkshopSettingsApplication.GetCustomizeEmployeeSettingsDetails(customizeEmployeeId); - // command.EmployeeIds = employeeId; + // return Partial("ModalSettingGroup", command); + //} - // return Partial("ModalSettingGroupEmployee", command); - // } + // public IActionResult OnPostGroupingSetting(EditCustomizeWorkshopGroupSettings command) + // { + // command.EmployeeIds = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByGroupSettingsId(command.Id).Select(x => x.EmployeeId).ToList(); + // OperationResult result = _customizeWorkshopSettingsApplication.EditRollCallGroupSetting(command); - // public IActionResult OnPostGroupingEmployeeSetting(EditCustomizeEmployeeSettings command) - // { - // command.WorkshopId = _workshopId; - // OperationResult result = _customizeWorkshopSettingsApplication.EditRollCallEmployeeSettings(command); + // return new JsonResult(new + // { + // isSuccess = result.IsSuccedded, + // message = result.Message + // }); + //} - // return new JsonResult(new - // { - // isSuccess = result.IsSuccedded, - // message = result.Message - // }); - //} - } + //public IActionResult OnGetGroupingEmployeeSetting(long customizeEmployeeId, List employeeId) + // { + // var command = _customizeWorkshopSettingsApplication.GetCustomizeEmployeeSettingsDetails(customizeEmployeeId); + // command.EmployeeIds = employeeId; + + // return Partial("ModalSettingGroupEmployee", command); + // } + + // public IActionResult OnPostGroupingEmployeeSetting(EditCustomizeEmployeeSettings command) + // { + // command.WorkshopId = _workshopId; + // OperationResult result = _customizeWorkshopSettingsApplication.EditRollCallEmployeeSettings(command); + + // return new JsonResult(new + // { + // isSuccess = result.IsSuccedded, + // message = result.Message + // }); + //} + } } From 366d42dec9ca6790082c7fcffee11f9d7eb17775 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 28 Apr 2025 19:48:54 +0330 Subject: [PATCH 6/8] styling RotatingShiftReport modal --- .../Repository/RollCallMandatoryRepository.cs | 3 ++- .../Checkouts/RotatingShiftReport.cshtml | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 8e889dea..9eb98555 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -840,7 +840,7 @@ CreateWorkingHoursTemp command, bool holidayWorking) var nightWorkingTime = new TimeSpan(); #endregion - + foreach (var shift in item.ShiftList) { #region DatePeriod @@ -1015,6 +1015,7 @@ CreateWorkingHoursTemp command, bool holidayWorking) #region Result var result = new RotatingShiftViewModel(); + result.RotatingDate = item.CreationDate.ToFarsi(); result.MorningWorkSpan = morningWorkingTime; result.EveningWorkSpan = eveningWorkingTime; result.NightWorkSpan = nightWorkingTime; diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml index 1defe4f4..8e8b867c 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReport.cshtml @@ -24,7 +24,7 @@ .modal-body2 { background-color: #f2fbfb; width: 100%; - height: 615px; + height: 644px; border-radius: 25px; position: absolute; } @@ -59,7 +59,20 @@