หลังอนุมัติลา แก้สถานะการลงเวลาเป็น ปกติ
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m47s
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m47s
This commit is contained in:
parent
1739aa8057
commit
f02413f2b2
1 changed files with 68 additions and 4 deletions
|
|
@ -11,6 +11,8 @@ using Microsoft.Extensions.Configuration;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
|
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
||||||
|
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
{
|
{
|
||||||
|
|
@ -29,6 +31,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
private readonly MinIOLeaveService _minIOService;
|
private readonly MinIOLeaveService _minIOService;
|
||||||
|
|
||||||
private readonly LeaveBeginningRepository _leaveBeginningRepository;
|
private readonly LeaveBeginningRepository _leaveBeginningRepository;
|
||||||
|
private readonly ProcessUserTimeStampRepository _processUserTimeStampRepository;
|
||||||
|
|
||||||
private readonly string URL = string.Empty;
|
private readonly string URL = string.Empty;
|
||||||
|
|
||||||
|
|
@ -44,7 +47,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
EmailSenderService emailSenderService,
|
EmailSenderService emailSenderService,
|
||||||
IApplicationDBContext appDbContext,
|
IApplicationDBContext appDbContext,
|
||||||
MinIOLeaveService minIOService,
|
MinIOLeaveService minIOService,
|
||||||
LeaveBeginningRepository leaveBeginningRepository) : base(dbContext, httpContextAccessor)
|
LeaveBeginningRepository leaveBeginningRepository,
|
||||||
|
ProcessUserTimeStampRepository processUserTimeStampRepository) : base(dbContext, httpContextAccessor)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
|
@ -58,6 +62,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
Console.WriteLine($"URL : {URL}");
|
Console.WriteLine($"URL : {URL}");
|
||||||
_minIOService = minIOService;
|
_minIOService = minIOService;
|
||||||
_leaveBeginningRepository = leaveBeginningRepository;
|
_leaveBeginningRepository = leaveBeginningRepository;
|
||||||
|
_processUserTimeStampRepository = processUserTimeStampRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -1325,9 +1330,68 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
}
|
}
|
||||||
await _appDbContext.SaveChangesAsync();
|
await _appDbContext.SaveChangesAsync();
|
||||||
|
|
||||||
// insert to process timestamp
|
// ปรับสถานะการลงเวลา
|
||||||
|
if (rawData.LeaveStartDate.Date == rawData.LeaveEndDate.Date)
|
||||||
|
{
|
||||||
|
var processCheckIn = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||||
|
.Where(x => x.KeycloakUserId == rawData.KeycloakUserId)
|
||||||
|
.Where(x => x.CheckIn.Date == rawData.LeaveStartDate.Date)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
|
||||||
|
if (processCheckIn is not null)
|
||||||
|
{
|
||||||
|
switch (rawData.LeaveRange.Trim().ToUpper())
|
||||||
|
{
|
||||||
|
case "MORNING":
|
||||||
|
processCheckIn.CheckInStatus = "NORMAL";
|
||||||
|
break;
|
||||||
|
case "AFTERNOON":
|
||||||
|
processCheckIn.CheckOutStatus = "NORMAL";
|
||||||
|
break;
|
||||||
|
case "ALL":
|
||||||
|
processCheckIn.CheckInStatus = "NORMAL";
|
||||||
|
processCheckIn.CheckOutStatus = "NORMAL";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var from = rawData.LeaveStartDate.Date;
|
||||||
|
var to = rawData.LeaveEndDate.Date;
|
||||||
|
for (var day = from.Date; day <= to.Date; day = day.AddDays(1))
|
||||||
|
{
|
||||||
|
var processCheckIn = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||||
|
.Where(x => x.KeycloakUserId == rawData.KeycloakUserId)
|
||||||
|
.Where(x => x.CheckIn.Date == day.Date)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
if (processCheckIn is not null)
|
||||||
|
{
|
||||||
|
switch (rawData.LeaveRange.Trim().ToUpper())
|
||||||
|
{
|
||||||
|
case "MORNING":
|
||||||
|
processCheckIn.CheckInStatus = "NORMAL";
|
||||||
|
break;
|
||||||
|
case "AFTERNOON":
|
||||||
|
processCheckIn.CheckOutStatus = "NORMAL";
|
||||||
|
break;
|
||||||
|
case "ALL":
|
||||||
|
processCheckIn.CheckInStatus = "NORMAL";
|
||||||
|
processCheckIn.CheckOutStatus = "NORMAL";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
// Send Noti
|
// Send Noti
|
||||||
var noti = new Notification
|
var noti = new Notification
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue