fix sum absent and late day
Some checks failed
release-dev / release-dev (push) Failing after 12s

This commit is contained in:
AdisakKanthawilang 2025-02-19 13:36:58 +07:00
parent 9e513d3f1a
commit 8c530d9769

View file

@ -16,6 +16,7 @@ using Swashbuckle.AspNetCore.Annotations;
using System.Globalization;
using System.Security.Claims;
using BMA.EHR.Application.Responses.Profiles;
using Microsoft.OpenApi.Any;
namespace BMA.EHR.Leave.Service.Controllers
{
@ -807,16 +808,13 @@ namespace BMA.EHR.Leave.Service.Controllers
var therapyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-011");
var therapyDayCount = therapyDay != null ? therapyDay.SumLeaveDay : 0;
var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.Keycloak ?? Guid.Empty,
req.StartDate,
req.EndDate);
var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.Keycloak ?? Guid.Empty,req.StartDate,req.EndDate);
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
if (defaultRound == null)
{
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
}
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
@ -824,7 +822,7 @@ namespace BMA.EHR.Leave.Service.Controllers
var duty = userRound ?? defaultRound;
var processTimeStamps = timeStamps
/* var processTimeStamps = timeStamps
.Select(d => new
{
d.Id,
@ -840,10 +838,16 @@ namespace BMA.EHR.Leave.Service.Controllers
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
"ABSENT" :
"NORMAL",
});
});*/
/*var absentCount = processTimeStamps.Count(x => x.CheckOutStatus == "ABSENT");
var lateCount = processTimeStamps.Count(x => x.CheckInStatus == "LATE");*/
var absentCount = timeStamps.Count(d =>
d.CheckOutStatus == "ABSENT"); // นับจำนวนที่มี CheckOutStatus == "ABSENT"
var lateCount = timeStamps.Count(d =>
d.CheckInStatus == "LATE"); // นับจำนวนที่มี CheckInStatus == "LATE"
var absentCount = processTimeStamps.Count(x => x.CheckOutStatus == "ABSENT");
var lateCount = processTimeStamps.Count(x => x.CheckInStatus == "LATE");
var emp = new
{