checkout list completed
This commit is contained in:
@@ -59,22 +59,22 @@ public class CheckoutDto
|
||||
/// <summary>
|
||||
/// کد پرسنلی
|
||||
/// </summary>
|
||||
public int PersonnelCode { get; set; }
|
||||
public string PersonnelCode { get; set; }
|
||||
/// <summary>
|
||||
/// فعال/غیرفعال
|
||||
/// </summary>
|
||||
public string IsActiveString { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// امضاء فیش
|
||||
/// </summary>
|
||||
public string Signature { get; set; }
|
||||
public bool Signature { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کارفرما
|
||||
/// </summary>
|
||||
public string EmployerName { get; set; }
|
||||
public string IsBlockCantracingParty { get; set; }
|
||||
public bool IsBlockCantracingParty { get; set; }
|
||||
/// <summary>
|
||||
/// آیا فیش نیاز به بروزرسانی دارد
|
||||
/// </summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using Company.Domain.RollCallAgg;
|
||||
using Company.Domain.RollCallEmployeeAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using Company.Domain.WorkshopEmployerAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto;
|
||||
@@ -33,6 +34,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.XPath;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
@@ -2763,8 +2765,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
public async Task<PagedResult<CheckoutDto>> GetList(CheckoutSearchModelDto searchModel)
|
||||
{
|
||||
var acountID = _authHelper.CurrentAccountId();
|
||||
var workshopAcounts =await _context.WorkshopAccounts.Where(x => x.AccountId == acountID)
|
||||
.Select(x => x.WorkshopId).ToListAsync();
|
||||
var workshopAccounts = _context.WorkshopAccounts.Where(x => x.AccountId == acountID)
|
||||
.Select(x => x.WorkshopId);
|
||||
|
||||
|
||||
//var checkouts =
|
||||
@@ -2798,36 +2800,82 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
// .FirstOrDefault(p => p.Employers.Any(e => e.id == res.workshopEmployer.Employer.id))
|
||||
// });
|
||||
|
||||
var checkouts =
|
||||
_context.CheckoutSet.Include(w => w.CheckoutWarningMessageList).Where(x => workshopAcounts.Contains(x.WorkshopId))
|
||||
.Join(_context.Workshops.AsSplitQuery(),
|
||||
ch => ch.WorkshopId,
|
||||
workshop => workshop.id,
|
||||
(ch, workshop) => new { ch, workshop })
|
||||
.Select(res => new
|
||||
{
|
||||
res.ch,
|
||||
res.workshop,
|
||||
});
|
||||
//var checkoutss =
|
||||
// _context.CheckoutSet.Include(w => w.CheckoutWarningMessageList).Where(x => workshopAcounts.Contains(x.WorkshopId))
|
||||
// .Join(_context.Workshops.AsSplitQuery(),
|
||||
// ch => ch.WorkshopId,
|
||||
// workshop => workshop.id,
|
||||
// (ch, workshop) => new { ch, workshop })
|
||||
// .Select(res => new
|
||||
// {
|
||||
// res.ch,
|
||||
// res.workshop,
|
||||
// });
|
||||
var watch = new Stopwatch();
|
||||
watch.Start();
|
||||
var checkouts =
|
||||
(
|
||||
from workshop in _context.Workshops.Where(x => workshopAccounts.Contains(x.id))
|
||||
join x in _context.CheckoutSet
|
||||
on workshop.id equals x.WorkshopId
|
||||
|
||||
//.Include(x=>x.CheckoutWarningMessageList)
|
||||
//join workshop in _context.Workshops
|
||||
// on ch.WorkshopId equals workshop.id
|
||||
|
||||
|
||||
select new
|
||||
{
|
||||
Id = x.id,
|
||||
EmployeeFullName = x.EmployeeFullName,
|
||||
EmployeeId = x.EmployeeId,
|
||||
ContractStart = x.ContractStart,
|
||||
ContractEnd = x.ContractEnd,
|
||||
PersonnelCode = x.PersonnelCode,
|
||||
SumOfWorkingDays = x.SumOfWorkingDays,
|
||||
Month = x.Month,
|
||||
Year = x.Year,
|
||||
ContractNo = x.ContractNo,
|
||||
IsActiveString = x.IsActiveString,
|
||||
Signature = x.Signature,
|
||||
IsUpdateNeeded = x.IsUpdateNeeded,
|
||||
WorkshopId = x.WorkshopId,
|
||||
ArchiveCode = workshop.ArchiveCode,
|
||||
WorkshopName = workshop.WorkshopFullName,
|
||||
WorkshopSignCheckout = workshop.SignCheckout,
|
||||
|
||||
}
|
||||
|
||||
).OrderByDescending(x => x.Id)
|
||||
.ThenByDescending(x => x.Year)
|
||||
.ThenByDescending(x=>x.ContractStart)
|
||||
.ThenBy(x => x.PersonnelCode).AsNoTracking();
|
||||
|
||||
Console.WriteLine("getList======================= : " + watch.Elapsed);
|
||||
#region SercheModel
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ContractNo))
|
||||
checkouts = checkouts.Where(x =>
|
||||
x.ch.ContractNo == searchModel.ContractNo);
|
||||
x.ContractNo == searchModel.ContractNo);
|
||||
if (searchModel.WorkshopId != 0)
|
||||
{
|
||||
checkouts = checkouts.Where(x => x.ch.WorkshopId == searchModel.WorkshopId);
|
||||
checkouts = checkouts.Where(x => x.WorkshopId == searchModel.WorkshopId)
|
||||
.OrderByDescending(x => x.ContractStart)
|
||||
.ThenBy(x => x.PersonnelCode);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.EmployeeFullName))
|
||||
{
|
||||
checkouts = checkouts.Where(x => x.ch.EmployeeFullName.Contains(searchModel.EmployeeFullName));
|
||||
checkouts = checkouts.Where(x => x.EmployeeFullName.Contains(searchModel.EmployeeFullName));
|
||||
}
|
||||
if (searchModel.EmployerId != 0)
|
||||
{
|
||||
var workshopIds = _context.WorkshopEmployers.Where(e => e.EmployerId == searchModel.EmployerId)
|
||||
.Select(e => e.WorkshopId);
|
||||
checkouts = checkouts.Where(x => workshopIds.Contains(x.WorkshopId))
|
||||
.OrderByDescending(x => x.ContractStart);
|
||||
}
|
||||
//if (searchModel.EmployerId != 0)
|
||||
//{
|
||||
// checkouts = checkouts.Where(x => x.contractingParty.Employers.Select(c => c.id).Contains(searchModel.EmployerId));
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2844,9 +2892,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
var endYearGr = endYear.ToGeorgianDateTime();
|
||||
|
||||
|
||||
checkouts = checkouts.Where(x => x.ch.ContractStart >= startyearGr && x.ch.ContractEnd <= endYearGr);
|
||||
checkouts = checkouts.Where(x => x.ContractStart >= startyearGr && x.ContractEnd <= endYearGr);
|
||||
if (searchModel.WorkshopId > 0 || !string.IsNullOrWhiteSpace(searchModel.EmployeeFullName) || searchModel.EmployerId > 0)
|
||||
checkouts = checkouts.OrderByDescending(x => x.ch.ContractEnd);
|
||||
checkouts = checkouts.OrderByDescending(x => x.ContractEnd);
|
||||
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month) &&
|
||||
@@ -2960,13 +3008,13 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
|
||||
//checkouts = checkouts.Where(x => x.ContractEndGr >= start && x.ContractEndGr <= end).ToList();
|
||||
checkouts = checkouts.Where(x =>
|
||||
x.ch.ContractStart >= startDate && x.ch.ContractStart < endDate && x.ch.ContractEnd > startDate &&
|
||||
x.ch.ContractEnd <= endDate ||
|
||||
x.ch.ContractStart <= startDate && x.ch.ContractEnd >= endDate ||
|
||||
startDate <= x.ch.ContractStart && endDate > x.ch.ContractStart ||
|
||||
endDate >= x.ch.ContractEnd && startDate < x.ch.ContractEnd);
|
||||
x.ContractStart >= startDate && x.ContractStart < endDate && x.ContractEnd > startDate &&
|
||||
x.ContractEnd <= endDate ||
|
||||
x.ContractStart <= startDate && x.ContractEnd >= endDate ||
|
||||
startDate <= x.ContractStart && endDate > x.ContractStart ||
|
||||
endDate >= x.ContractEnd && startDate < x.ContractEnd);
|
||||
//if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
||||
// checkouts = checkouts.OrderBy(x => x.ch.PersonnelCodeInt);
|
||||
// checkouts = checkouts.OrderBy(x => x.PersonnelCodeInt);
|
||||
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
||||
@@ -2978,51 +3026,79 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
var start = searchModel.ContractStart.ToGeorgianDateTime();
|
||||
var endd = searchModel.ContractEnd.ToGeorgianDateTime();
|
||||
checkouts = checkouts.Where(x =>
|
||||
x.ch.ContractStart >= start && x.ch.ContractStart <= endd);
|
||||
x.ContractStart >= start && x.ContractStart <= endd);
|
||||
|
||||
//if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
||||
// checkouts = checkouts.OrderByDescending(x => x.ch.ContractEnd).ThenBy(x => x.ch.PersonnelCodeInt);
|
||||
if (searchModel.WorkshopId > 0 || !string.IsNullOrWhiteSpace(searchModel.EmployeeFullName) || searchModel.EmployerId > 0)
|
||||
checkouts = checkouts.OrderByDescending(x => x.ContractEnd).ThenBy(x => x.PersonnelCode);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
var count = await checkouts.CountAsync();
|
||||
watch.Reset();
|
||||
watch.Start();
|
||||
|
||||
var checkoutQueryFilter = await checkouts.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
|
||||
Console.WriteLine("pagination===================== : " + watch.Elapsed);
|
||||
|
||||
var employers =await
|
||||
_context.WorkshopEmployers.Where(x => checkoutQueryFilter
|
||||
.Select(c => c.WorkshopId).Contains(x.WorkshopId))
|
||||
.Select(x=> new {x.Employer, x.WorkshopId}).ToListAsync();
|
||||
var contractingPartiesIds = employers.Select(x => x.Employer.ContractingPartyId).ToList();
|
||||
var warningMessages = await _context.CheckoutWarningMessages.Where(x => checkoutQueryFilter
|
||||
.Select(c => c.Id).Contains(x.CheckoutId)).ToListAsync();
|
||||
|
||||
|
||||
var contractnigParties = await _context.PersonalContractingParties
|
||||
.Where(x => contractingPartiesIds.Contains(x.id)).ToListAsync();
|
||||
|
||||
var options = await _context.EmployeeComputeOptionsSet.Where(x => checkoutQueryFilter
|
||||
.Select(c => c.WorkshopId).Contains(x.WorkshopId)).ToListAsync();
|
||||
|
||||
watch.Reset();
|
||||
watch.Start();
|
||||
var result = checkoutQueryFilter.Select(x =>
|
||||
|
||||
|
||||
var result = checkoutQueryFilter.Select(x => new CheckoutDto
|
||||
{
|
||||
Id = x.ch.id,
|
||||
EmployeeFullName = x.ch.EmployeeFullName,
|
||||
ContractStart = x.ch.ContractStart.ToFarsi(),
|
||||
ContractEnd = x.ch.ContractEnd.ToFarsi(),
|
||||
PersonnelCode = Convert.ToInt32(x.ch.PersonnelCode),
|
||||
ArchiveCode = x.workshop.ArchiveCode,
|
||||
SumOfWorkingDays = x.ch.SumOfWorkingDays,
|
||||
WorkshopName = x.workshop.WorkshopName,
|
||||
Month = x.ch.Month,
|
||||
Year = x.ch.Year,
|
||||
ContractNo = x.ch.ContractNo,
|
||||
IsActiveString = x.ch.IsActiveString,
|
||||
Signature = x.ch.Signature,
|
||||
//EmployerName = $"{x.workshopEmployer.Employer.FName} {x.workshopEmployer.Employer.LName}",
|
||||
//IsBlockCantracingParty = x.contractingParty.IsBlock,
|
||||
//HasSignCheckoutOption = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
|
||||
IsUpdateNeeded = x.ch.IsUpdateNeeded,
|
||||
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm => new CheckoutWarningMessageModel
|
||||
{
|
||||
WarningMessage = wm.WarningMessage,
|
||||
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
||||
var warningMessage = warningMessages.Where(wm => wm.CheckoutId == x.Id);
|
||||
var empl = employers.First(em => em.WorkshopId == x.WorkshopId);
|
||||
var isBlock = contractnigParties.Any(cp => cp.id == empl.Employer.ContractingPartyId && cp.IsBlock == "true");
|
||||
var option = options.FirstOrDefault(o => o.WorkshopId == x.WorkshopId && o.EmployeeId == x.EmployeeId);
|
||||
return new CheckoutDto
|
||||
{
|
||||
Id = x.Id,
|
||||
EmployeeFullName = x.EmployeeFullName,
|
||||
ContractStart = x.ContractStart.ToFarsi(),
|
||||
ContractEnd = x.ContractEnd.ToFarsi(),
|
||||
PersonnelCode = x.PersonnelCode,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
SumOfWorkingDays = x.SumOfWorkingDays,
|
||||
WorkshopName = x.WorkshopName,
|
||||
Month = x.Month,
|
||||
Year = x.Year,
|
||||
ContractNo = x.ContractNo,
|
||||
IsActive = x.IsActiveString == "true",
|
||||
Signature = x.Signature == "1",
|
||||
EmployerName = $"{empl.Employer.FullName}",
|
||||
IsBlockCantracingParty = isBlock,
|
||||
HasSignCheckoutOption = option != null ? option.SignCheckout : x.WorkshopSignCheckout,
|
||||
IsUpdateNeeded = x.IsUpdateNeeded,
|
||||
CheckoutWarningMessageList = warningMessage.Select(wm => new CheckoutWarningMessageModel
|
||||
{
|
||||
WarningMessage = wm.WarningMessage,
|
||||
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
||||
|
||||
}).ToList()
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
}).OrderByDescending(x => x.Id)
|
||||
.ThenByDescending(x => x.Year)
|
||||
.ThenBy(x => x.PersonnelCode)
|
||||
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
var count = await checkouts.CountAsync();
|
||||
Console.WriteLine("FinalList================================ : " + watch.Elapsed);
|
||||
return new PagedResult<CheckoutDto>()
|
||||
{
|
||||
TotalCount = count,
|
||||
|
||||
Reference in New Issue
Block a user