This commit is contained in:
parent
06a6019e97
commit
ed0bde9780
7 changed files with 169 additions and 6 deletions
|
|
@ -308,6 +308,46 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<LeaveRequest>> GetListLeaveRequestForAdminAsync(int year, Guid type, string status, DateTime startDate, DateTime endDate, string role, string? nodeId, int? node)
|
||||
{
|
||||
var rawData = _dbContext.Set<LeaveRequest>().AsNoTracking()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => x.LeaveStatus != "DRAFT")
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.AsQueryable();
|
||||
|
||||
if (year != 0)
|
||||
rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
|
||||
|
||||
if (type != Guid.Empty)
|
||||
rawData = rawData.Where(x => x.Type.Id == type);
|
||||
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
rawData = rawData.Where(x => x.LeaveStatus == status);
|
||||
|
||||
if (startDate != DateTime.MinValue)
|
||||
rawData = rawData.Where(x => x.LeaveStartDate >= startDate);
|
||||
|
||||
if (endDate != DateTime.MinValue)
|
||||
rawData = rawData.Where(x => x.LeaveEndDate <= endDate);
|
||||
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))));
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData = rawData
|
||||
//.Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId) : (node == null ? true : true))))))
|
||||
//.Where(x => node == 0 ? x.Child1DnaId == null : (node == 1 ? x.Child2DnaId == null : (node == 2 ? x.Child3DnaId == null : (node == 3 ? x.Child4DnaId == null : true))));
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!));
|
||||
}
|
||||
|
||||
|
||||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestForAdminWithAuthAsync(int year, Guid type, string status, DateTime startDate, DateTime endDate, List<Guid> keycloakIdList)
|
||||
{
|
||||
var rawData = _dbContext.Set<LeaveRequest>().AsNoTracking()
|
||||
|
|
|
|||
|
|
@ -780,6 +780,29 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<GetUserOCAllDto?> GetUserOCAll(Guid keycloakId, string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/user-oc-all/{keycloakId}";
|
||||
var apiKey = _configuration["API_KEY"];
|
||||
|
||||
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetUserOCAllResultDto>(apiResult);
|
||||
return raw?.Result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetUserOCIdDto?> GetUserOC(Guid keycloakId, string? accessToken)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
public string GovAge { get; set; } = string.Empty;
|
||||
public string Age { get; set; } = string.Empty;
|
||||
public DateTime DateAppoint { get; set; }
|
||||
public DateTime DateCurrent { get; set; }
|
||||
public int Amount { get; set; }
|
||||
public string? TelephoneNumber { get; set; } = string.Empty;
|
||||
public string PositionName { get; set; } = string.Empty;
|
||||
|
|
@ -26,7 +27,8 @@
|
|||
public class ProfileLeavePosition
|
||||
{
|
||||
public string? PositionName { get; set; } = string.Empty;
|
||||
public DateTime Date { get; set; }
|
||||
public DateTime DateStart { get; set; }
|
||||
public DateTime DateEnd { get; set; }
|
||||
public string? PositionType { get; set; } = string.Empty;
|
||||
public string? PositionLevel { get; set; } = string.Empty;
|
||||
public string? OrgRoot { get; set; } = string.Empty;
|
||||
|
|
|
|||
57
BMA.EHR.Application/Responses/Profiles/GetUserOCAllDto.cs
Normal file
57
BMA.EHR.Application/Responses/Profiles/GetUserOCAllDto.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
namespace BMA.EHR.Application.Responses.Profiles
|
||||
{
|
||||
public class GetUserOCAllDto
|
||||
{
|
||||
public Guid ProfileId { get; set; }
|
||||
public string? Prefix { get; set; }
|
||||
public string? Rank { get; set; }
|
||||
public string? Avatar { get; set; }
|
||||
public string? AvatarName { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? CitizenId { get; set; }
|
||||
public DateTime? BirthDate { get; set; }
|
||||
public string? Position { get; set; }
|
||||
|
||||
public int? PosMaster { get; set; }
|
||||
public int? PosMasterNo { get; set; }
|
||||
public string? PosLevelName { get; set; }
|
||||
public string? PosLevelRank { get; set; }
|
||||
public Guid? PosLevelId { get; set; }
|
||||
public string? PosTypeName { get; set; }
|
||||
public string? PosTypeRank { get; set; }
|
||||
public Guid? PosTypeId { get; set; }
|
||||
|
||||
public string? PosExecutiveName { get; set; }
|
||||
public int? PosExecutivePriority { get; set; }
|
||||
public Guid? PosExecutiveId { get; set; }
|
||||
|
||||
public string RootId { get; set; }
|
||||
public string? RootDnaId { get; set; }
|
||||
public string? Root { get; set; }
|
||||
public string? RootShortName { get; set; }
|
||||
|
||||
public string? Child1Id { get; set; }
|
||||
public string? Child1DnaId { get; set; }
|
||||
public string? Child1 { get; set; }
|
||||
public string? Child1ShortName { get; set; }
|
||||
|
||||
public string? Child2Id { get; set; }
|
||||
public string? Child2DnaId { get; set; }
|
||||
public string? Child2 { get; set; }
|
||||
public string? Child2ShortName { get; set; }
|
||||
|
||||
public string? Child3Id { get; set; }
|
||||
public string? Child3DnaId { get; set; }
|
||||
public string? Child3 { get; set; }
|
||||
public string? Child3ShortName { get; set; }
|
||||
|
||||
public string? Child4Id { get; set; }
|
||||
public string? Child4DnaId { get; set; }
|
||||
public string? Child4 { get; set; }
|
||||
public string? Child4ShortName { get; set; }
|
||||
|
||||
public int? Node { get; set; }
|
||||
public string? NodeId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
namespace BMA.EHR.Application.Responses.Profiles
|
||||
{
|
||||
public class GetUserOCAllResultDto
|
||||
{
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public int Status { get; set; } = -1;
|
||||
|
||||
public GetUserOCAllDto? Result { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -579,6 +579,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
govAge = profileLeave.GovAge.ToThaiNumber(),
|
||||
age = profileLeave.Age.ToThaiNumber(),
|
||||
dateAppoint = profileLeave.DateAppoint.ToThaiShortDate().ToThaiNumber(),
|
||||
dateCurrent = profileLeave.DateCurrent.ToThaiShortDate().ToThaiNumber(),
|
||||
amount = ((double)profileLeave.Amount).ToNumericText().ToThaiNumber(),
|
||||
telephoneNumber = profileLeave.TelephoneNumber == null ? "" : profileLeave.TelephoneNumber.ToThaiNumber(),
|
||||
|
||||
|
|
@ -595,7 +596,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
positions = profileLeave.Positions.Select(x => new
|
||||
{
|
||||
positionName = x.PositionName == null ? "" : x.PositionName.ToThaiNumber(),
|
||||
date = x.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
dateStart = x.DateStart.ToThaiShortDate().ToThaiNumber(),
|
||||
dateEnd = x.DateEnd.ToThaiShortDate().ToThaiNumber(),
|
||||
positionType = x.PositionType == null ? "" : x.PositionType.ToThaiNumber(),
|
||||
positionLevel = x.PositionLevel == null ? "" : x.PositionLevel.ToThaiNumber(),
|
||||
orgRoot = x.OrgRoot == null ? "" : x.OrgRoot.ToThaiNumber(),
|
||||
|
|
@ -609,7 +611,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
educationLevel = x.EducationLevel == null ? "" : x.EducationLevel.ToThaiNumber(),
|
||||
institute = x.Institute == null ? "" : x.Institute.ToThaiNumber(),
|
||||
country = x.Country == null ? "" : x.Country.ToThaiNumber(),
|
||||
finishDate = x.FinishDate == null ? "" : x.FinishDate.Value.ToThaiShortDate().ToThaiNumber()
|
||||
finishDate = x.FinishDate == null ? "-" : x.FinishDate.Value.ToThaiShortDate().ToThaiNumber()
|
||||
}).ToList()
|
||||
|
||||
//positionName = profileLeave.PositionName,
|
||||
|
|
@ -730,6 +732,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
govAge = profileLeave.GovAge.ToThaiNumber(),
|
||||
age = profileLeave.Age.ToThaiNumber(),
|
||||
dateAppoint = profileLeave.DateAppoint.ToThaiShortDate().ToThaiNumber(),
|
||||
dateCurrent = profileLeave.DateCurrent.ToThaiShortDate().ToThaiNumber(),
|
||||
amount = ((double)profileLeave.Amount).ToNumericText().ToThaiNumber(),
|
||||
telephoneNumber = profileLeave.TelephoneNumber == null ? "" : profileLeave.TelephoneNumber.ToThaiNumber(),
|
||||
|
||||
|
|
@ -746,7 +749,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
positions = profileLeave.Positions.Select(x => new
|
||||
{
|
||||
positionName = x.PositionName == null ? "" : x.PositionName.ToThaiNumber(),
|
||||
date = x.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
dateStart = x.DateStart.ToThaiShortDate().ToThaiNumber(),
|
||||
dateEnd = x.DateEnd.ToThaiShortDate().ToThaiNumber(),
|
||||
positionType = x.PositionType == null ? "" : x.PositionType.ToThaiNumber(),
|
||||
positionLevel = x.PositionLevel == null ? "" : x.PositionLevel.ToThaiNumber(),
|
||||
orgRoot = x.OrgRoot == null ? "" : x.OrgRoot.ToThaiNumber(),
|
||||
|
|
@ -760,7 +764,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
educationLevel = x.EducationLevel == null ? "" : x.EducationLevel.ToThaiNumber(),
|
||||
institute = x.Institute == null ? "" : x.Institute.ToThaiNumber(),
|
||||
country = x.Country == null ? "" : x.Country.ToThaiNumber(),
|
||||
finishDate = x.FinishDate == null ? "" : x.FinishDate.Value.ToThaiShortDate().ToThaiNumber()
|
||||
finishDate = x.FinishDate == null ? "-" : x.FinishDate.Value.ToThaiShortDate().ToThaiNumber()
|
||||
}).ToList()
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1580,7 +1580,33 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
//}
|
||||
|
||||
//var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminWithAuthAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, keycloakList);
|
||||
var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate);
|
||||
//var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate);
|
||||
|
||||
string role = jsonData["result"];
|
||||
var nodeId = string.Empty;
|
||||
var profileAdmin = new GetUserOCAllDto();
|
||||
profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken);
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
nodeId = profileAdmin?.Node == 4
|
||||
? profileAdmin?.Child4DnaId
|
||||
: profileAdmin?.Node == 3
|
||||
? profileAdmin?.Child3DnaId
|
||||
: profileAdmin?.Node == 2
|
||||
? profileAdmin?.Child2DnaId
|
||||
: profileAdmin?.Node == 1
|
||||
? profileAdmin?.Child1DnaId
|
||||
: profileAdmin?.Node == 0
|
||||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
||||
var rawData = await _leaveRequestRepository.GetListLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, role, nodeId, profileAdmin?.Node);
|
||||
|
||||
var result = new List<GetLeaveRequestForAdminResultDto>();
|
||||
|
||||
foreach (var item in rawData)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue