fix defect
This commit is contained in:
parent
be10c7ef95
commit
a167f5ec9e
3 changed files with 48 additions and 23 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
using Amazon.S3.Model.Internal.MarshallTransformations;
|
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.Commons;
|
using BMA.EHR.Domain.Models.Leave.Commons;
|
||||||
using BMA.EHR.Domain.Models.Leave.Requests;
|
using BMA.EHR.Domain.Models.Leave.Requests;
|
||||||
|
|
@ -7,7 +6,6 @@ using BMA.EHR.Domain.Models.Notifications;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Query;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
@ -23,6 +21,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
private readonly EmailSenderService _emailSenderService;
|
private readonly EmailSenderService _emailSenderService;
|
||||||
|
|
||||||
|
private readonly IApplicationDBContext _appDbContext;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Constructor and Destuctor "
|
#region " Constructor and Destuctor "
|
||||||
|
|
@ -32,7 +32,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
OrganizationCommonRepository organizationCommonRepository,
|
OrganizationCommonRepository organizationCommonRepository,
|
||||||
UserProfileRepository userProfileRepository,
|
UserProfileRepository userProfileRepository,
|
||||||
IConfiguration configuration,
|
IConfiguration configuration,
|
||||||
EmailSenderService emailSenderService) : base(dbContext, httpContextAccessor)
|
EmailSenderService emailSenderService,
|
||||||
|
IApplicationDBContext appDbContext) : base(dbContext, httpContextAccessor)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
|
@ -40,6 +41,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
_userProfileRepository = userProfileRepository;
|
_userProfileRepository = userProfileRepository;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_emailSenderService = emailSenderService;
|
_emailSenderService = emailSenderService;
|
||||||
|
_appDbContext = appDbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -240,8 +242,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
Type = "",
|
Type = "",
|
||||||
Payload = "",
|
Payload = "",
|
||||||
};
|
};
|
||||||
_dbContext.Set<Notification>().Add(noti);
|
_appDbContext.Set<Notification>().Add(noti);
|
||||||
await _dbContext.SaveChangesAsync();
|
await _appDbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RejectCancelLeaveRequestAsync(Guid id, string Reason)
|
public async Task RejectCancelLeaveRequestAsync(Guid id, string Reason)
|
||||||
|
|
@ -273,8 +275,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
Type = "",
|
Type = "",
|
||||||
Payload = "",
|
Payload = "",
|
||||||
};
|
};
|
||||||
_dbContext.Set<Notification>().Add(noti);
|
_appDbContext.Set<Notification>().Add(noti);
|
||||||
await _dbContext.SaveChangesAsync();
|
await _appDbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task OfficerApproveLeaveRequest(Guid id)
|
public async Task OfficerApproveLeaveRequest(Guid id)
|
||||||
|
|
@ -286,7 +288,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
}
|
}
|
||||||
|
|
||||||
rawData.LeaveStatus = "PENDING";
|
rawData.LeaveStatus = "PENDING";
|
||||||
rawData.ApproveStep = "st1";
|
rawData.ApproveStep = "st2";
|
||||||
|
|
||||||
await UpdateAsync(rawData);
|
await UpdateAsync(rawData);
|
||||||
}
|
}
|
||||||
|
|
@ -306,7 +308,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
rawData.LeaveStatus = "PENDING";
|
rawData.LeaveStatus = "PENDING";
|
||||||
rawData.LeaveComment = reason;
|
rawData.LeaveComment = reason;
|
||||||
rawData.ApproveStep = "st2";
|
rawData.ApproveStep = "st3";
|
||||||
|
|
||||||
await UpdateAsync(rawData);
|
await UpdateAsync(rawData);
|
||||||
}
|
}
|
||||||
|
|
@ -319,7 +321,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawData.ApproveStep != "st2")
|
if (rawData.ApproveStep != "st3")
|
||||||
{
|
{
|
||||||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||||
}
|
}
|
||||||
|
|
@ -332,7 +334,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
rawData.LeaveStatus = "APPROVE";
|
rawData.LeaveStatus = "APPROVE";
|
||||||
rawData.LeaveDirectorComment = reason;
|
rawData.LeaveDirectorComment = reason;
|
||||||
rawData.ApproveStep = "st2";
|
rawData.ApproveStep = "st4";
|
||||||
|
|
||||||
await UpdateAsync(rawData);
|
await UpdateAsync(rawData);
|
||||||
|
|
||||||
|
|
@ -344,8 +346,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
Type = "",
|
Type = "",
|
||||||
Payload = "",
|
Payload = "",
|
||||||
};
|
};
|
||||||
_dbContext.Set<Notification>().Add(noti);
|
_appDbContext.Set<Notification>().Add(noti);
|
||||||
await _dbContext.SaveChangesAsync();
|
await _appDbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RejectLeaveRequest(Guid id, string reason)
|
public async Task RejectLeaveRequest(Guid id, string reason)
|
||||||
|
|
@ -356,7 +358,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawData.ApproveStep != "st2")
|
if (rawData.ApproveStep != "st3")
|
||||||
{
|
{
|
||||||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||||
}
|
}
|
||||||
|
|
@ -369,7 +371,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
rawData.LeaveStatus = "REJECT";
|
rawData.LeaveStatus = "REJECT";
|
||||||
rawData.LeaveDirectorComment = reason;
|
rawData.LeaveDirectorComment = reason;
|
||||||
rawData.ApproveStep = "st2";
|
rawData.ApproveStep = "st5";
|
||||||
|
|
||||||
await UpdateAsync(rawData);
|
await UpdateAsync(rawData);
|
||||||
|
|
||||||
|
|
@ -381,8 +383,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
Type = "",
|
Type = "",
|
||||||
Payload = "",
|
Payload = "",
|
||||||
};
|
};
|
||||||
_dbContext.Set<Notification>().Add(noti);
|
_appDbContext.Set<Notification>().Add(noti);
|
||||||
await _dbContext.SaveChangesAsync();
|
await _appDbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetSumSendLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
|
public async Task<int> GetSumSendLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
private readonly HolidayRepository _holidayRepository;
|
private readonly HolidayRepository _holidayRepository;
|
||||||
private readonly CommandRepository _commandRepository;
|
private readonly CommandRepository _commandRepository;
|
||||||
|
|
||||||
|
private const string APPROVE_STEP_CREATE = "st1";
|
||||||
|
private const string APPROVE_STEP_OFFICER_APPROVE = "st2";
|
||||||
|
private const string APPROVE_STEP_COMMANDER_APPROVE = "st3";
|
||||||
|
private const string APPROVE_STEP_APPROVE = "st4";
|
||||||
|
private const string APPROVE_STEP_REJECT = "st5";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Constuctor and Destructor "
|
#region " Constuctor and Destructor "
|
||||||
|
|
@ -133,6 +139,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
LeaveSalaryText = req.LeaveSalaryText ?? "",
|
LeaveSalaryText = req.LeaveSalaryText ?? "",
|
||||||
LeaveStatus = "NEW",
|
LeaveStatus = "NEW",
|
||||||
KeycloakUserId = userId,
|
KeycloakUserId = userId,
|
||||||
|
ApproveStep = APPROVE_STEP_CREATE
|
||||||
};
|
};
|
||||||
|
|
||||||
// get leave last
|
// get leave last
|
||||||
|
|
@ -909,6 +916,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(rawData.KeycloakUserId,
|
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(rawData.KeycloakUserId,
|
||||||
rawData.Type.Id);
|
rawData.Type.Id);
|
||||||
|
|
||||||
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
|
var approver = string.Empty;
|
||||||
|
if (rootOc != null)
|
||||||
|
{
|
||||||
|
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
|
||||||
|
if (list.Count > 0)
|
||||||
|
approver = list.First().Name;
|
||||||
|
}
|
||||||
|
|
||||||
var result = new GetLeaveRequestForAdminByIdDto
|
var result = new GetLeaveRequestForAdminByIdDto
|
||||||
{
|
{
|
||||||
Id = rawData.Id,
|
Id = rawData.Id,
|
||||||
|
|
@ -928,8 +944,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
LeaveAddress = rawData.LeaveAddress,
|
LeaveAddress = rawData.LeaveAddress,
|
||||||
LeaveNumber = rawData.LeaveNumber,
|
LeaveNumber = rawData.LeaveNumber,
|
||||||
LeaveDetail = rawData.LeaveDetail,
|
LeaveDetail = rawData.LeaveDetail,
|
||||||
LeaveDocument = await _minIOService.ImagesPath(rawData.LeaveDocument.Id),
|
LeaveDocument = rawData.LeaveDocument == null ? "" : await _minIOService.ImagesPath(rawData.LeaveDocument.Id),
|
||||||
LeaveDraftDocument = await _minIOService.ImagesPath(rawData.LeaveDraftDocument.Id),
|
LeaveDraftDocument = rawData.LeaveDraftDocument == null ? "" : await _minIOService.ImagesPath(rawData.LeaveDraftDocument.Id),
|
||||||
|
|
||||||
LeaveLastStart = lastLeaveRequest == null ? null : lastLeaveRequest.LeaveStartDate,
|
LeaveLastStart = lastLeaveRequest == null ? null : lastLeaveRequest.LeaveStartDate,
|
||||||
LeaveLastEnd = lastLeaveRequest == null ? null : lastLeaveRequest.LeaveEndDate,
|
LeaveLastEnd = lastLeaveRequest == null ? null : lastLeaveRequest.LeaveEndDate,
|
||||||
|
|
@ -976,6 +992,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
CoupleDayStartDateHistory = rawData.CoupleDayStartDateHistory,
|
CoupleDayStartDateHistory = rawData.CoupleDayStartDateHistory,
|
||||||
CoupleDayEndDateHistory = rawData.CoupleDayEndDateHistory,
|
CoupleDayEndDateHistory = rawData.CoupleDayEndDateHistory,
|
||||||
CoupleDaySumTotalHistory = rawData.CoupleDaySumTotalHistory,
|
CoupleDaySumTotalHistory = rawData.CoupleDaySumTotalHistory,
|
||||||
|
|
||||||
|
Dear = approver,
|
||||||
|
ApproveStep = rawData.ApproveStep ?? "-",
|
||||||
};
|
};
|
||||||
|
|
||||||
return Success(result);
|
return Success(result);
|
||||||
|
|
|
||||||
|
|
@ -121,5 +121,9 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||||
public DateTime CoupleDayEndDateHistory { get; set; } = DateTime.Now;
|
public DateTime CoupleDayEndDateHistory { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
public string CoupleDaySumTotalHistory { get; set; } = string.Empty;
|
public string CoupleDaySumTotalHistory { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Dear { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string ApproveStep { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue