From bef21edf22cbe0856008bf120829ed4351fe70e4 Mon Sep 17 00:00:00 2001 From: gozareshgir Date: Mon, 26 Jan 2026 14:44:30 +0330 Subject: [PATCH] chnage GetContractAndIncluded --- .../GetContractAndIncludesDataToCreateDto.cs | 92 +++++++++++++++++- .../Checkout/ICheckoutApplication.cs | 2 +- .../Contract/ContractSeparationViewModel.cs | 2 + .../CheckoutApplication.cs | 38 ++++---- .../Repository/CheckoutRepository.cs | 96 +++++++++++++++++-- .../Admin/Controllers/CheckoutController.cs | 38 ++++++++ 6 files changed, 236 insertions(+), 32 deletions(-) diff --git a/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs b/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs index 8c916d79..6ee91430 100644 --- a/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs +++ b/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs @@ -1,6 +1,94 @@ -namespace CompanyManagment.App.Contracts.Checkout.Dto; +using CompanyManagment.App.Contracts.Contract; +using CompanyManagment.App.Contracts.EmployeeComputeOptions; +using CompanyManagment.App.Contracts.WorkingHoursTemp; +using System.Collections.Generic; + +namespace CompanyManagment.App.Contracts.Checkout.Dto; public class GetContractAndIncludesDataToCreateDto { - + + + /// + /// آی دی کارگاه + /// + public long WorkshopId { get; set; } + + /// + /// نام کارگاه + /// + public string WorkshopName { get; set; } + + + /// + /// کد بایگانی کارگاه + /// + public string ArchiveCode { get; set; } + + + + public List ContractIncludedData { get; set; } + +} + + +public class ContractIncludedData +{ + /// + /// شماره قرارداد + /// + public string ContractNo { get; set; } + + /// + /// آی دی پرسنل + /// + public long EmployeeId { get; set; } + /// + /// نام کامل پرسنل + /// + public string EmployeeFullName { get; set; } + + /// + /// نام پدر + /// + public string FathersName { get; set; } + + /// + /// کد ملی + /// + public string NationalCode { get; set; } + + /// + /// تاریخ تولد + /// + public string DateOfBirth { get; set; } + + + /// + /// کد پرسنلس + /// + public string PersonnelCode { get; set; } + + + /// + /// وضعیت تاهل + /// + + public string MaritalStatus { get; set; } + + + /// + /// ساعت کاری پرسنل + /// + public CreateWorkingHoursTemp WorkingHours { get; set; } + + /// + /// اطلاعات جداسازی تاریخ فیش + /// + public ContractSeparationViewModel Saparation { get; set; } + + /// + /// تنظیمات فنی پرسنل + /// + public EmployeeComputeOptionsViewModel EmployeeOption { 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 d10e24e1..e513875c 100644 --- a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs +++ b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs @@ -113,7 +113,7 @@ public interface ICheckoutApplication /// /// /// - Task CreateCheckoutApi(List ids, string year, string month, long workshopId); + Task> CreateCheckoutApi(List ids, string year, string month, long workshopId); #endregion } diff --git a/CompanyManagment.App.Contracts/Contract/ContractSeparationViewModel.cs b/CompanyManagment.App.Contracts/Contract/ContractSeparationViewModel.cs index b83f6b32..63175ca5 100644 --- a/CompanyManagment.App.Contracts/Contract/ContractSeparationViewModel.cs +++ b/CompanyManagment.App.Contracts/Contract/ContractSeparationViewModel.cs @@ -19,4 +19,6 @@ public class ContractSeparationViewModel public string ConsumableItems { get; set; } public bool checker { get; set; } public bool HasLeft { get; set; } + + public long EmployeeId { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index 54b68506..035aeeba 100644 --- a/CompanyManagment.Application/CheckoutApplication.cs +++ b/CompanyManagment.Application/CheckoutApplication.cs @@ -799,7 +799,7 @@ public class CheckoutApplication : ICheckoutApplication } - public async Task CreateCheckoutApi(List ids, string year, string month, long workshopId) + public async Task> CreateCheckoutApi(List ids, string year, string month, long workshopId) { var op = new OperationResult(); @@ -808,27 +808,27 @@ public class CheckoutApplication : ICheckoutApplication #region Validation - if (!string.IsNullOrWhiteSpace(year) && string.IsNullOrWhiteSpace(month)) - return op.Failed("ماه را انتخاب کنید"); - if (string.IsNullOrWhiteSpace(year) && !string.IsNullOrWhiteSpace(month)) - return op.Failed("سال را انتخاب کنید"); + //if (!string.IsNullOrWhiteSpace(year) && string.IsNullOrWhiteSpace(month)) + // return op.Failed("ماه را انتخاب کنید"); + //if (string.IsNullOrWhiteSpace(year) && !string.IsNullOrWhiteSpace(month)) + // return op.Failed("سال را انتخاب کنید"); - if (string.IsNullOrWhiteSpace(year) && string.IsNullOrWhiteSpace(month)) - { - year = "0"; - month = "0"; + //if (string.IsNullOrWhiteSpace(year) && string.IsNullOrWhiteSpace(month)) + //{ + // year = "0"; + // month = "0"; - var today = DateTime.Now; - var FaToday = today.ToFarsi(); - var convertedYear = FaToday.Substring(0, 4); - var convertedMonth = FaToday.Substring(5, 2); + // var today = DateTime.Now; + // var FaToday = today.ToFarsi(); + // var convertedYear = FaToday.Substring(0, 4); + // var convertedMonth = FaToday.Substring(5, 2); - year = convertedYear; - month = convertedMonth; - } + // year = convertedYear; + // month = convertedMonth; + //} - if (ids.Count == 0) - return op.Failed("هیچ موردی انتخاب نشده اشت"); + //if (ids.Count == 0) + // return op.Failed("هیچ موردی انتخاب نشده اشت"); #endregion @@ -841,7 +841,7 @@ public class CheckoutApplication : ICheckoutApplication var getContcatsData = await _checkoutRepository.GetContractsAndIncludeDataDataToCreateCheckout(ids, month, workshopId); - return op.Succcedded(); + return getContcatsData; } #endregion diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index 86a998fd..b9ca4e43 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -2922,6 +2922,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos var result = new CreateWorkingHoursTemp { + EmployeeId = getContracts.First(x=>x.id == workingHours.ContractId).EmployeeId, WorknigHoursId = workingHours.id, ShiftWork = "4", ShiftWorkTemp = "1", @@ -3271,6 +3272,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos { var result = new CreateWorkingHoursTemp { + EmployeeId = getContracts.First(x => x.id == workingHours.ContractId).EmployeeId, WorknigHoursId = workingHours.id, ShiftWork = workingHours.ShiftWork, ShiftWorkTemp = "4", @@ -3880,6 +3882,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos { var result = new CreateWorkingHoursTemp { + EmployeeId = getContracts.First(x => x.id == workingHours.ContractId).EmployeeId, WorknigHoursId = workingHours.id, ShiftWork = workingHours.ShiftWork, ShiftWorkTemp = "5", @@ -3930,7 +3933,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos { separation.Add(new ContractSeparationViewModel() { - checker = false + checker = false, + EmployeeId = item.EmployeeId }); } @@ -4001,6 +4005,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos ContractStartGr = startDate, ContractEndGr = endDate, checker = true, + EmployeeId = item.EmployeeId }); } @@ -4008,7 +4013,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos { separation.Add(new ContractSeparationViewModel() { - checker = false + checker = false, + EmployeeId = item.EmployeeId }); } @@ -4092,6 +4098,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos ContractStartGr = startDate, ContractEndGr = endDate, checker = true, + EmployeeId = item.EmployeeId }); } @@ -4099,7 +4106,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos { separation.Add(new ContractSeparationViewModel() { - checker = false + checker = false, + EmployeeId = item.EmployeeId }); } @@ -4109,7 +4117,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos separation.Add(new ContractSeparationViewModel() { - checker = false + checker = false, + EmployeeId = item.EmployeeId }); } @@ -4176,6 +4185,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos ContractEndGr = endDate, checker = true, LeftWorkDate = new DateTime(2121, 3, 21), + EmployeeId = item.EmployeeId }); @@ -4184,7 +4194,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos { separation.Add(new ContractSeparationViewModel() { - checker = false + checker = false, + EmployeeId = item.EmployeeId }); } @@ -4193,7 +4204,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos { separation.Add(new ContractSeparationViewModel() { - checker = false + checker = false, + EmployeeId = item.EmployeeId }); } @@ -4219,17 +4231,81 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos ComputeOptions = x.ComputeOptions, YearsOptions = x.YearsOptions, BonusesOptions = x.BonusesOptions, - }).AsNoTracking().ToListAsync(); #endregion + + var optionTime = optionTimer.Elapsed; + optionTimer.Stop(); + + + var toListTimer = new Stopwatch(); + toListTimer.Start(); + var incloudedData = getContracts.Select(x => + { + return new ContractIncludedData + { + ContractNo = x.ContractNo, + + + + //اطلاعات هویتی پرسنل + #region EmployeeData + EmployeeId = x.EmployeeId, + EmployeeFullName = x.Employee.FullName, + FathersName = x.Employee.FatherName, + NationalCode = x.Employee.NationalCode, + DateOfBirth = x.Employee.DateOfBirth.ToFarsi(), + PersonnelCode = $"{x.PersonnelCode}", + MaritalStatus = x.Employee.MaritalStatus, + #endregion + + //ساعت کاری پرسنل + #region WorkingHours + WorkingHours = workingHoursList.FirstOrDefault(wh => wh.EmployeeId == x.EmployeeId), + #endregion + + //اطلاعات جداسازی تاریخ فیش از قرارداد + #region Saparation + Saparation = separation.FirstOrDefault(sep => sep.EmployeeId == x.EmployeeId), + #endregion + + //تنظیمات فنی پرسنل + #region EmployeeOption + + EmployeeOption = employeeOptions.FirstOrDefault(option=> option.EmployeeId == x.EmployeeId) + + #endregion + + }; + }).ToList(); + + var finalResult = new GetContractAndIncludesDataToCreateDto() + { + //اطلاعات کارگاه + #region WorkshopData + + WorkshopId = workshop.id, + ArchiveCode = workshop.ArchiveCode, + WorkshopName = workshop.WorkshopName, + + #endregion + + + ContractIncludedData = incloudedData, + }; + + var tolistTime = toListTimer.Elapsed; Console.WriteLine("GetContracts - employeeIds - workshop: " + GetContractsTime); Console.WriteLine("workingHours " + workingHoursTime); Console.WriteLine("leftWork " + leftWorkTime); Console.WriteLine("Separation " + SeparationTime); - Console.WriteLine("EmployeeOptions : " + optionTimer.Elapsed); - Console.WriteLine("===================== sum : " + (GetContractsTime + workingHoursTime + leftWorkTime + SeparationTime + optionTimer.Elapsed) + "==================="); - return op.Succcedded(new GetContractAndIncludesDataToCreateDto()); + Console.WriteLine("EmployeeOptions : " + optionTime); + Console.WriteLine("TolistTime : " + tolistTime); + Console.WriteLine("===================== sum : " + (GetContractsTime + workingHoursTime + leftWorkTime + SeparationTime + optionTime + tolistTime) + "==================="); + + + return op.Succcedded(finalResult); } diff --git a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs index 67968610..a3bc805b 100644 --- a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs +++ b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs @@ -6,6 +6,7 @@ using CompanyManagment.App.Contracts.Workshop; using CompanyManagment.App.Contracts.Workshop.DTOs; using Microsoft.AspNetCore.Mvc; using NuGet.Packaging.Signing; +using NuGet.Protocol; using ServiceHost.BaseControllers; using WorkFlow.Application.Contracts.WorkFlow; @@ -122,6 +123,8 @@ public class CheckoutController : AdminBaseController #region testCreate var ids = result.Data.Where(x => x.CreateCheckoutStatus == CreateCheckoutStatus.ReadyToCreate).Select(x => x.Id).ToList(); + + Console.WriteLine(ids.ToJson()); var test = await _checkoutApplication.CreateCheckoutApi(ids, year, month,workshopId); #endregion @@ -129,6 +132,41 @@ public class CheckoutController : AdminBaseController return result; } + + [HttpPost] + public async Task> CreateCheckout() + { + var ids = new + List() + { + 283652, 290314, 290315, 290316, 290317, 290318, 290319, 290320, 290321, 290322, 290323, 290324, 290325, + 290326, 290327, 290328, 290329, 290330, 290331, 290332, 290333, 290334, 290335, 290336, 290337, 290338, + 290339, 290340, 290341, 290342, 290343, 290344, 290345, 290346, 290347, 290348, 290349, 290350, 290351, + 290352, 290353, 290354, 290355, 290356, 290357, 290358, 290359, 290360, 290361, 290362, 290363, 290364, + 290365, 290366, 290367, 290368, 290369, 290370, 290371, 290372, 290373, 290374, 290375, 290376, 290377, + 290378, 290379, 290380, 290381, 290382, 290383, 290384, 290385, 290386, 290387, 290388, 290389, 290390, + 290391, 290392, 290393, 290394, 290395, 290396, 290397, 290398, 290399, 290400, 290401, 290402, 290403, + 290404, 290405, 290406, 290407, 290408, 290409, 290410, 290411, 290412, 290413, 290414, 290415, 290416, + 290417, 290418, 290419, 290420, 290421, 290422, 290423, 290424, 290425, 290426, 290427, 290428, 290429, + 290430, 290431, 290432, 290433, 290434, 290435, 290436, 290437, 290438, 290439, 290440, 290441, 290442, + 290443, 290444, 290445, 290446, 290447, 290448, 290449, 290450, 290451, 290452, 290453, 290454, 290455, + 290456, 290457, 290458, 290459, 290460, 290461, 290462, 290463, 290464, 290465, 290466, 290467, 290468, + 290469, 290470, 290471, 290472, 290473, 290474, 290475, 290476, 290477, 290478, 290479, 290480, 290481, + 290482, 290483, 290484, 290485, 290486, 290487, 290488, 290489, 290490, 290491, 290492, 290493, 290494, + 290495, 290496, 290497, 290498, 290499, 290500, 290501, 290502, 290503, 290504, 290505, 290506, 290507, + 290508, 290509, 290510, 290511, 290512, 290513, 290514, 290515, 290516, 290517, 290518, 290519, 290520, + 290521, 290522, 290523, 290524, 290525, 290526, 290527, 290528, 290529, 290530, 290531, 290532, 290533, + 290534, 290535, 290536, 290537, 290538, 290539, 290540, 290541, 290542, 290543, 290544, 290545, 290546, + 290547, 290548, 290549, 290550, 290551, 290552, 290553, 290554, 290555, 290556, 290557, 290558, 290559, + 290560, 290561, 290562, 290563, 290564, 290565, 290566, 290567, 290568, 290569, 290570, 290571, 290572, + 290573, 290574, 290575, 290576, 290577, 290578, 290579, 290580, 290581, 290582, 290583, 290584, 290585, + 290586, 290587, 290588 + }; + + + var test = await _checkoutApplication.CreateCheckoutApi(ids, "1404", "10", 499); + return test; + } #endregion }