หา dna บรรจุ
This commit is contained in:
parent
b1ad88c37b
commit
1ef8544833
20 changed files with 1425 additions and 303 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Discipline.Service.Requests;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
|
|
@ -32,6 +33,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public DisciplineComplaint_AppealController(DisciplineDbContext context,
|
||||
|
|
@ -40,6 +42,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
MinIODisciplineService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
// _repository = repository;
|
||||
|
|
@ -49,6 +52,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +62,8 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.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"];
|
||||
private static string StatusDisciplineComplaintAppeal(string value)
|
||||
{
|
||||
switch (value)
|
||||
|
|
@ -361,6 +367,36 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{id}";
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
||||
|
||||
disciplineComplaint_Appeal.root = org.result.root;
|
||||
disciplineComplaint_Appeal.rootId = org.result.rootId;
|
||||
disciplineComplaint_Appeal.rootDnaId = org.result.rootDnaId;
|
||||
disciplineComplaint_Appeal.child1 = org.result.child1;
|
||||
disciplineComplaint_Appeal.child1Id = org.result.child1Id;
|
||||
disciplineComplaint_Appeal.child1DnaId = org.result.child1DnaId;
|
||||
disciplineComplaint_Appeal.child2 = org.result.child2;
|
||||
disciplineComplaint_Appeal.child2Id = org.result.child2Id;
|
||||
disciplineComplaint_Appeal.child2DnaId = org.result.child2DnaId;
|
||||
disciplineComplaint_Appeal.child3 = org.result.child3;
|
||||
disciplineComplaint_Appeal.child3Id = org.result.child3Id;
|
||||
disciplineComplaint_Appeal.child3DnaId = org.result.child3DnaId;
|
||||
disciplineComplaint_Appeal.child4 = org.result.child4;
|
||||
disciplineComplaint_Appeal.child4Id = org.result.child4Id;
|
||||
disciplineComplaint_Appeal.child4DnaId = org.result.child4DnaId;
|
||||
}
|
||||
var disciplineComplaint_Appeal_History = new DisciplineComplaint_Appeal_History
|
||||
{
|
||||
DisciplineComplaint_Appeal = disciplineComplaint_Appeal,
|
||||
|
|
@ -469,6 +505,37 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.ProfileId}";
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
||||
|
||||
disciplineComplaint_Appeal.root = org.result.root;
|
||||
disciplineComplaint_Appeal.rootId = org.result.rootId;
|
||||
disciplineComplaint_Appeal.rootDnaId = org.result.rootDnaId;
|
||||
disciplineComplaint_Appeal.child1 = org.result.child1;
|
||||
disciplineComplaint_Appeal.child1Id = org.result.child1Id;
|
||||
disciplineComplaint_Appeal.child1DnaId = org.result.child1DnaId;
|
||||
disciplineComplaint_Appeal.child2 = org.result.child2;
|
||||
disciplineComplaint_Appeal.child2Id = org.result.child2Id;
|
||||
disciplineComplaint_Appeal.child2DnaId = org.result.child2DnaId;
|
||||
disciplineComplaint_Appeal.child3 = org.result.child3;
|
||||
disciplineComplaint_Appeal.child3Id = org.result.child3Id;
|
||||
disciplineComplaint_Appeal.child3DnaId = org.result.child3DnaId;
|
||||
disciplineComplaint_Appeal.child4 = org.result.child4;
|
||||
disciplineComplaint_Appeal.child4Id = org.result.child4Id;
|
||||
disciplineComplaint_Appeal.child4DnaId = org.result.child4DnaId;
|
||||
}
|
||||
var disciplineComplaint_Appeal_History = new DisciplineComplaint_Appeal_History
|
||||
{
|
||||
DisciplineComplaint_Appeal = disciplineComplaint_Appeal,
|
||||
|
|
@ -653,6 +720,30 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
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 data_search = (from x in _context.DisciplineComplaint_Appeals
|
||||
where (x.Title == null ? false : x.Title.Contains(keyword)) ||
|
||||
(x.Description == null ? false : x.Description.Contains(keyword)) ||
|
||||
|
|
@ -667,6 +758,26 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
data_search = data_search.Where(x => x.Type == type).ToList();
|
||||
if (year != 0)
|
||||
data_search = data_search.Where(x => x.Year == year).ToList();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
data_search = data_search
|
||||
.Where(x => node == 4 ? x.child4DnaId == nodeId : (node == 3 ? x.child3DnaId == nodeId : (node == 2 ? x.child2DnaId == nodeId : (node == 1 ? x.child1DnaId == nodeId : (node == 0 ? x.rootDnaId == nodeId : (node == null ? true : true)))))).ToList();
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
{
|
||||
data_search = data_search
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data_search = data_search
|
||||
.Where(x => node == 0 ? x.child1DnaId == null : (node == 1 ? x.child2DnaId == null : (node == 2 ? x.child3DnaId == null : (node == 3 ? x.child4DnaId == null : true)))).ToList();
|
||||
}
|
||||
var data = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue