fix #1462, #1476
Some checks failed
release-dev / release-dev (push) Failing after 13s

This commit is contained in:
Bright 2025-05-06 18:16:14 +07:00
parent 06a6019e97
commit ed0bde9780
7 changed files with 169 additions and 6 deletions

View file

@ -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()

View file

@ -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

View file

@ -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;

View 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; }
}
}

View file

@ -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; }
}
}