feat: integrate workshop repository for roll call workflows

This commit is contained in:
2025-10-28 12:31:08 +03:30
parent 8134216a4a
commit c7bace728e

View File

@@ -1,6 +1,7 @@
using _0_Framework.Application;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using Company.Domain.RollCallAgg.DomainService;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.EmployeeDocuments;
using WorkFlow.Application.Contracts.RollCallConfirmedAbsence;
using WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak;
@@ -23,7 +24,9 @@ public class WorkFlowApplication : IWorkFlowApplication
private readonly IRollCallDomainService _rollCallDomainService;
private readonly IRollCallConfirmedWithoutLunchBreakRepository _rollCallConfirmedWithoutLunchBreakRepository;
private readonly IEmployeeDocumentsApplication _employeeDocumentsApplication;
public WorkFlowApplication(IRollCallConfirmedAbsenceRepository absenceRepository, IWorkFlowRollCallACL rollCallACL, IWorkFlowCheckoutACL checkoutACL, IWorkFlowCustomizedWorkshopSettingsACL customizedWorkshopSettingsACL, IRollCallConfirmedWithoutLunchBreakRepository rollCallConfirmedWithoutLunchBreakRepository, IRollCallDomainService rollCallDomainService, IEmployeeDocumentsApplication employeeDocumentsApplication)
private readonly IWorkshopRepository _workshopRepository;
public WorkFlowApplication(IRollCallConfirmedAbsenceRepository absenceRepository, IWorkFlowRollCallACL rollCallACL, IWorkFlowCheckoutACL checkoutACL, IWorkFlowCustomizedWorkshopSettingsACL customizedWorkshopSettingsACL, IRollCallConfirmedWithoutLunchBreakRepository rollCallConfirmedWithoutLunchBreakRepository, IRollCallDomainService rollCallDomainService, IEmployeeDocumentsApplication employeeDocumentsApplication, IWorkshopRepository workshopRepository)
{
_absenceRepository = absenceRepository;
_rollCallACL = rollCallACL;
@@ -32,6 +35,7 @@ public class WorkFlowApplication : IWorkFlowApplication
_rollCallConfirmedWithoutLunchBreakRepository = rollCallConfirmedWithoutLunchBreakRepository;
_rollCallDomainService = rollCallDomainService;
_employeeDocumentsApplication = employeeDocumentsApplication;
_workshopRepository = workshopRepository;
}
public async Task<OperationResult> CreateRollCallConfirmedAbsence(CreateRollCallConfirmedAbsence command)
@@ -416,6 +420,10 @@ public class WorkFlowApplication : IWorkFlowApplication
/// </summary>
public async Task<List<DailyRollCallWorkFlowViewModel>> GetUndefinedRollCalls(long workshopId)
{
var workshop = _workshopRepository.Get(workshopId);
if (workshop == null || workshop.IsStaticCheckout)
return [];
var now = DateTime.Now;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
@@ -443,6 +451,10 @@ public class WorkFlowApplication : IWorkFlowApplication
/// </summary>
public async Task<List<DailyRollCallWorkFlowViewModel>> GetRollCallWorkFlowsCutByBgService(long workshopId)
{
var workshop = _workshopRepository.Get(workshopId);
if (workshop == null || workshop.IsStaticCheckout)
return [];
var now = DateTime.Now;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
@@ -468,6 +480,11 @@ public class WorkFlowApplication : IWorkFlowApplication
public async Task<int> CountCutByBgServiceLastMonth(long workshopId)
{
var workshop = _workshopRepository.Get(workshopId);
if (workshop == null || workshop.IsStaticCheckout)
return 0;
DateTime lastMonthEnd = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1);
var now = lastMonthEnd;
var twoMonthsAgo = ($"{lastMonthEnd.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime();
@@ -496,7 +513,11 @@ public class WorkFlowApplication : IWorkFlowApplication
/// </summary>
public async Task<int> CountAbsentRollCallLastMonth(long workshopId)
{
var workshop = _workshopRepository.Get(workshopId);
if (workshop == null || workshop.IsStaticCheckout)
return 0;
DateTime lastMonthEnd = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1);
var now = lastMonthEnd;
var twoMonthsAgo = ($"{lastMonthEnd.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime();
@@ -558,6 +579,11 @@ public class WorkFlowApplication : IWorkFlowApplication
public async Task<int> CountEmployeesWithoutLunchBreakLastMonth(long workshopId)
{
var workshop = _workshopRepository.Get(workshopId);
if (workshop == null || workshop.IsStaticCheckout)
return 0;
DateTime lastMonthEnd = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1);
var now = lastMonthEnd;
var twoMonthsAgo = ($"{lastMonthEnd.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime();
@@ -596,6 +622,11 @@ public class WorkFlowApplication : IWorkFlowApplication
public async Task<int> CountUndefinedLastMonth(long workshopId)
{
var workshop = _workshopRepository.Get(workshopId);
if (workshop == null || workshop.IsStaticCheckout)
return 0;
DateTime lastMonthEnd = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1);
var now = lastMonthEnd;
var twoMonthsAgo = ($"{lastMonthEnd.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime();
@@ -625,7 +656,10 @@ public class WorkFlowApplication : IWorkFlowApplication
/// </summary>
public async Task<List<DailyRollCallWorkFlowViewModel>> GetAbsentRollCallWorkFlows(long workshopId)
{
var workshop = _workshopRepository.Get(workshopId);
if (workshop == null || workshop.IsStaticCheckout)
return [];
var now = DateTime.Now;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
@@ -689,6 +723,10 @@ public class WorkFlowApplication : IWorkFlowApplication
/// </summary>
public async Task<List<DailyRollCallConfirmedWithoutLunchBreakViewModel>> GetEmployeesWithoutLunchBreak(long workshopId)
{
var workshop = _workshopRepository.Get(workshopId);
if (workshop == null || workshop.IsStaticCheckout)
return [];
var now = DateTime.Now.Date;
now.AddMonthsFa(-2, out var twoMonthsAgo);