From 221f700722d9ef5e426b07dce0d7a146ab6d02ea Mon Sep 17 00:00:00 2001 From: moss <> Date: Tue, 8 Apr 2025 17:03:33 +0700 Subject: [PATCH] report leave --- .../Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs | 4 +++- BMA.EHR.Leave/Controllers/LeaveReportController.cs | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs index ee897d88..17d07e75 100644 --- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs @@ -139,7 +139,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants return data; } - public async Task> GetTimestampByDateLateAsync(string type, string role, string nodeId, int node) + public async Task> GetTimestampByDateLateAsync(string type, string role, string nodeId, int node, DateTime StartDate, DateTime EndDate) { var _nodeId = Guid.Parse(nodeId); var data = new List(); @@ -147,6 +147,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants { data = await _dbContext.Set().AsQueryable() .Where(x => x.CheckInStatus == "LATE") + .Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate) .Where(x => x.ProfileType == type.Trim().ToUpper()) .Where(x => node == 4 ? x.Child4Id == _nodeId : (node == 3 ? x.Child3Id == _nodeId : (node == 2 ? x.Child2Id == _nodeId : (node == 1 ? x.Child1Id == _nodeId : (node == 0 ? x.RootId == _nodeId : true))))) .ToListAsync(); @@ -155,6 +156,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants { data = await _dbContext.Set().AsQueryable() .Where(x => x.CheckInStatus == "LATE") + .Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate) .Where(x => x.ProfileType == type.Trim().ToUpper()) .Where(x => node == 4 ? x.Child4Id == _nodeId : (node == 3 ? x.Child3Id == _nodeId : (node == 2 ? x.Child2Id == _nodeId : (node == 1 ? x.Child1Id == _nodeId : (node == 0 ? x.RootId == _nodeId : true))))) .Where(x => node == 0 ? x.Child1Id == null : (node == 1 ? x.Child2Id == null : (node == 2 ? x.Child3Id == null : (node == 3 ? x.Child4Id == null : true)))) diff --git a/BMA.EHR.Leave/Controllers/LeaveReportController.cs b/BMA.EHR.Leave/Controllers/LeaveReportController.cs index cf530522..1f00526f 100644 --- a/BMA.EHR.Leave/Controllers/LeaveReportController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveReportController.cs @@ -197,7 +197,7 @@ namespace BMA.EHR.Leave.Service.Controllers // approver = list.First().Name; //} - + return new { @@ -1357,7 +1357,7 @@ namespace BMA.EHR.Leave.Service.Controllers count++; } } - employees = employees.OrderBy(x => x.checkInTimeRaw ?? DateTime.MaxValue).ThenBy(x => x.checkOutTimeRaw ?? DateTime.MaxValue).ToList(); + employees = employees.OrderBy(x => x.checkInDate).ThenBy(x => x.checkInTimeRaw ?? DateTime.MaxValue).ThenBy(x => x.checkOutTimeRaw ?? DateTime.MaxValue).ToList(); for (int i = 0; i < employees.Count; i++) { employees[i].no = i + 1; @@ -1421,7 +1421,7 @@ namespace BMA.EHR.Leave.Service.Controllers var employees = new List(); var count = 1; - var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper(), jsonData["result"]?.ToString(), req.nodeId, req.node); + var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper(), jsonData["result"]?.ToString(), req.nodeId, req.node, req.StartDate, req.EndDate); foreach (var p in userTimeStamps) { var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}";