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

This commit is contained in:
Suphonchai Phoonsawat 2025-05-07 15:36:31 +07:00
commit eeb82dcbe1
4 changed files with 23 additions and 51 deletions

View file

@ -31,7 +31,7 @@ namespace BMA.EHR.Application.Repositories
_httpContextAccessor = httpContextAccessor; _httpContextAccessor = httpContextAccessor;
_repositoryNoti = repositoryNoti; _repositoryNoti = repositoryNoti;
_configuration = configuration; _configuration = configuration;
URL = _configuration["MAIN_PAGE"]; URL = _configuration["VITE_URL_MGT"];
} }
#region " Properties " #region " Properties "
@ -143,7 +143,6 @@ namespace BMA.EHR.Application.Repositories
try try
{ {
var data = await _dbContext.Set<RetirementResignEmployee>().AsQueryable() var data = await _dbContext.Set<RetirementResignEmployee>().AsQueryable()
.AsNoTracking()
.Include(x => x.Approvers) .Include(x => x.Approvers)
.FirstOrDefaultAsync(x => x.Id == id); .FirstOrDefaultAsync(x => x.Id == id);
@ -155,15 +154,6 @@ namespace BMA.EHR.Application.Repositories
} }
} }
public async Task<RetirementResignEmployee?> GetByIdWithTrackingAsync(Guid id)
{
var data = await _dbContext.Set<RetirementResignEmployee>().AsQueryable()
//.AsNoTracking()
.Include(x => x.Approvers)
.FirstOrDefaultAsync(x => x.Id == id);
return data;
}
public async Task OfficerApproveRetirementResignEmployee(Guid id) public async Task OfficerApproveRetirementResignEmployee(Guid id)
{ {
var rawData = await GetByIdAsync(id); var rawData = await GetByIdAsync(id);
@ -200,7 +190,7 @@ namespace BMA.EHR.Application.Repositories
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var rawData = await GetByIdWithTrackingAsync(id); var rawData = await GetByIdAsync(id);
if (rawData == null) if (rawData == null)
{ {
throw new Exception(GlobalMessages.DataNotFound); throw new Exception(GlobalMessages.DataNotFound);
@ -266,7 +256,6 @@ namespace BMA.EHR.Application.Repositories
if (approver.Seq != maxSeq) if (approver.Seq != maxSeq)
{ {
rawData.Status = "PENDING"; rawData.Status = "PENDING";
await _dbContext.SaveChangesAsync();
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1); var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
@ -287,7 +276,6 @@ namespace BMA.EHR.Application.Repositories
// rawData.LeaveComment = reason; // rawData.LeaveComment = reason;
rawData.ApproveStep = "st3"; rawData.ApproveStep = "st3";
await _dbContext.SaveChangesAsync();
// TODO: Send notification to 1st Approver // TODO: Send notification to 1st Approver
var firstCommander = rawData.Approvers var firstCommander = rawData.Approvers
@ -314,7 +302,7 @@ namespace BMA.EHR.Application.Repositories
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var rawData = await GetByIdWithTrackingAsync(id); var rawData = await GetByIdAsync(id);
if (rawData == null) if (rawData == null)
{ {
throw new Exception(GlobalMessages.DataNotFound); throw new Exception(GlobalMessages.DataNotFound);
@ -365,7 +353,6 @@ namespace BMA.EHR.Application.Repositories
Payload = $"{URL}/retirement/resign-employee-detail/{id}", Payload = $"{URL}/retirement/resign-employee-detail/{id}",
}; };
_dbContext.Set<Notification>().Add(noti); _dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync();
rawData.Status = "PENDING"; rawData.Status = "PENDING";
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -376,7 +363,6 @@ namespace BMA.EHR.Application.Repositories
// rawData.LeaveComment = reason; // rawData.LeaveComment = reason;
rawData.ApproveStep = "st3"; rawData.ApproveStep = "st3";
await _dbContext.SaveChangesAsync();
// TODO: Send notification to 1st Approver // TODO: Send notification to 1st Approver
var firstCommander = rawData.Approvers var firstCommander = rawData.Approvers
@ -402,7 +388,7 @@ namespace BMA.EHR.Application.Repositories
// Get UserId from token // Get UserId from token
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var rawData = await GetByIdWithTrackingAsync(id); var rawData = await GetByIdAsync(id);
if (rawData == null) if (rawData == null)
{ {
throw new Exception(GlobalMessages.DataNotFound); throw new Exception(GlobalMessages.DataNotFound);
@ -452,8 +438,6 @@ namespace BMA.EHR.Application.Repositories
}; };
_dbContext.Set<Notification>().Add(noti1); _dbContext.Set<Notification>().Add(noti1);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
await _dbContext.SaveChangesAsync();
} }
else else
{ {
@ -461,8 +445,6 @@ namespace BMA.EHR.Application.Repositories
// rawData.LeaveDirectorComment = reason; // rawData.LeaveDirectorComment = reason;
rawData.ApproveStep = "st4"; rawData.ApproveStep = "st4";
await _dbContext.SaveChangesAsync();
// Send Noti // Send Noti
var noti = new Notification var noti = new Notification
{ {
@ -482,7 +464,7 @@ namespace BMA.EHR.Application.Repositories
// Get UserId from token // Get UserId from token
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var rawData = await GetByIdWithTrackingAsync(id); var rawData = await GetByIdAsync(id);
if (rawData == null) if (rawData == null)
{ {
throw new Exception(GlobalMessages.DataNotFound); throw new Exception(GlobalMessages.DataNotFound);

View file

@ -31,7 +31,7 @@ namespace BMA.EHR.Application.Repositories
_httpContextAccessor = httpContextAccessor; _httpContextAccessor = httpContextAccessor;
_repositoryNoti = repositoryNoti; _repositoryNoti = repositoryNoti;
_configuration = configuration; _configuration = configuration;
URL = _configuration["MAIN_PAGE"]; URL = _configuration["VITE_URL_MGT"];
} }
#region " Properties " #region " Properties "
@ -143,7 +143,6 @@ namespace BMA.EHR.Application.Repositories
try try
{ {
var data = await _dbContext.Set<RetirementResign>().AsQueryable() var data = await _dbContext.Set<RetirementResign>().AsQueryable()
.AsNoTracking()
.Include(x => x.Approvers) .Include(x => x.Approvers)
.FirstOrDefaultAsync(x => x.Id == id); .FirstOrDefaultAsync(x => x.Id == id);
@ -155,15 +154,6 @@ namespace BMA.EHR.Application.Repositories
} }
} }
public async Task<RetirementResign?> GetByIdWithTrackingAsync(Guid id)
{
var data = await _dbContext.Set<RetirementResign>().AsQueryable()
//.AsNoTracking()
.Include(x => x.Approvers)
.FirstOrDefaultAsync(x => x.Id == id);
return data;
}
public async Task OfficerApproveRetirementResign(Guid id) public async Task OfficerApproveRetirementResign(Guid id)
{ {
var rawData = await GetByIdAsync(id); var rawData = await GetByIdAsync(id);
@ -175,8 +165,6 @@ namespace BMA.EHR.Application.Repositories
rawData.Status = "PENDING"; rawData.Status = "PENDING";
rawData.ApproveStep = "st2"; rawData.ApproveStep = "st2";
await _dbContext.SaveChangesAsync();
// TODO: Send notification to 1st Commander // TODO: Send notification to 1st Commander
var firstCommander = rawData.Approvers var firstCommander = rawData.Approvers
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER") .Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
@ -200,7 +188,7 @@ namespace BMA.EHR.Application.Repositories
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var rawData = await GetByIdWithTrackingAsync(id); var rawData = await GetByIdAsync(id);
if (rawData == null) if (rawData == null)
{ {
throw new Exception(GlobalMessages.DataNotFound); throw new Exception(GlobalMessages.DataNotFound);
@ -266,7 +254,6 @@ namespace BMA.EHR.Application.Repositories
if (approver.Seq != maxSeq) if (approver.Seq != maxSeq)
{ {
rawData.Status = "PENDING"; rawData.Status = "PENDING";
await _dbContext.SaveChangesAsync();
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1); var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
@ -287,8 +274,6 @@ namespace BMA.EHR.Application.Repositories
// rawData.LeaveComment = reason; // rawData.LeaveComment = reason;
rawData.ApproveStep = "st3"; rawData.ApproveStep = "st3";
await _dbContext.SaveChangesAsync();
// TODO: Send notification to 1st Approver // TODO: Send notification to 1st Approver
var firstCommander = rawData.Approvers var firstCommander = rawData.Approvers
.Where(x => x.ApproveType!.ToUpper() == "APPROVER") .Where(x => x.ApproveType!.ToUpper() == "APPROVER")
@ -314,7 +299,7 @@ namespace BMA.EHR.Application.Repositories
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var rawData = await GetByIdWithTrackingAsync(id); var rawData = await GetByIdAsync(id);
if (rawData == null) if (rawData == null)
{ {
throw new Exception(GlobalMessages.DataNotFound); throw new Exception(GlobalMessages.DataNotFound);
@ -365,7 +350,6 @@ namespace BMA.EHR.Application.Repositories
Payload = $"{URL}/retirement/resign-detail/{id}", Payload = $"{URL}/retirement/resign-detail/{id}",
}; };
_dbContext.Set<Notification>().Add(noti); _dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync();
rawData.Status = "PENDING"; rawData.Status = "PENDING";
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
@ -376,8 +360,6 @@ namespace BMA.EHR.Application.Repositories
// rawData.LeaveComment = reason; // rawData.LeaveComment = reason;
rawData.ApproveStep = "st3"; rawData.ApproveStep = "st3";
await _dbContext.SaveChangesAsync();
// TODO: Send notification to 1st Approver // TODO: Send notification to 1st Approver
var firstCommander = rawData.Approvers var firstCommander = rawData.Approvers
.Where(x => x.ApproveType!.ToUpper() == "APPROVER") .Where(x => x.ApproveType!.ToUpper() == "APPROVER")
@ -402,7 +384,7 @@ namespace BMA.EHR.Application.Repositories
// Get UserId from token // Get UserId from token
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var rawData = await GetByIdWithTrackingAsync(id); var rawData = await GetByIdAsync(id);
if (rawData == null) if (rawData == null)
{ {
throw new Exception(GlobalMessages.DataNotFound); throw new Exception(GlobalMessages.DataNotFound);
@ -452,8 +434,6 @@ namespace BMA.EHR.Application.Repositories
}; };
_dbContext.Set<Notification>().Add(noti1); _dbContext.Set<Notification>().Add(noti1);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
await _dbContext.SaveChangesAsync();
} }
else else
{ {
@ -461,8 +441,6 @@ namespace BMA.EHR.Application.Repositories
// rawData.LeaveDirectorComment = reason; // rawData.LeaveDirectorComment = reason;
rawData.ApproveStep = "st4"; rawData.ApproveStep = "st4";
await _dbContext.SaveChangesAsync();
if (rawData.profileId != null) if (rawData.profileId != null)
{ {
// Send Noti // Send Noti
@ -485,7 +463,7 @@ namespace BMA.EHR.Application.Repositories
// Get UserId from token // Get UserId from token
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var rawData = await GetByIdWithTrackingAsync(id); var rawData = await GetByIdAsync(id);
if (rawData == null) if (rawData == null)
{ {
throw new Exception(GlobalMessages.DataNotFound); throw new Exception(GlobalMessages.DataNotFound);

View file

@ -363,6 +363,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.IsDiscipline, p.IsDiscipline,
p.CancelReason, p.CancelReason,
p.ApproveStep, p.ApproveStep,
Approvers = p.Approvers.Where(x => x.ApproveType.ToUpper() == "APPROVER"),
Commanders = p.Approvers.Where(x => x.ApproveType.ToUpper() == "COMMANDER"),
KeycloakUserId = p.CreatedUserId,
RetirementResignEmployeeCancels = p.RetirementResignEmployeeCancels.FirstOrDefault(), RetirementResignEmployeeCancels = p.RetirementResignEmployeeCancels.FirstOrDefault(),
RetirementResignEmployeeDocs = p.RetirementResignEmployeeDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }), RetirementResignEmployeeDocs = p.RetirementResignEmployeeDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
}) })
@ -442,6 +445,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
data.IsNoBurden, data.IsNoBurden,
data.IsDiscipline, data.IsDiscipline,
data.CancelReason, data.CancelReason,
data.KeycloakUserId,
data.Approvers,
data.Commanders,
data.ApproveStep, data.ApproveStep,
idCancel = data.RetirementResignEmployeeCancels?.Id ?? Guid.Empty, idCancel = data.RetirementResignEmployeeCancels?.Id ?? Guid.Empty,
statusCancel = data.RetirementResignEmployeeCancels?.Status ?? null, statusCancel = data.RetirementResignEmployeeCancels?.Status ?? null,
@ -528,6 +534,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.IsNoDebt, p.IsNoDebt,
p.IsNoBurden, p.IsNoBurden,
p.IsDiscipline, p.IsDiscipline,
Approvers = p.Approvers.Where(x => x.ApproveType.ToUpper() == "APPROVER"),
Commanders = p.Approvers.Where(x => x.ApproveType.ToUpper() == "COMMANDER"),
KeycloakUserId = p.CreatedUserId,
p.CancelReason, p.CancelReason,
idMain = p.RetirementResignEmployee.Id, idMain = p.RetirementResignEmployee.Id,
statusMain = p.RetirementResignEmployee.Status, statusMain = p.RetirementResignEmployee.Status,
@ -610,6 +619,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
data.CancelReason, data.CancelReason,
data.idMain, data.idMain,
data.statusMain, data.statusMain,
data.KeycloakUserId,
data.Approvers,
data.Commanders,
statusCancel = data.Status, statusCancel = data.Status,
Docs = retirementResignEmployeeDocs, Docs = retirementResignEmployeeDocs,
}; };

View file

@ -36,7 +36,7 @@
"BucketName": "bma-recruit" "BucketName": "bma-recruit"
}, },
"Protocol": "HTTPS", "Protocol": "HTTPS",
"MAIN_PAGE": "https://bma-ehr.frappet.synology.me", "VITE_URL_MGT": "https://bma-ehr.frappet.synology.me",
"API": "https://bma-ehr.frappet.synology.me/api/v1", "API": "https://bma-ehr.frappet.synology.me/api/v1",
"APIV2": "https://bma-ehr.frappet.synology.me/api/v2", "APIV2": "https://bma-ehr.frappet.synology.me/api/v2",
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz" "API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"