Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop
This commit is contained in:
commit
640976c90d
7 changed files with 167 additions and 19 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using System.Drawing;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.Leave.Commons;
|
||||
|
|
@ -575,6 +576,18 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return data.Count > 0;
|
||||
}
|
||||
|
||||
public async Task DeleteLeaveDocumentAsync(Guid Id)
|
||||
{
|
||||
var doc = await _dbContext.Set<LeaveDocument>()
|
||||
.Where(x => x.Id == Id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (doc != null)
|
||||
{
|
||||
_dbContext.Set<LeaveDocument>().Remove(doc);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
if (currentCheckIn != null)
|
||||
{
|
||||
return Error(new Exception("ไม่สามารถลงเวลาได้ เนืองจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest);
|
||||
return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -467,7 +467,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var checkInStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ?
|
||||
|
||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"LATE" :
|
||||
|
||||
"NORMAL";
|
||||
|
||||
// process - รอทำใน queue
|
||||
|
|
@ -519,7 +524,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var checkOutStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||
"LATE" :
|
||||
"ABSENT" :
|
||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
|
|
@ -766,7 +771,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
CheckInStatus = d.CheckInStatus != null || d.CheckInStatus != "" ? d.CheckInStatus :
|
||||
DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ?
|
||||
|
||||
DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{d.CheckIn.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"LATE" :
|
||||
|
||||
"NORMAL",
|
||||
CheckInDescription = d.CheckInRemark ?? "",
|
||||
IsLocationCheckIn = d.IsLocationCheckIn,
|
||||
|
|
@ -783,11 +793,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
d.CheckOutStatus != null || d.CheckOutStatus != "" ? d.CheckOutStatus :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||
"LATE" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"NORMAL",
|
||||
"ABSENT" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"NORMAL",
|
||||
CheckOutDescription = d.CheckOutRemark ?? "",
|
||||
|
||||
IsLocationCheckOut = d.IsLocationCheckOut,
|
||||
|
|
@ -860,7 +870,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
CheckInStatus = d.CheckInStatus != "" ? d.CheckInStatus :
|
||||
DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ?
|
||||
"LATE" :
|
||||
|
||||
DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{d.CheckIn.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"LATE" :
|
||||
|
||||
|
||||
"NORMAL",
|
||||
CheckInIsLocation = d.IsLocationCheckIn,
|
||||
CheckInLocationName = d.CheckInLocationName,
|
||||
|
|
@ -874,7 +890,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
CheckOutStatus = d.CheckOutStatus != "" ? d.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" :
|
||||
"ABSENT" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
|
|
@ -1130,14 +1146,22 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
CheckInStatus = checkInData == null ? null :
|
||||
DateTime.Parse(checkInData.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{checkInData.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ?
|
||||
|
||||
DateTime.Parse(checkInData.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{checkInData.CheckIn.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"LATE" :
|
||||
|
||||
"NORMAL",
|
||||
|
||||
CheckOutStatus = checkInData == null ? null :
|
||||
checkInData.CheckOut == null ? null :
|
||||
DateTime.Parse(checkInData.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{checkInData.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||
"LATE" :
|
||||
"ABSENT" :
|
||||
DateTime.Parse(checkInData.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{checkInData.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"NORMAL",
|
||||
|
||||
StartTimeMorning = duty.StartTimeMorning,
|
||||
|
|
@ -1359,7 +1383,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
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}") ?
|
||||
|
||||
DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{d.CheckIn.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"LATE" :
|
||||
|
||||
"NORMAL",
|
||||
CheckInDescription = d.CheckInRemark ?? "",
|
||||
|
||||
|
|
@ -1373,7 +1402,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
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" :
|
||||
"ABSENT" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"NORMAL",
|
||||
CheckOutDescription = d.CheckOutRemark ?? "",
|
||||
};
|
||||
|
|
@ -1470,6 +1502,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
CheckInStatus = checkInData == null ? null :
|
||||
DateTime.Parse(checkInData.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{checkInData.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ?
|
||||
DateTime.Parse(checkInData.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{checkInData.CheckIn.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"LATE" :
|
||||
"NORMAL",
|
||||
|
||||
|
|
@ -1477,7 +1512,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
checkInData.CheckOut == null ? null :
|
||||
DateTime.Parse(checkInData.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{checkInData.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||
"LATE" :
|
||||
"ABSENT" :
|
||||
DateTime.Parse(checkInData.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{checkInData.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"NORMAL",
|
||||
|
||||
CheckInLocation = checkInData == null ? "" : checkInData.CheckInPOI,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ using System.Security.Claims;
|
|||
using BMA.EHR.Application.Repositories.Commands;
|
||||
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
||||
using Org.BouncyCastle.Ocsp;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace BMA.EHR.Leave.Service.Controllers
|
||||
{
|
||||
|
|
@ -390,6 +391,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
ApproveStep = oldData.ApproveStep
|
||||
};
|
||||
|
||||
// assign old upload documents to new request
|
||||
leaveRequest.LeaveDraftDocument = oldData.LeaveDraftDocument;
|
||||
leaveRequest.LeaveDocument.AddRange(oldData.LeaveDocument);
|
||||
leaveRequest.LeaveCancelDocument = oldData.LeaveCancelDocument;
|
||||
|
||||
// get leave last
|
||||
leaveRequest.LeaveLast = await _leaveRequestRepository.GetLeaveLastByTypeForUserAsync(userId, req.Type);
|
||||
|
||||
|
|
@ -526,7 +532,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveRequest.PositionLevelName = profile.PositionLevel == null ? "" : profile.PositionLevel.Name;
|
||||
leaveRequest.OrganizationName = profile.Oc ?? "";
|
||||
|
||||
// delet old
|
||||
|
||||
|
||||
// delete old
|
||||
await _leaveRequestRepository.DeleteAsync(oldData);
|
||||
|
||||
// save to database
|
||||
|
|
@ -535,6 +543,35 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Success(new { id = leaveRequest.Id });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LV2_038 - ลบรายการการลา (USER)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("user/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteLeaveRequestAsync(Guid id)
|
||||
{
|
||||
var deleted = await _leaveRequestRepository.GetByIdAsync(id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
if (deleted.LeaveStatus != "DRAFT")
|
||||
{
|
||||
return Error("ไม่สามารถลบคำร้องขอลาที่นำส่งแล้วได้");
|
||||
}
|
||||
|
||||
await _leaveRequestRepository.DeleteAsync(deleted);
|
||||
return Success();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LV2_002 - ข้อมูลที่ user ขอยื่นลา (USER)
|
||||
/// </summary>
|
||||
|
|
@ -644,7 +681,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var totalDay = req.StartLeaveDate.DiffDay(req.EndLeaveDate);
|
||||
var sumWeekend = _holidayRepository.GetWeekEndCount(req.StartLeaveDate, req.EndLeaveDate, category);
|
||||
|
||||
var isLeave = sumLeave + (totalDay - sumWorkDay) <= leaveType.Limit;
|
||||
var isLeave = sumLeave + (totalDay - sumWorkDay - sumWeekend) <= leaveType.Limit;
|
||||
|
||||
var result = new GetLeaveCheckResultDto
|
||||
{
|
||||
|
|
@ -880,7 +917,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
foreach (var d in rawData.LeaveDocument)
|
||||
{
|
||||
var file = await _minIOService.ImagesPath(d.Document.Id);
|
||||
result.LeaveDocument.Add(file);
|
||||
result.LeaveDocument.Add(new LeaveDocumentDto
|
||||
{
|
||||
DocId = d.Document.Id,
|
||||
Path = file
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1375,7 +1416,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
foreach (var d in rawData.LeaveDocument)
|
||||
{
|
||||
var file = await _minIOService.ImagesPath(d.Document.Id);
|
||||
result.LeaveDocument.Add(file);
|
||||
result.LeaveDocument.Add(new LeaveDocumentDto
|
||||
{
|
||||
DocId = d.Document.Id,
|
||||
Path = file
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1434,6 +1479,36 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Success(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LV2_037 - ลบเอกสารประกอบรายละเอียดการลา (USER)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("user/file/document/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteLeaveDocumentByIdAsync(Guid id, [FromBody] DeleteLeaveDocumentDto req)
|
||||
{
|
||||
var leaveReq = await _leaveRequestRepository.GetByIdAsync(id);
|
||||
if (leaveReq == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
var doc = leaveReq.LeaveDocument.Where(x => x.Document.Id == req.DocId).FirstOrDefault();
|
||||
if (doc != null)
|
||||
{
|
||||
await _minIOService.DeleteFileAsync(doc.Document.Id);
|
||||
await _leaveRequestRepository.DeleteLeaveDocumentAsync(doc.Id);
|
||||
return Success();
|
||||
}
|
||||
else
|
||||
return Error("Document not found");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||
{
|
||||
public class DeleteLeaveDocumentDto
|
||||
{
|
||||
[Required]
|
||||
public Guid Id { get; set; } = Guid.Empty;
|
||||
|
||||
[Required]
|
||||
public Guid DocId { get; set; } = Guid.Empty;
|
||||
}
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
|||
|
||||
public string LeaveDetail { get; set; } = string.Empty;
|
||||
|
||||
public List<string> LeaveDocument { get; set; } = new();
|
||||
public List<LeaveDocumentDto> LeaveDocument { get; set; } = new();
|
||||
|
||||
public string LeaveDraftDocument { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
|||
|
||||
public string LeaveDetail { get; set; } = string.Empty;
|
||||
|
||||
public List<string> LeaveDocument { get; set; } = new();
|
||||
public List<LeaveDocumentDto> LeaveDocument { get; set; } = new();
|
||||
|
||||
public string LeaveDraftDocument { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||
{
|
||||
public class LeaveDocumentDto
|
||||
{
|
||||
public Guid DocId { get; set; } = Guid.Empty;
|
||||
|
||||
public string Path { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue