เพิ่ม

LV1_021 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล Tabรายการลงเวลา (ADMIN)

แก้ไข
LV1_011 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล Tabรายากรลงเวลาที่ประมวลผลแล้ว (ADMIN)
This commit is contained in:
Suphonchai Phoonsawat 2023-11-28 09:53:38 +07:00
parent a70b130178
commit ab9473c133

View file

@ -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
}
/// <summary>
/// LV1_011 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล
/// LV1_011 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล Tabรายากรลงเวลาที่ประมวลผลแล้ว (ADMIN)
/// </summary>
/// <returns>
/// </returns>
@ -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
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("admin/edit/approve/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> ApproveRequestAsync(Guid id, [FromBody] ApproveRequestDto req)
{
if (req.Reason == null || req.Reason == string.Empty)
@ -1131,6 +1135,9 @@ namespace BMA.EHR.Leave.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("admin/edit/reject/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> RejectRequestAsync(Guid id, [FromBody] RejectRequestDto req)
{
if (req.Reason == null || req.Reason == string.Empty)
@ -1163,6 +1170,82 @@ namespace BMA.EHR.Leave.Service.Controllers
}
/// <summary>
/// LV1_021 - รายละเอียดการลงเวลาปฎิบัติงานรายบุคคล Tabรายการลงเวลา (ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("log-record/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> 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