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.Commands;
|
||||||
using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
|
using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
|
||||||
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
||||||
|
using BMA.EHR.Application.Responses.Profiles;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
|
|
@ -842,13 +843,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
return Error(new Exception("วันเริ่มต้นต้องมีค่าน้อยกว่าหรือเท่ากับวันสิ้นสุด"), StatusCodes.Status400BadRequest);
|
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);
|
//var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
if (profile == null)
|
|
||||||
{
|
//var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
//if (profile == null)
|
||||||
}
|
//{
|
||||||
|
// return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
//}
|
||||||
|
|
||||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||||
if (defaultRound == null)
|
if (defaultRound == null)
|
||||||
|
|
@ -857,11 +860,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
|
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
|
||||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
|
//var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
|
||||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
//var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
//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 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}");
|
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)
|
foreach (var d in resultData)
|
||||||
{
|
{
|
||||||
var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken);
|
var pf = profiles.FirstOrDefault(x => x.Keycloak == d.KeycloakUserId);
|
||||||
if (pf == null) continue;
|
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
|
data.Add(new CheckInProcessHistoryForAdminDto
|
||||||
{
|
{
|
||||||
Id = d.Id,
|
Id = d.Id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue