From ab9473c133746592d71234ba88538ba1a97d9897 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Tue, 28 Nov 2023 09:53:38 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20LV1=5F021=20-=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=A5?= =?UTF-8?q?=E0=B8=B0=E0=B9=80=E0=B8=AD=E0=B8=B5=E0=B8=A2=E0=B8=94=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=A5=E0=B8=87=E0=B9=80=E0=B8=A7=E0=B8=A5?= =?UTF-8?q?=E0=B8=B2=E0=B8=9B=E0=B8=8E=E0=B8=B4=E0=B8=9A=E0=B8=B1=E0=B8=95?= =?UTF-8?q?=E0=B8=B4=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B8=A3=E0=B8=B2=E0=B8=A2?= =?UTF-8?q?=E0=B8=9A=E0=B8=B8=E0=B8=84=E0=B8=84=E0=B8=A5=20Tab=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A5=E0=B8=87?= =?UTF-8?q?=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2=20(ADMIN)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit แก้ไข LV1_011 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล Tabรายากรลงเวลาที่ประมวลผลแล้ว (ADMIN) --- .../Controllers/LeaveController.cs | 89 ++++++++++++++++++- 1 file changed, 86 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.Leave.Service/Controllers/LeaveController.cs b/BMA.EHR.Leave.Service/Controllers/LeaveController.cs index 0eb15ee1..c635ba21 100644 --- a/BMA.EHR.Leave.Service/Controllers/LeaveController.cs +++ b/BMA.EHR.Leave.Service/Controllers/LeaveController.cs @@ -1,4 +1,5 @@ -using BMA.EHR.Application.Repositories; +using Amazon.S3.Model; +using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.Leaves.TimeAttendants; using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Models.Leave.TimeAttendants; @@ -614,7 +615,7 @@ namespace BMA.EHR.Leave.Service.Controllers } /// - /// LV1_011 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล + /// LV1_011 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล Tabรายากรลงเวลาที่ประมวลผลแล้ว (ADMIN) /// /// /// @@ -630,7 +631,7 @@ namespace BMA.EHR.Leave.Service.Controllers var imgUrl = $"{_configuration["MinIO:Endpoint"]}{_configuration["MinIO:BucketName"]}"; - var d = (await _userTimeStampRepository.GetTimeStampById(id)); + var d = (await _processUserTimeStampRepository.GetTimeStampById(id)); if (d == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -1048,6 +1049,9 @@ namespace BMA.EHR.Leave.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPut("admin/edit/approve/{id:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> ApproveRequestAsync(Guid id, [FromBody] ApproveRequestDto req) { if (req.Reason == null || req.Reason == string.Empty) @@ -1131,6 +1135,9 @@ namespace BMA.EHR.Leave.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPut("admin/edit/reject/{id:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> RejectRequestAsync(Guid id, [FromBody] RejectRequestDto req) { if (req.Reason == null || req.Reason == string.Empty) @@ -1163,6 +1170,82 @@ namespace BMA.EHR.Leave.Service.Controllers } + /// + /// LV1_021 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล Tabรายการลงเวลา (ADMIN) + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("log-record/{id:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetLogRecordAsync([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 profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId); + if (profile == null) + { + return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + } + + var defaultRound = await _dutyTimeRepository.GetDefaultAsync(); + if (defaultRound == null) + { + return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound); + } + + var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty); + + var duty = userRound ?? defaultRound; + + var result = new CheckInDetailForAdminDto + { + Id = d.Id, + FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId), + + CheckInDate = d.CheckIn.Date, + CheckInTime = d.CheckIn.ToString("HH:mm"), + CheckInPOI = d.CheckInPOI, + CheckInLat = d.CheckInLat, + CheckInLon = d.CheckInLon, + CheckInImg = $"{imgUrl}/{d.CheckInImageUrl}", + CheckInStatus = DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) > + DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ? + "LATE" : + "NORMAL", + CheckInDescription = d.CheckInRemark ?? "", + + CheckOutDate = d.CheckOut == null ? null : d.CheckOut.Value.Date, + CheckOutTime = d.CheckOut == null ? "" : d.CheckOut.Value.ToString("HH:mm"), + CheckOutPOI = d.CheckOut == null ? "" : d.CheckOutPOI, + CheckOutLat = d.CheckOut == null ? null : d.CheckOutLat, + CheckOutLon = d.CheckOut == null ? null : d.CheckOutLon, + CheckOutImg = d.CheckOut == null ? "" : $"{imgUrl}/{d.CheckOutImageUrl}", + + CheckOutStatus = d.CheckOut == null ? null : + DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) < + DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ? + "LATE" : + "NORMAL", + CheckOutDescription = d.CheckOutRemark ?? "", + }; + + return Success(result); + } + } + #endregion #endregion