workshopSelectList api and employeeSelectlist

This commit is contained in:
gozareshgir
2026-01-20 18:17:32 +03:30
parent 3317bde6d6
commit 5b6f967fca
11 changed files with 197 additions and 10 deletions

View File

@@ -84,6 +84,12 @@ public interface ICheckoutRepository : IRepository<long, Checkout>
#region ForApi #region ForApi
/// <summary>
/// دریافت سلکت لیست پرسنل کارگاه
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long id);
/// <summary> /// <summary>
/// دریافت لیست فیش حقوقی /// دریافت لیست فیش حقوقی

View File

@@ -106,4 +106,14 @@ public interface IWorkshopRepository : IRepository<long, Workshop>
#endregion #endregion
#region ForApi
/// <summary>
/// دریافت لیست کارگاه های ادمین برای سلکت تو
/// Api
/// </summary>
/// <returns></returns>
Task<List<AdminWorkshopSelectListDto>> GetAdminWorkshopSelectList();
#endregion
} }

View File

@@ -0,0 +1,14 @@
namespace CompanyManagment.App.Contracts.Checkout.Dto;
public class EmployeeSelectListDto
{
/// <summary>
/// آی دی پرسنل
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام پرسنل
/// </summary>
public string EmployeeFullName { get; set; }
}

View File

@@ -67,6 +67,13 @@ public interface ICheckoutApplication
#region ForApi #region ForApi
/// <summary>
/// دریافت سلکت لیست پرسنل کارگاه
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long id);
/// <summary> /// <summary>
/// دریافت لیست فیش های حقوقی ادمین /// دریافت لیست فیش های حقوقی ادمین
/// </summary> /// </summary>

View File

@@ -0,0 +1,24 @@
namespace CompanyManagment.App.Contracts.Workshop.DTOs;
public class AdminWorkshopSelectListDto
{
/// <summary>
/// آی دی کارگاه
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام کارگاه
/// </summary>
public string WorkshopFullName { get; set; }
/// <summary>
/// کد بایگانی
/// </summary>
public string ArchiveCode { get; set; }
/// <summary>
/// آیا بلاک شده است
/// </summary>
public bool IsBlock { get; set; }
}

View File

@@ -1,10 +1,11 @@
using System.Collections.Generic; using _0_Framework.Application;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using _0_Framework.Application;
using AccountManagement.Application.Contracts.Account; using AccountManagement.Application.Contracts.Account;
using CompanyManagment.App.Contracts.Checkout.Dto;
using CompanyManagment.App.Contracts.Workshop.DTOs; using CompanyManagment.App.Contracts.Workshop.DTOs;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace CompanyManagment.App.Contracts.Workshop; namespace CompanyManagment.App.Contracts.Workshop;
@@ -92,6 +93,19 @@ public interface IWorkshopApplication
#endregion #endregion
Task<ActionResult<OperationResult>> CreateWorkshopWorkflowRegistration(CreateWorkshopWorkflowRegistration command); Task<ActionResult<OperationResult>> CreateWorkshopWorkflowRegistration(CreateWorkshopWorkflowRegistration command);
#region ForApi
/// <summary>
/// دریافت لیست کارگاه های ادمین برای سلکت تو
/// Api
/// </summary>
/// <returns></returns>
Task<List<AdminWorkshopSelectListDto>> GetAdminWorkshopSelectList();
#endregion
} }
public class CreateWorkshopWorkflowRegistration public class CreateWorkshopWorkflowRegistration

View File

@@ -717,7 +717,10 @@ public class CheckoutApplication : ICheckoutApplication
return _checkoutRepository.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, start, end); return _checkoutRepository.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, start, end);
} }
public async Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long id)
{
return await _checkoutRepository.GetEmployeeSelectListByWorkshopId(id);
}
#endregion #endregion

View File

@@ -11,6 +11,7 @@ using Company.Domain.InstitutionContractAgg;
using Company.Domain.LeftWorkAgg; using Company.Domain.LeftWorkAgg;
using Company.Domain.LeftWorkInsuranceAgg; using Company.Domain.LeftWorkInsuranceAgg;
using Company.Domain.WorkshopAgg; using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.Checkout.Dto;
using CompanyManagment.App.Contracts.Employee; using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.EmployeeChildren; using CompanyManagment.App.Contracts.EmployeeChildren;
using CompanyManagment.App.Contracts.LeftWork; using CompanyManagment.App.Contracts.LeftWork;
@@ -1130,5 +1131,17 @@ public class WorkshopAppliction : IWorkshopApplication
return operation.Succcedded(); return operation.Succcedded();
} }
#endregion
#region ForApi
public async Task<List<AdminWorkshopSelectListDto>> GetAdminWorkshopSelectList()
{
return await _workshopRepository.GetAdminWorkshopSelectList();
}
#endregion #endregion
} }

View File

@@ -2762,6 +2762,22 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
#region ForApi #region ForApi
public async Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long id)
{
var employeesHasLeftworkData =_context.LeftWorkList.Where(x => x.WorkshopId == id).Select(x => x.EmployeeId);
var employees =await _context.Employees
.Where(x => employeesHasLeftworkData.Contains(x.id))
.Select(x =>
new EmployeeSelectListDto()
{
Id = x.id,
EmployeeFullName = x.FullName
})
.AsNoTracking()
.ToListAsync();
return employees;
}
public async Task<PagedResult<CheckoutDto>> GetList(CheckoutSearchModelDto searchModel) public async Task<PagedResult<CheckoutDto>> GetList(CheckoutSearchModelDto searchModel)
{ {
var acountID = _authHelper.CurrentAccountId(); var acountID = _authHelper.CurrentAccountId();
@@ -3236,5 +3252,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
Console.WriteLine("print : " + watch.Elapsed); Console.WriteLine("print : " + watch.Elapsed);
return result; return result;
} }
#endregion #endregion
} }

View File

@@ -1187,14 +1187,14 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
.Where(x => !string.IsNullOrEmpty(x.ArchiveCode)) .Where(x => !string.IsNullOrEmpty(x.ArchiveCode))
.Select(x => x.ArchiveCode) .Select(x => x.ArchiveCode)
.ToList(); .ToList();
int maxArchiveCode = 0; int maxArchiveCode = 0;
foreach (var code in archiveCodes) foreach (var code in archiveCodes)
{ {
// Remove "b-" prefix if exists // Remove "b-" prefix if exists
string cleanCode = code.StartsWith("b-") ? code.Substring(2) : code; string cleanCode = code.StartsWith("b-") ? code.Substring(2) : code;
// Try to parse the clean code to an integer // Try to parse the clean code to an integer
if (int.TryParse(cleanCode, out int codeValue)) if (int.TryParse(cleanCode, out int codeValue))
{ {
@@ -1204,7 +1204,7 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
} }
} }
} }
return maxArchiveCode; return maxArchiveCode;
} }
@@ -2024,5 +2024,52 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
}).OrderByDescending(x => x.StartWork).ToList(); }).OrderByDescending(x => x.StartWork).ToList();
} }
#endregion
#region ForApi
public async Task<List<AdminWorkshopSelectListDto>> GetAdminWorkshopSelectList()
{
var watch = new Stopwatch();
watch.Start();
var acountId = _authHelper.CurrentAccountId();
var workshopIds = _context.WorkshopAccounts.AsNoTracking().Where(x => x.AccountId == acountId).Select(x => x.WorkshopId);
var employers = await
_context.WorkshopEmployers.AsNoTracking().Where(x => workshopIds.Contains(x.WorkshopId))
.Select(x => new { x.Employer, x.WorkshopId }).ToListAsync();
var blockedContractingParties =await _context.PersonalContractingParties
.Where(x => x.IsBlock == "true").Select(x=>x.id).ToListAsync();
var workshops = await _context.Workshops.AsNoTracking()
.Where(x => workshopIds.Contains(x.id))
.Where(x => x.IsActiveString == "true").ToListAsync();
var result = workshops.Select(x =>
{
var empl = employers.First(em => em.WorkshopId == x.id);
var isBlock = blockedContractingParties.Any(cp => cp == empl.Employer.ContractingPartyId);
return new AdminWorkshopSelectListDto
{
Id = x.id,
WorkshopFullName = x.WorkshopFullName,
ArchiveCode = x.ArchiveCode,
IsBlock = isBlock
};
}).OrderBy(x=>x.IsBlock ? 1 : 0)
.ToList();
Console.WriteLine("workshopSelectList : " +watch.Elapsed);
return result;
}
#endregion #endregion
} }

View File

@@ -2,6 +2,8 @@
using CompanyManagment.App.Contracts.Checkout; using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Checkout.Dto; using CompanyManagment.App.Contracts.Checkout.Dto;
using CompanyManagment.App.Contracts.InstitutionPlan; using CompanyManagment.App.Contracts.InstitutionPlan;
using CompanyManagment.App.Contracts.Workshop;
using CompanyManagment.App.Contracts.Workshop.DTOs;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NuGet.Packaging.Signing; using NuGet.Packaging.Signing;
using ServiceHost.BaseControllers; using ServiceHost.BaseControllers;
@@ -11,10 +13,12 @@ namespace ServiceHost.Areas.Admin.Controllers;
public class CheckoutController : AdminBaseController public class CheckoutController : AdminBaseController
{ {
private readonly ICheckoutApplication _checkoutApplication; private readonly ICheckoutApplication _checkoutApplication;
private readonly IWorkshopApplication _workshopApplication;
public CheckoutController(ICheckoutApplication checkoutApplication) public CheckoutController(ICheckoutApplication checkoutApplication, IWorkshopApplication workshopApplication)
{ {
_checkoutApplication = checkoutApplication; _checkoutApplication = checkoutApplication;
_workshopApplication = workshopApplication;
} }
/// <summary> /// <summary>
@@ -64,5 +68,31 @@ public class CheckoutController : AdminBaseController
return result; return result;
} }
#region CreateCheckout
/// <summary>
/// سلکت لیست کارگاه
/// </summary>
/// <returns></returns>
[HttpGet("WorkshopSelectList")]
public async Task<List<AdminWorkshopSelectListDto>> GetWorkshopSelectList()
{
var result =await _workshopApplication.GetAdminWorkshopSelectList();
return result;
}
/// <summary>
/// سلک لیست پرسنل
/// </summary>
/// <param name="workshopId"></param>
/// <returns></returns>
[HttpGet("EmployeeSelectList")]
public async Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long workshopId)
{
var result = await _checkoutApplication.GetEmployeeSelectListByWorkshopId(workshopId);
return result;
}
#endregion
} }