หา 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
|
||||
{
|
||||
|
|
|
|||
55
BMA.EHR.Discipline.Service/Requests/OrgRequest.cs
Normal file
55
BMA.EHR.Discipline.Service/Requests/OrgRequest.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
namespace BMA.EHR.Discipline.Service.Requests
|
||||
{
|
||||
public class OrgRequest
|
||||
{
|
||||
public OrgRequestData result { get; set; } = new();
|
||||
}
|
||||
public class OrgRequestData
|
||||
{
|
||||
public string? profileId { get; set; }
|
||||
public string? prefix { get; set; }
|
||||
public string? firstName { get; set; }
|
||||
public string? lastName { get; set; }
|
||||
public string? citizenId { get; set; }
|
||||
public string? root { get; set; }
|
||||
public string? rootId { get; set; }
|
||||
public string? rootDnaId { get; set; }
|
||||
public string? rootShortName { get; set; }
|
||||
public string? child1 { get; set; }
|
||||
public string? child1Id { get; set; }
|
||||
public string? child1DnaId { get; set; }
|
||||
public string? child1ShortName { get; set; }
|
||||
public string? child2 { get; set; }
|
||||
public string? child2Id { get; set; }
|
||||
public string? child2DnaId { get; set; }
|
||||
public string? child2ShortName { get; set; }
|
||||
public string? child3 { get; set; }
|
||||
public string? child3Id { get; set; }
|
||||
public string? child3DnaId { get; set; }
|
||||
public string? child3ShortName { get; set; }
|
||||
public string? child4 { get; set; }
|
||||
public string? child4Id { get; set; }
|
||||
public string? child4DnaId { get; set; }
|
||||
public string? child4ShortName { get; set; }
|
||||
public string? node { get; set; }
|
||||
public string? nodeId { get; set; }
|
||||
public string? nodeShortName { get; set; }
|
||||
public int? posMasterNo { get; set; }
|
||||
public string? position { get; set; }
|
||||
public string? posTypeId { get; set; }
|
||||
public string? posTypeName { get; set; }
|
||||
public int? posTypeRank { get; set; }
|
||||
public string? posLevelId { get; set; }
|
||||
public string? posTypeShortName { get; set; }
|
||||
public string? posLevelName { get; set; }
|
||||
public int? posLevelRank { get; set; }
|
||||
public string? posExecutiveId { get; set; }
|
||||
public string? posExecutiveName { get; set; }
|
||||
public string? positionExecutiveField { get; set; }
|
||||
public string? positionArea { get; set; }
|
||||
public string? posNo { get; set; }
|
||||
public DateTime? leaveDate { get; set; }
|
||||
public string? education { get; set; }
|
||||
public double? salary { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +47,36 @@ namespace BMA.EHR.Domain.Models.Discipline
|
|||
|
||||
[Comment("สถานภาพ (OFFICER->ข้าราชการ EMPLOYEE->ลูกจ้างประจำ)")]
|
||||
public string? profileType { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน root")]
|
||||
public string? root { get; set; }
|
||||
[Comment("id หน่วยงาน root")]
|
||||
public string? rootId { get; set; }
|
||||
[Comment("id หน่วยงาน root")]
|
||||
public string? rootDnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child1")]
|
||||
public string? child1 { get; set; }
|
||||
[Comment("id หน่วยงาน child1")]
|
||||
public string? child1Id { get; set; }
|
||||
[Comment("id หน่วยงาน child1")]
|
||||
public string? child1DnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child2")]
|
||||
public string? child2 { get; set; }
|
||||
[Comment("id หน่วยงาน child2")]
|
||||
public string? child2Id { get; set; }
|
||||
[Comment("id หน่วยงาน child2")]
|
||||
public string? child2DnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child3")]
|
||||
public string? child3 { get; set; }
|
||||
[Comment("id หน่วยงาน child3")]
|
||||
public string? child3Id { get; set; }
|
||||
[Comment("id หน่วยงาน child3")]
|
||||
public string? child3DnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child4")]
|
||||
public string? child4 { get; set; }
|
||||
[Comment("id หน่วยงาน child4")]
|
||||
public string? child4Id { get; set; }
|
||||
[Comment("id หน่วยงาน child4")]
|
||||
public string? child4DnaId { get; set; }
|
||||
|
||||
public virtual List<DisciplineComplaint_Appeal_Doc> DisciplineComplaint_Appeal_Docs { get; set; } = new List<DisciplineComplaint_Appeal_Doc>();
|
||||
public virtual List<DisciplineComplaint_Appeal_History> DisciplineComplaint_Appeal_Historys { get; set; } = new List<DisciplineComplaint_Appeal_History>();
|
||||
|
|
|
|||
|
|
@ -188,7 +188,6 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
[Comment("ด้าน/สาขา (เก่า)")]
|
||||
public string? positionAreaOld { get; set; }
|
||||
|
||||
|
||||
// public OrgEmployee? OrgEmployee { get; set; }
|
||||
// public PositionEmployeeStatus? PositionEmployeeStatus { get; set; }
|
||||
// public PositionEmployeeLine? PositionEmployeeLine { get; set; }
|
||||
|
|
|
|||
104
BMA.EHR.Domain/Models/Retirement/RetirementEmployeeQuestion.cs
Normal file
104
BMA.EHR.Domain/Models/Retirement/RetirementEmployeeQuestion.cs
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using BMA.EHR.Domain.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using BMA.EHR.Domain.Models.Documents;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
|
||||
namespace BMA.EHR.Domain.Models.Retirement
|
||||
{
|
||||
public class RetirementEmployeeQuestion : EntityBase
|
||||
{
|
||||
[Comment("รอบการลาออก")]
|
||||
public RetirementResignEmployee RetirementResignEmployee { get; set; }
|
||||
[Comment("เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร")]
|
||||
public string? ReasonWork { get; set; }
|
||||
[Comment("อื่นๆ เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร")]
|
||||
public string? ReasonWorkOther { get; set; }
|
||||
[Comment("สำหรับการลาออกในครั้งนี้ ท่านได้คิดทบทวนอย่างจริงจังเป็นระยะเวลานานเท่าใด")]
|
||||
public int? TimeThink { get; set; }
|
||||
[Comment("ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ")]
|
||||
public string? ExitFactor { get; set; }
|
||||
[Comment("อื่นๆ ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ")]
|
||||
public string? ExitFactorOther { get; set; }
|
||||
[Comment("อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง")]
|
||||
public string? Adjust { get; set; }
|
||||
[Comment("อื่นๆ อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง")]
|
||||
public string? AdjustOther { get; set; }
|
||||
[Comment("โปรดระบุสาเหตุที่แท้จริง ที่ทำให้ท่านตัดสินใจลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร")]
|
||||
public string? RealReason { get; set; }
|
||||
[Comment("ปัจจัยใดที่จะช่วยทำให้ท่านเปลี่ยนใจ ไม่อยากลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร")]
|
||||
public string? NotExitFactor { get; set; }
|
||||
[Comment("ท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร")]
|
||||
public bool? Havejob { get; set; }
|
||||
[Comment("เหตุผลท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร")]
|
||||
public string? HavejobReason { get; set; }
|
||||
[Comment("ท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่")]
|
||||
public bool? SuggestFriends { get; set; }
|
||||
[Comment("เหตุผลท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่")]
|
||||
public string? SuggestFriendsReason { get; set; }
|
||||
[Comment("หากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่")]
|
||||
public bool? FutureWork { get; set; }
|
||||
[Comment("เหตุผลหากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่")]
|
||||
public string? FutureWorkReason { get; set; }
|
||||
[Comment("ความคิดเห็นและข้อเสนอแนะอื่น ๆ ")]
|
||||
public string? Suggestion { get; set; }
|
||||
[Comment("กําหนดวันนัดหมายเพื่อทําการสัมภาษณ์การลาออก")]
|
||||
public DateTime? AppointDate { get; set; }
|
||||
|
||||
[Comment("คะแนนข้อ 1")]
|
||||
public int? Score1 { get; set; }
|
||||
[Comment("คะแนนข้อ 2")]
|
||||
public int? Score2 { get; set; }
|
||||
[Comment("คะแนนข้อ 3")]
|
||||
public int? Score3 { get; set; }
|
||||
[Comment("คะแนนข้อ 4")]
|
||||
public int? Score4 { get; set; }
|
||||
[Comment("คะแนนข้อ 5")]
|
||||
public int? Score5 { get; set; }
|
||||
[Comment("คะแนนข้อ 6")]
|
||||
public int? Score6 { get; set; }
|
||||
[Comment("คะแนนข้อ 7")]
|
||||
public int? Score7 { get; set; }
|
||||
[Comment("คะแนนข้อ 8")]
|
||||
public int? Score8 { get; set; }
|
||||
[Comment("คะแนนข้อ 9")]
|
||||
public int? Score9 { get; set; }
|
||||
[Comment("คะแนนข้อ 10")]
|
||||
public int? Score10 { get; set; }
|
||||
[Comment("คะแนนรวม")]
|
||||
public int? ScoreTotal { get; set; }
|
||||
[Comment("ความคิดเห็น")]
|
||||
public string? Comment { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน root ")]
|
||||
public string? root { get; set; }
|
||||
[Comment("id หน่วยงาน root ")]
|
||||
public string? rootId { get; set; }
|
||||
[Comment("id หน่วยงาน root ")]
|
||||
public string? rootDnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child1 ")]
|
||||
public string? child1 { get; set; }
|
||||
[Comment("id หน่วยงาน child1 ")]
|
||||
public string? child1Id { get; set; }
|
||||
[Comment("id หน่วยงาน child1 ")]
|
||||
public string? child1DnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child2 ")]
|
||||
public string? child2 { get; set; }
|
||||
[Comment("id หน่วยงาน child2 ")]
|
||||
public string? child2Id { get; set; }
|
||||
[Comment("id หน่วยงาน child2 ")]
|
||||
public string? child2DnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child3 ")]
|
||||
public string? child3 { get; set; }
|
||||
[Comment("id หน่วยงาน child3 ")]
|
||||
public string? child3Id { get; set; }
|
||||
[Comment("id หน่วยงาน child3 ")]
|
||||
public string? child3DnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child4 ")]
|
||||
public string? child4 { get; set; }
|
||||
[Comment("id หน่วยงาน child4 ")]
|
||||
public string? child4Id { get; set; }
|
||||
[Comment("id หน่วยงาน child4 ")]
|
||||
public string? child4DnaId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -70,5 +70,35 @@ namespace BMA.EHR.Domain.Models.Retirement
|
|||
public int? ScoreTotal { get; set; }
|
||||
[Comment("ความคิดเห็น")]
|
||||
public string? Comment { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน root ")]
|
||||
public string? root { get; set; }
|
||||
[Comment("id หน่วยงาน root ")]
|
||||
public string? rootId { get; set; }
|
||||
[Comment("id หน่วยงาน root ")]
|
||||
public string? rootDnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child1 ")]
|
||||
public string? child1 { get; set; }
|
||||
[Comment("id หน่วยงาน child1 ")]
|
||||
public string? child1Id { get; set; }
|
||||
[Comment("id หน่วยงาน child1 ")]
|
||||
public string? child1DnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child2 ")]
|
||||
public string? child2 { get; set; }
|
||||
[Comment("id หน่วยงาน child2 ")]
|
||||
public string? child2Id { get; set; }
|
||||
[Comment("id หน่วยงาน child2 ")]
|
||||
public string? child2DnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child3 ")]
|
||||
public string? child3 { get; set; }
|
||||
[Comment("id หน่วยงาน child3 ")]
|
||||
public string? child3Id { get; set; }
|
||||
[Comment("id หน่วยงาน child3 ")]
|
||||
public string? child3DnaId { get; set; }
|
||||
[Comment("ชื่อหน่วยงาน child4 ")]
|
||||
public string? child4 { get; set; }
|
||||
[Comment("id หน่วยงาน child4 ")]
|
||||
public string? child4Id { get; set; }
|
||||
[Comment("id หน่วยงาน child4 ")]
|
||||
public string? child4DnaId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,16 @@ namespace BMA.EHR.Domain.Models.Retirement
|
|||
public string? positionExecutiveFieldOld { get; set; }
|
||||
[Comment("ด้าน/สาขา (เก่า)")]
|
||||
public string? positionAreaOld { get; set; }
|
||||
[Comment("id หน่วยงาน root old")]
|
||||
public string? rootDnaOldId { get; set; }
|
||||
[Comment("id หน่วยงาน child1 old")]
|
||||
public string? child1DnaOldId { get; set; }
|
||||
[Comment("id หน่วยงาน child2 old")]
|
||||
public string? child2DnaOldId { get; set; }
|
||||
[Comment("id หน่วยงาน child3 old")]
|
||||
public string? child3DnaOldId { get; set; }
|
||||
[Comment("id หน่วยงาน child4 old")]
|
||||
public string? child4DnaOldId { get; set; }
|
||||
public List<RetirementResignCancelApprover> Approvers { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,6 +133,16 @@ namespace BMA.EHR.Domain.Models.Retirement
|
|||
public string? ApproveStep { get; set; } = string.Empty;
|
||||
[Comment("คนยื่นมาอยู่ในกลุ่ม")]
|
||||
public string? Group { get; set; } = string.Empty;
|
||||
[Comment("id หน่วยงาน root old")]
|
||||
public string? rootDnaOldId { get; set; }
|
||||
[Comment("id หน่วยงาน child1 old")]
|
||||
public string? child1DnaOldId { get; set; }
|
||||
[Comment("id หน่วยงาน child2 old")]
|
||||
public string? child2DnaOldId { get; set; }
|
||||
[Comment("id หน่วยงาน child3 old")]
|
||||
public string? child3DnaOldId { get; set; }
|
||||
[Comment("id หน่วยงาน child4 old")]
|
||||
public string? child4DnaOldId { get; set; }
|
||||
[Required, Comment("อ้างอิงรับย้าย")]
|
||||
public virtual RetirementResignEmployee RetirementResignEmployee { get; set; }
|
||||
public List<RetirementResignEmployeeCancelApprover> Approvers { get; set; } = new();
|
||||
|
|
|
|||
|
|
@ -350,6 +350,7 @@ namespace BMA.EHR.Infrastructure.Persistence
|
|||
public DbSet<RetirementExpulsion> RetirementExpulsions { get; set; }
|
||||
public DbSet<RetirementOther> RetirementOthers { get; set; }
|
||||
public DbSet<RetirementOtherDoc> RetirementOtherDocs { get; set; }
|
||||
public DbSet<RetirementEmployeeQuestion> RetirementEmployeeQuestions { get; set; }
|
||||
public DbSet<RetirementQuestion> RetirementQuestions { get; set; }
|
||||
public DbSet<RetirementQuestionnaireQuestion> RetirementQuestionnaireQuestions { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
|
|
@ -31,6 +32,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public PlacementAppointmentController(PlacementRepository repository,
|
||||
|
|
@ -39,6 +41,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permiss)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -47,6 +50,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permiss;
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +60,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
|
||||
|
||||
|
|
@ -76,11 +81,30 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// string?[] rootId = jsonData?.result?.rootId ?? null;
|
||||
// string?[] child1Id = jsonData?.result?.child1Id ?? null;
|
||||
// string?[] child2Id = jsonData?.result?.child2Id ?? null;
|
||||
// string?[] child3Id = jsonData?.result?.child3Id ?? null;
|
||||
// string?[] child4Id = jsonData?.result?.child4Id ?? 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 placementAppointments = await _context.PlacementAppointments.AsQueryable()
|
||||
.Where(x => x.type == "OFFICER")
|
||||
// .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
|
||||
|
|
@ -173,10 +197,35 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.positionAreaOld,
|
||||
p.CreatedAt,
|
||||
p.typeCommand,
|
||||
p.rootDnaId,
|
||||
p.child1DnaId,
|
||||
p.child2DnaId,
|
||||
p.child3DnaId,
|
||||
p.child4DnaId,
|
||||
})
|
||||
.ToListAsync();
|
||||
if (status != null && status.Trim().ToUpper() != "ALL")
|
||||
placementAppointments = placementAppointments.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
.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")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
.Where(x => node == 0 ? x.child1DnaId == null : (node == 1 ? x.child2DnaId == null : (node == 2 ? x.child3DnaId == null : (node == 3 ? x.child4DnaId == null : true)))).ToList();
|
||||
}
|
||||
return Success(placementAppointments);
|
||||
}
|
||||
|
||||
|
|
@ -477,8 +526,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
(org.result.child2 == null ? "" : org.result.child2 + "\n") +
|
||||
(org.result.child1 == null ? "" : org.result.child1 + "\n") +
|
||||
(org.result.root == null ? "" : org.result.root);
|
||||
placementAppointment.OrganizationPositionOld = org.result.position + "\n" +
|
||||
(placementAppointment.PositionExecutiveOld == null ? "" : (placementAppointment.positionExecutiveField == null ? placementAppointment.PositionExecutiveOld + "\n": placementAppointment.PositionExecutiveOld + "(" + placementAppointment.positionExecutiveField + ")" + "\n"))
|
||||
placementAppointment.OrganizationPositionOld = org.result.position + "\n" +
|
||||
(placementAppointment.PositionExecutiveOld == null ? "" : (placementAppointment.positionExecutiveField == null ? placementAppointment.PositionExecutiveOld + "\n" : placementAppointment.PositionExecutiveOld + "(" + placementAppointment.positionExecutiveField + ")" + "\n"))
|
||||
+ placementAppointment.OrganizationOld;
|
||||
placementAppointment.AmountOld = org.result.salary;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -30,6 +31,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public PlacementAppointmentEmployeeController(PlacementRepository repository,
|
||||
|
|
@ -38,6 +40,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -46,6 +49,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
|
|
@ -55,6 +59,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
|
||||
|
||||
|
|
@ -75,11 +80,30 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// string?[] rootId = jsonData?.result?.rootId ?? null;
|
||||
// string?[] child1Id = jsonData?.result?.child1Id ?? null;
|
||||
// string?[] child2Id = jsonData?.result?.child2Id ?? null;
|
||||
// string?[] child3Id = jsonData?.result?.child3Id ?? null;
|
||||
// string?[] child4Id = jsonData?.result?.child4Id ?? 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 placementAppointments = await _context.PlacementAppointments.AsQueryable()
|
||||
.Where(x => x.type == "EMPLOYEE")
|
||||
// .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
|
||||
|
|
@ -167,32 +191,35 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.positionOld,
|
||||
p.CreatedAt,
|
||||
p.typeCommand,
|
||||
p.rootDnaId,
|
||||
p.child1DnaId,
|
||||
p.child2DnaId,
|
||||
p.child3DnaId,
|
||||
p.child4DnaId,
|
||||
})
|
||||
.ToListAsync();
|
||||
// if (keyword != "")
|
||||
// {
|
||||
// var data = placementAppointments.Where(x =>
|
||||
// (x.citizenId != null && x.citizenId.Contains(keyword)) ||
|
||||
// (x.prefix != null && x.prefix.Contains(keyword)) ||
|
||||
// (x.firstName != null && x.firstName.Contains(keyword)) ||
|
||||
// (x.lastName != null && x.lastName.Contains(keyword)) ||
|
||||
// (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) ||
|
||||
// (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) ||
|
||||
// (x.OrganizationOld != null && x.OrganizationOld.Contains(keyword)) ||
|
||||
// (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) ||
|
||||
// (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) ||
|
||||
// (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) ||
|
||||
// (x.Reason != null && x.Reason.Contains(keyword)) ||
|
||||
// (x.nodeName != null && x.nodeName.Contains(keyword)))
|
||||
// .OrderByDescending(x => x.CreatedAt)
|
||||
// .Skip((page - 1) * pageSize)
|
||||
// .Take(pageSize)
|
||||
// .ToList();
|
||||
|
||||
// placementAppointments = data;
|
||||
// }
|
||||
if (status != null && status.Trim().ToUpper() != "ALL")
|
||||
placementAppointments = placementAppointments.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
.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")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
.Where(x => node == 0 ? x.child1DnaId == null : (node == 1 ? x.child2DnaId == null : (node == 2 ? x.child3DnaId == null : (node == 3 ? x.child4DnaId == null : true)))).ToList();
|
||||
}
|
||||
return Success(placementAppointments);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
|
|
@ -31,6 +32,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public PlacementOfficerController(PlacementRepository repository,
|
||||
|
|
@ -39,6 +41,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -47,6 +50,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +60,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
|
||||
|
||||
|
|
@ -76,11 +81,30 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// string?[] rootId = jsonData?.result?.rootId ?? null;
|
||||
// string?[] child1Id = jsonData?.result?.child1Id ?? null;
|
||||
// string?[] child2Id = jsonData?.result?.child2Id ?? null;
|
||||
// string?[] child3Id = jsonData?.result?.child3Id ?? null;
|
||||
// string?[] child4Id = jsonData?.result?.child4Id ?? 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 placementOfficers = await _context.PlacementOfficers.AsQueryable()
|
||||
// .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
|
||||
// .Where(x => child1Id == null ? true : child1Id.Contains(x.child1OldId))
|
||||
|
|
@ -128,10 +152,35 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.Organization,
|
||||
p.OrganizationPositionOld,
|
||||
p.IsActive,
|
||||
p.rootDnaOldId,
|
||||
p.child1DnaOldId,
|
||||
p.child2DnaOldId,
|
||||
p.child3DnaOldId,
|
||||
p.child4DnaOldId,
|
||||
})
|
||||
.ToListAsync();
|
||||
if (status != null && status.Trim().ToUpper() != "ALL")
|
||||
placementOfficers = placementOfficers.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
placementOfficers = placementOfficers
|
||||
.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")
|
||||
{
|
||||
placementOfficers = placementOfficers
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementOfficers = placementOfficers
|
||||
.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(placementOfficers);
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +470,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
(org.result.child2 == null ? "" : org.result.child2 + "\n") +
|
||||
(org.result.child1 == null ? "" : org.result.child1 + "\n") +
|
||||
(org.result.root == null ? "" : org.result.root);
|
||||
placementOfficer.OrganizationPositionOld = org.result.position + "\n" +
|
||||
placementOfficer.OrganizationPositionOld = org.result.position + "\n" +
|
||||
(placementOfficer.PositionExecutiveOld == null ? "" : (placementOfficer.positionExecutiveField == null ? placementOfficer.PositionExecutiveOld + "\n" : placementOfficer.PositionExecutiveOld + "(" + placementOfficer.positionExecutiveField + ")" + "\n"))
|
||||
+ placementOfficer.OrganizationOld;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ using Swashbuckle.AspNetCore.Annotations;
|
|||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using System.Reflection;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
{
|
||||
|
|
@ -32,6 +33,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public PlacementReceiveController(PlacementRepository repository,
|
||||
|
|
@ -40,6 +42,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permiss)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -48,6 +51,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permiss;
|
||||
}
|
||||
|
||||
|
|
@ -57,6 +61,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
|
||||
|
||||
|
|
@ -77,11 +82,30 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// string?[] rootId = jsonData?.result?.rootId ?? null;
|
||||
// string?[] child1Id = jsonData?.result?.child1Id ?? null;
|
||||
// string?[] child2Id = jsonData?.result?.child2Id ?? null;
|
||||
// string?[] child3Id = jsonData?.result?.child3Id ?? null;
|
||||
// string?[] child4Id = jsonData?.result?.child4Id ?? 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 placementReceives = await _context.PlacementReceives.AsQueryable()
|
||||
// .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
|
||||
// .Where(x => child1Id == null ? true : child1Id.Contains(x.child1OldId))
|
||||
|
|
@ -165,10 +189,35 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.posLevelNameOld,
|
||||
p.CreatedAt,
|
||||
p.profileId,
|
||||
p.rootDnaId,
|
||||
p.child1DnaId,
|
||||
p.child2DnaId,
|
||||
p.child3DnaId,
|
||||
p.child4DnaId,
|
||||
})
|
||||
.ToListAsync();
|
||||
if (status != null && status.Trim().ToUpper() != "ALL")
|
||||
placementReceives = placementReceives.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
placementReceives = placementReceives
|
||||
.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")
|
||||
{
|
||||
placementReceives = placementReceives
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementReceives = placementReceives
|
||||
.Where(x => node == 0 ? x.child1DnaId == null : (node == 1 ? x.child2DnaId == null : (node == 2 ? x.child3DnaId == null : (node == 3 ? x.child4DnaId == null : true)))).ToList();
|
||||
}
|
||||
return Success(placementReceives);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
|
|
@ -32,6 +33,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public PlacementRepatriationController(PlacementRepository repository,
|
||||
|
|
@ -40,6 +42,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permiss)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -48,6 +51,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permiss;
|
||||
}
|
||||
|
||||
|
|
@ -57,6 +61,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
|
||||
|
||||
|
|
@ -77,11 +82,30 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// string?[] rootId = jsonData?.result?.rootId ?? null;
|
||||
// string?[] child1Id = jsonData?.result?.child1Id ?? null;
|
||||
// string?[] child2Id = jsonData?.result?.child2Id ?? null;
|
||||
// string?[] child3Id = jsonData?.result?.child3Id ?? null;
|
||||
// string?[] child4Id = jsonData?.result?.child4Id ?? 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 placementRepatriations = await _context.PlacementRepatriations.AsQueryable()
|
||||
// .Where(x => rootId == null ? true : rootId.Contains(x.rootOldId))
|
||||
// .Where(x => child1Id == null ? true : child1Id.Contains(x.child1OldId))
|
||||
|
|
@ -133,10 +157,35 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.OrganizationPositionOld,
|
||||
p.IsActive,
|
||||
p.DateRepatriation,
|
||||
p.rootDnaOldId,
|
||||
p.child1DnaOldId,
|
||||
p.child2DnaOldId,
|
||||
p.child3DnaOldId,
|
||||
p.child4DnaOldId,
|
||||
})
|
||||
.ToListAsync();
|
||||
if (status != null && status.Trim().ToUpper() != "ALL")
|
||||
placementRepatriations = placementRepatriations.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
placementRepatriations = placementRepatriations
|
||||
.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")
|
||||
{
|
||||
placementRepatriations = placementRepatriations
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementRepatriations = placementRepatriations
|
||||
.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(placementRepatriations);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Repositories.Reports;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -34,6 +35,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public RetirementDeceasedController(RetirementRepository repository,
|
||||
|
|
@ -43,6 +45,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
MinIOService documentService,
|
||||
IConfiguration configuration,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -52,6 +55,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
|
|
@ -61,6 +65,7 @@ namespace BMA.EHR.Retirement.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
|
||||
|
||||
|
|
@ -81,19 +86,32 @@ namespace BMA.EHR.Retirement.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;
|
||||
}
|
||||
|
||||
string?[] rootId = jsonData?.result?.rootId ?? null;
|
||||
string?[] child1Id = jsonData?.result?.child1Id ?? null;
|
||||
string?[] child2Id = jsonData?.result?.child2Id ?? null;
|
||||
string?[] child3Id = jsonData?.result?.child3Id ?? null;
|
||||
string?[] child4Id = jsonData?.result?.child4Id ?? null;
|
||||
var node = profileAdmin?.Node;
|
||||
var retirementDeceaseds = await _context.RetirementDeceaseds.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Where(x => rootId == null ? true : rootId.Contains(x.rootId))
|
||||
.Where(x => child1Id == null ? true : child1Id.Contains(x.child1Id))
|
||||
.Where(x => child2Id == null ? true : child2Id.Contains(x.child2Id))
|
||||
.Where(x => child3Id == null ? true : child3Id.Contains(x.child3Id))
|
||||
.Where(x => child4Id == null ? true : child4Id.Contains(x.child4Id))
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
|
|
@ -120,8 +138,33 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.posTypeName,
|
||||
p.CreatedAt,
|
||||
p.IsActive,
|
||||
p.rootDnaId,
|
||||
p.child1DnaId,
|
||||
p.child2DnaId,
|
||||
p.child3DnaId,
|
||||
p.child4DnaId,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
retirementDeceaseds = retirementDeceaseds
|
||||
.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")
|
||||
{
|
||||
retirementDeceaseds = retirementDeceaseds
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementDeceaseds = retirementDeceaseds
|
||||
.Where(x => node == 0 ? x.child1DnaId == null : (node == 1 ? x.child2DnaId == null : (node == 2 ? x.child3DnaId == null : (node == 3 ? x.child4DnaId == null : true)))).ToList();
|
||||
}
|
||||
return Success(retirementDeceaseds);
|
||||
}
|
||||
|
||||
|
|
@ -482,7 +525,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
@ -652,32 +695,32 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
};
|
||||
//if (retirementDeceased.profileType.Trim().ToUpper() == "OFFICER")
|
||||
//{
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{item.ProfileId}";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{item.ProfileId}";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
|
||||
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
|
||||
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
|
||||
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
|
||||
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
|
||||
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
|
||||
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
|
||||
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "\n") +
|
||||
(org.result.child3 == null ? "" : org.result.child3 + "\n") +
|
||||
(org.result.child2 == null ? "" : org.result.child2 + "\n") +
|
||||
(org.result.child1 == null ? "" : org.result.child1 + "\n") +
|
||||
(org.result.root == null ? "" : org.result.root);
|
||||
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
|
||||
}
|
||||
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
|
||||
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
|
||||
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
|
||||
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
|
||||
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
|
||||
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "\n") +
|
||||
(org.result.child3 == null ? "" : org.result.child3 + "\n") +
|
||||
(org.result.child2 == null ? "" : org.result.child2 + "\n") +
|
||||
(org.result.child1 == null ? "" : org.result.child1 + "\n") +
|
||||
(org.result.root == null ? "" : org.result.root);
|
||||
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
|
||||
}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
|
|
@ -31,6 +32,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public RetirementOtherController(RetirementRepository repository,
|
||||
|
|
@ -39,6 +41,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -47,6 +50,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +60,7 @@ namespace BMA.EHR.Retirement.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
|
||||
|
||||
|
|
@ -77,135 +82,140 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var rootId = "";
|
||||
var child1Id = "";
|
||||
var child2Id = "";
|
||||
var child3Id = "";
|
||||
var child4Id = "";
|
||||
var apiUrl = $"{_configuration["API"]}/org/permission/checkOrg/{UserId}";
|
||||
using (var client = new HttpClient())
|
||||
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")
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
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);
|
||||
rootId = org.result.rootId == null ? "" : org.result.rootId;
|
||||
child1Id = org.result.child1Id == null ? "" : org.result.child1Id;
|
||||
child2Id = org.result.child2Id == null ? "" : org.result.child2Id;
|
||||
child3Id = org.result.child3Id == null ? "" : org.result.child3Id;
|
||||
child4Id = org.result.child4Id == null ? "" : org.result.child4Id;
|
||||
|
||||
var retirementOthers = await _context.RetirementOthers.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
// .Where(x => rootId == "" ? true : (child1Id == "" ? x.rootOldId == rootId : (child2Id == "" ? x.child1OldId == child1Id : (child3Id == "" ? x.child2OldId == child2Id : (child4Id == "" ? x.child3OldId == child3Id : x.child4OldId == child4Id)))))
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
p.lastName,
|
||||
p.root,
|
||||
p.rootId,
|
||||
p.rootShortName,
|
||||
p.child1,
|
||||
p.child1Id,
|
||||
p.child1ShortName,
|
||||
p.child2,
|
||||
p.child2Id,
|
||||
p.child2ShortName,
|
||||
p.child3,
|
||||
p.child3Id,
|
||||
p.child3ShortName,
|
||||
p.child4,
|
||||
p.child4Id,
|
||||
p.child4ShortName,
|
||||
p.orgRevisionId,
|
||||
p.positionId,
|
||||
p.posMasterNo,
|
||||
p.position,
|
||||
p.PositionExecutive,
|
||||
p.positionField,
|
||||
p.posTypeId,
|
||||
p.posTypeName,
|
||||
p.posLevelId,
|
||||
p.posLevelName,
|
||||
node = p.root == null ? (int?)null : (p.child1 == null ? 0 : (p.child2 == null ? 1 : (p.child3 == null ? 2 : (p.child4 == null ? 3 : 4)))),
|
||||
nodeName = p.root == null ? null : (p.child1 == null ? p.root : (p.child2 == null ? p.child1 : (p.child3 == null ? p.child2 : (p.child4 == null ? p.child3 : p.child4)))),
|
||||
nodeId = p.rootId == null ? null : (p.child1Id == null ? p.rootId : (p.child2Id == null ? p.child1Id : (p.child3Id == null ? p.child2Id : (p.child4Id == null ? p.child3Id : p.child4Id)))),
|
||||
nodeShortName = p.rootShortName == null ? null : (p.child1ShortName == null ? p.rootShortName : (p.child2ShortName == null ? p.child1ShortName : (p.child3ShortName == null ? p.child2ShortName : (p.child4ShortName == null ? p.child3ShortName : p.child4ShortName)))),
|
||||
|
||||
p.rootOld,
|
||||
p.rootOldId,
|
||||
p.rootShortNameOld,
|
||||
p.child1Old,
|
||||
p.child1OldId,
|
||||
p.child1ShortNameOld,
|
||||
p.child2Old,
|
||||
p.child2OldId,
|
||||
p.child2ShortNameOld,
|
||||
p.child3Old,
|
||||
p.child3OldId,
|
||||
p.child3ShortNameOld,
|
||||
p.child4Old,
|
||||
p.child4OldId,
|
||||
p.child4ShortNameOld,
|
||||
p.PositionOld,
|
||||
p.PositionExecutiveOld,
|
||||
p.posMasterNoOld,
|
||||
p.posTypeOldId,
|
||||
p.posTypeNameOld,
|
||||
p.posLevelOldId,
|
||||
p.posLevelNameOld,
|
||||
|
||||
p.Status,
|
||||
p.Amount,
|
||||
p.ReportingDate,
|
||||
|
||||
p.CreatedAt,
|
||||
p.Reason,
|
||||
p.MilitaryDate,
|
||||
p.EducationOld,
|
||||
p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.posmasterId,
|
||||
p.PositionDate,
|
||||
CommandType = p.CommandType == null ? null : p.CommandType.Name,
|
||||
})
|
||||
.ToListAsync();
|
||||
// if (keyword != "")
|
||||
// {
|
||||
// var data = retirementOthers.Where(x =>
|
||||
// (x.prefix != null && x.prefix.Contains(keyword)) ||
|
||||
// (x.firstName != null && x.firstName.Contains(keyword)) ||
|
||||
// (x.lastName != null && x.lastName.Contains(keyword)) ||
|
||||
// (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) ||
|
||||
// (x.posMasterNoOld != null && x.posMasterNoOld.ToString().Contains(keyword)) ||
|
||||
// (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) ||
|
||||
// (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) ||
|
||||
// (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) ||
|
||||
// (x.Reason != null && x.Reason.Contains(keyword)))
|
||||
// .OrderByDescending(x => x.CreatedAt)
|
||||
// .Skip((page - 1) * pageSize)
|
||||
// .Take(pageSize)
|
||||
// .ToList();
|
||||
|
||||
// retirementOthers = data;
|
||||
// }
|
||||
if (status != null && status.Trim().ToUpper() != "ALL")
|
||||
retirementOthers = retirementOthers.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
return Success(retirementOthers);
|
||||
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 retirementOthers = await _context.RetirementOthers.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
p.lastName,
|
||||
p.root,
|
||||
p.rootId,
|
||||
p.rootShortName,
|
||||
p.child1,
|
||||
p.child1Id,
|
||||
p.child1ShortName,
|
||||
p.child2,
|
||||
p.child2Id,
|
||||
p.child2ShortName,
|
||||
p.child3,
|
||||
p.child3Id,
|
||||
p.child3ShortName,
|
||||
p.child4,
|
||||
p.child4Id,
|
||||
p.child4ShortName,
|
||||
p.orgRevisionId,
|
||||
p.positionId,
|
||||
p.posMasterNo,
|
||||
p.position,
|
||||
p.PositionExecutive,
|
||||
p.positionField,
|
||||
p.posTypeId,
|
||||
p.posTypeName,
|
||||
p.posLevelId,
|
||||
p.posLevelName,
|
||||
node = p.root == null ? (int?)null : (p.child1 == null ? 0 : (p.child2 == null ? 1 : (p.child3 == null ? 2 : (p.child4 == null ? 3 : 4)))),
|
||||
nodeName = p.root == null ? null : (p.child1 == null ? p.root : (p.child2 == null ? p.child1 : (p.child3 == null ? p.child2 : (p.child4 == null ? p.child3 : p.child4)))),
|
||||
nodeId = p.rootId == null ? null : (p.child1Id == null ? p.rootId : (p.child2Id == null ? p.child1Id : (p.child3Id == null ? p.child2Id : (p.child4Id == null ? p.child3Id : p.child4Id)))),
|
||||
nodeShortName = p.rootShortName == null ? null : (p.child1ShortName == null ? p.rootShortName : (p.child2ShortName == null ? p.child1ShortName : (p.child3ShortName == null ? p.child2ShortName : (p.child4ShortName == null ? p.child3ShortName : p.child4ShortName)))),
|
||||
|
||||
p.rootOld,
|
||||
p.rootOldId,
|
||||
p.rootShortNameOld,
|
||||
p.child1Old,
|
||||
p.child1OldId,
|
||||
p.child1ShortNameOld,
|
||||
p.child2Old,
|
||||
p.child2OldId,
|
||||
p.child2ShortNameOld,
|
||||
p.child3Old,
|
||||
p.child3OldId,
|
||||
p.child3ShortNameOld,
|
||||
p.child4Old,
|
||||
p.child4OldId,
|
||||
p.child4ShortNameOld,
|
||||
p.PositionOld,
|
||||
p.PositionExecutiveOld,
|
||||
p.posMasterNoOld,
|
||||
p.posTypeOldId,
|
||||
p.posTypeNameOld,
|
||||
p.posLevelOldId,
|
||||
p.posLevelNameOld,
|
||||
|
||||
p.Status,
|
||||
p.Amount,
|
||||
p.ReportingDate,
|
||||
|
||||
p.CreatedAt,
|
||||
p.Reason,
|
||||
p.MilitaryDate,
|
||||
p.EducationOld,
|
||||
p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.posmasterId,
|
||||
p.PositionDate,
|
||||
CommandType = p.CommandType == null ? null : p.CommandType.Name,
|
||||
p.rootDnaOldId,
|
||||
p.child1DnaOldId,
|
||||
p.child2DnaOldId,
|
||||
p.child3DnaOldId,
|
||||
p.child4DnaOldId,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (status != null && status.Trim().ToUpper() != "ALL")
|
||||
retirementOthers = retirementOthers.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
retirementOthers = retirementOthers
|
||||
.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")
|
||||
{
|
||||
retirementOthers = retirementOthers
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementOthers = retirementOthers
|
||||
.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(retirementOthers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -351,14 +361,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
var apiUrl = string.Empty;
|
||||
if (req.profileType.Trim().ToUpper() == "EMPLOYEE")
|
||||
{
|
||||
|
||||
|
||||
apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{req.Id}";
|
||||
}
|
||||
else
|
||||
{
|
||||
apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.Id}";
|
||||
}
|
||||
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
|
|
@ -745,7 +755,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
(p.root == null ? "" : $"{p.root}"),
|
||||
NewPositionType = p.posTypeName == null ? "-" : p.posTypeName,
|
||||
NewPositionLevel = p.posLevelName == null ? "-" : p.posLevelName,
|
||||
NewPositionNumber = p.rootShortName == null && p.posMasterNo == null ? null : $"{(p.child1ShortName == null ? p.rootShortName : (p.child2ShortName == null ? p.child1ShortName : (p.child3ShortName == null ? p.child2ShortName : (p.child4ShortName == null ? p.child3ShortName : p.child4ShortName))))}"+
|
||||
NewPositionNumber = p.rootShortName == null && p.posMasterNo == null ? null : $"{(p.child1ShortName == null ? p.rootShortName : (p.child2ShortName == null ? p.child1ShortName : (p.child3ShortName == null ? p.child2ShortName : (p.child4ShortName == null ? p.child3ShortName : p.child4ShortName))))}" +
|
||||
$" {p.posMasterNo?.ToString().ToThaiNumber()}",
|
||||
NewSalary = r.Amount == null ? "-" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
AppointDate = p.PositionDate == null ? "-" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
|
|
@ -32,6 +33,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public RetirementOutController(RetirementRepository repository,
|
||||
|
|
@ -40,6 +42,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -48,6 +51,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
|
|
@ -57,6 +61,7 @@ namespace BMA.EHR.Retirement.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
|
||||
|
|
@ -78,83 +83,106 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var rootId = "";
|
||||
var child1Id = "";
|
||||
var child2Id = "";
|
||||
var child3Id = "";
|
||||
var child4Id = "";
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
|
||||
using (var client = new HttpClient())
|
||||
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")
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
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);
|
||||
rootId = org.result.rootId == null ? "" : org.result.rootId;
|
||||
child1Id = org.result.child1Id == null ? "" : org.result.child1Id;
|
||||
child2Id = org.result.child2Id == null ? "" : org.result.child2Id;
|
||||
child3Id = org.result.child3Id == null ? "" : org.result.child3Id;
|
||||
child4Id = org.result.child4Id == null ? "" : org.result.child4Id;
|
||||
|
||||
var retirementOuts = await _context.RetirementOuts.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Where(x => x.profileType.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||
// .Where(x => rootId == "" ? true : (child1Id == "" ? x.rootOldId == rootId : (child2Id == "" ? x.child1OldId == child1Id : (child3Id == "" ? x.child2OldId == child2Id : (child4Id == "" ? x.child3OldId == child3Id : x.child4OldId == child4Id)))))
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.profileType,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
p.lastName,
|
||||
p.rootOld,
|
||||
p.rootOldId,
|
||||
p.rootShortNameOld,
|
||||
p.child1Old,
|
||||
p.child1OldId,
|
||||
p.child1ShortNameOld,
|
||||
p.child2Old,
|
||||
p.child2OldId,
|
||||
p.child2ShortNameOld,
|
||||
p.child3Old,
|
||||
p.child3OldId,
|
||||
p.child3ShortNameOld,
|
||||
p.child4Old,
|
||||
p.child4OldId,
|
||||
p.child4ShortNameOld,
|
||||
p.PositionOld,
|
||||
p.PositionExecutiveOld,
|
||||
p.posMasterNoOld,
|
||||
p.posTypeOldId,
|
||||
p.posTypeNameOld,
|
||||
p.posLevelOldId,
|
||||
p.posLevelNameOld,
|
||||
p.CreatedAt,
|
||||
p.Organization,
|
||||
p.Reason,
|
||||
p.Status,
|
||||
p.Date,
|
||||
salary = p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.IsActive,
|
||||
})
|
||||
.ToListAsync();
|
||||
//if (status != null && status.Trim().ToUpper() != "WAITTING")
|
||||
if (status != null)
|
||||
retirementOuts = retirementOuts.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
return Success(retirementOuts);
|
||||
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 retirementOuts = await _context.RetirementOuts.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Where(x => x.profileType.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.profileType,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
p.lastName,
|
||||
p.rootOld,
|
||||
p.rootOldId,
|
||||
p.rootShortNameOld,
|
||||
p.child1Old,
|
||||
p.child1OldId,
|
||||
p.child1ShortNameOld,
|
||||
p.child2Old,
|
||||
p.child2OldId,
|
||||
p.child2ShortNameOld,
|
||||
p.child3Old,
|
||||
p.child3OldId,
|
||||
p.child3ShortNameOld,
|
||||
p.child4Old,
|
||||
p.child4OldId,
|
||||
p.child4ShortNameOld,
|
||||
p.PositionOld,
|
||||
p.PositionExecutiveOld,
|
||||
p.posMasterNoOld,
|
||||
p.posTypeOldId,
|
||||
p.posTypeNameOld,
|
||||
p.posLevelOldId,
|
||||
p.posLevelNameOld,
|
||||
p.CreatedAt,
|
||||
p.Organization,
|
||||
p.Reason,
|
||||
p.Status,
|
||||
p.Date,
|
||||
salary = p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.IsActive,
|
||||
p.rootDnaOldId,
|
||||
p.child1DnaOldId,
|
||||
p.child2DnaOldId,
|
||||
p.child3DnaOldId,
|
||||
p.child4DnaOldId,
|
||||
})
|
||||
.ToListAsync();
|
||||
//if (status != null && status.Trim().ToUpper() != "WAITTING")
|
||||
if (status != null)
|
||||
retirementOuts = retirementOuts.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
retirementOuts = retirementOuts
|
||||
.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")
|
||||
{
|
||||
retirementOuts = retirementOuts
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementOuts = retirementOuts
|
||||
.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(retirementOuts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Repositories.Reports;
|
||||
using BMA.EHR.Application.Repositories.Reports;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
|
|
@ -34,6 +35,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly PermissionRepository _permission;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly RetireReportRepository _service;
|
||||
|
||||
public RetirementResignController(RetirementRepository repository,
|
||||
|
|
@ -43,6 +45,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission,
|
||||
UserProfileRepository userProfileRepository,
|
||||
RetireReportRepository service)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -52,6 +55,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_permission = permission;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_service = service;
|
||||
}
|
||||
|
||||
|
|
@ -61,6 +65,7 @@ namespace BMA.EHR.Retirement.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
|
||||
// private List<string> GetOcNameFullPath(Guid id, bool showRoot = false)
|
||||
|
|
@ -234,6 +239,30 @@ namespace BMA.EHR.Retirement.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 retirementResigns = await _context.RetirementResigns.AsQueryable()
|
||||
.Where(x => type.Trim().ToUpper() == "APPROVE" ? (x.Status == "APPROVE" || x.Status == "REJECT") : x.Status == type.Trim().ToUpper())
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
|
|
@ -266,9 +295,34 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.CreatedAt,
|
||||
p.ApproveStep,
|
||||
p.Group,
|
||||
p.rootDnaOldId,
|
||||
p.child1DnaOldId,
|
||||
p.child2DnaOldId,
|
||||
p.child3DnaOldId,
|
||||
p.child4DnaOldId,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
.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")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
.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(retirementResigns);
|
||||
}
|
||||
|
||||
|
|
@ -289,6 +343,30 @@ namespace BMA.EHR.Retirement.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 retirementResigns = await _context.RetirementResignCancels.AsQueryable()
|
||||
.Where(x => type.Trim().ToUpper() == "APPROVE" ? (x.Status == "APPROVE" || x.Status == "REJECT") : x.Status == type.Trim().ToUpper())
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
|
|
@ -320,9 +398,34 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.CreatedAt,
|
||||
p.ApproveStep,
|
||||
p.Group,
|
||||
p.rootDnaOldId,
|
||||
p.child1DnaOldId,
|
||||
p.child2DnaOldId,
|
||||
p.child3DnaOldId,
|
||||
p.child4DnaOldId,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
.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")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
.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(retirementResigns);
|
||||
}
|
||||
|
||||
|
|
@ -1572,18 +1675,23 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
citizenId = updated.citizenId,
|
||||
rootOld = updated.rootOld,
|
||||
rootOldId = updated.rootOldId,
|
||||
rootDnaOldId = updated.rootDnaOldId,
|
||||
rootShortNameOld = updated.rootShortNameOld,
|
||||
child1Old = updated.child1Old,
|
||||
child1OldId = updated.child1OldId,
|
||||
child1DnaOldId = updated.child1DnaOldId,
|
||||
child1ShortNameOld = updated.child1ShortNameOld,
|
||||
child2Old = updated.child2Old,
|
||||
child2OldId = updated.child2OldId,
|
||||
child2DnaOldId = updated.child2DnaOldId,
|
||||
child2ShortNameOld = updated.child2ShortNameOld,
|
||||
child3Old = updated.child3Old,
|
||||
child3OldId = updated.child3OldId,
|
||||
child3DnaOldId = updated.child3DnaOldId,
|
||||
child3ShortNameOld = updated.child3ShortNameOld,
|
||||
child4Old = updated.child4Old,
|
||||
child4OldId = updated.child4OldId,
|
||||
child4DnaOldId = updated.child4DnaOldId,
|
||||
child4ShortNameOld = updated.child4ShortNameOld,
|
||||
posMasterNoOld = updated.posMasterNoOld,
|
||||
posTypeOldId = updated.posTypeOldId,
|
||||
|
|
@ -2001,6 +2109,30 @@ namespace BMA.EHR.Retirement.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 = await _context.RetirementQuestions.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
|
|
@ -2026,8 +2158,33 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
LastUpdatedAt = p.LastUpdatedAt,
|
||||
CreatedAt = p.CreatedAt,
|
||||
AppointDate = p.AppointDate,
|
||||
p.rootDnaId,
|
||||
p.child1DnaId,
|
||||
p.child2DnaId,
|
||||
p.child3DnaId,
|
||||
p.child4DnaId,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
data = data
|
||||
.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 = data
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data = data
|
||||
.Where(x => node == 0 ? x.child1DnaId == null : (node == 1 ? x.child2DnaId == null : (node == 2 ? x.child3DnaId == null : (node == 3 ? x.child4DnaId == null : true)))).ToList();
|
||||
}
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
|
|
@ -2150,6 +2307,37 @@ namespace BMA.EHR.Retirement.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/{retirementResign.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);
|
||||
|
||||
period.root = org.result.root;
|
||||
period.rootId = org.result.rootId;
|
||||
period.rootDnaId = org.result.rootDnaId;
|
||||
period.child1 = org.result.child1;
|
||||
period.child1Id = org.result.child1Id;
|
||||
period.child1DnaId = org.result.child1DnaId;
|
||||
period.child2 = org.result.child2;
|
||||
period.child2Id = org.result.child2Id;
|
||||
period.child2DnaId = org.result.child2DnaId;
|
||||
period.child3 = org.result.child3;
|
||||
period.child3Id = org.result.child3Id;
|
||||
period.child3DnaId = org.result.child3DnaId;
|
||||
period.child4 = org.result.child4;
|
||||
period.child4Id = org.result.child4Id;
|
||||
period.child4DnaId = org.result.child4DnaId;
|
||||
}
|
||||
await _context.RetirementQuestions.AddAsync(period);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
|
@ -2637,7 +2825,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
positionLevel = p.PositionLevelOld,
|
||||
isLeave = p.IsCancel == true ? false : true,
|
||||
//leaveReason = "ออกจากราชการ",
|
||||
leaveReason = p.ReasonResign == "อื่น ๆ"
|
||||
leaveReason = p.ReasonResign == "อื่น ๆ"
|
||||
? string.IsNullOrWhiteSpace(p.Remark) ? p.ReasonResign : $"{p.ReasonResign}({p.Remark})"
|
||||
: p.ReasonResign,
|
||||
dateLeave = r.commandDateAffect,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
|
|
@ -31,6 +32,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public RetirementResignEmployeeController(RetirementEmployeeRepository repository,
|
||||
|
|
@ -39,6 +41,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
UserProfileRepository userProfileRepository,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
_repository = repository;
|
||||
|
|
@ -47,6 +50,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +60,7 @@ namespace BMA.EHR.Retirement.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
|
||||
/// <summary>
|
||||
|
|
@ -173,6 +178,30 @@ namespace BMA.EHR.Retirement.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 retirementResignEmployees = await _context.RetirementResignEmployees.AsQueryable()
|
||||
.Where(x => type.Trim().ToUpper() == "APPROVE" ? (x.Status == "APPROVE" || x.Status == "REJECT") : x.Status == type.Trim().ToUpper())
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
|
|
@ -205,9 +234,34 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.CreatedAt,
|
||||
p.ApproveStep,
|
||||
p.Group,
|
||||
p.rootDnaOldId,
|
||||
p.child1DnaOldId,
|
||||
p.child2DnaOldId,
|
||||
p.child3DnaOldId,
|
||||
p.child4DnaOldId,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
.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")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
.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(retirementResignEmployees);
|
||||
}
|
||||
|
||||
|
|
@ -228,6 +282,30 @@ namespace BMA.EHR.Retirement.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 retirementResignEmployees = await _context.RetirementResignEmployeeCancels.AsQueryable()
|
||||
.Where(x => type.Trim().ToUpper() == "APPROVE" ? (x.Status == "APPROVE" || x.Status == "REJECT") : x.Status == type.Trim().ToUpper())
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
|
|
@ -258,9 +336,34 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.CreatedAt,
|
||||
p.ApproveStep,
|
||||
p.Group,
|
||||
p.rootDnaOldId,
|
||||
p.child1DnaOldId,
|
||||
p.child2DnaOldId,
|
||||
p.child3DnaOldId,
|
||||
p.child4DnaOldId,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
.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")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
.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(retirementResignEmployees);
|
||||
}
|
||||
|
||||
|
|
@ -1490,18 +1593,23 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
citizenId = updated.citizenId,
|
||||
rootOld = updated.rootOld,
|
||||
rootOldId = updated.rootOldId,
|
||||
rootDnaOldId = updated.rootDnaOldId,
|
||||
rootShortNameOld = updated.rootShortNameOld,
|
||||
child1Old = updated.child1Old,
|
||||
child1OldId = updated.child1OldId,
|
||||
child1DnaOldId = updated.child1DnaOldId,
|
||||
child1ShortNameOld = updated.child1ShortNameOld,
|
||||
child2Old = updated.child2Old,
|
||||
child2OldId = updated.child2OldId,
|
||||
child2DnaOldId = updated.child2DnaOldId,
|
||||
child2ShortNameOld = updated.child2ShortNameOld,
|
||||
child3Old = updated.child3Old,
|
||||
child3OldId = updated.child3OldId,
|
||||
child3DnaOldId = updated.child3DnaOldId,
|
||||
child3ShortNameOld = updated.child3ShortNameOld,
|
||||
child4Old = updated.child4Old,
|
||||
child4OldId = updated.child4OldId,
|
||||
child4DnaOldId = updated.child4DnaOldId,
|
||||
child4ShortNameOld = updated.child4ShortNameOld,
|
||||
posMasterNoOld = updated.posMasterNoOld,
|
||||
posTypeOldId = updated.posTypeOldId,
|
||||
|
|
@ -1929,7 +2037,31 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var data = await _context.RetirementQuestions.AsQueryable()
|
||||
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 = await _context.RetirementEmployeeQuestions.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
|
|
@ -1954,11 +2086,115 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
LastUpdatedAt = p.LastUpdatedAt,
|
||||
CreatedAt = p.CreatedAt,
|
||||
AppointDate = p.AppointDate,
|
||||
p.rootDnaId,
|
||||
p.child1DnaId,
|
||||
p.child2DnaId,
|
||||
p.child3DnaId,
|
||||
p.child4DnaId,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
data = data
|
||||
.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 = data
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data = data
|
||||
.Where(x => node == 0 ? x.child1DnaId == null : (node == 1 ? x.child2DnaId == null : (node == 2 ? x.child3DnaId == null : (node == 3 ? x.child4DnaId == null : true)))).ToList();
|
||||
}
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// สร้างแบบสอบถามหลังลาออก
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("questionnaire")]
|
||||
public async Task<ActionResult<ResponseObject>> PostQuestion([FromBody] RetirementQuestionRequest req)
|
||||
{
|
||||
var retirementResign = await _context.RetirementResignEmployees.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == req.RetirementResignId);
|
||||
if (retirementResign == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound);
|
||||
|
||||
var period = new RetirementEmployeeQuestion
|
||||
{
|
||||
RetirementResignEmployee = retirementResign,
|
||||
ReasonWork = Newtonsoft.Json.JsonConvert.SerializeObject(req.ReasonWork),
|
||||
ReasonWorkOther = req.ReasonWorkOther,
|
||||
TimeThink = req.TimeThink,
|
||||
ExitFactor = Newtonsoft.Json.JsonConvert.SerializeObject(req.ExitFactor),
|
||||
ExitFactorOther = req.ExitFactorOther,
|
||||
Adjust = Newtonsoft.Json.JsonConvert.SerializeObject(req.Adjust),
|
||||
AdjustOther = req.AdjustOther,
|
||||
RealReason = req.RealReason,
|
||||
NotExitFactor = req.NotExitFactor,
|
||||
Havejob = req.Havejob,
|
||||
HavejobReason = req.HavejobReason,
|
||||
SuggestFriends = req.SuggestFriends,
|
||||
SuggestFriendsReason = req.SuggestFriendsReason,
|
||||
FutureWork = req.FutureWork,
|
||||
FutureWorkReason = req.FutureWorkReason,
|
||||
Suggestion = req.Suggestion,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
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-employee/profileid/position/{retirementResign.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);
|
||||
|
||||
period.root = org.result.root;
|
||||
period.rootId = org.result.rootId;
|
||||
period.rootDnaId = org.result.rootDnaId;
|
||||
period.child1 = org.result.child1;
|
||||
period.child1Id = org.result.child1Id;
|
||||
period.child1DnaId = org.result.child1DnaId;
|
||||
period.child2 = org.result.child2;
|
||||
period.child2Id = org.result.child2Id;
|
||||
period.child2DnaId = org.result.child2DnaId;
|
||||
period.child3 = org.result.child3;
|
||||
period.child3Id = org.result.child3Id;
|
||||
period.child3DnaId = org.result.child3DnaId;
|
||||
period.child4 = org.result.child4;
|
||||
period.child4Id = org.result.child4Id;
|
||||
period.child4DnaId = org.result.child4DnaId;
|
||||
}
|
||||
await _context.RetirementEmployeeQuestions.AddAsync(period);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-23
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue