LeaveListPrint

This commit is contained in:
SamSys
2025-12-27 14:06:10 +03:30
parent 54c67fe8f7
commit ba778bb519
6 changed files with 85 additions and 10 deletions

View File

@@ -54,4 +54,11 @@ public interface ILeaveRepository : IRepository<long, Leave>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<List<GroupLeaveListDto>> GetGroupList(LeaveListSearchModel searchModel);
/// <summary>
/// پرینت لیستی
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
Task<LeaveListPrintDto> ListPrint(List<long> ids);
}

View File

@@ -97,6 +97,13 @@ public interface ILeaveApplication
/// <returns></returns>
Task<OperationResult<RotatingShiftDto>> HasRotatingShift(long workshopId, long employeeId, string startLeaveDate);
/// <summary>
/// پرینت لیستی
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
Task<LeaveListPrintDto> ListPrint(List<long> ids);
}
public class LeavePrintResponseViewModel

View File

@@ -2,7 +2,11 @@
namespace CompanyManagment.App.Contracts.Leave;
public class LeavePrintListDto
/// <summary>
/// پرینت لیستی
/// api
/// </summary>
public class LeaveListPrintDto
{
/// <summary>
@@ -10,15 +14,17 @@ public class LeavePrintListDto
/// </summary>
public string EmployeeFullName { get; set; }
/// <summary>
/// مجموع مرخصی پرسنل
/// </summary>
public string? SumOfEmployeeleaves { get; set; }
/// <summary>
/// لیست مرخصی
/// </summary>
public List<LeavePrintListItemsDto> LeavePrintListItemsDto { get; set; }
/// <summary>
/// مجموع مرخصی پرسنل
/// </summary>
public string? SumOfEmployeeleaves { get; set; }
}
public class LeavePrintListItemsDto

View File

@@ -960,4 +960,10 @@ public class LeaveApplication : ILeaveApplication
return op.Succcedded(result);
}
#endregion
public async Task<LeaveListPrintDto> ListPrint(List<long> ids)
{
return await _leaveRepository.ListPrint(ids);
}
}

View File

@@ -1,9 +1,7 @@
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Azure.Core;
using Company.Domain.LeaveAgg;
using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.InstitutionPlan;
using CompanyManagment.App.Contracts.Leave;
using Microsoft.EntityFrameworkCore;
using System;
@@ -11,6 +9,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CompanyManagment.EFCore.Repository;
public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
@@ -678,6 +677,7 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
query = query.OrderByDescending(x => x.CreationDate);
var queryPaginationFilter = await query.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
var leaveResult = queryPaginationFilter.Select(item => new leaveListDto()
{
@@ -796,5 +796,54 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
return leaveList;
}
public async Task<LeaveListPrintDto> ListPrint(List<long> ids)
{
var result = new LeaveListPrintDto();
var timeSpanHourlyLeave = new TimeSpan();
var dailyLeaveTime = new TimeSpan();
if (ids.Any())
{
var query = _context.LeaveList.Where(x => ids.Contains(x.id)).OrderByDescending(x=>x.StartLeave).AsQueryable();
#region sumOfLeaves
var hourly = await query.Where(x => x.PaidLeaveType == "ساعتی").Select(x => x.LeaveHourses).ToListAsync();
var daily = await query.Where(x => x.PaidLeaveType == "روزانه").Select(x => x.LeaveHourses).ToListAsync();
if (hourly.Any())
timeSpanHourlyLeave = new TimeSpan(hourly.Sum(x => TimeOnly.Parse(x).Ticks));
if (daily.Any())
dailyLeaveTime = daily.Sum(x => Convert.ToInt32(x)) * TimeSpan.FromDays(1);
var sumOfLeaves = timeSpanHourlyLeave.Add(dailyLeaveTime);
result.SumOfEmployeeleaves = sumOfLeaves.ToFarsiDaysAndHoursAndMinutes();
#endregion
result.LeavePrintListItemsDto = await query.Select(item => new LeavePrintListItemsDto
{
YearStr = $"{item.Year}",
MonthStr = item.Month.ToFarsiMonthByIntNumber(),
StartLeave = item.StartLeave.ToFarsi(),
EndLeave = item.EndLeave.ToFarsi(),
LeaveType = item.LeaveType,
HourlyInterval = item.PaidLeaveType == "ساعتی" ? $"{item.StartLeave.TimeOfDay:hh\\:mm} الی {item.EndLeave.TimeOfDay:hh\\:mm}" : "-",
LeaveDuration = Tools.CalculateLeaveHoursAndDays(item.PaidLeaveType, item.LeaveHourses),
IsAccepted = item.IsAccepted,
}).ToListAsync();
result.EmployeeFullName = query.FirstOrDefault()!.EmployeeFullName;
}
return result;
}
#endregion
}

View File

@@ -111,14 +111,14 @@ public class LeaveController : ClientBaseController
}
/// <summary>
/// پرینت گروهی
/// پرینت لیستی
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpGet("ListPrint")]
public async Task<OperationResult<LeavePrintListDto>> ListPrint([FromQuery] List<long> ids,)
public async Task<ActionResult<LeaveListPrintDto>> ListPrint([FromQuery] List<long> ids)
{
var leavePrints = await _leaveApplication.PrintAllAsync(ids, _workshopId);
var leavePrints = await _leaveApplication.ListPrint(ids);
return Ok(leavePrints);
}