fix : API ลงเวลา
This commit is contained in:
parent
2ae1b13440
commit
6b89316ab6
1 changed files with 26 additions and 12 deletions
|
|
@ -2,6 +2,7 @@
|
|||
using BMA.EHR.Application.Repositories.Commands;
|
||||
using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
|
||||
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -842,13 +843,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(new Exception("วันเริ่มต้นต้องมีค่าน้อยกว่าหรือเท่ากับวันสิ้นสุด"), StatusCodes.Status400BadRequest);
|
||||
}
|
||||
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
var profiles = new List<GetProfileByKeycloakIdDto>();
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
//var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
//var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
//if (profile == null)
|
||||
//{
|
||||
// return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
//}
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
|
|
@ -857,11 +860,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
|
||||
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
|
||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
//var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
|
||||
//var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
//var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
var duty = userRound ?? defaultRound;
|
||||
//var duty = userRound ?? defaultRound;
|
||||
var duty = defaultRound;
|
||||
|
||||
var checkin_base = DateTime.Parse($"{DateTime.Now.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}");
|
||||
var checkout_base = DateTime.Parse($"{DateTime.Now.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}");
|
||||
|
|
@ -875,8 +879,18 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
foreach (var d in resultData)
|
||||
{
|
||||
var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken);
|
||||
if (pf == null) continue;
|
||||
var pf = profiles.FirstOrDefault(x => x.Keycloak == d.KeycloakUserId);
|
||||
if (pf == null)
|
||||
{
|
||||
pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken);
|
||||
if (pf == null)
|
||||
continue;
|
||||
else
|
||||
profiles.Add(pf);
|
||||
}
|
||||
|
||||
//var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken);
|
||||
//if (pf == null) continue;
|
||||
data.Add(new CheckInProcessHistoryForAdminDto
|
||||
{
|
||||
Id = d.Id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue