Merge branch 'develop' into adiDev
Some checks failed
release-dev / release-dev (push) Failing after 13s

This commit is contained in:
AdisakKanthawilang 2025-06-10 11:11:34 +07:00
commit fdae099855
7 changed files with 177 additions and 57 deletions

View file

@ -1,8 +1,6 @@
using Amazon.S3.Model; 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.Application.Responses.Leaves; using BMA.EHR.Application.Responses.Leaves;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Leave.Commons; using BMA.EHR.Domain.Models.Leave.Commons;
using BMA.EHR.Domain.Models.Leave.Requests; using BMA.EHR.Domain.Models.Leave.Requests;
using BMA.EHR.Domain.Models.Notifications; using BMA.EHR.Domain.Models.Notifications;
@ -10,8 +8,6 @@ using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Nest;
using System.Drawing;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Http.Json; using System.Net.Http.Json;
@ -415,7 +411,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.Type.Id == leaveType.Id) .Where(x => x.Type.Id == leaveType.Id)
//.Where(x => x.LeaveStartDate.Year == year) //.Where(x => x.LeaveStartDate.Year == year)
.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate) .Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.Sum(x => x.LeaveTotal); .Sum(x => x.LeaveTotal);
return data; return data;
@ -444,7 +440,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.Type.Id == leaveTypeId) .Where(x => x.Type.Id == leaveTypeId)
//.Where(x => x.LeaveStartDate.Year == year) //.Where(x => x.LeaveStartDate.Year == year)
.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate) .Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
//.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE") //.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
.ToListAsync(); .ToListAsync();
@ -470,7 +466,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.Type) .Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId) .Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
//.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE") //.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
.OrderByDescending(x => x.LeaveStartDate.Date) .OrderByDescending(x => x.LeaveStartDate.Date)
.Select(x => x.LeaveStartDate.Date) .Select(x => x.LeaveStartDate.Date)
@ -486,7 +482,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.LeaveStartDate.Date < beforeDate.Date) .Where(x => x.LeaveStartDate.Date < beforeDate.Date)
.Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId) .Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
//.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE") //.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
.OrderByDescending(x => x.LeaveStartDate.Date) .OrderByDescending(x => x.LeaveStartDate.Date)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
@ -637,11 +633,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ"); throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ");
//var _result = await _res.Content.ReadAsStringAsync(); //var _result = await _res.Content.ReadAsStringAsync();
} }
} }
// TODO: remove วันลา // TODO: remove วันลา
// Send Noti // Send Noti หาเจ้าของใบลา
var noti = new Notification var noti = new Notification
{ {
Body = $"การขอยกเลิกใบลาของคุณได้รับการอนุมัติ", Body = $"การขอยกเลิกใบลาของคุณได้รับการอนุมัติ",
@ -650,6 +646,25 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
Payload = "", Payload = "",
}; };
_appDbContext.Set<Notification>().Add(noti); _appDbContext.Set<Notification>().Add(noti);
var commanders = rawData.Approvers
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
.OrderBy(x => x.Seq)
.ToList();
foreach(var commander in commanders)
{
var noti1 = new Notification
{
Body = $"การขอยกเลิกใบลาของ {rawData.FirstName} {rawData.LastName} ได้รับการอนุมัติแล้ว",
ReceiverUserId = commander.ProfileId,
Type = "",
Payload = "",
};
_appDbContext.Set<Notification>().Add(noti1);
}
await _appDbContext.SaveChangesAsync(); await _appDbContext.SaveChangesAsync();
@ -712,6 +727,25 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
Payload = "", Payload = "",
}; };
_appDbContext.Set<Notification>().Add(noti); _appDbContext.Set<Notification>().Add(noti);
var commanders = rawData.Approvers
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
.OrderBy(x => x.Seq)
.ToList();
foreach (var commander in commanders)
{
var noti1 = new Notification
{
Body = $"การขอยกเลิกใบลาของ {rawData.FirstName} {rawData.LastName} ไม่ได้รับการอนุมัติ \r\nเนืองจาก {Reason}",
ReceiverUserId = commander.ProfileId,
Type = "",
Payload = "",
};
_appDbContext.Set<Notification>().Add(noti1);
}
await _appDbContext.SaveChangesAsync(); await _appDbContext.SaveChangesAsync();
} }
@ -1366,7 +1400,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId) .Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStartDate.Year == year) .Where(x => x.LeaveStartDate.Year == year)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.ToListAsync(); .ToListAsync();
if (data.Count > 0) if (data.Count > 0)
@ -1382,7 +1416,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId) .Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.ToListAsync(); .ToListAsync();
if (data.Count > 0) if (data.Count > 0)
@ -1397,7 +1431,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.Type) .Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.ToListAsync(); .ToListAsync();
if (data.Count > 0) if (data.Count > 0)
@ -1411,7 +1445,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
var data = await _dbContext.Set<LeaveRequest>().AsQueryable() var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
.Include(x => x.Type) .Include(x => x.Type)
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => x.LeaveStatus == "APPROVE").ToListAsync(); .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
var res = (from d in data var res = (from d in data
group d by new { d.KeycloakUserId, LeaveTypeId = d.Type.Id, LeaveTypeCode = d.Type.Code } into grp group d by new { d.KeycloakUserId, LeaveTypeId = d.Type.Id, LeaveTypeCode = d.Type.Code } into grp
@ -1438,7 +1472,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.ProfileType == type.Trim().ToUpper()) .Where(x => x.ProfileType == type.Trim().ToUpper())
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true)))))) .Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true))))))
.Where(x => x.LeaveStatus == "APPROVE").ToListAsync(); .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
} }
else else
{ {
@ -1448,7 +1482,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true)))))) .Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true))))))
.Where(x => node == 0 ? x.Child1Id == null : (node == 1 ? x.Child2Id == null : (node == 2 ? x.Child3Id == null : (node == 3 ? x.Child4Id == null : true)))) .Where(x => node == 0 ? x.Child1Id == null : (node == 1 ? x.Child2Id == null : (node == 2 ? x.Child3Id == null : (node == 3 ? x.Child4Id == null : true))))
.Where(x => x.LeaveStatus == "APPROVE").ToListAsync(); .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
} }
var res = (from d in data var res = (from d in data
@ -1504,7 +1538,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
var data = await _dbContext.Set<LeaveRequest>().AsQueryable() var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
.Include(x => x.Type) .Include(x => x.Type)
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => x.LeaveStatus == "APPROVE").ToListAsync(); .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.ToListAsync();
var res = (from d in data var res = (from d in data
group d by new { d.KeycloakUserId, LeaveTypeId = d.Type.Id, LeaveTypeCode = d.Type.Code } into grp group d by new { d.KeycloakUserId, LeaveTypeId = d.Type.Id, LeaveTypeCode = d.Type.Code } into grp
@ -1527,7 +1562,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId) .Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.ToListAsync(); .ToListAsync();
if (data.Count > 0) if (data.Count > 0)
@ -1543,7 +1578,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId) .Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.ToListAsync(); .ToListAsync();
return data.Count; return data.Count;
@ -1628,7 +1663,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking() var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
.Include(x => x.Type) .Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.LeaveStatus == "APPROVE") .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.Where(x => x.LeaveStartDate.Date <= date.Date && x.LeaveEndDate >= date.Date) .Where(x => x.LeaveStartDate.Date <= date.Date && x.LeaveEndDate >= date.Date)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
return data; return data;

View file

@ -170,6 +170,20 @@ namespace BMA.EHR.Application.Repositories
else if (rawData.ApproveStep == "st3") else if (rawData.ApproveStep == "st3")
{ {
rawData.ApproveStep = "st4"; rawData.ApproveStep = "st4";
// TODO: Send notification to 1st Approver
var _firstCommander = rawData.Approvers
.Where(x => x.ApproveType!.ToUpper() == "APPROVER")
.OrderBy(x => x.Seq)
.FirstOrDefault();
// Send Notification
var _noti1 = new Notification
{
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = _firstCommander!.ProfileId,
Type = "",
Payload = $"{URL}/retirement/resign-employee-detail/{id}",
};
_dbContext.Set<Notification>().Add(_noti1);
} }
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -573,6 +587,7 @@ namespace BMA.EHR.Application.Repositories
{ {
var data = await _dbContext.Set<RetirementResignEmployeeCancel>().AsQueryable() var data = await _dbContext.Set<RetirementResignEmployeeCancel>().AsQueryable()
.Include(x => x.Approvers) .Include(x => x.Approvers)
.Include(x => x.RetirementResignEmployee)
.FirstOrDefaultAsync(x => x.Id == id); .FirstOrDefaultAsync(x => x.Id == id);
return data; return data;
@ -599,6 +614,20 @@ namespace BMA.EHR.Application.Repositories
else if (rawData.ApproveStep == "st3") else if (rawData.ApproveStep == "st3")
{ {
rawData.ApproveStep = "st4"; rawData.ApproveStep = "st4";
// TODO: Send notification to 1st Approver
var _firstCommander = rawData.Approvers
.Where(x => x.ApproveType!.ToUpper() == "APPROVER")
.OrderBy(x => x.Seq)
.FirstOrDefault();
// Send Notification
var _noti1 = new Notification
{
Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = _firstCommander!.ProfileId,
Type = "",
Payload = $"{URL}/retirement/resign-employee-detail/{rawData.RetirementResignEmployee.Id}",
};
_dbContext.Set<Notification>().Add(_noti1);
} }
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -611,10 +640,10 @@ namespace BMA.EHR.Application.Repositories
// Send Notification // Send Notification
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = firstCommander!.ProfileId, ReceiverUserId = firstCommander!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-employee-detail/{id}", Payload = $"{URL}/retirement/resign-employee-detail/{rawData.RetirementResignEmployee.Id}",
}; };
_dbContext.Set<Notification>().Add(noti1); _dbContext.Set<Notification>().Add(noti1);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -699,10 +728,10 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti = new Notification var noti = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = nextApprover!.ProfileId, ReceiverUserId = nextApprover!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-employee-detail/{id}", Payload = $"{URL}/retirement/resign-employee-detail/{rawData.RetirementResignEmployee.Id}",
}; };
_dbContext.Set<Notification>().Add(noti); _dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -726,10 +755,10 @@ namespace BMA.EHR.Application.Repositories
// Send Notification // Send Notification
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = firstCommander!.ProfileId, ReceiverUserId = firstCommander!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-employee-detail/{id}", Payload = $"{URL}/retirement/resign-employee-detail/{rawData.RetirementResignEmployee.Id}",
}; };
_dbContext.Set<Notification>().Add(noti1); _dbContext.Set<Notification>().Add(noti1);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -788,10 +817,10 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti = new Notification var noti = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = nextApprover!.ProfileId, ReceiverUserId = nextApprover!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-employee-detail/{id}", Payload = $"{URL}/retirement/resign-employee-detail/{rawData.RetirementResignEmployee.Id}",
}; };
_dbContext.Set<Notification>().Add(noti); _dbContext.Set<Notification>().Add(noti);
@ -816,10 +845,10 @@ namespace BMA.EHR.Application.Repositories
// Send Notification // Send Notification
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = firstCommander!.ProfileId, ReceiverUserId = firstCommander!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-employee-detail/{id}", Payload = $"{URL}/retirement/resign-employee-detail/{rawData.RetirementResignEmployee.Id}",
}; };
_dbContext.Set<Notification>().Add(noti1); _dbContext.Set<Notification>().Add(noti1);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -876,7 +905,7 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = nextApprover!.ProfileId, ReceiverUserId = nextApprover!.ProfileId,
Type = "", Type = "",
Payload = "", Payload = "",
@ -900,7 +929,7 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti = new Notification var noti = new Notification
{ {
Body = $"การขอลาออกของคุณได้รับการอนุมัติ", Body = $"การขอยกเลิกลาออกของคุณได้รับการอนุมัติ",
ReceiverUserId = Guid.Parse(rawData.profileId), ReceiverUserId = Guid.Parse(rawData.profileId),
Type = "", Type = "",
Payload = "", Payload = "",
@ -960,7 +989,7 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = nextApprover!.ProfileId, ReceiverUserId = nextApprover!.ProfileId,
Type = "", Type = "",
Payload = "", Payload = "",
@ -984,7 +1013,7 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti = new Notification var noti = new Notification
{ {
Body = $"การขอลาออกของคุณไม่ได้รับการอนุมัติ \r\nเนื่องจาก{reason}", Body = $"การขอยกเลิกลาออกของคุณไม่ได้รับการอนุมัติ \r\nเนื่องจาก{reason}",
ReceiverUserId = Guid.Parse(rawData.profileId), ReceiverUserId = Guid.Parse(rawData.profileId),
Type = "", Type = "",
Payload = "", Payload = "",

View file

@ -547,10 +547,10 @@ namespace BMA.EHR.Application.Repositories
// Send Notification // Send Notification
var _noti1 = new Notification var _noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = _firstCommander!.ProfileId, ReceiverUserId = _firstCommander!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-detail/{id}", Payload = $"{URL}/retirement/resign-detail/{rawData.RetirementResign.Id}",
}; };
_dbContext.Set<Notification>().Add(_noti1); _dbContext.Set<Notification>().Add(_noti1);
} }
@ -563,10 +563,10 @@ namespace BMA.EHR.Application.Repositories
// Send Notification // Send Notification
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = firstCommander!.ProfileId, ReceiverUserId = firstCommander!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-detail/{id}", Payload = $"{URL}/retirement/resign-detail/{rawData.RetirementResign.Id}",
}; };
_dbContext.Set<Notification>().Add(noti1); _dbContext.Set<Notification>().Add(noti1);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -623,10 +623,10 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti = new Notification var noti = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = nextApprover!.ProfileId, ReceiverUserId = nextApprover!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-detail/{id}", Payload = $"{URL}/retirement/resign-detail/{rawData.RetirementResign.Id}",
}; };
_dbContext.Set<Notification>().Add(noti); _dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -647,10 +647,10 @@ namespace BMA.EHR.Application.Repositories
// Send Notification // Send Notification
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = firstCommander!.ProfileId, ReceiverUserId = firstCommander!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-detail/{id}", Payload = $"{URL}/retirement/resign-detail/{rawData.RetirementResign.Id}",
}; };
_dbContext.Set<Notification>().Add(noti1); _dbContext.Set<Notification>().Add(noti1);
} }
@ -710,10 +710,10 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti = new Notification var noti = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = nextApprover!.ProfileId, ReceiverUserId = nextApprover!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-detail/{id}", Payload = $"{URL}/retirement/resign-detail/{rawData.RetirementResign.Id}",
}; };
_dbContext.Set<Notification>().Add(noti); _dbContext.Set<Notification>().Add(noti);
@ -739,10 +739,10 @@ namespace BMA.EHR.Application.Repositories
// Send Notification // Send Notification
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = firstCommander!.ProfileId, ReceiverUserId = firstCommander!.ProfileId,
Type = "", Type = "",
Payload = $"{URL}/retirement/resign-detail/{id}", Payload = $"{URL}/retirement/resign-detail/{rawData.RetirementResign.Id}",
}; };
_dbContext.Set<Notification>().Add(noti1); _dbContext.Set<Notification>().Add(noti1);
} }
@ -800,7 +800,7 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = nextApprover!.ProfileId, ReceiverUserId = nextApprover!.ProfileId,
Type = "", Type = "",
Payload = "", Payload = "",
@ -826,7 +826,7 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti = new Notification var noti = new Notification
{ {
Body = $"การขอลาออกของคุณได้รับการอนุมัติ", Body = $"การขอยกเลิกลาออกของคุณได้รับการอนุมัติ",
ReceiverUserId = Guid.Parse(rawData.profileId), ReceiverUserId = Guid.Parse(rawData.profileId),
Type = "", Type = "",
Payload = "", Payload = "",
@ -887,7 +887,7 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti1 = new Notification var noti1 = new Notification
{ {
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ", Body = $"การขอยกเลิกลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = nextApprover!.ProfileId, ReceiverUserId = nextApprover!.ProfileId,
Type = "", Type = "",
Payload = "", Payload = "",
@ -910,7 +910,7 @@ namespace BMA.EHR.Application.Repositories
// Send Noti // Send Noti
var noti = new Notification var noti = new Notification
{ {
Body = $"การขอลาออกของคุณไม่ได้รับการอนุมัติ \r\nเนื่องจาก{reason}", Body = $"การขอยกเลิกลาออกของคุณไม่ได้รับการอนุมัติ \r\nเนื่องจาก{reason}",
ReceiverUserId = Guid.Parse(rawData.profileId), ReceiverUserId = Guid.Parse(rawData.profileId),
Type = "", Type = "",
Payload = "", Payload = "",

View file

@ -8,6 +8,7 @@ using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Leave.Commons; using BMA.EHR.Domain.Models.Leave.Commons;
using BMA.EHR.Domain.Models.Leave.Requests; using BMA.EHR.Domain.Models.Leave.Requests;
using BMA.EHR.Domain.Models.Notifications;
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.LeaveRequest; using BMA.EHR.Leave.Service.DTOs.LeaveRequest;
@ -35,6 +36,7 @@ namespace BMA.EHR.Leave.Service.Controllers
#region " Fields " #region " Fields "
private readonly LeaveDbContext _context; private readonly LeaveDbContext _context;
private readonly ApplicationDBContext _appDbContext;
private readonly IHttpContextAccessor _httpContextAccessor; private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IWebHostEnvironment _hostingEnvironment; private readonly IWebHostEnvironment _hostingEnvironment;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
@ -54,6 +56,8 @@ namespace BMA.EHR.Leave.Service.Controllers
private const string APPROVE_STEP_APPROVE = "st4"; private const string APPROVE_STEP_APPROVE = "st4";
private const string APPROVE_STEP_REJECT = "st5"; private const string APPROVE_STEP_REJECT = "st5";
private readonly string URL = string.Empty;
#endregion #endregion
#region " Constuctor and Destructor " #region " Constuctor and Destructor "
@ -70,7 +74,8 @@ namespace BMA.EHR.Leave.Service.Controllers
CommandRepository commandRepository, CommandRepository commandRepository,
UserCalendarRepository userCalendarRepository, UserCalendarRepository userCalendarRepository,
PermissionRepository permission, PermissionRepository permission,
LeaveBeginningRepository leaveBeginningRepository) LeaveBeginningRepository leaveBeginningRepository,
ApplicationDBContext appDbContext)
{ {
_context = context; _context = context;
_httpContextAccessor = httpContextAccessor; _httpContextAccessor = httpContextAccessor;
@ -85,6 +90,9 @@ namespace BMA.EHR.Leave.Service.Controllers
_userCalendarRepository = userCalendarRepository; _userCalendarRepository = userCalendarRepository;
_permission = permission; _permission = permission;
_leaveBeginningRepository = leaveBeginningRepository; _leaveBeginningRepository = leaveBeginningRepository;
_appDbContext = appDbContext;
URL = (_configuration["VITE_URL_MGT"]).Replace("/api/v1", "");
} }
#endregion #endregion
@ -1726,6 +1734,27 @@ namespace BMA.EHR.Leave.Service.Controllers
// save to database // save to database
await _leaveRequestRepository.UpdateWithTrackingAsync(data); await _leaveRequestRepository.UpdateWithTrackingAsync(data);
// TODO: Send notification to 1st Commander
var approvers = data.Approvers
.Where(x => x.ApproveType!.ToUpper() == "APPROVER")
.OrderBy(x => x.Seq)
.ToList();
foreach(var approver in approvers)
{
// Send Notification
var noti1 = new Notification
{
Body = $"คำร้องขอยกเลิกการลาของคุณ {data.FirstName} {data.LastName} รอรับการอนุมัติจากคุณ",
ReceiverUserId = approver!.ProfileId,
Type = "",
Payload = $"{URL}/leave/detail/{id}",
};
_appDbContext.Set<Notification>().Add(noti1);
}
return Success(); return Success();
} }

View file

@ -842,6 +842,20 @@ namespace BMA.EHR.Retirement.Service.Controllers
positionTypeNew = p.posTypeId, positionTypeNew = p.posTypeId,
positionLevelNew = p.posLevelId, positionLevelNew = p.posLevelId,
positionNameNew = p.position, positionNameNew = p.position,
posmasterId = p.posmasterId,
posTypeNameNew = p.posTypeName,
posLevelNameNew = p.posLevelName,
posNoNew = p.posMasterNo?.ToString(),
posNoAbbNew = p.child4ShortName != null ? $"{p.child4ShortName}" :
p.child3ShortName != null ? $"{p.child3ShortName}" :
p.child2ShortName != null ? $"{p.child2ShortName}" :
p.child1ShortName != null ? $"{p.child1ShortName}" :
p.rootShortName != null ? $"{p.rootShortName}" : "",
orgRootNew = p.root,
orgChild1New = p.child1,
orgChild2New = p.child2,
orgChild3New = p.child3,
orgChild4New = p.child4
}).ToList(); }).ToList();
var baseAPIOrg = _configuration["API"]; var baseAPIOrg = _configuration["API"];
@ -1070,6 +1084,20 @@ namespace BMA.EHR.Retirement.Service.Controllers
positionTypeNew = p.posTypeId, positionTypeNew = p.posTypeId,
positionLevelNew = p.posLevelId, positionLevelNew = p.posLevelId,
positionNameNew = p.position, positionNameNew = p.position,
posmasterId = p.posmasterId,
posTypeNameNew = p.posTypeName,
posLevelNameNew = p.posLevelName,
posNoNew = p.posMasterNo?.ToString(),
posNoAbbNew = p.child4ShortName != null ? $"{p.child4ShortName}" :
p.child3ShortName != null ? $"{p.child3ShortName}" :
p.child2ShortName != null ? $"{p.child2ShortName}" :
p.child1ShortName != null ? $"{p.child1ShortName}" :
p.rootShortName != null ? $"{p.rootShortName}" : "",
orgRootNew = p.root,
orgChild1New = p.child1,
orgChild2New = p.child2,
orgChild3New = p.child3,
orgChild4New = p.child4
}).ToList(); }).ToList();
var baseAPIOrg = _configuration["API"]; var baseAPIOrg = _configuration["API"];

View file

@ -1493,7 +1493,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
if (updated == null) if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404); return Error(GlobalMessages.RetirementResignNotFound, 404);
// updated.Status = "APPROVE";
updated.CommanderReject = false; updated.CommanderReject = false;
updated.CommanderApproveReason = req.Reason; updated.CommanderApproveReason = req.Reason;
updated.LastUpdateFullName = FullName ?? "System Administrator"; updated.LastUpdateFullName = FullName ?? "System Administrator";
@ -2455,7 +2454,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
PositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(), PositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(),
ActiveDate = p.ActiveDate == null ? "-" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(), ActiveDate = p.ActiveDate == null ? "-" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(),
Salary = p.AmountOld == null ? "-" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), Salary = p.AmountOld == null ? "-" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
Remark = p.Reason ?? "-", Remark = p.Reason?.ToThaiNumber() ?? "-",
RemarkHorizontal = r.RemarkHorizontal == null ? "-" : r.RemarkHorizontal.ToThaiNumber(), RemarkHorizontal = r.RemarkHorizontal == null ? "-" : r.RemarkHorizontal.ToThaiNumber(),
RemarkVertical = r.RemarkVertical == null ? "-" : r.RemarkVertical.ToThaiNumber() RemarkVertical = r.RemarkVertical == null ? "-" : r.RemarkVertical.ToThaiNumber()
}).ToList(); }).ToList();

View file

@ -1887,12 +1887,12 @@ namespace BMA.EHR.Retirement.Service.Controllers
(p.child2Old == null ? "" : $"{p.child2Old}\n") + (p.child2Old == null ? "" : $"{p.child2Old}\n") +
(p.child1Old == null ? "" : $"{p.child1Old}\n") + (p.child1Old == null ? "" : $"{p.child1Old}\n") +
(p.rootOld == null ? "" : $"{p.rootOld}"), (p.rootOld == null ? "" : $"{p.rootOld}"),
PositionLevel = p.PositionLevelOld ?? "-", PositionLevel = p.PositionLevelOld?.ToThaiNumber() ?? "-",
PositionType = p.PositionTypeOld ?? "-", PositionType = p.PositionTypeOld ?? "-",
PositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(), PositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(),
ActiveDate = p.ActiveDate == null ? "-" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(), ActiveDate = p.ActiveDate == null ? "-" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(),
Salary = p.AmountOld == null ? "-" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), Salary = p.AmountOld == null ? "-" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
Remark = p.Reason ?? "-", Remark = p.Reason?.ToThaiNumber() ?? "-",
RemarkHorizontal = r.RemarkHorizontal == null ? "-" : r.RemarkHorizontal.ToThaiNumber(), RemarkHorizontal = r.RemarkHorizontal == null ? "-" : r.RemarkHorizontal.ToThaiNumber(),
RemarkVertical = r.RemarkVertical == null ? "-" : r.RemarkVertical.ToThaiNumber() RemarkVertical = r.RemarkVertical == null ? "-" : r.RemarkVertical.ToThaiNumber()
}).ToList(); }).ToList();
@ -1987,7 +1987,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
}).ToList(); }).ToList();
var baseAPIOrg = _configuration["API"]; var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));