ClientCheckoutApi List init
This commit is contained in:
@@ -6,6 +6,7 @@ using CompanyManagment.App.Contracts.Leave;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto.ClientDto;
|
||||
|
||||
|
||||
namespace Company.Domain.CheckoutAgg;
|
||||
@@ -152,4 +153,12 @@ public interface ICheckoutRepository : IRepository<long, Checkout>
|
||||
Task<OperationResult<List<LeavePrintForCheckoutDto>>> LeavePrintForCheckout(long id);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ClientApi
|
||||
|
||||
Task<PagedResult<CheckoutListClientDto>> GetListForClient(long workshopId,
|
||||
CheckoutListClientSearchModel searchModel);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using _0_Framework.Application;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Checkout.Dto.ClientDto;
|
||||
|
||||
public class CheckoutListClientDto
|
||||
{
|
||||
/// <summary>
|
||||
/// ای دی فیش
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سال
|
||||
/// </summary>
|
||||
public string Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ماه
|
||||
/// </summary>
|
||||
public string Month { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره قراداد
|
||||
/// </summary>
|
||||
public string ContractNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ شروع فیش
|
||||
/// </summary>
|
||||
public string ContractStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان فیش
|
||||
/// </summary>
|
||||
public string ContractEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// امضاء
|
||||
/// </summary>
|
||||
public bool Signature { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// کد پرسنلی
|
||||
/// </summary>
|
||||
public string PersonnelCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا فیش نیاز به بروزرسانی دارد
|
||||
/// </summary>
|
||||
public bool IsUpdateNeeded { get; set; }
|
||||
/// <summary>
|
||||
/// لیست پیام های هشدار فیش حقوقی
|
||||
/// </summary>
|
||||
public List<CheckoutWarningMessageModel> CheckoutWarningMessageList { get; set; }
|
||||
}
|
||||
|
||||
public class CheckoutListClientSearchModel : PaginationRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long? EmployeeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سال
|
||||
/// </summary>
|
||||
public int Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ماه
|
||||
/// </summary>
|
||||
public int Month { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ شروع فیش
|
||||
/// </summary>
|
||||
public string StartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان فیش
|
||||
/// </summary>
|
||||
public string EndDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مرتب سازی
|
||||
/// </summary>
|
||||
public CheckoutClientListOrderType? OrderType { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum CheckoutClientListOrderType
|
||||
{
|
||||
//بر اساس تاریخ ایجاد
|
||||
ByCheckoutCreationDate,
|
||||
|
||||
/// <summary>
|
||||
/// بر اساس امضاء شده
|
||||
/// </summary>
|
||||
BySignedCheckout,
|
||||
|
||||
/// <summary>
|
||||
/// بر اساس امضاء نشده
|
||||
/// </summary>
|
||||
ByUnSignedCheckout,
|
||||
|
||||
/// <summary>
|
||||
/// بر اساس کد پرسنلی
|
||||
/// کوچک به بزرگ
|
||||
/// </summary>
|
||||
ByPersonnelCode,
|
||||
|
||||
/// <summary>
|
||||
/// بر اساس کد پرسنلی
|
||||
/// بزرگ به کوچک
|
||||
/// </summary>
|
||||
ByPersonnelCodeDescending,
|
||||
|
||||
/// <summary>
|
||||
/// بر اساس تاریخ شروع
|
||||
/// کوچک به بزرگ
|
||||
/// </summary>
|
||||
ByCheckoutStartDate,
|
||||
|
||||
/// <summary>
|
||||
/// براساس تاریخ شروع
|
||||
/// بزرگ به کوچک
|
||||
/// </summary>
|
||||
ByCheckoutStartDateDescending
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto.ClientDto;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Checkout;
|
||||
|
||||
@@ -150,6 +151,13 @@ public interface ICheckoutApplication
|
||||
/// <returns></returns>
|
||||
Task<OperationResult<List<LeavePrintForCheckoutDto>>> LeavePrintForCheckout(long id);
|
||||
#endregion
|
||||
|
||||
#region ClientApi
|
||||
|
||||
Task<PagedResult<CheckoutListClientDto>> GetListForClient(long workshopId,
|
||||
CheckoutListClientSearchModel searchModel);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class CheckoutPrintInstallmentDto
|
||||
|
||||
@@ -39,6 +39,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto.ClientDto;
|
||||
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
@@ -1601,5 +1602,16 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
return await _checkoutRepository.LeavePrintForCheckout(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClientApi
|
||||
|
||||
public async Task<PagedResult<CheckoutListClientDto>> GetListForClient(long workshopId, CheckoutListClientSearchModel searchModel)
|
||||
{
|
||||
return await _checkoutRepository.GetListForClient(workshopId, searchModel);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using Company.Domain.WorkshopAgg;
|
||||
using Company.Domain.WorkshopEmployerAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto.ClientDto;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.EmployeeComputeOptions;
|
||||
@@ -37,6 +38,7 @@ using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.XPath;
|
||||
using _0_Framework.Exceptions;
|
||||
using static CompanyManagment.EFCore.Repository.ContractRepository;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
||||
|
||||
@@ -5118,5 +5120,125 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
|
||||
return op.Succcedded(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region ClientApi
|
||||
|
||||
public async Task<PagedResult<CheckoutListClientDto>> GetListForClient(long workshopId,
|
||||
CheckoutListClientSearchModel searchModel)
|
||||
{
|
||||
bool isSearched = false;
|
||||
string yearStr = searchModel.Year > 0 ? $"{searchModel.Year:0000}" : "";
|
||||
string monthStr = searchModel.Month > 0 ? $"{searchModel.Month:00}" : "";
|
||||
var query = _context.CheckoutSet.Where(x => x.WorkshopId == workshopId).AsNoTracking();
|
||||
if (searchModel.EmployeeId is > 0)
|
||||
{
|
||||
isSearched = true;
|
||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
|
||||
{
|
||||
if (!searchModel.StartDate.TryToGeorgianDateTime(out var startDateGr))
|
||||
throw new BadRequestException("تاریخ شروع جستجو نامعتبر است");
|
||||
|
||||
if (!searchModel.EndDate.TryToGeorgianDateTime(out var endDateGr))
|
||||
{
|
||||
throw new BadRequestException("تاریخ پایان جستجو نامعتبر است");
|
||||
}
|
||||
isSearched = true;
|
||||
query = query.Where(x => x.ContractStart <= endDateGr && x.ContractEnd >= startDateGr);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(yearStr))
|
||||
{
|
||||
isSearched = true;
|
||||
query = query.Where(x => x.Year == yearStr);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(monthStr))
|
||||
{
|
||||
isSearched = true;
|
||||
var searchedMonth = searchModel.Month.ToFarsiMonthByIntNumber();
|
||||
|
||||
query = query.Where(x => x.Month == searchedMonth);
|
||||
}
|
||||
|
||||
query = searchModel.OrderType switch
|
||||
{
|
||||
CheckoutClientListOrderType.ByCheckoutCreationDate =>
|
||||
query.OrderBy(x => x.CreationDate),
|
||||
|
||||
CheckoutClientListOrderType.ByCheckoutStartDate =>
|
||||
query.OrderBy(x => x.ContractStart),
|
||||
|
||||
CheckoutClientListOrderType.ByCheckoutStartDateDescending =>
|
||||
query.OrderByDescending(x => x.ContractStart),
|
||||
|
||||
CheckoutClientListOrderType.ByPersonnelCode =>
|
||||
query.OrderBy(x => x.PersonnelCode),
|
||||
|
||||
CheckoutClientListOrderType.ByPersonnelCodeDescending =>
|
||||
query.OrderByDescending(x => x.PersonnelCode),
|
||||
|
||||
CheckoutClientListOrderType.BySignedCheckout =>
|
||||
query.OrderByDescending(x => x.Signature == "1"),
|
||||
|
||||
CheckoutClientListOrderType.ByUnSignedCheckout =>
|
||||
query.OrderBy(x => x.Signature == "1"),
|
||||
|
||||
_ => query.OrderByDescending(x => x.id)
|
||||
};
|
||||
|
||||
//int count = 2000;
|
||||
//if (isSearched == false)
|
||||
// query = query.Take(count);
|
||||
|
||||
|
||||
var list = await query.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
|
||||
var checkoutIdList = list.Select(x => x.id).ToList();
|
||||
var warningMessages = await _context.CheckoutWarningMessages.Where(x => checkoutIdList.Contains(x.CheckoutId)).AsNoTracking().ToListAsync();
|
||||
|
||||
var resList = list.Select(x =>
|
||||
{
|
||||
var warningMessage = warningMessages.Where(wm => wm.CheckoutId == x.id);
|
||||
return new CheckoutListClientDto()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractStart = x.ContractStart.ToFarsi(),
|
||||
ContractEnd = x.ContractEnd.ToFarsi(),
|
||||
Year = x.Year,
|
||||
Month = x.Month,
|
||||
ContractNo = x.ContractNo,
|
||||
EmployeeName = x.EmployeeFullName,
|
||||
Signature = x.Signature == "1",
|
||||
PersonnelCode = x.PersonnelCode,
|
||||
IsUpdateNeeded = x.IsUpdateNeeded,
|
||||
CheckoutWarningMessageList = warningMessage.Select(wm => new CheckoutWarningMessageModel
|
||||
{
|
||||
WarningMessage = wm.WarningMessage,
|
||||
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
|
||||
}).ToList();
|
||||
|
||||
var res = new PagedResult<CheckoutListClientDto>
|
||||
{
|
||||
TotalCount = await query.CountAsync(),
|
||||
List = resList
|
||||
};
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
28
ServiceHost/Areas/Client/Controllers/CheckoutController.cs
Normal file
28
ServiceHost/Areas/Client/Controllers/CheckoutController.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.ContractAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto.ClientDto;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers;
|
||||
|
||||
public class CheckoutController : ClientBaseController
|
||||
{
|
||||
private readonly ICheckoutApplication _checkoutApplication;
|
||||
private readonly long _workshopId;
|
||||
public CheckoutController(ICheckoutApplication checkoutApplication, IAuthHelper authHelper)
|
||||
{
|
||||
_checkoutApplication = checkoutApplication;
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<PagedResult<CheckoutListClientDto>> GetList(CheckoutListClientSearchModel searchModel)
|
||||
{
|
||||
var result = await _checkoutApplication.GetListForClient(_workshopId, searchModel);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user