diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs index 769c3141..d3adcdda 100644 --- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs @@ -102,6 +102,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants return data; } + public async Task GetTimeStampById(Guid id) + { + var data = await _dbContext.Set() + .Where(u => u.Id == id) + .FirstOrDefaultAsync(); + + return data; + } + #endregion } } diff --git a/BMA.EHR.Leave.Service/Controllers/LeaveController.cs b/BMA.EHR.Leave.Service/Controllers/LeaveController.cs index bdb74ff6..16b4f23b 100644 --- a/BMA.EHR.Leave.Service/Controllers/LeaveController.cs +++ b/BMA.EHR.Leave.Service/Controllers/LeaveController.cs @@ -6,8 +6,10 @@ using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Models.Leave.TimeAttendants; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; +using iTextSharp.text; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; using Swashbuckle.AspNetCore.Annotations; using System.ComponentModel.DataAnnotations; using System.Security.Claims; @@ -519,6 +521,52 @@ namespace BMA.EHR.Command.Service.Controllers return Success(data); } + /// + /// LV1_011 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("time-record/{id:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetTimeRecordAsync([Required] Guid id) + { + var imgUrl = $"{_configuration["MinIO:Endpoint"]}{_configuration["MinIO:BucketName"]}"; + var d = (await _userTimeStampRepository.GetTimeStampById(id)); + if(d == null) + { + throw new Exception(GlobalMessages.DataNotFound); + } + else + { + var result = new CheckInHistoryForAdminDto + { + CheckInId = d.Id, + FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId), + + CheckInDate = d.CheckIn.Date, + CheckInTime = d.CheckIn.ToString("HH:mm"), + CheckInLocation = d.CheckInPOI, + CheckInLat = d.CheckInLat, + CheckInLon = d.CheckInLon, + CheckInImageUrl = $"{imgUrl}/{d.CheckInImageUrl}", + + CheckOutDate = d.CheckOut == null ? null : d.CheckOut.Value.Date, + CheckOutTime = d.CheckOut == null ? "" : d.CheckOut.Value.ToString("HH:mm"), + CheckOutLocation = d.CheckOut == null ? "" : d.CheckOutPOI, + CheckOutLat = d.CheckOut == null ? null : d.CheckOutLat, + CheckOutLon = d.CheckOut == null ? null : d.CheckOutLon, + CheckOutImageUrl = d.CheckOut == null ? "" : $"{imgUrl}/{d.CheckOutImageUrl}", + }; + + return Success(result); + } + } + #endregion #endregion