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 5d3c861c..828c631d 100644 --- a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs +++ b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs @@ -69,8 +69,20 @@ public interface ICheckoutApplication #region ForApi + /// + /// دریافت لیست فیش های حقوقی ادمین + /// + /// + /// Task> GetList(CheckoutSearchModelDto searchModel); + /// + /// دریافت نوبتکاری + /// + /// + /// + Task GetRotatingShiftApi(long id); + #endregion } diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index 501291ca..0e68c173 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) @@ -726,5 +736,47 @@ public class CheckoutApplication : ICheckoutApplication return await _checkoutRepository.GetList(searchModel); } + + 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) + { + result = await _rollCallMandatoryRepository.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId, checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork, true, workingHours, false); + typeOfWorkingHours = "دارای حضورغیاب"; + + } + else + { + 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, + + 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.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, diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index b4619895..4abe4c9d 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -2827,48 +2827,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 = @@ -2876,12 +2835,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, @@ -2910,6 +2863,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..ebd90777 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -1604,9 +1604,14 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll bool workshopHolidyWorking) { var rollCallList = new List(); - + #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; + } + }