get checkout list init

This commit is contained in:
gozareshgir
2026-01-14 16:39:05 +03:30
parent 8ec13ffae1
commit 12af5dcb56
7 changed files with 499 additions and 16 deletions

View File

@@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Checkout.Dto;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Company.Domain.CheckoutAgg;
@@ -80,4 +81,16 @@ public interface ICheckoutRepository : IRepository<long, Checkout>
#endregion
Task<Checkout> GetByWorkshopIdEmployeeIdInDate(long workshopId, long employeeId, DateTime inDate);
#region ForApi
/// <summary>
/// دریافت لیست فیش حقوقی
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<PagedResult<CheckoutDto>> GetList(CheckoutSearchModelDto searchModel);
#endregion
}

View File

@@ -0,0 +1,92 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.Checkout.Dto;
public class CheckoutDto
{
/// <summary>
/// آی دی فیش
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام پرسنل
/// </summary>
public string EmployeeFullName { get; set; }
/// <summary>
/// نام کارگاه
/// </summary>
public string WorkshopName { 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 string Month { get; set; }
/// <summary>
/// سال
/// </summary>
public string Year { get; set; }
/// <summary>
/// روزهای کارکرد
/// </summary>
public string SumOfWorkingDays { get; set; }
/// <summary>
/// شماره کارگاه
/// </summary>
public string ArchiveCode { get; set; }
/// <summary>
/// کد پرسنلی
/// </summary>
public int PersonnelCode { get; set; }
/// <summary>
/// فعال/غیرفعال
/// </summary>
public string IsActiveString { get; set; }
/// <summary>
/// امضاء فیش
/// </summary>
public string Signature { get; set; }
/// <summary>
/// نام کارفرما
/// </summary>
public string EmployerName { get; set; }
public string IsBlockCantracingParty { get; set; }
/// <summary>
/// آیا فیش نیاز به بروزرسانی دارد
/// </summary>
public bool IsUpdateNeeded { get; set; }
/// <summary>
/// لیست پیام های هشدار فیش حقوقی
/// </summary>
public List<CheckoutWarningMessageModel> CheckoutWarningMessageList { get; set; }
/// <summary>
/// نیاز به امزا دارد یا خیر
/// </summary>
public bool HasSignCheckoutOption { get; set; }
}

View File

@@ -0,0 +1,47 @@
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.Checkout.Dto;
public class CheckoutSearchModelDto : PaginationRequest
{
/// <summary>
/// نام پرسنل
/// </summary>
public string EmployeeFullName { get; set; }
/// <summary>
/// آی دی کارگاه
/// </summary>
public long WorkshopId { 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 string Month { get; set; }
/// <summary>
/// سال
/// </summary>
public string Year { get; set; }
/// <summary>
/// آی دی گارفرما
/// </summary>
public long EmployerId { get; set; }
}

View File

@@ -1,9 +1,10 @@
using System;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.Checkout.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.Checkout;
@@ -62,4 +63,11 @@ public interface ICheckoutApplication
long workshopId, DateTime start, DateTime end);
#endregion
#region ForApi
Task<PagedResult<CheckoutDto>> GetList(CheckoutSearchModelDto searchModel);
#endregion
}

View File

@@ -23,6 +23,7 @@ using CompanyManagment.EFCore.Repository;
using System.Globalization;
using Company.Domain.LeaveAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.Checkout.Dto;
namespace CompanyManagment.Application;
@@ -706,5 +707,18 @@ public class CheckoutApplication : ICheckoutApplication
return _checkoutRepository.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, start, end);
}
#endregion
#endregion
#region ForApi
public async Task<PagedResult<CheckoutDto>> GetList(CheckoutSearchModelDto searchModel)
{
return await _checkoutRepository.GetList(searchModel);
}
#endregion
}

View File

@@ -1,12 +1,4 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.CheckoutAgg;
using Company.Domain.LeftWorkAgg;
@@ -14,9 +6,11 @@ using Company.Domain.RollCallAgg;
using Company.Domain.RollCallEmployeeAgg;
using Company.Domain.WorkshopEmployerAgg;
using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Checkout.Dto;
using CompanyManagment.App.Contracts.Contract;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.HolidayItem;
using CompanyManagment.App.Contracts.InstitutionPlan;
using CompanyManagment.App.Contracts.InsuranceList;
using CompanyManagment.App.Contracts.Leave;
using CompanyManagment.App.Contracts.LeftWork;
@@ -31,6 +25,14 @@ using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using PersianTools.Core;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Threading.Tasks;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace CompanyManagment.EFCore.Repository;
@@ -2752,4 +2754,281 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
}
#endregion
#region ForApi
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 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 })
// .GroupJoin(_context.EmployeeComputeOptionsSet.AsSplitQuery(),
// x => x.workshop.id,
// option => option.WorkshopId,
// (x, options) => new { x.ch, x.workshop, options })
// .SelectMany(
// x => x.options.DefaultIfEmpty(),
// (x, option) => new { x.ch, x.workshop, option })
// .GroupJoin(_context.WorkshopEmployers.AsSplitQuery().Include(we => we.Employer),
// result => result.workshop.id,
// workshopEmployer => workshopEmployer.WorkshopId,
// (result, workshopEmployer) => new { result.ch, result.workshop, result.option, workshopEmployer })
// .SelectMany(
// y => y.workshopEmployer.DefaultIfEmpty(),
// (y, workshopEmployer) => new { y.option, y.ch, y.workshop, workshopEmployer })
// .Select(res => new
// {
// res.ch,
// res.workshop,
// option = _context.EmployeeComputeOptionsSet.FirstOrDefault(x => x.WorkshopId == res.ch.WorkshopId && x.EmployeeId == res.ch.EmployeeId),
// res.workshopEmployer,
// contractingParty = _context.PersonalContractingParties
// .Include(p => p.Employers)
// .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,
});
#region SercheModel
if (!string.IsNullOrWhiteSpace(searchModel.ContractNo))
checkouts = checkouts.Where(x =>
x.ch.ContractNo == searchModel.ContractNo);
if (searchModel.WorkshopId != 0)
{
checkouts = checkouts.Where(x => x.ch.WorkshopId == searchModel.WorkshopId);
}
if (!string.IsNullOrWhiteSpace(searchModel.EmployeeFullName))
{
checkouts = checkouts.Where(x => x.ch.EmployeeFullName.Contains(searchModel.EmployeeFullName));
}
//if (searchModel.EmployerId != 0)
//{
// checkouts = checkouts.Where(x => x.contractingParty.Employers.Select(c => c.id).Contains(searchModel.EmployerId));
//}
//سرچ سال
if (!string.IsNullOrWhiteSpace(searchModel.Year) && string.IsNullOrWhiteSpace(searchModel.Month) &&
(string.IsNullOrWhiteSpace(searchModel.ContractStart) ||
string.IsNullOrWhiteSpace(searchModel.ContractEnd)))
{
var startYear = searchModel.Year + "/01/01";
var startyearGr = startYear.ToGeorgianDateTime();
var endYear = $"{searchModel.Year}/12/01".FindeEndOfMonth();
var endYearGr = endYear.ToGeorgianDateTime();
checkouts = checkouts.Where(x => x.ch.ContractStart >= startyearGr && x.ch.ContractEnd <= endYearGr);
if (searchModel.WorkshopId > 0 || !string.IsNullOrWhiteSpace(searchModel.EmployeeFullName) || searchModel.EmployerId > 0)
checkouts = checkouts.OrderByDescending(x => x.ch.ContractEnd);
}
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month) &&
string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
string.IsNullOrWhiteSpace(searchModel.ContractEnd))
{
//سرچ سال و ماه
string y1 = $"{searchModel.Year}/{searchModel.Month}/01";
var startDate = y1.ToGeorgianDateTime();
string y2 = string.Empty;
int month = Convert.ToInt32(searchModel.Month);
int year = Convert.ToInt32(searchModel.Year);
if (month <= 6)
{
y2 = $"{searchModel.Year}/{searchModel.Month}/31";
}
else if (month > 6 && month < 12)
{
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
}
else if (month == 12)
{
switch (year)
{
case 1346:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1350:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1354:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1358:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1362:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1366:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1370:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1375:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1379:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1383:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1387:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1391:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1395:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1399:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1403:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1408:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1412:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1416:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1420:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1424:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1428:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1432:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1436:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1441:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
case 1445:
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
break;
default:
y2 = $"{searchModel.Year}/{searchModel.Month}/29";
break;
}
}
var endDate = y2.ToGeorgianDateTime();
//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);
//if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
// checkouts = checkouts.OrderBy(x => x.ch.PersonnelCodeInt);
}
else if (!string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
!string.IsNullOrWhiteSpace(searchModel.ContractEnd) &&
string.IsNullOrWhiteSpace(searchModel.Year) && string.IsNullOrWhiteSpace(searchModel.Month))
{
//سرچ تاریخ
var start = searchModel.ContractStart.ToGeorgianDateTime();
var endd = searchModel.ContractEnd.ToGeorgianDateTime();
checkouts = checkouts.Where(x =>
x.ch.ContractStart >= start && x.ch.ContractStart <= endd);
//if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
// checkouts = checkouts.OrderByDescending(x => x.ch.ContractEnd).ThenBy(x => x.ch.PersonnelCodeInt);
}
#endregion
var count = await checkouts.CountAsync();
var checkoutQueryFilter = await checkouts.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
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,
}).ToList()
}).OrderByDescending(x => x.Id)
.ThenByDescending(x => x.Year)
.ThenBy(x => x.PersonnelCode)
.ToList();
return new PagedResult<CheckoutDto>()
{
TotalCount = count,
List = result
};
}
#endregion
}

View File

@@ -0,0 +1,30 @@
using _0_Framework.Application;
using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Checkout.Dto;
using CompanyManagment.App.Contracts.InstitutionPlan;
using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers;
namespace ServiceHost.Areas.Admin.Controllers;
public class CheckoutController : AdminBaseController
{
private readonly ICheckoutApplication _checkoutApplication;
public CheckoutController(ICheckoutApplication checkoutApplication)
{
_checkoutApplication = checkoutApplication;
}
/// <summary>
/// دریافت لیست فیش حقوقی
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
[HttpGet("GetList")]
public async Task<ActionResult<PagedResult<CheckoutDto>>> GetList(CheckoutSearchModelDto searchModel)
{
return await _checkoutApplication.GetList(searchModel);
}
}