หา dna บรรจุ
This commit is contained in:
parent
b1ad88c37b
commit
1ef8544833
20 changed files with 1425 additions and 303 deletions
|
|
@ -15,6 +15,7 @@ using System.Net.Http.Headers;
|
|||
using System.Security.Claims;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using BMA.EHR.Application.Repositories.Reports;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
{
|
||||
|
|
@ -33,6 +34,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly PermissionRepository _permission;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly TransferReportRepository _service;
|
||||
|
||||
public PlacementTransferController(PlacementRepository repository,
|
||||
|
|
@ -42,6 +44,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission,
|
||||
UserProfileRepository userProfileRepository,
|
||||
TransferReportRepository service)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -51,6 +54,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_permission = permission;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_service = service;
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +64,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -169,18 +174,31 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// var data = JsonConvert.DeserializeObject<OrgPermissionRequest>(getPermission);
|
||||
// string?[]? root = data?.Result?.Root ?? null;
|
||||
// string?[]? child1 = data?.Result?.Child1 ?? null;
|
||||
// string?[]? child2 = data?.Result?.Child2 ?? null;
|
||||
// string?[]? child3 = data?.Result?.Child3 ?? null;
|
||||
// string?[]? child4 = data?.Result?.Child4 ?? null;
|
||||
string role = jsonData["result"];
|
||||
var nodeId = string.Empty;
|
||||
var profileAdmin = new GetUserOCAllDto();
|
||||
profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken);
|
||||
if (role == "NORMAL" || 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 if (role == "ROOT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
||||
var node = profileAdmin?.Node;
|
||||
var placementTransfers = await _context.PlacementTransfers.AsQueryable()
|
||||
// .Where(x => root == null ? true : root.Contains(x.rootOldId))
|
||||
// .Where(x => child1 == null ? true : child1.Contains(x.child1OldId))
|
||||
// .Where(x => child2 == null ? true : child2.Contains(x.child2OldId))
|
||||
// .Where(x => child3 == null ? true : child3.Contains(x.child3OldId))
|
||||
// .Where(x => child4 == null ? true : child4.Contains(x.child4OldId))
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
|
|
@ -225,10 +243,36 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.IsActive,
|
||||
p.rootDnaOldId,
|
||||
p.child1DnaOldId,
|
||||
p.child2DnaOldId,
|
||||
p.child3DnaOldId,
|
||||
p.child4DnaOldId,
|
||||
})
|
||||
.ToListAsync();
|
||||
if (status != null && status.Trim().ToUpper() != "ALL")
|
||||
placementTransfers = placementTransfers.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
placementTransfers = placementTransfers
|
||||
.Where(x => node == 4 ? x.child4DnaOldId == nodeId : (node == 3 ? x.child3DnaOldId == nodeId : (node == 2 ? x.child2DnaOldId == nodeId : (node == 1 ? x.child1DnaOldId == nodeId : (node == 0 ? x.rootDnaOldId == nodeId : (node == null ? true : true)))))).ToList();
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
{
|
||||
placementTransfers = placementTransfers
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementTransfers = placementTransfers
|
||||
.Where(x => node == 0 ? x.child1DnaOldId == null : (node == 1 ? x.child2DnaOldId == null : (node == 2 ? x.child3DnaOldId == null : (node == 3 ? x.child4DnaOldId == null : true)))).ToList();
|
||||
}
|
||||
|
||||
return Success(placementTransfers);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue