Compare commits
19 Commits
Feature/Ex
...
Feature/Cl
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ed1907075 | |||
| efcf40eea8 | |||
|
|
d2acf59eba | ||
|
|
3139552217 | ||
|
|
dc4c8e9a26 | ||
|
|
4b40580658 | ||
|
|
cddaf2f709 | ||
|
|
337cd40a4e | ||
|
|
a98300cacd | ||
|
|
daded35ab1 | ||
|
|
ba778bb519 | ||
|
|
54c67fe8f7 | ||
|
|
a638913172 | ||
|
|
69476f3f2d | ||
|
|
4bc65e500d | ||
| 07587d162f | |||
|
|
59bbb7aae6 | ||
|
|
89de3162de | ||
|
|
132c8ac5a4 |
@@ -54,6 +54,7 @@ public interface IEmployeeRepository : IRepository<long, Employee>
|
||||
|
||||
Employee GetIgnoreQueryFilter(long id);
|
||||
|
||||
[Obsolete("این متد منسوخ شده است و از متد WorkedEmployeesInWorkshopSelectList استفاده کنید")]
|
||||
Task<List<EmployeeSelectListViewModel>> WorkedEmployeesInWorkshopSelectList(long workshopId);
|
||||
|
||||
|
||||
@@ -77,7 +78,32 @@ public interface IEmployeeRepository : IRepository<long, Employee>
|
||||
Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id);
|
||||
Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel);
|
||||
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پرسنل کلاینت
|
||||
/// api
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// پرینت تجمیعی پرسنل کلاینت
|
||||
/// api
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// سلکت لیست پرسنل های کارگاه کلاینت
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
using CompanyManagment.App.Contracts.Leave;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.LeaveAgg;
|
||||
|
||||
@@ -10,7 +12,7 @@ public interface ILeaveRepository : IRepository<long, Leave>
|
||||
{
|
||||
EditLeave GetDetails(long id);
|
||||
List<LeaveViewModel> search(LeaveSearchModel searchModel);
|
||||
OperationResult RemoveLeave(long id);
|
||||
Task<OperationResult> RemoveLeave(long id);
|
||||
|
||||
#region Pooya
|
||||
List<LeaveViewModel> GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime start, DateTime end);
|
||||
@@ -27,6 +29,8 @@ public interface ILeaveRepository : IRepository<long, Leave>
|
||||
List<LeaveMainViewModel> searchClient(LeaveSearchModel searchModel);
|
||||
LeavePrintViewModel PrintOne(long id);
|
||||
List<LeavePrintViewModel> PrintAll(List<long> id);
|
||||
|
||||
Task<List<LeavePrintResponseViewModel>> PrintAllAsync(List<long> ids, long workshopId);
|
||||
|
||||
#region Vafa
|
||||
|
||||
@@ -34,4 +38,27 @@ public interface ILeaveRepository : IRepository<long, Leave>
|
||||
|
||||
#endregion
|
||||
bool CheckIfValidToEdit(long id);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست مرخصی ها در کلاینت
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedResult<leaveListDto>> GetList(
|
||||
LeaveListSearchModel searchModel);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست گروه بندی شده
|
||||
/// </summary>
|
||||
/// <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);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// لیست پرسنل کلاینت
|
||||
/// api
|
||||
/// </summary>
|
||||
public class EmployeeListDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کامل پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeFullName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// کد پرسنلی
|
||||
/// </summary>
|
||||
public int PersonnelCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت تاهل
|
||||
/// </summary>
|
||||
public string MaritalStatus { 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 LatestContractStartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ترک کار قرارداد
|
||||
/// </summary>
|
||||
public string ContractLeftDate { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آخرین تاریخ شروع بکار بیمه
|
||||
/// </summary>
|
||||
public string LatestInsuranceStartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ترک کار بیمه
|
||||
/// </summary>
|
||||
public string InsuranceLeftDate { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دارای قرارداد است؟
|
||||
/// </summary>
|
||||
public bool HasContract { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// دارای بیمه است؟
|
||||
/// </summary>
|
||||
public bool HasInsurance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت پرسنل در کارگاه
|
||||
/// </summary>
|
||||
public EmployeeStatusInWorkshop EmployeeStatusInWorkshop { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// سرچ مدل پرسنل
|
||||
/// api
|
||||
/// </summary>
|
||||
public class EmployeeSearchModelDto
|
||||
{
|
||||
/// <summary>
|
||||
/// نام پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeFullName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// کد ملی
|
||||
/// </summary>
|
||||
public string NationalCode { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت پرسنل در کارگاه
|
||||
/// api
|
||||
/// </summary>
|
||||
public enum EmployeeStatusInWorkshop
|
||||
{
|
||||
/// <summary>
|
||||
/// ایجاد شده توسط کارفرما
|
||||
/// </summary>
|
||||
CreatedByClient,
|
||||
|
||||
/// <summary>
|
||||
/// ترک کار موقت
|
||||
/// </summary>
|
||||
LefWorkTemp,
|
||||
|
||||
/// <summary>
|
||||
/// در حال کار در کارگاه
|
||||
/// </summary>
|
||||
Working,
|
||||
|
||||
/// <summary>
|
||||
/// قطع ارتباط و ترک کار کامب
|
||||
/// </summary>
|
||||
HasLeft,
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// پرینت تجمیعی پرسنل
|
||||
/// </summary>
|
||||
public class PrintAllEmployeesInfoDtoClient
|
||||
{
|
||||
public PrintAllEmployeesInfoDtoClient(EmployeeListDto source)
|
||||
{
|
||||
Id = source.Id;
|
||||
EmployeeFullName = source.EmployeeFullName;
|
||||
PersonnelCode = source.PersonnelCode;
|
||||
MaritalStatus = source.MaritalStatus;
|
||||
NationalCode = source.NationalCode;
|
||||
IdNumber = source.IdNumber;
|
||||
DateOfBirth = source.DateOfBirth;
|
||||
FatherName = source.FatherName;
|
||||
NumberOfChildren = source.NumberOfChildren;
|
||||
LatestContractStartDate = source.LatestContractStartDate;
|
||||
ContractLeftDate = source.ContractLeftDate;
|
||||
LatestInsuranceStartDate = source.LatestInsuranceStartDate;
|
||||
InsuranceLeftDate = source.InsuranceLeftDate;
|
||||
EmployeeStatusInWorkshop = source.EmployeeStatusInWorkshop;
|
||||
}
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کامل پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeFullName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// کد پرسنلی
|
||||
/// </summary>
|
||||
public int PersonnelCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت تاهل
|
||||
/// </summary>
|
||||
public string MaritalStatus { 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 LatestContractStartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ترک کار قرارداد
|
||||
/// </summary>
|
||||
public string ContractLeftDate { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آخرین تاریخ شروع بکار بیمه
|
||||
/// </summary>
|
||||
public string LatestInsuranceStartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ترک کار بیمه
|
||||
/// </summary>
|
||||
public string InsuranceLeftDate { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت پرسنل در کارگاه
|
||||
/// </summary>
|
||||
public EmployeeStatusInWorkshop EmployeeStatusInWorkshop { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
|
||||
@@ -73,6 +75,7 @@ public interface IEmployeeApplication
|
||||
long workshopId);
|
||||
Task<OperationResult> EditEmployeeInEmployeeDocumentWorkFlow(EditEmployeeInEmployeeDocument command);
|
||||
|
||||
[Obsolete("این متد منسوخ شده است و از متد WorkedEmployeesInWorkshopSelectList استفاده کنید")]
|
||||
Task<List<EmployeeSelectListViewModel>> WorkedEmployeesInWorkshopSelectList(long workshopId);
|
||||
|
||||
Task<OperationResult<EmployeeDataFromApiViewModel>> GetEmployeeDataFromApi(string nationalCode, string birthDate);
|
||||
@@ -103,8 +106,26 @@ public interface IEmployeeApplication
|
||||
/// <returns></returns>
|
||||
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پرسنل کلاینت
|
||||
/// api
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// پرینت تجمیعی پرسنل کلاینت
|
||||
/// api
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
|
||||
#endregion
|
||||
|
||||
Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId);
|
||||
}
|
||||
|
||||
public class GetClientEmployeeListSearchModel
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
public class CheckIsInvalidLeaveDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آیا تعطیل است
|
||||
/// </summary>
|
||||
public bool IsHoliday { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// فاقد/دارای اعتبار فیش غیر رسمی
|
||||
/// </summary>
|
||||
public bool CanCreateInvalid { get; set; }
|
||||
|
||||
}
|
||||
78
CompanyManagment.App.Contracts/Leave/CreateLeaveDto.cs
Normal file
78
CompanyManagment.App.Contracts/Leave/CreateLeaveDto.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
public class CreateLeaveDto
|
||||
{
|
||||
/// <summary>
|
||||
/// تاریخ شروع مرخصی
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "این مقدار نمی تواند خالی باشد")]
|
||||
public string StartLeave { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان مرخصی
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "این مقدار نمی تواند خالی باشد")]
|
||||
public string EndLeave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی کارگاه
|
||||
/// </summary>
|
||||
public long WorkshopId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نوع مدت مرخص روزانه/ ساعتی
|
||||
/// </summary>
|
||||
public PaidLeaveType PaidLeaveType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نوع مرخصی استحقاقی/استعلاجی
|
||||
/// </summary>
|
||||
public LeaveType LeaveType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کامل کارگاه
|
||||
/// </summary>
|
||||
public string WorkshopName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ساعت شروع مرخصی
|
||||
/// </summary>
|
||||
public string StartHoures { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ساعت پایان مرخصی
|
||||
/// </summary>
|
||||
public string EndHours { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// موافقت / عدم موافقت کارفرما
|
||||
/// </summary>
|
||||
public bool IsAccepted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// توضیحات
|
||||
/// </summary>
|
||||
public string Decription { get; set; }
|
||||
|
||||
|
||||
public List<CustomizeRotatingShiftsViewModel> RotatingShifts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// دارای اعتبار / فاقد اعتبار فیش غیررسمی
|
||||
/// </summary>
|
||||
public bool IsInvallid { get; set; }
|
||||
public CustomizeRotatingShiftsViewModel SelectedShift { get; set; }
|
||||
|
||||
}
|
||||
88
CompanyManagment.App.Contracts/Leave/GroupLeaveListDto.cs
Normal file
88
CompanyManagment.App.Contracts/Leave/GroupLeaveListDto.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
public class GroupLeaveListDto
|
||||
{
|
||||
/// <summary>
|
||||
/// سال مرخصی
|
||||
/// </summary>
|
||||
public string YearStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ماه مرخصی
|
||||
/// </summary>
|
||||
public string MonthStr { get; set; }
|
||||
/// <summary>
|
||||
/// آیتم های هر گروه
|
||||
/// </summary>
|
||||
public List<LeaveListItemsDto> LeaveListItemsDto { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// آیتم های هر گروه
|
||||
/// </summary>
|
||||
public class LeaveListItemsDto
|
||||
{
|
||||
/// <summary>
|
||||
/// نوع مرخصی، استحقاقی/استعلاجی
|
||||
/// </summary>
|
||||
public string LeaveType { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ شروع مرخصی
|
||||
/// </summary>
|
||||
public string StartLeave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان مرخصی
|
||||
/// </summary>
|
||||
public string EndLeave { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// زمان مرخصی
|
||||
/// بازه مرخصی ساعتی
|
||||
/// </summary>
|
||||
public string HourlyInterval { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مدت مرخصی
|
||||
/// </summary>
|
||||
public string LeaveDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// موافقت/عدم موافقت کارفرما
|
||||
/// </summary>
|
||||
public bool IsAccepted { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آی دی
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آی دی گارگاه
|
||||
/// </summary>
|
||||
public long WorkshopId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///آیا فاقد اعتبار است. فاقد اعتبار ها فقط برای فیش های غیررسمی مورد استفاده قرار میگیرند
|
||||
/// </summary>
|
||||
public bool IsInvalid { get; set; }
|
||||
}
|
||||
@@ -19,6 +19,7 @@ public interface ILeaveApplication
|
||||
GroupLeavePrintViewModel PrintPersonnelLeaveList(List<long> id);
|
||||
|
||||
OperationResult RemoveLeave(long id);
|
||||
Task<OperationResult> RemoveLeaveAsync(long id);
|
||||
LeaveViewModel LeavOnChekout(DateTime starContract, DateTime endContract, long employeeId, long workshopId);
|
||||
List<LeaveMainViewModel> searchClient(LeaveSearchModel search);
|
||||
|
||||
@@ -36,5 +37,117 @@ public interface ILeaveApplication
|
||||
TimeSpan GetEmployeeLeaveTimeSpanInDates(long workshopId, long employeeId, string startFa, string endFa,
|
||||
string type);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست مرخصی ها در کلاینت
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedResult<leaveListDto>> GetList(
|
||||
LeaveListSearchModel searchModel);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست گروه بندی شده
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<GroupLeaveListDto>> GetGroupList(LeaveListSearchModel searchModel);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت مجکوع مرخصی پرسنل
|
||||
/// اگر آی دی پرسنل، سال و ماه خالی نباشد
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <param name="yearStr"></param>
|
||||
/// <param name="monthStr"></param>
|
||||
/// <param name="leaveType"></param>
|
||||
/// <returns></returns>
|
||||
TimeSpan SumOfEmployeeLeaveTimeSpanInDates(long workshopId, long employeeId, string yearStr, string monthStr,
|
||||
LeaveType leaveType);
|
||||
|
||||
Task<List<LeavePrintResponseViewModel>> PrintAllAsync(List<long> ids, long workshopId);
|
||||
Task<LeavePrintResponseViewModel> PrintOneAsync(long id, long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// چک میکند که تاریخ وارد شده در شروع مرخصی تعطیل است یا خیر
|
||||
/// دارای/فاقد اعتبار فیش غیررسمی را چک میکند
|
||||
/// </summary>
|
||||
/// <param name="startLeaveDate"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult<CheckIsInvalidLeaveDto>> CheckIsInvalidLeave(string startLeaveDate, long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد مرخصی از ای پی آی
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> CreateLeave(CreateLeaveDto command);
|
||||
|
||||
/// <summary>
|
||||
/// چک میکند که آیا پرسنل حضور غیاب دارای شیفت گردشی دارد یا خیر
|
||||
/// اگر داشت دریافت شیف گردشی
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <param name="startLeaveDate"></param>
|
||||
/// <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);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// محاسبه مدت مرخصی ساعتی
|
||||
/// </summary>
|
||||
/// <param name="startHours"></param>
|
||||
/// <param name="endHours"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetHourlyLeaveDuration(string startHours, string endHours);
|
||||
|
||||
/// <summary>
|
||||
/// محاسبه مدت مرخصی روزانه
|
||||
/// </summary>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetDailyLeaveDuration(string startDate, string endDate);
|
||||
|
||||
}
|
||||
|
||||
public class LeavePrintResponseViewModel
|
||||
{
|
||||
public string FullName { get; set; }
|
||||
public string NationalCode { get; set; }
|
||||
public string WorkshopName { get; set; }
|
||||
public List<string> EmployerNames { get; set; }
|
||||
public string PaidLeaveType { get; set; }
|
||||
public string ContractNo { get; set; }
|
||||
public LeavePrintHourlyResponseViewModel HourlyLeave { get; set; }
|
||||
public LeavePrintDailyResponseViewModel DailyLeave { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class LeavePrintDailyResponseViewModel
|
||||
{
|
||||
public string StartLeave { get; set; }
|
||||
public string EndLeave { get; set; }
|
||||
public string TotalDay { get; set; }
|
||||
}
|
||||
|
||||
public class LeavePrintHourlyResponseViewModel
|
||||
{
|
||||
public string LeaveDate { get; set; }
|
||||
public string StartHour { get; set; }
|
||||
public string EndHour { get; set; }
|
||||
public string TotalHour { get; set; }
|
||||
}
|
||||
24
CompanyManagment.App.Contracts/Leave/LeaveListMultipleDto.cs
Normal file
24
CompanyManagment.App.Contracts/Leave/LeaveListMultipleDto.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using _0_Framework.Application;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
public class LeaveListMultipleDto
|
||||
{
|
||||
/// <summary>
|
||||
/// لیست گروهبندی شده بر اساس سال و ماه
|
||||
/// اگر در جستجو پرسنل انتخاب شود
|
||||
/// </summary>
|
||||
public List<GroupLeaveListDto>? GroupLeaveListDto { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// لیست نرمال PageResult
|
||||
/// </summary>
|
||||
public PagedResult<leaveListDto>? leaveListDto { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مجموع مرخصی پرسنل
|
||||
/// اگر پرسنل انتخاب شده باشد
|
||||
/// </summary>
|
||||
public string? SumOfEmployeeleaves { get; set; }
|
||||
}
|
||||
77
CompanyManagment.App.Contracts/Leave/LeaveListPrintDto.cs
Normal file
77
CompanyManagment.App.Contracts/Leave/LeaveListPrintDto.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
/// <summary>
|
||||
/// پرینت لیستی
|
||||
/// api
|
||||
/// </summary>
|
||||
public class LeaveListPrintDto
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// نام کامل پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeFullName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مجموع مرخصی پرسنل
|
||||
/// </summary>
|
||||
public string? SumOfEmployeeleaves { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// لیست مرخصی
|
||||
/// </summary>
|
||||
public List<LeavePrintListItemsDto> LeavePrintListItemsDto { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class LeavePrintListItemsDto
|
||||
{
|
||||
/// <summary>
|
||||
/// سال مرخصی
|
||||
/// </summary>
|
||||
public string YearStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ماه مرخصی
|
||||
/// </summary>
|
||||
public string MonthStr { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// نوع مرخصی، استحقاقی/استعلاجی
|
||||
/// </summary>
|
||||
public string LeaveType { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ شروع مرخصی
|
||||
/// </summary>
|
||||
public string StartLeave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان مرخصی
|
||||
/// </summary>
|
||||
public string EndLeave { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// زمان مرخصی
|
||||
/// بازه مرخصی ساعتی
|
||||
/// </summary>
|
||||
public string HourlyInterval { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مدت مرخصی
|
||||
/// </summary>
|
||||
public string LeaveDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// موافقت/عدم موافقت کارفرما
|
||||
/// </summary>
|
||||
public bool IsAccepted { get; set; }
|
||||
|
||||
}
|
||||
45
CompanyManagment.App.Contracts/Leave/LeaveListSearchModel.cs
Normal file
45
CompanyManagment.App.Contracts/Leave/LeaveListSearchModel.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
public class LeaveListSearchModel : PaginationRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی کارگاه
|
||||
/// </summary>
|
||||
public long WorkshopId { get; set; }
|
||||
/// <summary>
|
||||
/// نوع مرخصی، استحقاقی/استعلاجی
|
||||
/// </summary>
|
||||
public LeaveType LeaveType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سال مرخصی
|
||||
/// </summary>
|
||||
public string YearStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ماه مرخصی
|
||||
/// </summary>
|
||||
public string MonthStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///آیا فاقد اعتبار است. فاقد اعتبار ها فقط برای فیش های غیررسمی مورد استفاده قرار میگیرند
|
||||
/// </summary>
|
||||
public bool IsInvalid { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ شروع مرخصی
|
||||
/// </summary>
|
||||
public string StartLeave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان مرخصی
|
||||
/// </summary>
|
||||
public string EndLeave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long EmployeeId { get; set; }
|
||||
}
|
||||
18
CompanyManagment.App.Contracts/Leave/LeaveType.cs
Normal file
18
CompanyManagment.App.Contracts/Leave/LeaveType.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
public enum LeaveType
|
||||
{
|
||||
/// <summary>
|
||||
/// هر دو
|
||||
/// </summary>
|
||||
Both,
|
||||
/// <summary>
|
||||
/// مرخصی استعلاجی
|
||||
/// </summary>
|
||||
SickLeave,
|
||||
|
||||
/// <summary>
|
||||
/// مرخصی استحقاقی
|
||||
/// </summary>
|
||||
PaidLeave
|
||||
}
|
||||
17
CompanyManagment.App.Contracts/Leave/PaidLeaveType.cs
Normal file
17
CompanyManagment.App.Contracts/Leave/PaidLeaveType.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
/// <summary>
|
||||
/// نوع مدت مرخصی
|
||||
/// </summary>
|
||||
public enum PaidLeaveType
|
||||
{
|
||||
/// <summary>
|
||||
/// روزانه
|
||||
/// </summary>
|
||||
Daily,
|
||||
|
||||
/// <summary>
|
||||
/// ساعتی
|
||||
/// </summary>
|
||||
Hourly,
|
||||
}
|
||||
17
CompanyManagment.App.Contracts/Leave/RotatingShiftDto.cs
Normal file
17
CompanyManagment.App.Contracts/Leave/RotatingShiftDto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
public class RotatingShiftDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آیا حضورغیاب به همراه گروهبندی گردشی دارد
|
||||
/// </summary>
|
||||
public bool HasRollCall {get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// لیست شیفت های گردشی پرسنل
|
||||
/// </summary>
|
||||
public List<CustomizeRotatingShiftsViewModel> RotatingShifts { get; set; }
|
||||
}
|
||||
84
CompanyManagment.App.Contracts/Leave/leaveListDto.cs
Normal file
84
CompanyManagment.App.Contracts/Leave/leaveListDto.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
namespace CompanyManagment.App.Contracts.Leave;
|
||||
|
||||
public class leaveListDto
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// نام کامل پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeFullName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// سال مرخصی
|
||||
/// </summary>
|
||||
public string YearStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ماه مرخصی
|
||||
/// </summary>
|
||||
public string MonthStr { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// نوع مرخصی، استحقاقی/استعلاجی
|
||||
/// </summary>
|
||||
public string LeaveType { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ شروع مرخصی
|
||||
/// </summary>
|
||||
public string StartLeave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان مرخصی
|
||||
/// </summary>
|
||||
public string EndLeave { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// زمان مرخصی
|
||||
/// بازه مرخصی ساعتی
|
||||
/// </summary>
|
||||
public string HourlyInterval { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مدت مرخصی
|
||||
/// </summary>
|
||||
public string LeaveDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// موافقت/عدم موافقت کارفرما
|
||||
/// </summary>
|
||||
public bool IsAccepted { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آی دی
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آی دی گارگاه
|
||||
/// </summary>
|
||||
public long WorkshopId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///آیا فاقد اعتبار است. فاقد اعتبار ها فقط برای فیش های غیررسمی مورد استفاده قرار میگیرند
|
||||
/// </summary>
|
||||
public bool IsInvalid { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Workshop;
|
||||
|
||||
@@ -92,6 +93,8 @@ public interface IWorkshopApplication
|
||||
#endregion
|
||||
|
||||
Task<ActionResult<OperationResult>> CreateWorkshopWorkflowRegistration(CreateWorkshopWorkflowRegistration command);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class CreateWorkshopWorkflowRegistration
|
||||
|
||||
@@ -1734,5 +1734,20 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
return await _EmployeeRepository.GetClientEmployeeList(searchModel, workshopId);
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.ListOfAllEmployeesClient(searchModel, workshopId);
|
||||
}
|
||||
|
||||
public async Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.PrintAllEmployeesInfoClient(workshopId);
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.GetWorkingEmployeesSelectList(workshopId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,17 +1,25 @@
|
||||
using System;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using Company.Domain.HolidayItemAgg;
|
||||
using Company.Domain.LeaveAgg;
|
||||
using Company.Domain.RollCallAgg;
|
||||
using Company.Domain.RollCallServiceAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||
using CompanyManagment.App.Contracts.HolidayItem;
|
||||
using CompanyManagment.App.Contracts.Leave;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
|
||||
using CompanyManagment.App.Contracts.RollCallService;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using Company.Domain.LeaveAgg;
|
||||
using Company.Domain.RollCallAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.Leave;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -23,9 +31,12 @@ public class LeaveApplication : ILeaveApplication
|
||||
private readonly IRollCallRepository _rollCallRepository;
|
||||
private readonly ICustomizeWorkshopEmployeeSettingsRepository _employeeSettingsRepository;
|
||||
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
|
||||
private readonly IHolidayItemRepository _holidayItemRepository;
|
||||
private readonly IRollCallServiceRepository _rollCallServiceRepository;
|
||||
|
||||
|
||||
|
||||
public LeaveApplication(ILeaveRepository leaveRepository, IEmployeeRepository employeeRepository, IWorkshopRepository workshopRepository, IRollCallRepository rollCallRepository, ICustomizeWorkshopEmployeeSettingsRepository employeeSettingsRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication)
|
||||
public LeaveApplication(ILeaveRepository leaveRepository, IEmployeeRepository employeeRepository, IWorkshopRepository workshopRepository, IRollCallRepository rollCallRepository, ICustomizeWorkshopEmployeeSettingsRepository employeeSettingsRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IHolidayItemRepository holidayItemRepository, IRollCallServiceRepository rollCallServiceRepository)
|
||||
{
|
||||
_leaveRepository = leaveRepository;
|
||||
_employeeRepository = employeeRepository;
|
||||
@@ -33,6 +44,8 @@ public class LeaveApplication : ILeaveApplication
|
||||
_rollCallRepository = rollCallRepository;
|
||||
_employeeSettingsRepository = employeeSettingsRepository;
|
||||
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
|
||||
_holidayItemRepository = holidayItemRepository;
|
||||
_rollCallServiceRepository = rollCallServiceRepository;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateLeave command)
|
||||
@@ -237,7 +250,7 @@ public class LeaveApplication : ILeaveApplication
|
||||
|
||||
var employeeFullName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
|
||||
var workshopName = _workshopRepository.GetDetails(command.WorkshopId).WorkshopName;
|
||||
var leave = new Leave(start, end, totalhourses, command.WorkshopId, command.EmployeeId
|
||||
var leave = new Company.Domain.LeaveAgg.Leave(start, end, totalhourses, command.WorkshopId, command.EmployeeId
|
||||
, command.PaidLeaveType, command.LeaveType, employeeFullName, workshopName, command.IsAccepted, command.Decription,
|
||||
year, month, shiftDuration, hasShiftDuration,command.IsInvallid);
|
||||
_leaveRepository.Create(leave);
|
||||
@@ -509,7 +522,12 @@ public class LeaveApplication : ILeaveApplication
|
||||
|
||||
public OperationResult RemoveLeave(long id)
|
||||
{
|
||||
return _leaveRepository.RemoveLeave(id);
|
||||
return _leaveRepository.RemoveLeave(id).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public async Task<OperationResult> RemoveLeaveAsync(long id)
|
||||
{
|
||||
return await _leaveRepository.RemoveLeave(id);
|
||||
}
|
||||
|
||||
public LeaveViewModel LeavOnChekout(DateTime starContract, DateTime endContract, long employeeId, long workshopId)
|
||||
@@ -590,11 +608,435 @@ public class LeaveApplication : ILeaveApplication
|
||||
return leaveTotalTimeSpan;
|
||||
}
|
||||
|
||||
private TimeSpan CalculateTotalLeaveTimeSpan(List<LeavePrintViewModel> leaves)
|
||||
|
||||
|
||||
private TimeSpan CalculateTotalLeaveTimeSpan(List<LeavePrintViewModel> leaves)
|
||||
{
|
||||
var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType != "روزانه").Sum(x => (x.EndLeaveGr - x.StartLeaveGr).Ticks));
|
||||
var dailyLeaveCount = leaves.Count(x => x.PaidLeaveType == "روزانه") * new TimeSpan(1, 0, 0, 0);
|
||||
return timeSpanHourlyLeave + dailyLeaveCount;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<PagedResult<leaveListDto>> GetList(LeaveListSearchModel searchModel)
|
||||
{
|
||||
return await _leaveRepository.GetList(searchModel);
|
||||
}
|
||||
|
||||
public async Task<List<GroupLeaveListDto>> GetGroupList(LeaveListSearchModel searchModel)
|
||||
{
|
||||
return await _leaveRepository.GetGroupList(searchModel);
|
||||
}
|
||||
|
||||
public TimeSpan SumOfEmployeeLeaveTimeSpanInDates(long workshopId, long employeeId, string yearStr, string monthStr, LeaveType leaveType)
|
||||
{
|
||||
|
||||
|
||||
var startFa = $"{yearStr}/{monthStr:00}/01";
|
||||
var endFa = startFa.FindeEndOfMonth();
|
||||
|
||||
if (startFa.TryToGeorgianDateTime(out var start) == false || endFa.TryToGeorgianDateTime(out var end) == false)
|
||||
return TimeSpan.Zero;
|
||||
|
||||
var leaveTotalTimeSpan = TimeSpan.Zero;
|
||||
|
||||
var leaves = _leaveRepository.GetByWorkshopIdEmployeeIdInDates(workshopId, employeeId, start, end);
|
||||
//var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType != "روزانه").Sum(x => (x.EndLeaveGr - x.StartLeaveGr).Ticks));
|
||||
//var dailyLeaveCount = leaves.Count(x => x.PaidLeaveType == "روزانه") * new TimeSpan(1, 0, 0, 0);
|
||||
|
||||
if (leaveType == LeaveType.PaidLeave)
|
||||
{
|
||||
var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType == "ساعتی" && x.LeaveType == "استحقاقی")
|
||||
.Sum(x => TimeOnly.Parse(x.LeaveHourses).Ticks));
|
||||
var dailyLeaveTime = leaves.Where(x => x.PaidLeaveType == "روزانه" && x.LeaveType == "استحقاقی")
|
||||
.Sum(x => Convert.ToInt32(x.LeaveHourses)) * TimeSpan.FromDays(1);
|
||||
|
||||
leaveTotalTimeSpan = timeSpanHourlyLeave + dailyLeaveTime;
|
||||
}
|
||||
else if (leaveType == LeaveType.SickLeave)
|
||||
{
|
||||
var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType == "ساعتی" && x.LeaveType == "استعلاجی")
|
||||
.Sum(x => TimeOnly.Parse(x.LeaveHourses).Ticks));
|
||||
|
||||
var dailyLeaveTime = leaves.Where(x => x.PaidLeaveType == "روزانه" && x.LeaveType == "استعلاجی")
|
||||
.Sum(x => Convert.ToInt32(x.LeaveHourses)) * TimeSpan.FromDays(1);
|
||||
|
||||
leaveTotalTimeSpan = timeSpanHourlyLeave + dailyLeaveTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
var timeSpanHourlyLeave = new TimeSpan(leaves.Where(x => x.PaidLeaveType == "ساعتی").Sum(x => TimeOnly.Parse(x.LeaveHourses).Ticks));
|
||||
var dailyLeaveTime = leaves.Where(x => x.PaidLeaveType == "روزانه").Sum(x => Convert.ToInt32(x.LeaveHourses)) * TimeSpan.FromDays(1);
|
||||
leaveTotalTimeSpan = timeSpanHourlyLeave + dailyLeaveTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return leaveTotalTimeSpan;
|
||||
}
|
||||
|
||||
public async Task<List<LeavePrintResponseViewModel>> PrintAllAsync(List<long> ids,long workshopId)
|
||||
{
|
||||
return await _leaveRepository.PrintAllAsync(ids,workshopId);
|
||||
}
|
||||
|
||||
public async Task<LeavePrintResponseViewModel> PrintOneAsync(long id, long workshopId)
|
||||
{
|
||||
return (await _leaveRepository.PrintAllAsync([id],workshopId)).FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult<CheckIsInvalidLeaveDto>> CheckIsInvalidLeave(string startLeaveDate, long workshopId)
|
||||
{
|
||||
var op = new OperationResult<CheckIsInvalidLeaveDto>();
|
||||
var result = new CheckIsInvalidLeaveDto();
|
||||
if (startLeaveDate.TryToGeorgianDateTime(out var startLeaveDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ وارد شده صحیح نیست");
|
||||
}
|
||||
|
||||
if (startLeaveDateGr.DayOfWeek == DayOfWeek.Friday || _holidayItemRepository.GetHoliday(startLeaveDateGr))
|
||||
{
|
||||
result.IsHoliday = true;
|
||||
}
|
||||
|
||||
if (result.IsHoliday)
|
||||
{
|
||||
var rollCallService = _rollCallServiceRepository.GetActiveServiceByWorkshopId(workshopId);
|
||||
if (rollCallService != null)
|
||||
{
|
||||
result.CanCreateInvalid = rollCallService.HasCustomizeCheckoutService == "true";
|
||||
}
|
||||
}
|
||||
|
||||
return op.Succcedded(result);
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult> CreateLeave(CreateLeaveDto command)
|
||||
{
|
||||
TimeSpan shiftDuration = TimeSpan.Zero;
|
||||
bool hasShiftDuration = false;
|
||||
var startH = new TimeSpan();
|
||||
var endH = new TimeSpan();
|
||||
var op = new OperationResult();
|
||||
if ((command.PaidLeaveType == PaidLeaveType.Daily && command.LeaveType == LeaveType.PaidLeave) || command.LeaveType == LeaveType.SickLeave)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(command.StartLeave))
|
||||
{
|
||||
return op.Failed("لطفا تاریخ شروع را وارد کنید");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(command.EndLeave))
|
||||
{
|
||||
return op.Failed("لطفا تاریخ پایان را وارد کنید");
|
||||
}
|
||||
}
|
||||
else if (command.PaidLeaveType == PaidLeaveType.Hourly)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(command.StartLeave))
|
||||
return op.Failed("لطفا تاریخ شروع را وارد کنید");
|
||||
if (string.IsNullOrWhiteSpace(command.StartHoures) || string.IsNullOrWhiteSpace(command.EndHours))
|
||||
return op.Failed("ساعت شروع و پایان نمیتواند خالی باشد");
|
||||
|
||||
string pattern = @"^([01]\d|2[0-3]):[0-5]\d$";
|
||||
|
||||
if (!Regex.IsMatch(command.StartHoures, pattern))
|
||||
return op.Failed("لطفا ساعت شروع را به درستی وارد کنید");
|
||||
|
||||
if (!Regex.IsMatch(command.EndHours, pattern))
|
||||
return op.Failed("لطفا ساعت پایان را به درستی وارد کنید");
|
||||
|
||||
startH = TimeSpan.Parse(command.StartHoures);
|
||||
endH = TimeSpan.Parse(command.EndHours);
|
||||
if (startH == endH)
|
||||
return op.Failed("ساعت شروع و پایان نباید برابر باشد");
|
||||
}
|
||||
|
||||
|
||||
//if (command.LeaveType == LeaveType.SickLeave && string.IsNullOrWhiteSpace(command.StartLeave))
|
||||
// return op.Failed("لطفا تاریخ شروع را وارد کنید");
|
||||
//if (command.LeaveType == LeaveType.SickLeave && string.IsNullOrWhiteSpace(command.EndLeave))
|
||||
// return op.Failed("لطفا تاریخ پایان را وارد کنید");
|
||||
|
||||
|
||||
if (command.StartLeave.TryToGeorgianDateTime(out var start) == false)
|
||||
{
|
||||
return op.Failed("تاریخ شروع صحیح نیست");
|
||||
}
|
||||
|
||||
var end = new DateTime();
|
||||
if (command.PaidLeaveType == PaidLeaveType.Daily)
|
||||
{
|
||||
if (command.EndLeave.TryToGeorgianDateTime(out end) == false)
|
||||
{
|
||||
return op.Failed("تاریخ پایان صحیح نیست");
|
||||
}
|
||||
}
|
||||
end = start;
|
||||
|
||||
|
||||
var checkErr = _leaveRepository.CheckErrors(start, end, command.EmployeeId, command.WorkshopId, command.IsInvallid);
|
||||
|
||||
|
||||
if (checkErr.HasChekout)
|
||||
return op.Failed(checkErr.CheckoutErrMessage);
|
||||
if (checkErr.HasNotContract)
|
||||
return op.Failed(checkErr.ContractErrMessage);
|
||||
if (checkErr.HasLeftWork)
|
||||
return op.Failed(checkErr.LeftWorlErrMessage);
|
||||
|
||||
if (start > end)
|
||||
return op.Failed("تارخ شروع از پایان بزرگتر است");
|
||||
|
||||
|
||||
var totalhourses = "-";
|
||||
if (command.LeaveType == LeaveType.PaidLeave && command.PaidLeaveType == PaidLeaveType.Hourly)
|
||||
{
|
||||
|
||||
start = new DateTime(start.Year, start.Month, start.Day, startH.Hours, startH.Minutes, startH.Seconds);
|
||||
end = new DateTime(start.Year, start.Month, start.Day, endH.Hours, endH.Minutes, endH.Seconds);
|
||||
if (start > end)
|
||||
end = end.AddDays(1);
|
||||
|
||||
var totalLeavHourses = (end - start);
|
||||
var h = totalLeavHourses.Hours < 10 ? $"0{totalLeavHourses.Hours}" : $"{totalLeavHourses.Hours}";
|
||||
var m = totalLeavHourses.Minutes < 10 ? $"0{totalLeavHourses.Minutes}" : $"{totalLeavHourses.Minutes}";
|
||||
totalhourses = $"{h}:{m}";
|
||||
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("برای ساعت شروع سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("برای ساعت پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
|
||||
var end24 = endH.Hours == 0 && endH.Minutes == 0 ? end.AddDays(-1) : end;
|
||||
if (_leaveRepository.Exists(x =>
|
||||
(x.StartLeave.Date == start.Date || x.EndLeave.Date == end24.Date) && (x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه")))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
}
|
||||
else if (command.LeaveType == LeaveType.PaidLeave && command.PaidLeaveType == PaidLeaveType.Daily)
|
||||
{
|
||||
var totalLeavHourses = (end - start).TotalDays + 1;
|
||||
totalhourses = $"{(int)totalLeavHourses}";
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
|
||||
|
||||
var employeeSettings = _employeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(command.WorkshopId, command.EmployeeId);
|
||||
|
||||
var isActive = _rollCallEmployeeStatusApplication.IsActiveInPeriod(command.EmployeeId, command.WorkshopId, start, end);
|
||||
var hasRollCall = isActive && employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Rotating;
|
||||
if (hasRollCall)
|
||||
{
|
||||
|
||||
if ((end - start).TotalDays > 1 && employeeSettings.WorkshopShiftStatus != WorkshopShiftStatus.Regular)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید بیشتر از یک روز مرخصی روزانه ثبت کنید");
|
||||
}
|
||||
|
||||
if (employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Rotating &&
|
||||
command.SelectedShift == null)
|
||||
{
|
||||
return op.Failed("لطفا شیفت پرسنل را انتخاب کنید");
|
||||
}
|
||||
|
||||
if (command.SelectedShift != null)
|
||||
{
|
||||
var validShiftStart = TimeOnly.TryParse(command.SelectedShift.StartTime, out var shiftStart);
|
||||
var validShiftEnd = TimeOnly.TryParse(command.SelectedShift.EndTime, out var shiftEnd);
|
||||
|
||||
if (validShiftStart == false && validShiftEnd == false)
|
||||
{
|
||||
return op.Failed("شیفت های انتخاب شده معتبر نمیباشد");
|
||||
}
|
||||
|
||||
var shiftStartDateTime = new DateTime(new DateOnly(), shiftStart);
|
||||
var shiftEndDateTime = new DateTime(new DateOnly(), shiftEnd);
|
||||
if (shiftEndDateTime <= shiftStartDateTime)
|
||||
shiftEndDateTime = shiftEndDateTime.AddDays(1);
|
||||
shiftDuration = shiftEndDateTime - shiftStartDateTime;
|
||||
hasShiftDuration = true;
|
||||
}
|
||||
else if (employeeSettings is { WorkshopShiftStatus: WorkshopShiftStatus.Irregular })
|
||||
{
|
||||
if ((end - start).TotalDays > 1)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید بیشتر از یک روز مرخصی روزانه ثبت کنید");
|
||||
}
|
||||
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
shiftDuration = employeeSettings.IrregularShift.WorkshopIrregularShifts switch
|
||||
{
|
||||
WorkshopIrregularShifts.TwelveThirtySix => TimeSpan.FromHours(12),
|
||||
WorkshopIrregularShifts.TwelveTwentyFour => TimeSpan.FromHours(12),
|
||||
WorkshopIrregularShifts.TwentyFourFortyEight => TimeSpan.FromHours(24),
|
||||
WorkshopIrregularShifts.TwentyFourTwentyFour => TimeSpan.FromHours(24),
|
||||
_ => new TimeSpan()
|
||||
};
|
||||
hasShiftDuration = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (command.LeaveType == LeaveType.SickLeave)
|
||||
{
|
||||
var totalLeavHourses = (end - start).TotalDays + 1;
|
||||
totalhourses = $"{(int)totalLeavHourses}";
|
||||
command.PaidLeaveType = PaidLeaveType.Daily;
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
|
||||
return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
|
||||
if (_leaveRepository.Exists(x =>
|
||||
x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
|
||||
return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
|
||||
}
|
||||
var year = Convert.ToInt32(command.StartLeave.Substring(0, 4));
|
||||
var month = Convert.ToInt32(command.StartLeave.Substring(5, 2));
|
||||
var paidLeaveType = command.PaidLeaveType == PaidLeaveType.Daily ? "روزانه" : "ساعتی";
|
||||
var leaveType = command.LeaveType == LeaveType.PaidLeave ? "استحقاقی" : "استعلاجی";
|
||||
var validation = ValidateNewLeaveWithExistingRollCalls(command.WorkshopId, command.EmployeeId, paidLeaveType, start, end);
|
||||
if (validation.IsSuccedded == false)
|
||||
return validation;
|
||||
|
||||
var employeeFullName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
|
||||
var workshopName = _workshopRepository.GetDetails(command.WorkshopId).WorkshopName;
|
||||
var leave = new Company.Domain.LeaveAgg.Leave(start, end, totalhourses, command.WorkshopId, command.EmployeeId
|
||||
, paidLeaveType, leaveType, employeeFullName, workshopName, command.IsAccepted, command.Decription,
|
||||
year, month, shiftDuration, hasShiftDuration, command.IsInvallid);
|
||||
await _leaveRepository.CreateAsync(leave);
|
||||
await _leaveRepository.SaveChangesAsync();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult<RotatingShiftDto>> HasRotatingShift(long workshopId,long employeeId, string startLeaveDate)
|
||||
{
|
||||
var op = new OperationResult<RotatingShiftDto>();
|
||||
var result = new RotatingShiftDto();
|
||||
if (startLeaveDate.TryToGeorgianDateTime(out var startDateTimeGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ شروع صحیح نیست");
|
||||
}
|
||||
var employeeSettings = _employeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(workshopId, employeeId);
|
||||
//اگر گروه بندی نداشت
|
||||
if (employeeSettings == null)
|
||||
{
|
||||
return op.Succcedded(result);
|
||||
}
|
||||
|
||||
var isActive = _rollCallEmployeeStatusApplication.IsActiveInPeriod(employeeId, workshopId, startDateTimeGr, startDateTimeGr);
|
||||
|
||||
result.HasRollCall = isActive && employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Rotating;
|
||||
result.RotatingShifts = employeeSettings.CustomizeRotatingShifts.Select(x =>
|
||||
new CustomizeRotatingShiftsViewModel()
|
||||
{
|
||||
EndTime = x.EndTime.ToString("HH:mm"),
|
||||
StartTime = x.StartTime.ToString("HH:mm")
|
||||
}).ToList();
|
||||
return op.Succcedded(result);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public async Task<LeaveListPrintDto> ListPrint(List<long> ids)
|
||||
{
|
||||
return await _leaveRepository.ListPrint(ids);
|
||||
}
|
||||
|
||||
|
||||
public async Task<string> GetHourlyLeaveDuration(string startHours, string endHours)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(startHours) || string.IsNullOrWhiteSpace(endHours))
|
||||
return "";
|
||||
|
||||
var start = new DateTime();
|
||||
var end = new DateTime();
|
||||
try
|
||||
{
|
||||
|
||||
start = Convert.ToDateTime(startHours);
|
||||
end = Convert.ToDateTime(endHours);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
return "";
|
||||
}
|
||||
if (start > end || start == end)
|
||||
{
|
||||
end = end.AddDays(1);
|
||||
}
|
||||
|
||||
var HourlyDate = (end - start);
|
||||
var hours = (int)HourlyDate.TotalHours;
|
||||
var minutes = HourlyDate.TotalMinutes % 60;
|
||||
|
||||
if (hours > 0 && minutes > 0)
|
||||
{
|
||||
return (hours + " " + "ساعت و" + " " + minutes + " " + "دقیقه");
|
||||
}
|
||||
else if (hours > 0 && minutes == 0)
|
||||
{
|
||||
return (hours + " " + "ساعت ");
|
||||
|
||||
}
|
||||
else if (hours == 0 && minutes > 0)
|
||||
{
|
||||
return (minutes + " " + "دقیقه");
|
||||
|
||||
}
|
||||
|
||||
return ($"{hours}");
|
||||
|
||||
}
|
||||
|
||||
public async Task<string> GetDailyLeaveDuration(string startDate, string endDate)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(startDate) || string.IsNullOrWhiteSpace(endDate))
|
||||
return "";
|
||||
|
||||
if (startDate.TryToGeorgianDateTime(out var start) == false || endDate.TryToGeorgianDateTime(out var end) == false)
|
||||
return "";
|
||||
|
||||
|
||||
|
||||
if (end >= start)
|
||||
{
|
||||
var daysSpan = (end - start).TotalDays + 1;
|
||||
return $"{(int)daysSpan} روز";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "تاریخ پایان از تاریخ شروع کوچکتر است.";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ using Company.Domain.LeftWorkAgg;
|
||||
using Company.Domain.LeftWorkInsuranceAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.EmployeeChildren;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
using CompanyManagment.App.Contracts.RollCallService;
|
||||
@@ -1126,5 +1127,6 @@ public class WorkshopAppliction : IWorkshopApplication
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,23 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Exceptions;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.ClientEmployeeWorkshopAgg;
|
||||
using Company.Domain.EmployeeAccountAgg;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using Company.Domain.EmployeeInsuranceRecordAgg;
|
||||
using Company.Domain.InsuranceListAgg;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
public bool city = true;
|
||||
public DateTime initial = new DateTime(1922, 01, 01, 00, 00, 00, 0000000);
|
||||
private readonly IAuthHelper _authHelper;
|
||||
public EmployeeRepository(CompanyContext context, IConfiguration configuration, IAuthHelper authHelper) :base(context)
|
||||
public EmployeeRepository(CompanyContext context, IConfiguration configuration, IAuthHelper authHelper) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_configuration = configuration;
|
||||
@@ -42,13 +43,13 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
|
||||
public List<EmployeeViewModel> GetEmployee()
|
||||
{
|
||||
return _context.Employees.Where(x=>x.IsActive).Select(x => new EmployeeViewModel
|
||||
return _context.Employees.Where(x => x.IsActive).Select(x => new EmployeeViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
FName = x.FName,
|
||||
|
||||
|
||||
LName = x.LName,
|
||||
EmployeeFullName = x.FName +" "+x.LName,
|
||||
EmployeeFullName = x.FName + " " + x.LName,
|
||||
FatherName = x.FatherName,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
@@ -61,48 +62,48 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
public EditEmployee GetDetails(long id)
|
||||
{
|
||||
return _context.Employees.Select(x => new EditEmployee
|
||||
{
|
||||
Id = x.id,
|
||||
FName = x.FName,
|
||||
LName = x.LName,
|
||||
Gender = x.Gender,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
Nationality = x.Nationality,
|
||||
FatherName = x.FatherName,
|
||||
DateOfBirth = x.DateOfBirth == initial ? "" : x.DateOfBirth.ToFarsi(),
|
||||
DateOfIssue = x.DateOfIssue == initial ? "" : x.DateOfIssue.ToFarsi(),
|
||||
PlaceOfIssue = x.PlaceOfIssue,
|
||||
Phone = x.Phone,
|
||||
Address = x.Address,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
MaritalStatus = x.MaritalStatus,
|
||||
MilitaryService = x.MilitaryService,
|
||||
LevelOfEducation = x.LevelOfEducation,
|
||||
FieldOfStudy = x.FieldOfStudy,
|
||||
BankCardNumber = x.BankCardNumber,
|
||||
BankBranch = x.BankBranch,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
|
||||
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
|
||||
NumberOfChildren = x.NumberOfChildren,
|
||||
OfficePhone = x.OfficePhone,
|
||||
EmployeeFullName = x.FName + " " + x.LName,
|
||||
MclsUserName =x.MclsUserName,
|
||||
MclsPassword = x.MclsPassword,
|
||||
EserviceUserName = x.EserviceUserName,
|
||||
EservicePassword = x.EservicePassword,
|
||||
TaxOfficeUserName = x.TaxOfficeUserName,
|
||||
TaxOfficepassword = x.TaxOfficepassword,
|
||||
SanaUserName = x.SanaUserName,
|
||||
SanaPassword = x.SanaPassword,
|
||||
{
|
||||
Id = x.id,
|
||||
FName = x.FName,
|
||||
LName = x.LName,
|
||||
Gender = x.Gender,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
Nationality = x.Nationality,
|
||||
FatherName = x.FatherName,
|
||||
DateOfBirth = x.DateOfBirth == initial ? "" : x.DateOfBirth.ToFarsi(),
|
||||
DateOfIssue = x.DateOfIssue == initial ? "" : x.DateOfIssue.ToFarsi(),
|
||||
PlaceOfIssue = x.PlaceOfIssue,
|
||||
Phone = x.Phone,
|
||||
Address = x.Address,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
MaritalStatus = x.MaritalStatus,
|
||||
MilitaryService = x.MilitaryService,
|
||||
LevelOfEducation = x.LevelOfEducation,
|
||||
FieldOfStudy = x.FieldOfStudy,
|
||||
BankCardNumber = x.BankCardNumber,
|
||||
BankBranch = x.BankBranch,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
|
||||
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
|
||||
NumberOfChildren = x.NumberOfChildren,
|
||||
OfficePhone = x.OfficePhone,
|
||||
EmployeeFullName = x.FName + " " + x.LName,
|
||||
MclsUserName = x.MclsUserName,
|
||||
MclsPassword = x.MclsPassword,
|
||||
EserviceUserName = x.EserviceUserName,
|
||||
EservicePassword = x.EservicePassword,
|
||||
TaxOfficeUserName = x.TaxOfficeUserName,
|
||||
TaxOfficepassword = x.TaxOfficepassword,
|
||||
SanaUserName = x.SanaUserName,
|
||||
SanaPassword = x.SanaPassword,
|
||||
|
||||
|
||||
|
||||
})
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeViewModel>> Search(EmployeeSearchModel searchModel)
|
||||
@@ -182,10 +183,10 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
return query.OrderByDescending(x => x.Id).Take(100).ToList();
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetEmployeeToList()
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetEmployeeToList()
|
||||
{
|
||||
var watch = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
|
||||
List<EmployeeSelectListViewModel> result = null;
|
||||
var connection = _configuration.GetConnectionString("MesbahDb");
|
||||
using (var conn = new SqlConnection(connection))
|
||||
@@ -195,7 +196,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
var command = new SqlCommand("EmployeeFullNameId", conn);
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
|
||||
|
||||
|
||||
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
@@ -273,45 +274,45 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
public EditEmployee GetDetailsByADDate(long id)
|
||||
{
|
||||
return _context.Employees.Select(x => new EditEmployee
|
||||
{
|
||||
Id = x.id,
|
||||
FName = x.FName,
|
||||
LName = x.LName,
|
||||
Gender = x.Gender,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
Nationality = x.Nationality,
|
||||
FatherName = x.FatherName,
|
||||
DateOfBirthGr = x.DateOfBirth ,
|
||||
DateOfIssueGr = x.DateOfIssue ,
|
||||
DateOfBirth = x.DateOfBirth.ToFarsi(),
|
||||
DateOfIssue = x.DateOfIssue.ToFarsi(),
|
||||
PlaceOfIssue = x.PlaceOfIssue,
|
||||
Phone = x.Phone,
|
||||
Address = x.Address,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
MaritalStatus = x.MaritalStatus,
|
||||
MilitaryService = x.MilitaryService,
|
||||
LevelOfEducation = x.LevelOfEducation,
|
||||
FieldOfStudy = x.FieldOfStudy,
|
||||
BankCardNumber = x.BankCardNumber,
|
||||
BankBranch = x.BankBranch,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
|
||||
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
|
||||
NumberOfChildren = x.NumberOfChildren,
|
||||
OfficePhone = x.OfficePhone,
|
||||
EmployeeFullName = x.FName + " " + x.LName,
|
||||
MclsUserName = x.MclsUserName,
|
||||
MclsPassword = x.MclsPassword,
|
||||
EserviceUserName = x.EserviceUserName,
|
||||
EservicePassword = x.EservicePassword,
|
||||
TaxOfficeUserName = x.TaxOfficeUserName,
|
||||
TaxOfficepassword = x.TaxOfficepassword,
|
||||
SanaUserName = x.SanaUserName,
|
||||
SanaPassword = x.SanaPassword,
|
||||
})
|
||||
{
|
||||
Id = x.id,
|
||||
FName = x.FName,
|
||||
LName = x.LName,
|
||||
Gender = x.Gender,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
Nationality = x.Nationality,
|
||||
FatherName = x.FatherName,
|
||||
DateOfBirthGr = x.DateOfBirth,
|
||||
DateOfIssueGr = x.DateOfIssue,
|
||||
DateOfBirth = x.DateOfBirth.ToFarsi(),
|
||||
DateOfIssue = x.DateOfIssue.ToFarsi(),
|
||||
PlaceOfIssue = x.PlaceOfIssue,
|
||||
Phone = x.Phone,
|
||||
Address = x.Address,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
MaritalStatus = x.MaritalStatus,
|
||||
MilitaryService = x.MilitaryService,
|
||||
LevelOfEducation = x.LevelOfEducation,
|
||||
FieldOfStudy = x.FieldOfStudy,
|
||||
BankCardNumber = x.BankCardNumber,
|
||||
BankBranch = x.BankBranch,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
|
||||
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
|
||||
NumberOfChildren = x.NumberOfChildren,
|
||||
OfficePhone = x.OfficePhone,
|
||||
EmployeeFullName = x.FName + " " + x.LName,
|
||||
MclsUserName = x.MclsUserName,
|
||||
MclsPassword = x.MclsPassword,
|
||||
EserviceUserName = x.EserviceUserName,
|
||||
EservicePassword = x.EservicePassword,
|
||||
TaxOfficeUserName = x.TaxOfficeUserName,
|
||||
TaxOfficepassword = x.TaxOfficepassword,
|
||||
SanaUserName = x.SanaUserName,
|
||||
SanaPassword = x.SanaPassword,
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
@@ -324,7 +325,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
EmployeeFullName = x.FName + " " + x.LName,
|
||||
IsActive = x.IsActive
|
||||
|
||||
}).Where(x=>x.IsActive).ToList();
|
||||
}).Where(x => x.IsActive).ToList();
|
||||
}
|
||||
|
||||
#region Client
|
||||
@@ -452,7 +453,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
|
||||
var employeeData = new Employee(command.FName, command.LName, command.FatherName, dateOfBirth,
|
||||
dateOfIssue,
|
||||
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality,command.IdNumberSerial,command.IdNumberSeri,
|
||||
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality, command.IdNumberSerial, command.IdNumberSeri,
|
||||
command.Phone, command.Address,
|
||||
command.State, command.City, command.MaritalStatus, command.MilitaryService, command.LevelOfEducation,
|
||||
command.FieldOfStudy, command.BankCardNumber,
|
||||
@@ -706,20 +707,20 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
{
|
||||
case null:
|
||||
case "":
|
||||
query = query.Where(x => x.IsActive == true).ToList();
|
||||
break;
|
||||
query = query.Where(x => x.IsActive == true).ToList();
|
||||
break;
|
||||
case "false":
|
||||
query = query.Where(x => x.IsActive == false).ToList();
|
||||
hasSearch = true;
|
||||
break;
|
||||
query = query.Where(x => x.IsActive == false).ToList();
|
||||
hasSearch = true;
|
||||
break;
|
||||
case "both":
|
||||
query = query.Where(x => x.IsActive == true || x.IsActive == false).ToList();
|
||||
hasSearch = true;
|
||||
break;
|
||||
query = query.Where(x => x.IsActive == true || x.IsActive == false).ToList();
|
||||
hasSearch = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (hasSearch)
|
||||
{
|
||||
return query.OrderByDescending(x => x.Id).ToList();
|
||||
@@ -816,11 +817,11 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
var employeesQuery = _context.Employees.Where(x =>
|
||||
workshopActiveLeftWorksQuery.Any(y => y.EmployeeId == x.id) ||
|
||||
workshopActiveInsuranceLeftWorksQuery.Any(y => y.EmployeeId == x.id)).Select(x => new
|
||||
{
|
||||
leftWork = workshopActiveLeftWorksQuery.Where(l => l.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
|
||||
insuranceLeftWork = workshopActiveInsuranceLeftWorksQuery.Where(i => i.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
|
||||
Employee = x
|
||||
});
|
||||
{
|
||||
leftWork = workshopActiveLeftWorksQuery.Where(l => l.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
|
||||
insuranceLeftWork = workshopActiveInsuranceLeftWorksQuery.Where(i => i.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
|
||||
Employee = x
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -878,7 +879,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(long employeeId, long workshopId)
|
||||
{
|
||||
var employee = await _context.Employees.Where(x => x.id == employeeId).Select(x => new GetEditEmployeeInEmployeeDocumentViewModel()
|
||||
@@ -946,13 +947,13 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Api
|
||||
#region Api
|
||||
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id)
|
||||
{
|
||||
var query = _context.Employees.AsQueryable();
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText, long id)
|
||||
{
|
||||
var query = _context.Employees.AsQueryable();
|
||||
EmployeeSelectListViewModel idSelected = null;
|
||||
if (id > 0)
|
||||
{
|
||||
@@ -963,104 +964,104 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
}).FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchText))
|
||||
{
|
||||
query = query.Where(x => (x.FName + " " + x.LName).Contains(searchText));
|
||||
}
|
||||
{
|
||||
query = query.Where(x => (x.FName + " " + x.LName).Contains(searchText));
|
||||
}
|
||||
|
||||
var list = await query.Take(100).Select(x => new EmployeeSelectListViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
EmployeeFullName = x.FName + " " + x.LName
|
||||
}).ToListAsync();
|
||||
var list = await query.Take(100).Select(x => new EmployeeSelectListViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
EmployeeFullName = x.FName + " " + x.LName
|
||||
}).ToListAsync();
|
||||
|
||||
if (idSelected != null)
|
||||
list.Add(idSelected);
|
||||
|
||||
return list.DistinctBy(x=>x.Id).ToList();
|
||||
return list.DistinctBy(x => x.Id).ToList();
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel)
|
||||
{
|
||||
var query = _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances).AsQueryable();
|
||||
public async Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel)
|
||||
{
|
||||
var query = _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances).AsQueryable();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
|
||||
{
|
||||
query = query.Where(x => x.NationalCode.Contains(searchModel.NationalCode));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
|
||||
{
|
||||
query = query.Where(x => x.NationalCode.Contains(searchModel.NationalCode));
|
||||
}
|
||||
|
||||
if (searchModel.EmployeeId > 0)
|
||||
{
|
||||
query = query.Where(x => x.id == searchModel.EmployeeId);
|
||||
}
|
||||
if (searchModel.EmployeeId > 0)
|
||||
{
|
||||
query = query.Where(x => x.id == searchModel.EmployeeId);
|
||||
}
|
||||
|
||||
if (searchModel.WorkshopId > 0)
|
||||
{
|
||||
query = query.Where(x => x.LeftWorks.Any(l => l.WorkshopId == searchModel.WorkshopId) || x.LeftWorkInsurances.Any(l => l.WorkshopId == searchModel.WorkshopId));
|
||||
}
|
||||
if (searchModel.WorkshopId > 0)
|
||||
{
|
||||
query = query.Where(x => x.LeftWorks.Any(l => l.WorkshopId == searchModel.WorkshopId) || x.LeftWorkInsurances.Any(l => l.WorkshopId == searchModel.WorkshopId));
|
||||
}
|
||||
|
||||
|
||||
#region employer
|
||||
#region employer
|
||||
|
||||
if (searchModel.EmployerId > 0)
|
||||
{
|
||||
if (searchModel.EmployerId > 0)
|
||||
{
|
||||
|
||||
var workshopIdsByEmployer = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId)
|
||||
.Include(x => x.Workshop).Select(x => x.Workshop.id).AsQueryable();
|
||||
var workshopIdsByEmployer = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId)
|
||||
.Include(x => x.Workshop).Select(x => x.Workshop.id).AsQueryable();
|
||||
|
||||
query = query.Where(x =>
|
||||
x.LeftWorks.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)) ||
|
||||
x.LeftWorkInsurances.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)));
|
||||
query = query.Where(x =>
|
||||
x.LeftWorks.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)) ||
|
||||
x.LeftWorkInsurances.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)));
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (!string.IsNullOrEmpty(searchModel.InsuranceCode))
|
||||
{
|
||||
query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(searchModel.InsuranceCode))
|
||||
{
|
||||
query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode));
|
||||
}
|
||||
|
||||
if (searchModel.EmployeeStatus != ActivationStatus.None)
|
||||
{
|
||||
var status = searchModel.EmployeeStatus switch
|
||||
{
|
||||
ActivationStatus.Active => true,
|
||||
ActivationStatus.DeActive => false,
|
||||
_ => throw new BadRequestException("پارامتر جستجو نامعتبر است")
|
||||
};
|
||||
query = query.Where(x => x.IsActiveString == status.ToString() || x.IsActive == status);
|
||||
}
|
||||
if (searchModel.EmployeeStatus != ActivationStatus.None)
|
||||
{
|
||||
var status = searchModel.EmployeeStatus switch
|
||||
{
|
||||
ActivationStatus.Active => true,
|
||||
ActivationStatus.DeActive => false,
|
||||
_ => throw new BadRequestException("پارامتر جستجو نامعتبر است")
|
||||
};
|
||||
query = query.Where(x => x.IsActiveString == status.ToString() || x.IsActive == status);
|
||||
}
|
||||
|
||||
var list = await query.Skip(searchModel.PageIndex).Take(30).ToListAsync();
|
||||
var list = await query.Skip(searchModel.PageIndex).Take(30).ToListAsync();
|
||||
|
||||
var employeeIds = list.Select(x => x.id);
|
||||
var employeeIds = list.Select(x => x.id);
|
||||
|
||||
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
|
||||
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
|
||||
|
||||
var result = list.Select(x => new GetEmployeeListViewModel()
|
||||
{
|
||||
BirthDate = x.DateOfBirth.ToFarsi(),
|
||||
ChildrenCount = children.Count(c => c.EmployeeId == x.id).ToString(),
|
||||
EmployeeFullName = x.FullName,
|
||||
EmployeeStatus = x.IsActive switch
|
||||
{
|
||||
true => ActivationStatus.Active,
|
||||
false => ActivationStatus.DeActive
|
||||
},
|
||||
Gender = x.Gender switch
|
||||
{
|
||||
"مرد" => Gender.Male,
|
||||
"زن" => Gender.Female,
|
||||
_ => Gender.None
|
||||
},
|
||||
Id = x.id,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
NationalCode = x.NationalCode
|
||||
}).ToList();
|
||||
var result = list.Select(x => new GetEmployeeListViewModel()
|
||||
{
|
||||
BirthDate = x.DateOfBirth.ToFarsi(),
|
||||
ChildrenCount = children.Count(c => c.EmployeeId == x.id).ToString(),
|
||||
EmployeeFullName = x.FullName,
|
||||
EmployeeStatus = x.IsActive switch
|
||||
{
|
||||
true => ActivationStatus.Active,
|
||||
false => ActivationStatus.DeActive
|
||||
},
|
||||
Gender = x.Gender switch
|
||||
{
|
||||
"مرد" => Gender.Male,
|
||||
"زن" => Gender.Female,
|
||||
_ => Gender.None
|
||||
},
|
||||
Id = x.id,
|
||||
InsuranceCode = x.InsuranceCode,
|
||||
NationalCode = x.NationalCode
|
||||
}).ToList();
|
||||
|
||||
return result;
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId)
|
||||
{
|
||||
@@ -1170,7 +1171,144 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
//
|
||||
// };
|
||||
// }).OrderByDescending(x => x.StartWork).ToList();
|
||||
throw new NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, 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();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.EmployeeFullName))
|
||||
baseQuery = baseQuery.Where(x => x.Employee.FullName.Contains(searchModel.EmployeeFullName)).ToList();
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
|
||||
baseQuery = baseQuery.Where(x => x.Employee.NationalCode.Contains(searchModel.NationalCode)).ToList();
|
||||
|
||||
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 clientTemp = await _context.EmployeeClientTemps.Where(x => x.WorkshopId == workshopId)
|
||||
.Select(x => x.EmployeeId).ToListAsync();
|
||||
var leftWorkTempData = await _context.LeftWorkTemps.Where(x => x.WorkshopId == workshopId).ToListAsync();
|
||||
var startWorkTemp = leftWorkTempData.Where(x => x.LeftWorkType == LeftWorkTempType.StartWork).ToList();
|
||||
var leftWorkTemp = leftWorkTempData.Where(x => x.LeftWorkType == LeftWorkTempType.LeftWork).ToList();
|
||||
|
||||
|
||||
|
||||
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 contractStart = left != null ? left.StartWorkDate.ToFarsi() : "";
|
||||
var contractLeft = left != null
|
||||
? left.LeftWorkDate != hasNotStoppedWorkingYet ? left.LeftWorkDate.ToFarsi() : ""
|
||||
: "";
|
||||
|
||||
var insuranceStart = insuranceLeftWork != null ? insuranceLeftWork.StartWorkDate.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));
|
||||
bool hasClientTemp = clientTemp.Any(c => c == x.Employee.id);
|
||||
bool hasStartWorkTemp = startWorkTemp.Any(st => st.EmployeeId == x.Employee.id);
|
||||
bool hasLeftWorkTemp = leftWorkTemp.Any(lf => lf.EmployeeId == x.Employee.id);
|
||||
return new EmployeeListDto
|
||||
{
|
||||
Id = x.Employee.id,
|
||||
EmployeeFullName = x.Employee.FullName,
|
||||
PersonnelCode = personnelCode,
|
||||
MaritalStatus = x.Employee.MaritalStatus,
|
||||
NationalCode = x.Employee.NationalCode,
|
||||
IdNumber = x.Employee.IdNumber,
|
||||
DateOfBirth = x.Employee.DateOfBirth.ToFarsi(),
|
||||
FatherName = x.Employee.FatherName,
|
||||
NumberOfChildren = $"{numberOfChildren}",
|
||||
LatestContractStartDate = contractStart,
|
||||
ContractLeftDate = contractLeft,
|
||||
LatestInsuranceStartDate = insuranceStart,
|
||||
InsuranceLeftDate = insuranceLeft,
|
||||
HasContract = !string.IsNullOrWhiteSpace(contractStart),
|
||||
HasInsurance = !string.IsNullOrWhiteSpace(insuranceStart),
|
||||
EmployeeStatusInWorkshop =
|
||||
hasClientTemp || hasStartWorkTemp ? EmployeeStatusInWorkshop.CreatedByClient :
|
||||
hasLeftWorkTemp ? EmployeeStatusInWorkshop.LefWorkTemp :
|
||||
employeeHasLeft ? EmployeeStatusInWorkshop.HasLeft : EmployeeStatusInWorkshop.Working,
|
||||
|
||||
};
|
||||
}).OrderBy(x => x.EmployeeStatusInWorkshop).ThenBy(x => x.PersonnelCode).ToList();
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId)
|
||||
{
|
||||
var res = await ListOfAllEmployeesClient(new EmployeeSearchModelDto(), workshopId);
|
||||
|
||||
return res
|
||||
.Where(x=>x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.CreatedByClient
|
||||
&& x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.LefWorkTemp)
|
||||
.Select(x => new PrintAllEmployeesInfoDtoClient(x)).ToList();
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
|
||||
{
|
||||
var dateNow = DateTime.Now.Date;
|
||||
|
||||
|
||||
var workshopActiveLeftWorksQuery = _context.LeftWorkList.Where(x => x.WorkshopId == workshopId &&
|
||||
x.StartWorkDate <= dateNow && x.LeftWorkDate > dateNow);
|
||||
|
||||
|
||||
var workshopActiveInsuranceLeftWorksQuery = _context.LeftWorkInsuranceList.Where(x => x.WorkshopId == workshopId &&
|
||||
x.StartWorkDate <= dateNow && (x.LeftWorkDate > dateNow || x.LeftWorkDate == null));
|
||||
|
||||
|
||||
var employeesQuery = _context.Employees.Where(x => workshopActiveLeftWorksQuery.Any(y => y.EmployeeId == x.id) ||
|
||||
workshopActiveInsuranceLeftWorksQuery.Any(y => y.EmployeeId == x.id));
|
||||
|
||||
|
||||
return await employeesQuery.Select(x => new EmployeeSelectListViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
EmployeeFullName = x.FullName
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.LeaveAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Leave;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -17,6 +19,7 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
|
||||
public LeaveRepository(CompanyContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
|
||||
}
|
||||
|
||||
public EditLeave GetDetails(long id)
|
||||
@@ -290,6 +293,65 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
|
||||
return query;
|
||||
}
|
||||
|
||||
public async Task<List<LeavePrintResponseViewModel>> PrintAllAsync(List<long> ids, long workshopId)
|
||||
{
|
||||
var leaves =await _context
|
||||
.LeaveList.Where(x => ids.Contains(x.id) && x.WorkshopId == workshopId).ToListAsync();
|
||||
|
||||
var minLeave = leaves.Min(x => x.StartLeave);
|
||||
var maxLeave = leaves.Max(x => x.EndLeave);
|
||||
|
||||
var employeeIds = leaves.Select(x => x.EmployeeId).Distinct().ToList();
|
||||
|
||||
var contracts = await _context.Contracts
|
||||
.Where(x => x.WorkshopIds == workshopId && employeeIds.Contains(x.EmployeeId)
|
||||
&& x.ContarctStart<= maxLeave && x.ContractEnd>= minLeave)
|
||||
.ToListAsync();
|
||||
|
||||
var employees = await _context
|
||||
.Employees.Where(x=> employeeIds.Contains(x.id)).ToListAsync();
|
||||
|
||||
var employerNames = _context.WorkshopEmployers.Include(x=>x.Employer)
|
||||
.Where(x=>x.WorkshopId == workshopId).Select(x=>x.Employer.FName+" "+x.Employer.LName).ToList();
|
||||
|
||||
var workshopName = _context.Workshops.FirstOrDefault(x => x.id == workshopId)?.WorkshopName;
|
||||
|
||||
var res = leaves.Select(leave =>
|
||||
{
|
||||
var employee = employees.FirstOrDefault(x => x.id == leave.EmployeeId);
|
||||
return new LeavePrintResponseViewModel
|
||||
{
|
||||
FullName = employee?.FName + " " +
|
||||
employee?.LName,
|
||||
NationalCode = employee?.NationalCode,
|
||||
WorkshopName = workshopName,
|
||||
EmployerNames = employerNames,
|
||||
PaidLeaveType = leave.PaidLeaveType,
|
||||
ContractNo = contracts.FirstOrDefault(x =>
|
||||
x.EmployeeId == leave.EmployeeId &&
|
||||
x.ContarctStart <= leave.StartLeave &&
|
||||
x.ContractEnd >= leave.EndLeave)?.ContractNo,
|
||||
DailyLeave = leave.PaidLeaveType == "روزانه" ? new LeavePrintDailyResponseViewModel
|
||||
{
|
||||
StartLeave = leave.StartLeave.ToFarsi(),
|
||||
EndLeave = leave.EndLeave.ToFarsi(),
|
||||
TotalDay = leave.LeaveHourses
|
||||
} : null,
|
||||
|
||||
HourlyLeave = leave.PaidLeaveType == "ساعتی" ?
|
||||
new LeavePrintHourlyResponseViewModel
|
||||
{
|
||||
LeaveDate = leave.StartLeave.ToFarsi(),
|
||||
StartHour = leave.StartLeave.ToString("HH:mm"),
|
||||
EndHour = leave.EndLeave.ToString("HH:mm"),
|
||||
TotalHour = TimeSpan.Parse(leave.LeaveHourses)
|
||||
.TotalHours.ToString("F0")
|
||||
} : null
|
||||
};
|
||||
}).ToList();
|
||||
return res;
|
||||
}
|
||||
|
||||
#region Vafa
|
||||
|
||||
public List<LeaveViewModel> LastLeaveMain(LeaveSearchModel searchModel)
|
||||
@@ -371,15 +433,17 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
|
||||
}
|
||||
}
|
||||
|
||||
public OperationResult RemoveLeave(long id)
|
||||
|
||||
|
||||
public async Task<OperationResult> RemoveLeave(long id)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
var item = _context.LeaveList.FirstOrDefault(x => x.id == id);
|
||||
if (item != null)
|
||||
{
|
||||
var checkoutExist = _context.CheckoutSet
|
||||
var checkoutExist =await _context.CheckoutSet
|
||||
.Where(x => x.WorkshopId == item.WorkshopId && x.EmployeeId == item.EmployeeId)
|
||||
.Where(x => item.StartLeave <= x.ContractEnd).ToList();
|
||||
.Where(x => item.StartLeave <= x.ContractEnd).ToListAsync();
|
||||
if (checkoutExist.Count > 0)
|
||||
{
|
||||
return op.Failed("در بازه زمانی این مرخصی و یا بعد از آن فیش حقوقی وجود دارد");
|
||||
@@ -536,4 +600,250 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
|
||||
(starContract >= x.StartLeaveGr && starContract <= x.EndLeaveGr) ||
|
||||
(endContract >= x.StartLeaveGr && endContract <= x.EndLeaveGr));
|
||||
}
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<PagedResult<leaveListDto>> GetList(LeaveListSearchModel searchModel)
|
||||
{
|
||||
var query = _context.LeaveList.Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
|
||||
if (searchModel.EmployeeId != 0)
|
||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||
|
||||
if (searchModel.LeaveType == LeaveType.PaidLeave)
|
||||
query = query.Where(x => x.LeaveType == "استحقاقی");
|
||||
|
||||
if (searchModel.LeaveType == LeaveType.SickLeave)
|
||||
query = query.Where(x => x.LeaveType == "استعلاجی");
|
||||
|
||||
if (searchModel.IsInvalid)
|
||||
{
|
||||
query = query.IgnoreQueryFilters().Where(x => x.IsInvalid);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.StartLeave) && !string.IsNullOrWhiteSpace(searchModel.EndLeave))
|
||||
{
|
||||
var start = new DateTime();
|
||||
var end = new DateTime();
|
||||
try
|
||||
{
|
||||
start = searchModel.StartLeave.ToGeorgianDateTime();
|
||||
end = searchModel.EndLeave.ToGeorgianDateTime();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new PagedResult<leaveListDto>();
|
||||
}
|
||||
|
||||
query = query.Where(x => x.StartLeave >= start && x.EndLeave <= end);
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(searchModel.YearStr) || !string.IsNullOrWhiteSpace(searchModel.MonthStr))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.YearStr))
|
||||
{
|
||||
try
|
||||
{
|
||||
int year = Convert.ToInt32(searchModel.YearStr);
|
||||
query = query.Where(x => x.Year == year);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
return new PagedResult<leaveListDto>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.MonthStr))
|
||||
{
|
||||
try
|
||||
{
|
||||
int month = Convert.ToInt32(searchModel.MonthStr);
|
||||
query = query.Where(x => x.Month == month);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
return new PagedResult<leaveListDto>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
var count = await query.CountAsync();
|
||||
query = query.OrderByDescending(x => x.CreationDate);
|
||||
var queryPaginationFilter = await query.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
|
||||
|
||||
|
||||
|
||||
var leaveResult = queryPaginationFilter.Select(item => new leaveListDto()
|
||||
{
|
||||
Id = item.id,
|
||||
EmployeeFullName = item.EmployeeFullName,
|
||||
YearStr = $"{item.Year}",
|
||||
MonthStr = item.Month.ToFarsiMonthByIntNumber(),
|
||||
IsInvalid = item.IsInvalid,
|
||||
LeaveType = item.LeaveType,
|
||||
StartLeave = item.StartLeave.ToFarsi(),
|
||||
EndLeave = item.EndLeave.ToFarsi(),
|
||||
HourlyInterval = item.PaidLeaveType == "ساعتی" ? $"{item.StartLeave.TimeOfDay:hh\\:mm} الی {item.EndLeave.TimeOfDay:hh\\:mm}" : "-",
|
||||
LeaveDuration = Tools.CalculateLeaveHoursAndDays(item.PaidLeaveType, item.LeaveHourses),
|
||||
IsAccepted = item.IsAccepted,
|
||||
WorkshopId = item.WorkshopId,
|
||||
EmployeeId = item.EmployeeId,
|
||||
|
||||
}).ToList();
|
||||
return new PagedResult<leaveListDto>()
|
||||
{
|
||||
TotalCount = count,
|
||||
List = leaveResult
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<GroupLeaveListDto>> GetGroupList(LeaveListSearchModel searchModel)
|
||||
{
|
||||
var query = _context.LeaveList.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
|
||||
|
||||
|
||||
|
||||
if (searchModel.LeaveType == LeaveType.PaidLeave)
|
||||
query = query.Where(x => x.LeaveType == "استحقاقی");
|
||||
|
||||
if (searchModel.LeaveType == LeaveType.SickLeave)
|
||||
query = query.Where(x => x.LeaveType == "استعلاجی");
|
||||
|
||||
if (searchModel.IsInvalid)
|
||||
{
|
||||
query = query.IgnoreQueryFilters().Where(x => x.IsInvalid);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.StartLeave) && !string.IsNullOrWhiteSpace(searchModel.EndLeave))
|
||||
{
|
||||
var start = new DateTime();
|
||||
var end = new DateTime();
|
||||
try
|
||||
{
|
||||
start = searchModel.StartLeave.ToGeorgianDateTime();
|
||||
end = searchModel.EndLeave.ToGeorgianDateTime();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new List<GroupLeaveListDto>();
|
||||
}
|
||||
|
||||
query = query.Where(x => x.StartLeave >= start && x.EndLeave <= end);
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(searchModel.YearStr) || !string.IsNullOrWhiteSpace(searchModel.MonthStr))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.YearStr))
|
||||
{
|
||||
try
|
||||
{
|
||||
int year = Convert.ToInt32(searchModel.YearStr);
|
||||
query = query.Where(x => x.Year == year);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
return new List<GroupLeaveListDto>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.MonthStr))
|
||||
{
|
||||
try
|
||||
{
|
||||
int month = Convert.ToInt32(searchModel.MonthStr);
|
||||
query = query.Where(x => x.Month == month);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
return new List<GroupLeaveListDto>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
var leaveList = await query.GroupBy(x => new { x.Year, x.Month })
|
||||
.OrderByDescending(group => group.Key.Year)
|
||||
.ThenByDescending(group => group.Key.Month)
|
||||
.Select(group => new GroupLeaveListDto
|
||||
{
|
||||
YearStr = $"{group.Key.Year}",
|
||||
MonthStr = group.Key.Month.ToFarsiMonthByIntNumber(),
|
||||
LeaveListItemsDto = group.OrderByDescending(x=>x.StartLeave).Select(item => new LeaveListItemsDto
|
||||
{
|
||||
Id = item.id,
|
||||
IsInvalid = item.IsInvalid,
|
||||
LeaveType = item.LeaveType,
|
||||
StartLeave = item.StartLeave.ToFarsi(),
|
||||
EndLeave = item.EndLeave.ToFarsi(),
|
||||
HourlyInterval = item.PaidLeaveType == "ساعتی" ? $"{item.StartLeave.TimeOfDay:hh\\:mm} الی {item.EndLeave.TimeOfDay:hh\\:mm}" : "-",
|
||||
LeaveDuration = Tools.CalculateLeaveHoursAndDays(item.PaidLeaveType, item.LeaveHourses),
|
||||
IsAccepted = item.IsAccepted,
|
||||
WorkshopId = item.WorkshopId,
|
||||
EmployeeId = item.EmployeeId,
|
||||
}).ToList()
|
||||
}).ToListAsync();
|
||||
|
||||
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
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
@@ -16,10 +17,38 @@ public class EmployeeController:ClientBaseController
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("select-list")]
|
||||
public async Task<ActionResult<List<EmployeeSelectListViewModel>>> GetEmployeeSelectList()
|
||||
{
|
||||
var result = await _employeeApplication.WorkedEmployeesInWorkshopSelectList(_workshopId);
|
||||
var result = await _employeeApplication.GetWorkingEmployeesSelectList(_workshopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پرسنل
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<EmployeeListDto>>> GetList(EmployeeSearchModelDto searchModel)
|
||||
{
|
||||
var result = await _employeeApplication.ListOfAllEmployeesClient(searchModel, _workshopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// پرینت تجمیعی پرسنل
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("PrintAllEmployeesInfo")]
|
||||
public async Task<ActionResult<List<PrintAllEmployeesInfoDtoClient>>> PrintAllEmployeesInfo()
|
||||
{
|
||||
var result = await _employeeApplication.PrintAllEmployeesInfoClient(_workshopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
172
ServiceHost/Areas/Client/Controllers/LeaveController.cs
Normal file
172
ServiceHost/Areas/Client/Controllers/LeaveController.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
using CompanyManagment.App.Contracts.InsuranceList;
|
||||
using CompanyManagment.App.Contracts.Leave;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers;
|
||||
|
||||
public class LeaveController : ClientBaseController
|
||||
{
|
||||
private readonly ILeaveApplication _leaveApplication;
|
||||
private long _workshopId;
|
||||
public LeaveController(ILeaveApplication leaveApplication, IAuthHelper authHelper)
|
||||
{
|
||||
_leaveApplication = leaveApplication;
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست مرخصی ها
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetLeaveList")]
|
||||
public async Task<ActionResult<LeaveListMultipleDto>> GetLeaveList(LeaveListSearchModel searchModel)
|
||||
{
|
||||
var result = new LeaveListMultipleDto();
|
||||
searchModel.WorkshopId = _workshopId;
|
||||
if (searchModel.EmployeeId > 0)
|
||||
{
|
||||
//لیست گروه بندی شده
|
||||
result.GroupLeaveListDto = await _leaveApplication.GetGroupList(searchModel);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.YearStr) && !string.IsNullOrWhiteSpace(searchModel.MonthStr))
|
||||
{
|
||||
TimeSpan timeSpan = _leaveApplication.SumOfEmployeeLeaveTimeSpanInDates(_workshopId, searchModel.EmployeeId, searchModel.YearStr, searchModel.MonthStr, searchModel.LeaveType);
|
||||
//مجموع مرخصی پرسنل
|
||||
result.SumOfEmployeeleaves = timeSpan.ToFarsiDaysAndHoursAndMinutes();
|
||||
}
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
//لیست نرمال PageResult
|
||||
result.leaveListDto = await _leaveApplication.GetList(searchModel);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// چک کردن تاریخ شروع مرخصی
|
||||
///// </summary>
|
||||
///// <param name="startLeaveDate"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet("CheckIsInvalidLeave")]
|
||||
//public async Task<OperationResult<CheckIsInvalidLeaveDto>> CheckIsInvalidLeave(string startLeaveDate)
|
||||
//{
|
||||
// return await _leaveApplication.CheckIsInvalidLeave(startLeaveDate, _workshopId);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد مرخصی
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateLeave")]
|
||||
public async Task<ActionResult<OperationResult>> CreateLeave([FromBody] CreateLeaveDto command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
|
||||
var result = await _leaveApplication.CreateLeave(command);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت شیفت گردشی اگر داشت
|
||||
/// در مودال ایجاد
|
||||
/// </summary>
|
||||
/// <param name="startLeaveDate"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetRotatingShift")]
|
||||
public async Task<OperationResult<RotatingShiftDto>> GetRotatingShift(long employeeId, string startLeaveDate)
|
||||
{
|
||||
|
||||
return await _leaveApplication.HasRotatingShift(_workshopId, employeeId, startLeaveDate);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// محاسبه مدت مرخصی ساعتی
|
||||
/// در مودال ایجاد
|
||||
/// </summary>
|
||||
/// <param name="startHours"></param>
|
||||
/// <param name="endHours"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetHourlyLeaveDuration")]
|
||||
public async Task<ActionResult<string>> GetHourlyLeaveDuration(string startHours, string endHours)
|
||||
{
|
||||
var result =await _leaveApplication.GetHourlyLeaveDuration(startHours, endHours);
|
||||
return Ok(new { LeaveDuration = result });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// محاسبه مدت مرخصی روزانه
|
||||
/// در مودال ایجاد
|
||||
/// </summary>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetDailyLeaveDuration")]
|
||||
public async Task<ActionResult<string>> GetDailyLeaveDuration(string startDate, string endDate)
|
||||
{
|
||||
var result = await _leaveApplication.GetDailyLeaveDuration(startDate, endDate);
|
||||
return Ok(new { LeaveDuration = result });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// پرینت تکی
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("print/{id}")]
|
||||
public async Task<ActionResult<LeavePrintResponseViewModel>> PrintOneAsync(long id)
|
||||
{
|
||||
var leavePrint = await _leaveApplication.PrintOneAsync(id, _workshopId);
|
||||
return leavePrint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// پرینت گروهی
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("print")]
|
||||
public async Task<ActionResult<List<LeavePrintResponseViewModel>>> PrintAllAsync([FromQuery] List<long> ids, LeaveListSearchModel searchModel)
|
||||
{
|
||||
var leavePrints = await _leaveApplication.PrintAllAsync(ids, _workshopId);
|
||||
return Ok(leavePrints);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// پرینت لیستی
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("ListPrint")]
|
||||
public async Task<ActionResult<LeaveListPrintDto>> ListPrint([FromQuery] List<long> ids)
|
||||
{
|
||||
var leavePrints = await _leaveApplication.ListPrint(ids);
|
||||
return Ok(leavePrints);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// حذف مرخصی
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("RemoveLeave/{id}")]
|
||||
public async Task<ActionResult<object>> RemoveLeaveAsync(long id)
|
||||
{
|
||||
var op =await _leaveApplication.RemoveLeaveAsync(id);
|
||||
return Ok(new
|
||||
{
|
||||
isSuccedded = op.IsSuccedded,
|
||||
message = op.Message,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user