add PrintAllDetailsPersonnelInfoClient metoth controler
This commit is contained in:
@@ -96,6 +96,13 @@ public interface IEmployeeRepository : IRepository<long, Employee>
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// پرینت گروهی تفکیکی پرسنل
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// سلکت لیست پرسنل های کارگاه کلاینت
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// پرینت گروهی تفکیکی پرسنل
|
||||
/// </summary>
|
||||
public class PrintAllDetailsPersonnelInfoDtoClient
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// نام کامل پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeFullName { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///کد ملی
|
||||
/// </summary>
|
||||
public string NationalCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ تولد
|
||||
/// </summary>
|
||||
public string DateOfBirth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام پدر
|
||||
/// </summary>
|
||||
public string FatherName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تعداد فرزندان
|
||||
/// </summary>
|
||||
public string NumberOfChildren { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// استان
|
||||
/// </summary>
|
||||
public string State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شهر
|
||||
/// </summary>
|
||||
public string City { get; set; }
|
||||
|
||||
|
||||
public string Address { get; set; }
|
||||
}
|
||||
@@ -124,6 +124,14 @@ public interface IEmployeeApplication
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// پرینت گروهی تفکیکی پرسنل
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// سلکت لیست پرسنل های کارگاه کلاینت
|
||||
/// </summary>
|
||||
|
||||
@@ -1744,6 +1744,11 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
return await _EmployeeRepository.PrintAllEmployeesInfoClient(workshopId);
|
||||
}
|
||||
|
||||
public async Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient(long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.PrintAllDetailsPersonnelInfoClient(workshopId);
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.GetWorkingEmployeesSelectList(workshopId);
|
||||
|
||||
@@ -1287,7 +1287,99 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
&& x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.LefWorkTemp)
|
||||
.Select(x => new PrintAllEmployeesInfoDtoClient(x)).ToList();
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient(long workshopId)
|
||||
{
|
||||
var hasNotStoppedWorkingYet = Tools.GetUndefinedDateTime();
|
||||
|
||||
var baseQuery = await
|
||||
(
|
||||
from personnelCode in _context.PersonnelCodeSet
|
||||
join employee in _context.Employees
|
||||
on personnelCode.EmployeeId equals employee.id
|
||||
where personnelCode.WorkshopId == workshopId
|
||||
select new
|
||||
{
|
||||
Employee = employee,
|
||||
PersonnelCode = personnelCode
|
||||
}
|
||||
).ToListAsync();
|
||||
|
||||
|
||||
var employeeIds = baseQuery.Select(x => x.Employee.id).ToList();
|
||||
|
||||
var leftWorks = await _context.LeftWorkList
|
||||
.Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId))
|
||||
.ToListAsync();
|
||||
|
||||
var insuranceLeftWorks = await _context.LeftWorkInsuranceList
|
||||
.Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId))
|
||||
.ToListAsync();
|
||||
|
||||
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
|
||||
|
||||
|
||||
|
||||
|
||||
var result = baseQuery.Select(x =>
|
||||
{
|
||||
var left = leftWorks
|
||||
.Where(l => l.EmployeeId == x.Employee.id)
|
||||
.MaxBy(l => l.StartWorkDate);
|
||||
|
||||
var insuranceLeftWork = insuranceLeftWorks
|
||||
.Where(l => l.EmployeeId == x.Employee.id).MaxBy(l => l.StartWorkDate);
|
||||
|
||||
|
||||
var contractLeft = left != null
|
||||
? left.LeftWorkDate != hasNotStoppedWorkingYet ? left.LeftWorkDate.ToFarsi() : ""
|
||||
: "";
|
||||
|
||||
|
||||
var insuranceLeft = insuranceLeftWork != null
|
||||
? insuranceLeftWork.LeftWorkDate != null ? insuranceLeftWork.LeftWorkDate.ToFarsi() : ""
|
||||
: "";
|
||||
int personnelCode = Convert.ToInt32($"{x.PersonnelCode.PersonnelCode}");
|
||||
|
||||
int numberOfChildren = children.Count(ch => ch.EmployeeId == x.Employee.id);
|
||||
|
||||
bool employeeHasLeft =
|
||||
(!string.IsNullOrWhiteSpace(insuranceLeft) && !string.IsNullOrWhiteSpace(contractLeft))
|
||||
|| (left == null && !string.IsNullOrWhiteSpace(insuranceLeft))
|
||||
|| (insuranceLeftWork == null && !string.IsNullOrWhiteSpace(contractLeft));
|
||||
|
||||
return new
|
||||
{
|
||||
EmployeeFullName = x.Employee.FullName,
|
||||
PersonnelCode = personnelCode,
|
||||
NationalCode = x.Employee.NationalCode,
|
||||
IdNumber = x.Employee.IdNumber,
|
||||
DateOfBirth = x.Employee.DateOfBirth.ToFarsi(),
|
||||
FatherName = x.Employee.FatherName,
|
||||
NumberOfChildren = $"{numberOfChildren}",
|
||||
Black = employeeHasLeft,
|
||||
State = x.Employee.State,
|
||||
City = x.Employee.City,
|
||||
Address = x.Employee.Address
|
||||
};
|
||||
}).OrderBy(x => x.Black ? 1 : 0).ThenBy(x => x.PersonnelCode).ToList();
|
||||
|
||||
return result.Select(x => new PrintAllDetailsPersonnelInfoDtoClient
|
||||
{
|
||||
EmployeeFullName = x.EmployeeFullName,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
FatherName = x.FatherName,
|
||||
DateOfBirth = x.DateOfBirth,
|
||||
NumberOfChildren = x.NumberOfChildren,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address
|
||||
|
||||
}).ToList();
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
|
||||
{
|
||||
var hasNotStoppedWorkingYet = Tools.GetUndefinedDateTime();
|
||||
|
||||
@@ -52,6 +52,16 @@ public class EmployeeController:ClientBaseController
|
||||
var result = await _employeeApplication.PrintAllEmployeesInfoClient(_workshopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// پرینت گروهی تفکیکی پرسنل
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("PrintAllDetailsPersonnelInfo")]
|
||||
public async Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient()
|
||||
{
|
||||
var result = await _employeeApplication.PrintAllDetailsPersonnelInfoClient(_workshopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user