add API จัดการปฏิทินวันหยุด ขรก
This commit is contained in:
parent
0e22e3886f
commit
77410d9fa3
4 changed files with 81 additions and 10 deletions
|
|
@ -1,7 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using BMA.EHR.Application.Common.Interfaces;
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
using BMA.EHR.Application.Messaging;
|
using BMA.EHR.Application.Messaging;
|
||||||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||||
|
|
@ -11,7 +7,7 @@ using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||||
{
|
{
|
||||||
public class UserCalendarRepository : GenericLeaveRepository<Guid, UserDutyTime>
|
public class UserCalendarRepository : GenericLeaveRepository<Guid, UserCalendar>
|
||||||
{
|
{
|
||||||
#region " Fields "
|
#region " Fields "
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ namespace BMA.EHR.Application.Repositories.MetaData
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetWeekEndCount(DateTime startDate, DateTime endDate)
|
public int GetWeekEndCount(DateTime startDate, DateTime endDate, string category = "NORMAL")
|
||||||
{
|
{
|
||||||
var dates = new List<DateTime>();
|
var dates = new List<DateTime>();
|
||||||
|
|
||||||
|
|
@ -45,7 +45,11 @@ namespace BMA.EHR.Application.Repositories.MetaData
|
||||||
dates.Add(i);
|
dates.Add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
var count = dates.Where(d => d.DayOfWeek == DayOfWeek.Saturday || d.DayOfWeek == DayOfWeek.Sunday).Count();
|
var count = 0;
|
||||||
|
if (category == "NORMAL")
|
||||||
|
count = dates.Where(d => d.DayOfWeek == DayOfWeek.Saturday || d.DayOfWeek == DayOfWeek.Sunday).Count();
|
||||||
|
else
|
||||||
|
count = dates.Where(d => d.DayOfWeek == DayOfWeek.Sunday).Count();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using BMA.EHR.Infrastructure.Persistence;
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
using BMA.EHR.Leave.Service.DTOs.AdditionalCheck;
|
using BMA.EHR.Leave.Service.DTOs.AdditionalCheck;
|
||||||
|
using BMA.EHR.Leave.Service.DTOs.Calendar;
|
||||||
using BMA.EHR.Leave.Service.DTOs.ChangeRound;
|
using BMA.EHR.Leave.Service.DTOs.ChangeRound;
|
||||||
using BMA.EHR.Leave.Service.DTOs.CheckIn;
|
using BMA.EHR.Leave.Service.DTOs.CheckIn;
|
||||||
using BMA.EHR.Leave.Service.DTOs.DutyTime;
|
using BMA.EHR.Leave.Service.DTOs.DutyTime;
|
||||||
|
|
@ -38,6 +39,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
private readonly UserDutyTimeRepository _userDutyTimeRepository;
|
private readonly UserDutyTimeRepository _userDutyTimeRepository;
|
||||||
private readonly AdditionalCheckRequestRepository _additionalCheckRequestRepository;
|
private readonly AdditionalCheckRequestRepository _additionalCheckRequestRepository;
|
||||||
|
|
||||||
|
private readonly UserCalendarRepository _userCalendarRepository;
|
||||||
|
|
||||||
private readonly string _bucketName = "check-in";
|
private readonly string _bucketName = "check-in";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -54,7 +57,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
MinIOService minIOService,
|
MinIOService minIOService,
|
||||||
ProcessUserTimeStampRepository processUserTimeStampRepository,
|
ProcessUserTimeStampRepository processUserTimeStampRepository,
|
||||||
UserDutyTimeRepository userDutyTimeRepository,
|
UserDutyTimeRepository userDutyTimeRepository,
|
||||||
AdditionalCheckRequestRepository additionalCheckRequestRepository)
|
AdditionalCheckRequestRepository additionalCheckRequestRepository,
|
||||||
|
UserCalendarRepository userCalendarRepository)
|
||||||
{
|
{
|
||||||
_dutyTimeRepository = dutyTimeRepository;
|
_dutyTimeRepository = dutyTimeRepository;
|
||||||
_context = context;
|
_context = context;
|
||||||
|
|
@ -67,6 +71,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
_processUserTimeStampRepository = processUserTimeStampRepository;
|
_processUserTimeStampRepository = processUserTimeStampRepository;
|
||||||
_userDutyTimeRepository = userDutyTimeRepository;
|
_userDutyTimeRepository = userDutyTimeRepository;
|
||||||
_additionalCheckRequestRepository = additionalCheckRequestRepository;
|
_additionalCheckRequestRepository = additionalCheckRequestRepository;
|
||||||
|
_userCalendarRepository = userCalendarRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -1490,6 +1495,65 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#region " ปฏิทินการทำงานของ ขรก. "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LV1_023 - แสดงปฏิทินวันทำงานรายคน (ADMIN)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// </returns>
|
||||||
|
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("admin/work/{id:guid}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetCalendarByProfileAsync(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _userCalendarRepository.GetExist(id);
|
||||||
|
if (data == null)
|
||||||
|
return Success(new { Work = "NORMAL" });
|
||||||
|
else
|
||||||
|
return Success(new { Work = data.Calendar });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LV1_024 - บันทึกแก้ไขปฏิทินวันทำงาน (ADMIN)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// </returns>
|
||||||
|
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("admin/work/{id:guid}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> UpdateCalendarByProfileAsync(Guid id, [FromBody] UpdateCalendarDto req)
|
||||||
|
{
|
||||||
|
var data = await _userCalendarRepository.GetExist(id);
|
||||||
|
if (data != null)
|
||||||
|
{
|
||||||
|
data.Calendar = req.Work;
|
||||||
|
await _userCalendarRepository.UpdateAsync(data);
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = new UserCalendar
|
||||||
|
{
|
||||||
|
ProfileId = id,
|
||||||
|
Calendar = req.Work
|
||||||
|
};
|
||||||
|
|
||||||
|
await _userCalendarRepository.AddAsync(data);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
7
BMA.EHR.Leave.Service/DTOs/Calendar/UpdateCalendarDto.cs
Normal file
7
BMA.EHR.Leave.Service/DTOs/Calendar/UpdateCalendarDto.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace BMA.EHR.Leave.Service.DTOs.Calendar
|
||||||
|
{
|
||||||
|
public class UpdateCalendarDto
|
||||||
|
{
|
||||||
|
public string Work { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue