หา 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.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