From 5b6f967fca768d12619a536111937b5250988975 Mon Sep 17 00:00:00 2001 From: gozareshgir Date: Tue, 20 Jan 2026 18:17:32 +0330 Subject: [PATCH] workshopSelectList api and employeeSelectlist --- .../CheckoutAgg/ICheckoutRepository.cs | 6 ++ .../WorkshopAgg/IWorkshopRepository.cs | 10 ++++ .../Checkout/Dto/EmployeeSelectListDto.cs | 14 +++++ .../Checkout/ICheckoutApplication.cs | 7 +++ .../DTOs/AdminWorkshopSelectListDto.cs | 24 ++++++++ .../Workshop/IWorkshopApplication.cs | 22 ++++++-- .../CheckoutApplication.cs | 5 +- .../WorkshopAppliction.cs | 13 +++++ .../Repository/CheckoutRepository.cs | 19 +++++++ .../Repository/WorkshopRepository.cs | 55 +++++++++++++++++-- .../Admin/Controllers/CheckoutController.cs | 32 ++++++++++- 11 files changed, 197 insertions(+), 10 deletions(-) create mode 100644 CompanyManagment.App.Contracts/Checkout/Dto/EmployeeSelectListDto.cs create mode 100644 CompanyManagment.App.Contracts/Workshop/DTOs/AdminWorkshopSelectListDto.cs diff --git a/Company.Domain/CheckoutAgg/ICheckoutRepository.cs b/Company.Domain/CheckoutAgg/ICheckoutRepository.cs index c1bba732..167c323c 100644 --- a/Company.Domain/CheckoutAgg/ICheckoutRepository.cs +++ b/Company.Domain/CheckoutAgg/ICheckoutRepository.cs @@ -84,6 +84,12 @@ public interface ICheckoutRepository : IRepository #region ForApi + /// + /// دریافت سلکت لیست پرسنل کارگاه + /// + /// + /// + Task> GetEmployeeSelectListByWorkshopId(long id); /// /// دریافت لیست فیش حقوقی diff --git a/Company.Domain/WorkshopAgg/IWorkshopRepository.cs b/Company.Domain/WorkshopAgg/IWorkshopRepository.cs index 6d5f56ea..b9193076 100644 --- a/Company.Domain/WorkshopAgg/IWorkshopRepository.cs +++ b/Company.Domain/WorkshopAgg/IWorkshopRepository.cs @@ -106,4 +106,14 @@ public interface IWorkshopRepository : IRepository #endregion + + #region ForApi + /// + /// دریافت لیست کارگاه های ادمین برای سلکت تو + /// Api + /// + /// + Task> GetAdminWorkshopSelectList(); + + #endregion } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Checkout/Dto/EmployeeSelectListDto.cs b/CompanyManagment.App.Contracts/Checkout/Dto/EmployeeSelectListDto.cs new file mode 100644 index 00000000..4384aaa3 --- /dev/null +++ b/CompanyManagment.App.Contracts/Checkout/Dto/EmployeeSelectListDto.cs @@ -0,0 +1,14 @@ +namespace CompanyManagment.App.Contracts.Checkout.Dto; + +public class EmployeeSelectListDto +{ + /// + /// آی دی پرسنل + /// + public long Id { get; set; } + + /// + /// نام پرسنل + /// + public string EmployeeFullName { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs index a3e75d18..89822fca 100644 --- a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs +++ b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs @@ -67,6 +67,13 @@ public interface ICheckoutApplication #region ForApi + /// + /// دریافت سلکت لیست پرسنل کارگاه + /// + /// + /// + Task> GetEmployeeSelectListByWorkshopId(long id); + /// /// دریافت لیست فیش های حقوقی ادمین /// diff --git a/CompanyManagment.App.Contracts/Workshop/DTOs/AdminWorkshopSelectListDto.cs b/CompanyManagment.App.Contracts/Workshop/DTOs/AdminWorkshopSelectListDto.cs new file mode 100644 index 00000000..8ed1da5d --- /dev/null +++ b/CompanyManagment.App.Contracts/Workshop/DTOs/AdminWorkshopSelectListDto.cs @@ -0,0 +1,24 @@ +namespace CompanyManagment.App.Contracts.Workshop.DTOs; + +public class AdminWorkshopSelectListDto +{ + /// + /// آی دی کارگاه + /// + public long Id { get; set; } + + /// + /// نام کارگاه + /// + public string WorkshopFullName { get; set; } + + /// + /// کد بایگانی + /// + public string ArchiveCode { get; set; } + + /// + /// آیا بلاک شده است + /// + public bool IsBlock { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Workshop/IWorkshopApplication.cs b/CompanyManagment.App.Contracts/Workshop/IWorkshopApplication.cs index 9e9ec0ac..b73faf8b 100644 --- a/CompanyManagment.App.Contracts/Workshop/IWorkshopApplication.cs +++ b/CompanyManagment.App.Contracts/Workshop/IWorkshopApplication.cs @@ -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.Checkout.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,19 @@ public interface IWorkshopApplication #endregion Task> CreateWorkshopWorkflowRegistration(CreateWorkshopWorkflowRegistration command); + + + #region ForApi + + + /// + /// دریافت لیست کارگاه های ادمین برای سلکت تو + /// Api + /// + /// + Task> GetAdminWorkshopSelectList(); + + #endregion } public class CreateWorkshopWorkflowRegistration diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index 30263813..37ac1a18 100644 --- a/CompanyManagment.Application/CheckoutApplication.cs +++ b/CompanyManagment.Application/CheckoutApplication.cs @@ -717,7 +717,10 @@ public class CheckoutApplication : ICheckoutApplication return _checkoutRepository.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, start, end); } - + public async Task> GetEmployeeSelectListByWorkshopId(long id) + { + return await _checkoutRepository.GetEmployeeSelectListByWorkshopId(id); + } #endregion diff --git a/CompanyManagment.Application/WorkshopAppliction.cs b/CompanyManagment.Application/WorkshopAppliction.cs index c2110263..5f7ab020 100644 --- a/CompanyManagment.Application/WorkshopAppliction.cs +++ b/CompanyManagment.Application/WorkshopAppliction.cs @@ -11,6 +11,7 @@ using Company.Domain.InstitutionContractAgg; using Company.Domain.LeftWorkAgg; using Company.Domain.LeftWorkInsuranceAgg; using Company.Domain.WorkshopAgg; +using CompanyManagment.App.Contracts.Checkout.Dto; using CompanyManagment.App.Contracts.Employee; using CompanyManagment.App.Contracts.EmployeeChildren; using CompanyManagment.App.Contracts.LeftWork; @@ -1130,5 +1131,17 @@ public class WorkshopAppliction : IWorkshopApplication return operation.Succcedded(); } + + + #endregion + + + #region ForApi + + public async Task> GetAdminWorkshopSelectList() + { + return await _workshopRepository.GetAdminWorkshopSelectList(); + } + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index 51f6b8c7..cc0041f9 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -2762,6 +2762,22 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos #region ForApi + public async Task> 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> GetList(CheckoutSearchModelDto searchModel) { var acountID = _authHelper.CurrentAccountId(); @@ -3236,5 +3252,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos Console.WriteLine("print : " + watch.Elapsed); return result; } + + + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/WorkshopRepository.cs b/CompanyManagment.EFCore/Repository/WorkshopRepository.cs index 30a06a9f..e19bdd73 100644 --- a/CompanyManagment.EFCore/Repository/WorkshopRepository.cs +++ b/CompanyManagment.EFCore/Repository/WorkshopRepository.cs @@ -1187,14 +1187,14 @@ public class WorkshopRepository : RepositoryBase !string.IsNullOrEmpty(x.ArchiveCode)) .Select(x => x.ArchiveCode) .ToList(); - + int maxArchiveCode = 0; - + foreach (var code in archiveCodes) { // Remove "b-" prefix if exists string cleanCode = code.StartsWith("b-") ? code.Substring(2) : code; - + // Try to parse the clean code to an integer if (int.TryParse(cleanCode, out int codeValue)) { @@ -1204,7 +1204,7 @@ public class WorkshopRepository : RepositoryBase x.StartWork).ToList(); } + + + + #endregion + + + #region ForApi + + public async Task> 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 } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs index 3056151b..0cf5f2a1 100644 --- a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs +++ b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs @@ -2,6 +2,8 @@ using CompanyManagment.App.Contracts.Checkout; using CompanyManagment.App.Contracts.Checkout.Dto; using CompanyManagment.App.Contracts.InstitutionPlan; +using CompanyManagment.App.Contracts.Workshop; +using CompanyManagment.App.Contracts.Workshop.DTOs; using Microsoft.AspNetCore.Mvc; using NuGet.Packaging.Signing; using ServiceHost.BaseControllers; @@ -11,10 +13,12 @@ namespace ServiceHost.Areas.Admin.Controllers; public class CheckoutController : AdminBaseController { private readonly ICheckoutApplication _checkoutApplication; + private readonly IWorkshopApplication _workshopApplication; - public CheckoutController(ICheckoutApplication checkoutApplication) + public CheckoutController(ICheckoutApplication checkoutApplication, IWorkshopApplication workshopApplication) { _checkoutApplication = checkoutApplication; + _workshopApplication = workshopApplication; } /// @@ -64,5 +68,31 @@ public class CheckoutController : AdminBaseController return result; } + + #region CreateCheckout + /// + /// سلکت لیست کارگاه + /// + /// + [HttpGet("WorkshopSelectList")] + public async Task> GetWorkshopSelectList() + { + var result =await _workshopApplication.GetAdminWorkshopSelectList(); + return result; + } + + /// + /// سلک لیست پرسنل + /// + /// + /// + [HttpGet("EmployeeSelectList")] + public async Task> GetEmployeeSelectListByWorkshopId(long workshopId) + { + var result = await _checkoutApplication.GetEmployeeSelectListByWorkshopId(workshopId); + return result; + } + #endregion + }