From 38603b22496dafe807fa183134f21bf30cce37a1 Mon Sep 17 00:00:00 2001 From: gozareshgir Date: Sun, 18 Jan 2026 18:54:33 +0330 Subject: [PATCH 1/3] rotatingshift init --- .../Dto/RotatingShiftOfCheckoutDto.cs | 75 +++++++++++++ .../Checkout/ICheckoutApplication.cs | 12 +++ .../CheckoutApplication.cs | 101 ++++++++++++++---- .../Repository/CheckoutRepository.cs | 50 +-------- .../Repository/RollCallMandatoryRepository.cs | 2 +- 5 files changed, 173 insertions(+), 67 deletions(-) create mode 100644 CompanyManagment.App.Contracts/Checkout/Dto/RotatingShiftOfCheckoutDto.cs diff --git a/CompanyManagment.App.Contracts/Checkout/Dto/RotatingShiftOfCheckoutDto.cs b/CompanyManagment.App.Contracts/Checkout/Dto/RotatingShiftOfCheckoutDto.cs new file mode 100644 index 00000000..281bd662 --- /dev/null +++ b/CompanyManagment.App.Contracts/Checkout/Dto/RotatingShiftOfCheckoutDto.cs @@ -0,0 +1,75 @@ +using System.Collections.Generic; + +namespace CompanyManagment.App.Contracts.Checkout.Dto; + +public class RotatingShiftOfCheckoutDto +{ + /// + /// نام پرسنل + /// + public string FullName { get; set; } + + /// + /// وضعیت نوبتکاری + /// + public string RotatingShiftStatus { get; set; } + + /// + /// آیا نوبت کاری دارد + /// + public bool HasRotatingShift { get; set; } + + /// + /// سال و ماه + /// + public string YearAndMonth { get; set; } + + + /// + /// نوع ساعت کاری + /// + public string TypeOfWorkingHours { get; set; } + + /// + /// لیست نوبت کاری + /// + public List RotatingShiftList { get; set; } +} + +public class RotatingShiftListDto +{ + /// + /// بازه کاری صبح + /// + public string MorningShiftSpan { get; set; } + + /// + /// بازه کاری عصر + /// + public string EveningShiftSpan { get; set; } + + /// + /// بازه کاری شب + /// + public string NightShiftSpan { get; set; } + + + /// + /// آیا صبح کاری داشته + /// + public bool IsMorningShift { get; set; } + + /// + /// آیا عصرکاری داشته + /// + public bool IsEveningShift { get; set; } + + /// + /// آیا شبکاری داشته + /// + public bool IsNightShift { get; set; } + /// + /// تاریخ شیفت + /// + public string ShiftDate { 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 e06f76c7..fde532f6 100644 --- a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs +++ b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs @@ -67,7 +67,19 @@ public interface ICheckoutApplication #region ForApi + /// + /// دریافت لیست فیش های حقوقی ادمین + /// + /// + /// Task> GetList(CheckoutSearchModelDto searchModel); + /// + /// دریافت نوبتکاری + /// + /// + /// + Task GetRotatingShift(long id); + #endregion } \ No newline at end of file diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index e5853920..5b171b36 100644 --- a/CompanyManagment.Application/CheckoutApplication.cs +++ b/CompanyManagment.Application/CheckoutApplication.cs @@ -1,29 +1,34 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Threading.Tasks; -using _0_Framework.Application; +using _0_Framework.Application; +using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects; using Company.Domain.CheckoutAgg; using Company.Domain.CheckoutAgg.ValueObjects; -using Company.Domain.LeftWorkAgg; -using Company.Domain.YearlySalaryAgg; +using Company.Domain.EmployeeAgg; using Company.Domain.empolyerAgg; +using Company.Domain.LeaveAgg; +using Company.Domain.LeftWorkAgg; using Company.Domain.RollCallAgg; +using Company.Domain.WorkingHoursTempAgg; +using Company.Domain.WorkshopAgg; +using Company.Domain.YearlySalaryAgg; using CompanyManagment.App.Contracts.Checkout; -using CompanyManagment.App.Contracts.PersonalContractingParty; +using CompanyManagment.App.Contracts.Checkout.Dto; +using CompanyManagment.App.Contracts.Contract; +using CompanyManagment.App.Contracts.HolidayItem; using CompanyManagment.App.Contracts.Leave; using CompanyManagment.App.Contracts.MandantoryHours; -using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects; -using Company.Domain.EmployeeAgg; -using CompanyManagment.App.Contracts.HolidayItem; +using CompanyManagment.App.Contracts.PersonalContractingParty; using CompanyManagment.App.Contracts.RollCall; +using CompanyManagment.App.Contracts.WorkingHoursTemp; +using CompanyManagment.App.Contracts.Workshop; using CompanyManagment.EFCore.Migrations; using CompanyManagment.EFCore.Repository; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Globalization; -using Company.Domain.LeaveAgg; -using Company.Domain.WorkshopAgg; -using CompanyManagment.App.Contracts.Checkout.Dto; +using System.Linq; +using System.Threading.Tasks; + namespace CompanyManagment.Application; @@ -39,11 +44,14 @@ public class CheckoutApplication : ICheckoutApplication private readonly IRollCallMandatoryRepository _rollCallMandatoryRepository; private readonly IRollCallRepository _rollCallRepository; private readonly IHolidayItemApplication _holidayItemApplication; + private readonly IWorkingHoursTempRepository _workingHoursTempRepository; + private readonly IWorkshopRepository _workshopRepository; - public CheckoutApplication(ICheckoutRepository checkoutRepository, IYearlySalaryRepository yearlySalaryRepository, + + public CheckoutApplication(ICheckoutRepository checkoutRepository, IYearlySalaryRepository yearlySalaryRepository, ILeftWorkRepository leftWorkRepository, - IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository, IHolidayItemApplication holidayItemApplication) + IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository, IHolidayItemApplication holidayItemApplication, IWorkingHoursTempRepository workingHoursTempRepository, IWorkshopRepository workshopRepository) { _checkoutRepository = checkoutRepository; _yearlySalaryRepository = yearlySalaryRepository; @@ -55,7 +63,9 @@ public class CheckoutApplication : ICheckoutApplication _rollCallMandatoryRepository = rollCallMandatoryRepository; _rollCallRepository = rollCallRepository; _holidayItemApplication = holidayItemApplication; - } + _workingHoursTempRepository = workingHoursTempRepository; + _workshopRepository = workshopRepository; + } [SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", MessageId = "count: 241")] public void Create(CreateCheckout command) @@ -720,5 +730,60 @@ public class CheckoutApplication : ICheckoutApplication return await _checkoutRepository.GetList(searchModel); } + + public async Task GetRotatingShift(long id) + { + var checkout = GetDetails(id); + var workingHours = _workingHoursTempRepository.GetByContractIdConvertToShiftwork4(checkout.ContractId); + + if (checkout.HasRollCall) + { + var result = await _rollCallMandatoryRepository.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId, checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork, true, workingHours, false); + var items = result.RotatingResultList.Select(x => new RotatingShiftListDto() + { + MorningShiftSpan = x.MorningString, + EveningShiftSpan = x.EveningString, + NightShiftSpan = x.NightString, + + IsMorningShift = x.IsMorningShift, + IsEveningShift = x.IsEveningShift, + IsNightShift = x.IsNightShift, + + ShiftDate = x.RotatingDate + }).ToList(); + return new RotatingShiftOfCheckoutDto() + { + FullName = checkout.EmployeeFullName, + YearAndMonth = $"{checkout.Month} {checkout.Year}", + HasRotatingShift = result.RotatingStatus == "نوبت کاری ندارد", + RotatingShiftStatus = result.RotatingStatus, + TypeOfWorkingHours = "دارای حضورغیاب", + RotatingShiftList = items + }; + } + else + { + var ConvertYear = checkout.ContractStart.Substring(0, 4); + var ConvertMonth = checkout.ContractStart.Substring(5, 2); + + //var contract = _contractApplication.GetDetails(checkout.ContractId); + var workshop = _workshopRepository.GetDetails(checkout.WorkshopId); + //var separation = _contractApplication.contractSeparation(ConvertYear, ConvertMonth, + // contract.ContractStartGr, contract.ContractEndGr, contract.EmployeeId, contract.WorkshopIds); + //workingHours.ContractStartGr = separation.ContractStartGr; + //workingHours.ContractEndGr = separation.ContractEndGr; + //workingHours.ContarctStart = separation.ContarctStart; + //workingHours.ContractEnd = separation.ContractEnd; + //workingHours.GetWorkDate = contract.GetWorkDate; + //workingHours.GetWorkDateHide = contract.GetWorkDate; + //workingHours.WorkshopId = contract.WorkshopIds; + //workingHours.EmployeeId = contract.EmployeeId; + + var result = await _rollCallMandatoryRepository.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId, checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork, false, workingHours, workshop.WorkshopHolidayWorking); + } + + + return new RotatingShiftOfCheckoutDto(); + } #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index 87871b5b..1e56389a 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -2769,48 +2769,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos .Select(x => x.WorkshopId); - //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 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 = @@ -2818,12 +2777,6 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos 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, @@ -2852,6 +2805,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos .ThenBy(x => x.PersonnelCode).AsNoTracking(); Console.WriteLine("getList======================= : " + watch.Elapsed); + #region SercheModel if (!string.IsNullOrWhiteSpace(searchModel.ContractNo)) diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 904ce85f..2bc69ffe 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -1604,7 +1604,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll bool workshopHolidyWorking) { var rollCallList = new List(); - + #region Entities var sdate = command.ContarctStart.ToEnglishNumber(); From 21302803b6e3db426d381d1d06c93a4e10e7eba5 Mon Sep 17 00:00:00 2001 From: gozareshgir Date: Mon, 19 Jan 2026 12:32:51 +0330 Subject: [PATCH 2/3] insurance WorkingDays bug Fixed --- CompanyManagment.Application/InsuranceListApplication.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CompanyManagment.Application/InsuranceListApplication.cs b/CompanyManagment.Application/InsuranceListApplication.cs index d0fbb990..47697d80 100644 --- a/CompanyManagment.Application/InsuranceListApplication.cs +++ b/CompanyManagment.Application/InsuranceListApplication.cs @@ -1524,7 +1524,8 @@ public class InsuranceListApplication : IInsuranceListApplication var dateOfBirth = employeeData.DateOfBirthGr.ToFarsi(); var dateOfIssue = employeeData.DateOfIssueGr.ToFarsi(); var leftDate = employeeData.LeftWorkDateGr != null ? employeeData.LeftWorkDateGr.Value.AddDays(-1) : new DateTime(); - var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employeeData.StartWorkDateGr, leftDate, startDateGr, endDateGr, employeeData.EmployeeId); + + var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employeeData.StartWorkDateGr, leftDate, startDateGr, endDateGr, employeeData.EmployeeId); var leftWorkFa = workingDays.hasLeftWorkInMonth ? employeeData.LeftWorkDateGr.ToFarsi() : ""; var startWorkFa = employeeData.StartWorkDateGr.ToFarsi(); var workshop = _workShopRepository.GetDetails(workshopId); @@ -1606,7 +1607,7 @@ public class InsuranceListApplication : IInsuranceListApplication MaritalStatus = employeeData.MaritalStatus, StartMonthCurrent = startMonthFa, - WorkingDays = workingDays.countWorkingDays, + WorkingDays = employeeData.WorkingDays, StartWorkDate = startWorkFa, StartWorkDateGr = employeeData.StartWorkDateGr, LeftWorkDate = leftWorkFa, From 4463fdc1772cc27fed0bae364a6927be4ae1cd29 Mon Sep 17 00:00:00 2001 From: gozareshgir Date: Mon, 19 Jan 2026 13:41:36 +0330 Subject: [PATCH 3/3] Rotating Shift api completed --- .../Checkout/ICheckoutApplication.cs | 2 +- .../CheckoutApplication.cs | 69 ++++++++----------- .../Repository/RollCallMandatoryRepository.cs | 5 ++ .../Admin/Controllers/CheckoutController.cs | 15 +++- 4 files changed, 48 insertions(+), 43 deletions(-) diff --git a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs index fde532f6..cdc831af 100644 --- a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs +++ b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs @@ -79,7 +79,7 @@ public interface ICheckoutApplication /// /// /// - Task GetRotatingShift(long id); + Task GetRotatingShiftApi(long id); #endregion } \ No newline at end of file diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index 5b171b36..1681fe34 100644 --- a/CompanyManagment.Application/CheckoutApplication.cs +++ b/CompanyManagment.Application/CheckoutApplication.cs @@ -731,59 +731,46 @@ public class CheckoutApplication : ICheckoutApplication } - public async Task GetRotatingShift(long id) + public async Task GetRotatingShiftApi(long id) { + var result = new ComputingViewModel(); var checkout = GetDetails(id); var workingHours = _workingHoursTempRepository.GetByContractIdConvertToShiftwork4(checkout.ContractId); - + var typeOfWorkingHours = ""; if (checkout.HasRollCall) { - var result = await _rollCallMandatoryRepository.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId, checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork, true, workingHours, false); - var items = result.RotatingResultList.Select(x => new RotatingShiftListDto() - { - MorningShiftSpan = x.MorningString, - EveningShiftSpan = x.EveningString, - NightShiftSpan = x.NightString, + result = await _rollCallMandatoryRepository.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId, checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork, true, workingHours, false); + typeOfWorkingHours = "دارای حضورغیاب"; - IsMorningShift = x.IsMorningShift, - IsEveningShift = x.IsEveningShift, - IsNightShift = x.IsNightShift, - - ShiftDate = x.RotatingDate - }).ToList(); - return new RotatingShiftOfCheckoutDto() - { - FullName = checkout.EmployeeFullName, - YearAndMonth = $"{checkout.Month} {checkout.Year}", - HasRotatingShift = result.RotatingStatus == "نوبت کاری ندارد", - RotatingShiftStatus = result.RotatingStatus, - TypeOfWorkingHours = "دارای حضورغیاب", - RotatingShiftList = items - }; } else { - var ConvertYear = checkout.ContractStart.Substring(0, 4); - var ConvertMonth = checkout.ContractStart.Substring(5, 2); - - //var contract = _contractApplication.GetDetails(checkout.ContractId); - var workshop = _workshopRepository.GetDetails(checkout.WorkshopId); - //var separation = _contractApplication.contractSeparation(ConvertYear, ConvertMonth, - // contract.ContractStartGr, contract.ContractEndGr, contract.EmployeeId, contract.WorkshopIds); - //workingHours.ContractStartGr = separation.ContractStartGr; - //workingHours.ContractEndGr = separation.ContractEndGr; - //workingHours.ContarctStart = separation.ContarctStart; - //workingHours.ContractEnd = separation.ContractEnd; - //workingHours.GetWorkDate = contract.GetWorkDate; - //workingHours.GetWorkDateHide = contract.GetWorkDate; - //workingHours.WorkshopId = contract.WorkshopIds; - //workingHours.EmployeeId = contract.EmployeeId; - - var result = await _rollCallMandatoryRepository.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId, checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork, false, workingHours, workshop.WorkshopHolidayWorking); + var workshop = _workshopRepository.GetDetails(checkout.WorkshopId); + result = await _rollCallMandatoryRepository.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId, checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork, false, workingHours, workshop.WorkshopHolidayWorking); + typeOfWorkingHours = "بدون حضورغیاب"; } + var items = result.RotatingResultList.Select(x => new RotatingShiftListDto() + { + MorningShiftSpan = x.MorningString, + EveningShiftSpan = x.EveningString, + NightShiftSpan = x.NightString, - return new RotatingShiftOfCheckoutDto(); + IsMorningShift = x.IsMorningShift, + IsEveningShift = x.IsEveningShift, + IsNightShift = x.IsNightShift, + + ShiftDate = x.RotatingDate + }).ToList(); + return new RotatingShiftOfCheckoutDto() + { + FullName = checkout.EmployeeFullName, + YearAndMonth = $"{checkout.Month} {checkout.Year}", + HasRotatingShift = result.RotatingStatus != "نوبت کاری ندارد", + RotatingShiftStatus = result.RotatingStatus, + TypeOfWorkingHours = typeOfWorkingHours, + RotatingShiftList = items + }; } #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 2bc69ffe..ebd90777 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -1607,6 +1607,11 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll #region Entities + if (string.IsNullOrWhiteSpace(command.ContarctStart) || string.IsNullOrWhiteSpace(command.ContractEnd)) + { + command.ContarctStart = command.ContractStartGr.ToFarsi(); + command.ContractEnd = command.ContractEndGr.ToFarsi(); + } var sdate = command.ContarctStart.ToEnglishNumber(); var edate = command.ContractEnd.ToEnglishNumber(); var syear = Convert.ToInt32(sdate.Substring(0, 4)); diff --git a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs index b8ef27ba..8f3df3e9 100644 --- a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs +++ b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs @@ -21,10 +21,23 @@ public class CheckoutController : AdminBaseController /// /// /// - [HttpGet("GetList")] + [HttpGet] public async Task>> GetList(CheckoutSearchModelDto searchModel) { return await _checkoutApplication.GetList(searchModel); } + + /// + /// دریافت نوبت کاری + /// + /// + /// + [HttpGet("RotatingShift")] + public async Task GetRotatingShift(long id) + { + var result =await _checkoutApplication.GetRotatingShiftApi(id); + return result; + } + }