rotatingshift init

This commit is contained in:
gozareshgir
2026-01-18 18:54:33 +03:30
parent bf03247f81
commit 38603b2249
5 changed files with 173 additions and 67 deletions

View File

@@ -0,0 +1,75 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.Checkout.Dto;
public class RotatingShiftOfCheckoutDto
{
/// <summary>
/// نام پرسنل
/// </summary>
public string FullName { get; set; }
/// <summary>
/// وضعیت نوبتکاری
/// </summary>
public string RotatingShiftStatus { get; set; }
/// <summary>
/// آیا نوبت کاری دارد
/// </summary>
public bool HasRotatingShift { get; set; }
/// <summary>
/// سال و ماه
/// </summary>
public string YearAndMonth { get; set; }
/// <summary>
/// نوع ساعت کاری
/// </summary>
public string TypeOfWorkingHours { get; set; }
/// <summary>
/// لیست نوبت کاری
/// </summary>
public List<RotatingShiftListDto> RotatingShiftList { get; set; }
}
public class RotatingShiftListDto
{
/// <summary>
/// بازه کاری صبح
/// </summary>
public string MorningShiftSpan { get; set; }
/// <summary>
/// بازه کاری عصر
/// </summary>
public string EveningShiftSpan { get; set; }
/// <summary>
/// بازه کاری شب
/// </summary>
public string NightShiftSpan { get; set; }
/// <summary>
/// آیا صبح کاری داشته
/// </summary>
public bool IsMorningShift { get; set; }
/// <summary>
/// آیا عصرکاری داشته
/// </summary>
public bool IsEveningShift { get; set; }
/// <summary>
/// آیا شبکاری داشته
/// </summary>
public bool IsNightShift { get; set; }
/// <summary>
/// تاریخ شیفت
/// </summary>
public string ShiftDate { get; set; }
}

View File

@@ -67,7 +67,19 @@ public interface ICheckoutApplication
#region ForApi
/// <summary>
/// دریافت لیست فیش های حقوقی ادمین
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<PagedResult<CheckoutDto>> GetList(CheckoutSearchModelDto searchModel);
/// <summary>
/// دریافت نوبتکاری
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<RotatingShiftOfCheckoutDto> GetRotatingShift(long id);
#endregion
}

View File

@@ -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<RotatingShiftOfCheckoutDto> 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
}

View File

@@ -2769,48 +2769,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, 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<long, Checkout>, 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<long, Checkout>, ICheckoutRepos
.ThenBy(x => x.PersonnelCode).AsNoTracking();
Console.WriteLine("getList======================= : " + watch.Elapsed);
#region SercheModel
if (!string.IsNullOrWhiteSpace(searchModel.ContractNo))

View File

@@ -1604,7 +1604,7 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
bool workshopHolidyWorking)
{
var rollCallList = new List<RollCallViewModel>();
#region Entities
var sdate = command.ContarctStart.ToEnglishNumber();