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/CompanyManagement.Infrastructure.Excel/CWS/CustomizeWorkshopGroupSettingExcelGenerator.cs b/CompanyManagement.Infrastructure.Excel/CWS/CustomizeWorkshopGroupSettingExcelGenerator.cs new file mode 100644 index 00000000..4d27f8bc --- /dev/null +++ b/CompanyManagement.Infrastructure.Excel/CWS/CustomizeWorkshopGroupSettingExcelGenerator.cs @@ -0,0 +1,179 @@ +using CompanyManagement.Infrastructure.Excel.EmployeeBankInfo; +using OfficeOpenXml.Style; +using OfficeOpenXml; +using System.Drawing; +using _0_Framework.Application; + +namespace CompanyManagement.Infrastructure.Excel.CWS; +public class CustomizeWorkshopGroupExcelViewModel +{ + public string Name { get; set; } + public string ShiftType { get; set; } + public string Shifts { get; set; } + public string Salary { get; set; } + public List EmployeeSettings { get; set; } +} + +public class CustomizeWorkshopEmployeeExcelViewModel +{ + public string Name { get; set; } + public string ShiftType { get; set; } + public string Shifts { get; set; } + public int LeavePermitted { get; set; } + public string Salary { get; set; } +} +public class CustomizeWorkshopGroupSettingExcelGenerator +{ + public static byte[] Generate(List groups) + { + ExcelPackage.LicenseContext = LicenseContext.NonCommercial; + using (var package = new ExcelPackage()) + { + var worksheet = package.Workbook.Worksheets.Add("GroupsAndEmployees"); + + // Headers + worksheet.Cells[1, 1].Value = "نام گروه"; + worksheet.Cells[1, 2].Value = "نوع شیفت گروه"; + worksheet.Cells[1, 3].Value = "شیفت گروه"; + worksheet.Cells[1, 4].Value = "حقوق گروه"; + + worksheet.Cells[1, 5].Value = "نام پرسنل"; + worksheet.Cells[1, 6].Value = "مجاز مرخصی پرسنل"; + worksheet.Cells[1, 7].Value = "نوع شیفت پرسنل"; + worksheet.Cells[1, 8].Value = "شیفت پرسنل"; + worksheet.Cells[1, 9].Value = "حقوق پرسنل"; + + using (var range = worksheet.Cells[1, 1, 1, 9]) + { + range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; + range.Style.VerticalAlignment = ExcelVerticalAlignment.Center; + range.Style.Font.Bold = true; + range.Style.Fill.PatternType = ExcelFillStyle.Solid; + range.Style.Fill.BackgroundColor.SetColor(Color.LightGray); // رنگ پس زمینه خاکستری + + range.Style.Border.BorderAround(ExcelBorderStyle.Thin); + } + + int row = 2; + + foreach (var group in groups) + { + var employees = group.EmployeeSettings ?? new List(); + int groupStartRow = row; + int groupEndRow = employees.Count > 0 ? (row + employees.Count - 1) : row; + + if (employees.Count == 0) + { + // گروه بدون پرسنل + worksheet.Cells[row, 1].Value = group.Name; + worksheet.Cells[row, 2].Value = group.ShiftType; + worksheet.Cells[row, 3].Value = group.Shifts; + worksheet.Cells[row, 4].Value = Convert.ToInt32(group.Salary); + + ApplyGroupStyle(worksheet, row, row); + worksheet.Cells[row, 4].Style.Numberformat.Format = "#,##0"; + using (var thickBorderRange = worksheet.Cells[groupEndRow, 1, groupEndRow, 9]) + { + thickBorderRange.Style.Border.Bottom.Style = ExcelBorderStyle.Thick; + } + row++; + } + else + { + foreach (var employee in employees) + { + worksheet.Cells[row, 5].Value = employee.Name; + worksheet.Cells[row, 6].Value = employee.LeavePermitted; + worksheet.Cells[row, 7].Value = employee.ShiftType; + worksheet.Cells[row, 8].Value = employee.Shifts; + worksheet.Cells[row, 9].Value = Convert.ToInt32(employee.Salary); + + ApplyEmployeeStyle(worksheet, row); + worksheet.Cells[row, 9].Style.Numberformat.Format = "#,##0"; + row++; + } + + // Merge اطلاعات گروه برای تمام پرسنل + worksheet.Cells[groupStartRow, 1, groupEndRow, 1].Merge = true; + worksheet.Cells[groupStartRow, 1].Value = group.Name; + + worksheet.Cells[groupStartRow, 2, groupEndRow, 2].Merge = true; + worksheet.Cells[groupStartRow, 2].Value = group.ShiftType; + + worksheet.Cells[groupStartRow, 3, groupEndRow, 3].Merge = true; + worksheet.Cells[groupStartRow, 3].Value = group.Shifts; + + worksheet.Cells[groupStartRow, 4, groupEndRow, 4].Merge = true; + worksheet.Cells[groupStartRow, 4].Value = Convert.ToInt32(group.Salary); + + ApplyGroupStyle(worksheet, groupStartRow, groupEndRow); + + worksheet.Cells[groupStartRow, 4, groupEndRow, 4].Style.Numberformat.Format = "#,##0"; + + + worksheet.Cells[groupEndRow, 1, groupEndRow, 9].Style.Border.Bottom.Style = ExcelBorderStyle.Thick; + + } + } + worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); + + for (int i = 2; i <= worksheet.Dimension.Rows; i++) + { + worksheet.Row(i).Height = 50; + } + + int groupShiftCol = 3; + int employeeShiftCol = 8; + int groupSalary = 4; + int employeeSalary = 9; + int employeeName =5; + worksheet.Columns[groupShiftCol].Width = 15; + worksheet.Columns[employeeShiftCol].Width = 15; + worksheet.Columns[groupSalary].Width = 16; + worksheet.Columns[employeeSalary].Width = 16; + worksheet.Columns[employeeName].Width = 24; + worksheet.View.RightToLeft = true; // فارسی + return package.GetAsByteArray(); + } + } + + private static void ApplyEmployeeStyle(ExcelWorksheet worksheet, int row) + { + using (var range = worksheet.Cells[row, 5, row, 9]) + { + //range.Style.Fill.PatternType = ExcelFillStyle.Solid; + //range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(198, 239, 206)); // سبز خیلی روشن + range.Style.Border.BorderAround(ExcelBorderStyle.Thin); + range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; + range.Style.VerticalAlignment = ExcelVerticalAlignment.Center; + + // اضافه کردن بوردر به همه‌ی سلول‌های ردیف پرسنل + range.Style.Border.Top.Style = ExcelBorderStyle.Thin; + range.Style.Border.Bottom.Style = ExcelBorderStyle.Thin; + range.Style.Border.Left.Style = ExcelBorderStyle.Thin; + range.Style.Border.Right.Style = ExcelBorderStyle.Thin; + + range.Style.WrapText = true; + } + } + + private static void ApplyGroupStyle(ExcelWorksheet worksheet, int startRow, int endRow) + { + using (var range = worksheet.Cells[startRow, 1, endRow, 4]) + { + //range.Style.Fill.PatternType = ExcelFillStyle.Solid; + //range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(255, 255, 204)); // زرد خیلی روشن + range.Style.Border.BorderAround(ExcelBorderStyle.Thin); + range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; + range.Style.VerticalAlignment = ExcelVerticalAlignment.Center; + + // اضافه کردن بوردر به همه‌ی سلول‌های گروه + range.Style.Border.Top.Style = ExcelBorderStyle.Thin; + range.Style.Border.Bottom.Style = ExcelBorderStyle.Thin; + range.Style.Border.Left.Style = ExcelBorderStyle.Thin; + range.Style.Border.Right.Style = ExcelBorderStyle.Thin; + + range.Style.WrapText = true; + } + } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Contract/ComputingViewModel.cs b/CompanyManagment.App.Contracts/Contract/ComputingViewModel.cs index 6a53dfda..c300613d 100644 --- a/CompanyManagment.App.Contracts/Contract/ComputingViewModel.cs +++ b/CompanyManagment.App.Contracts/Contract/ComputingViewModel.cs @@ -36,6 +36,7 @@ public class ComputingViewModel public string MarriedAllowance { get; set; } public string RotatingShiftValue { get; set; } public List RotatingResultList { get; set; } + public bool HasRollCall { get; set; } diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopSettingsViewModel.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopSettingsViewModel.cs index 7079d21c..ba6e6dc7 100644 --- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopSettingsViewModel.cs +++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopSettingsViewModel.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using _0_Framework.Domain.CustomizeCheckoutShared.Enums; namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings; @@ -9,4 +10,6 @@ public class CustomizeWorkshopSettingsViewModel public string Name { get; set; } public WorkshopShiftStatus WorkshopShiftStatus { get; set; } public List GroupSettings { get; set; } + public TimeOnly Offset { get; set; } + } \ 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/InsuranceJobApplication.cs b/CompanyManagment.Application/InsuranceJobApplication.cs index dc3577fd..e9cf91fe 100644 --- a/CompanyManagment.Application/InsuranceJobApplication.cs +++ b/CompanyManagment.Application/InsuranceJobApplication.cs @@ -89,8 +89,8 @@ public class InsuranceJobApplication: IInsuranceJobApplication if (_insuranceJobRepositpry.Exists(x => x.InsuranceJobTitle == command.InsuranceJobTitle && x.id!=command.Id)) return opration.Failed("عنوان صنف و درجه تکراری است"); - if (_insuranceJobRepositpry.Exists(x => x.EconomicCode == command.EconomicCode && x.id != command.Id)) - return opration.Failed("کد اقتصادی تکراری است"); + //if (_insuranceJobRepositpry.Exists(x => x.EconomicCode == command.EconomicCode && x.id != command.Id)) + // return opration.Failed("کد اقتصادی تکراری است"); try { 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..f3f93596 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -90,7 +90,16 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos TotalDeductions = x.TotalDeductions, 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/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/CustomizeWorkshopSettingsRepository.cs b/CompanyManagment.EFCore/Repository/CustomizeWorkshopSettingsRepository.cs index 352b6e4b..5652d774 100644 --- a/CompanyManagment.EFCore/Repository/CustomizeWorkshopSettingsRepository.cs +++ b/CompanyManagment.EFCore/Repository/CustomizeWorkshopSettingsRepository.cs @@ -92,6 +92,7 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext, return new CustomizeWorkshopSettingsViewModel() { Id = entity.id, + Offset = entity.EndTimeOffSet, GroupSettings = entity.CustomizeWorkshopGroupSettingsCollection.Where(x => !x.MainGroup).Select(x => new CustomizeWorkshopGroupSettingsViewModel() { @@ -106,7 +107,7 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext, EmployeeId = y.EmployeeId, IsSettingChanged = y.IsSettingChanged, IsShiftChanged = y.IsShiftChanged, - Name = $"{employee.FName} {employee.LName}", + Name = $"{employee?.FName} {employee?.LName}", RollCallWorkshopShifts = y.CustomizeWorkshopEmployeeSettingsShifts.Select(s => new CustomizeWorkshopShiftViewModel() { @@ -115,7 +116,14 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext, StartTime = s.StartTime.ToString("HH:mm") }).ToList(), Salary = y.Salary, - + CustomizeRotatingShiftsViewModels = y.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel + { + StartTime = r.StartTime.ToString("HH:mm"), + EndTime = r.EndTime.ToString("HH:mm") + }).ToList(), + LeavePermittedDays = y.LeavePermittedDays, + IrregularShift = y.IrregularShift, + WorkshopShiftStatus = y.WorkshopShiftStatus }; }).ToList(), Salary = x.Salary, @@ -127,7 +135,16 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext, StartTime = s.StartTime.ToString("HH:mm") }).ToList(), - MainGroup = x.MainGroup + MainGroup = x.MainGroup, + WorkshopShiftStatus = x.WorkshopShiftStatus, + CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel + { + StartTime = r.StartTime.ToString("HH:mm"), + EndTime = r.EndTime.ToString("HH:mm") + }).ToList(), + IrregularShift = x.IrregularShift + + }).ToList(), }; 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; diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 24ff10d8..9eb98555 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) @@ -738,7 +840,7 @@ CreateWorkingHoursTemp command, bool holidayWorking) var nightWorkingTime = new TimeSpan(); #endregion - + foreach (var shift in item.ShiftList) { #region DatePeriod @@ -913,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/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml index 1dad3f2b..eace4adc 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml @@ -1323,6 +1323,30 @@ } } + 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..d7964fb3 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,93 @@ public class IndexModel : PageModel //chekoutlist = await _checkoutApplication.Search(searchModel); } - public async Task OnGetSearch(CheckoutSearchModel searchModel) + /// + /// گزارش نوبت کاری + /// + /// + /// + + #region RotatngShiftReport + + public async Task OnGetRotatngShiftReportDesktop(long id) + { + var result = new ComputingViewModel(); + var checkout = _checkoutApplication.GetDetails(id); + var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(checkout.ContractId); + if (checkout.HasRollCall) + { + result = await _rollCallMandatoryApplication.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId,checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork); + result.HasRollCall = true; + } + 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 Partial("./RotatingShiftReportDesktop", result); + } + + public async Task OnGetRotatngShiftReportMobile(long id) + { + var result = new ComputingViewModel(); + var checkout = _checkoutApplication.GetDetails(id); + var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(checkout.ContractId); + if (checkout.HasRollCall) + { + result = await _rollCallMandatoryApplication.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId, checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork); + result.HasRollCall = true; + } + 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 Partial("./RotatingShiftReportMobile", result); + } + + #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..2601fb48 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/MainSearch.cshtml @@ -212,9 +212,12 @@ - + *@ + +
@@ -231,8 +234,7 @@ - +
diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReportDesktop.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReportDesktop.cshtml new file mode 100644 index 00000000..7e0804d1 --- /dev/null +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReportDesktop.cshtml @@ -0,0 +1,158 @@ +@model CompanyManagment.App.Contracts.Contract.ComputingViewModel +@{ + +} + + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReportMobile.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReportMobile.cshtml new file mode 100644 index 00000000..bc0beff7 --- /dev/null +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/RotatingShiftReportMobile.cshtml @@ -0,0 +1,156 @@ +@model CompanyManagment.App.Contracts.Contract.ComputingViewModel +@{ + +} + + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/Grouping.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/Grouping.cshtml index 63f33901..86752faf 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/Grouping.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/Grouping.cshtml @@ -36,9 +36,28 @@
- +
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 + // }); + //} + } }