change round
This commit is contained in:
parent
22d9210416
commit
2bf43a52b5
27 changed files with 69774 additions and 7 deletions
|
|
@ -4,6 +4,7 @@ using BMA.EHR.Domain.Common;
|
|||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Leave.Service.DTOs.ChangeRound;
|
||||
using BMA.EHR.Leave.Service.DTOs.CheckIn;
|
||||
using BMA.EHR.Leave.Service.DTOs.DutyTime;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
|
@ -11,6 +12,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace BMA.EHR.Leave.Service.Controllers
|
||||
{
|
||||
|
|
@ -33,6 +35,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
private readonly UserTimeStampRepository _userTimeStampRepository;
|
||||
private readonly MinIOService _minIOService;
|
||||
private readonly ProcessUserTimeStampRepository _processUserTimeStampRepository;
|
||||
private readonly UserDutyTimeRepository _userDutyTimeRepository;
|
||||
|
||||
private readonly string _bucketName = "check-in";
|
||||
|
||||
|
|
@ -48,7 +51,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
UserProfileRepository userProfileRepository,
|
||||
UserTimeStampRepository userTimeStampRepository,
|
||||
MinIOService minIOService,
|
||||
ProcessUserTimeStampRepository processUserTimeStampRepository)
|
||||
ProcessUserTimeStampRepository processUserTimeStampRepository,
|
||||
UserDutyTimeRepository userDutyTimeRepository)
|
||||
{
|
||||
_dutyTimeRepository = dutyTimeRepository;
|
||||
_context = context;
|
||||
|
|
@ -59,6 +63,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
_userTimeStampRepository = userTimeStampRepository;
|
||||
_minIOService = minIOService;
|
||||
_processUserTimeStampRepository = processUserTimeStampRepository;
|
||||
_userDutyTimeRepository = userDutyTimeRepository;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -632,6 +637,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetTimeRecordAsync([Required] DateTime startDate, [Required] DateTime endDate, int page = 1, int pageSize = 10,string status = "NORMAL", string keyword = "")
|
||||
{
|
||||
if (startDate.Date > endDate.Date)
|
||||
|
|
@ -692,6 +698,82 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#region " เปลี่ยนรอบการทำงาน "
|
||||
|
||||
/// <summary>
|
||||
/// LV1_006 - เช็คเวลาต้องลงเวลาเข้าหรือออกงาน (USER)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("search")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> SearchProfileAsync([FromBody] SearchProfileDto req)
|
||||
{
|
||||
var profile = await _userProfileRepository.SearchProfile(req.CitizenId, req.FirstName, req.LastName);
|
||||
|
||||
var pagedProfile = profile.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList();
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
|
||||
|
||||
var resultSet = new List<SearchProfileResultDto>();
|
||||
|
||||
foreach (var p in pagedProfile)
|
||||
{
|
||||
var roundId = p.DutyTimeId ?? Guid.Empty;
|
||||
var round = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
var res = new SearchProfileResultDto
|
||||
{
|
||||
ProfileId = p.Id,
|
||||
CitizenId = p.CitizenId,
|
||||
FullName = $"{p.Prefix.Name}{p.FirstName} {p.LastName}",
|
||||
StartTimeMorning = round != null ? round.StartTimeMorning : defaultRound.StartTimeMorning,
|
||||
LeaveTimeAfterNoon = round != null ? round.EndTimeAfternoon : defaultRound.EndTimeAfternoon,
|
||||
EffectiveDate = p.DutyTimeEffectiveDate
|
||||
};
|
||||
resultSet.Add(res);
|
||||
}
|
||||
|
||||
return Success(new { data = resultSet, total = profile.Count });
|
||||
}
|
||||
|
||||
// <summary>
|
||||
/// LV1_014 - เปลี่ยนรอบการลงเวลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("round")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> CreateChangeRoundAsync([FromBody] CreateChangeRoundDto req)
|
||||
{
|
||||
var data = new UserDutyTime
|
||||
{
|
||||
ProfileId = req.ProfileId,
|
||||
DutyTimeId = req.RoundId,
|
||||
EffectiveDate = req.EffectiveDate,
|
||||
Remark = req.Remark,
|
||||
};
|
||||
|
||||
await _userDutyTimeRepository.AddAsync(data);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue