no message
This commit is contained in:
parent
dc91f81262
commit
57164f5d45
11 changed files with 34879 additions and 185 deletions
|
|
@ -116,41 +116,43 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new
|
||||
{
|
||||
PersonalId = x.Id,
|
||||
Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id,
|
||||
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
|
||||
IdCard = x.CitizenId,
|
||||
ProfilePhoto = x.Id,
|
||||
ExamNumber = x.ExamNumber,
|
||||
posmasterId = x.posmasterId,
|
||||
root = x.root,
|
||||
rootId = x.rootId,
|
||||
rootShortName = x.rootShortName,
|
||||
child1 = x.child1,
|
||||
child1Id = x.child1Id,
|
||||
child1ShortName = x.child1ShortName,
|
||||
child2 = x.child2,
|
||||
child2Id = x.child2Id,
|
||||
child2ShortName = x.child2ShortName,
|
||||
child3 = x.child3,
|
||||
child3Id = x.child3Id,
|
||||
child3ShortName = x.child3ShortName,
|
||||
child4 = x.child4,
|
||||
child4Id = x.child4Id,
|
||||
child4ShortName = x.child4ShortName,
|
||||
orgRevisionId = x.orgRevisionId,
|
||||
positionId = x.positionId,
|
||||
posMasterNo = x.posMasterNo,
|
||||
positionName = x.positionName,
|
||||
positionField = x.positionField,
|
||||
posTypeId = x.posTypeId,
|
||||
posTypeName = x.posTypeName,
|
||||
posLevelId = x.posLevelId,
|
||||
posLevelName = x.posLevelName,
|
||||
PositionCandidate = x.PositionCandidate == null ? null : x.PositionCandidate.Name,
|
||||
PositionCandidateId = x.PositionCandidate == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionCandidate.Id,
|
||||
// OrganizationName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||
PosNumber = x.PosNumber,
|
||||
PosPath = x.PosPath,
|
||||
organizationName = x.organizationName,
|
||||
orgTreeShortName = x.orgTreeShortName,
|
||||
ReportingDate = x.ReportingDate,
|
||||
BmaOfficer = x.IsOfficer,
|
||||
StatusId = x.PlacementStatus,
|
||||
Draft = x.Draft,
|
||||
ExamNumber = x.ExamNumber,
|
||||
Deferment = x.IsRelief,
|
||||
|
||||
node = x.node,
|
||||
nodeId = x.nodeId,
|
||||
posmasterId = x.posmasterId,
|
||||
positionId = x.positionId,
|
||||
|
||||
ContainDate = x.RecruitDate,
|
||||
OrganizationPositionId = x.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationPosition.Id,
|
||||
// PosNoId = x.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionNumber.Id,
|
||||
// PositionId = x.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionPath.Id,
|
||||
PositionLevelId = x.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionLevel.Id,
|
||||
PositionLineId = x.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionLine.Id,
|
||||
PositionPathSideId = x.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionPathSide.Id,
|
||||
PositionTypeId = x.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionType.Id,
|
||||
SalaryAmount = x.Amount,
|
||||
MouthSalaryAmount = x.MouthSalaryAmount,
|
||||
PositionSalaryAmount = x.PositionSalaryAmount,
|
||||
Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id,
|
||||
typeCommand = x.typeCommand,
|
||||
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
|
||||
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
|
||||
}).OrderBy(x => x.ExamNumber).ToListAsync();
|
||||
|
||||
var result = new List<dynamic>();
|
||||
|
|
@ -159,40 +161,48 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
var _data = new
|
||||
{
|
||||
p.PersonalId,
|
||||
Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar),
|
||||
p.FullName,
|
||||
p.IdCard,
|
||||
p.ProfilePhoto,
|
||||
p.ExamNumber,
|
||||
p.posmasterId,
|
||||
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,
|
||||
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.orgRevisionId,
|
||||
p.positionId,
|
||||
p.posMasterNo,
|
||||
p.positionName,
|
||||
p.positionField,
|
||||
p.posTypeId,
|
||||
p.posTypeName,
|
||||
p.posLevelId,
|
||||
p.posLevelName,
|
||||
p.PositionCandidate,
|
||||
p.PositionCandidateId,
|
||||
// p.OrganizationName,
|
||||
p.OrganizationShortName,
|
||||
p.PosNumber,
|
||||
p.PosPath,
|
||||
p.organizationName,
|
||||
p.orgTreeShortName,
|
||||
p.ReportingDate,
|
||||
BmaOfficer = await _documentService.CheckBmaOfficer(p.IdCard),
|
||||
BmaOfficer = p.IdCard == null ? null : await _documentService.CheckBmaOfficer(p.IdCard),
|
||||
p.StatusId,
|
||||
p.Draft,
|
||||
p.ExamNumber,
|
||||
p.Deferment,
|
||||
|
||||
p.ContainDate,
|
||||
p.OrganizationPositionId,
|
||||
// p.PosNoId,
|
||||
// p.PositionId,
|
||||
p.PositionLevelId,
|
||||
p.PositionLineId,
|
||||
p.PositionPathSideId,
|
||||
p.PositionTypeId,
|
||||
p.SalaryAmount,
|
||||
p.MouthSalaryAmount,
|
||||
p.PositionSalaryAmount,
|
||||
Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar),
|
||||
p.node,
|
||||
p.nodeId,
|
||||
p.posmasterId,
|
||||
p.positionId,
|
||||
p.typeCommand,
|
||||
p.posLevelCandidateId,
|
||||
p.posTypeCandidateId,
|
||||
};
|
||||
result.Add(_data);
|
||||
}
|
||||
|
|
@ -200,99 +210,128 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
var profileOrg = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId ?? "00000000-0000-0000-0000-000000000000"));
|
||||
if (profileOrg == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
// var ocIdList = _documentService.GetAllIdByRoot(profileOrg.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : profileOrg.OcId);
|
||||
var ocIdList = _documentService.GetAllIdByRoot(profileOrg.OcId);
|
||||
var data = await _context.PlacementProfiles
|
||||
.Where(x => x.Placement.Id == examId)
|
||||
.Where(x => x.OrganizationPosition != null)
|
||||
.Where(x => x.OrganizationPosition.Organization != null)
|
||||
.Where(x => x.Draft == true)
|
||||
.Where(x => ocIdList.Contains(x.OrganizationPosition.Organization.Id))
|
||||
.Select(x => new
|
||||
var rootId = "";
|
||||
var child1Id = "";
|
||||
var child2Id = "";
|
||||
var child3Id = "";
|
||||
var child4Id = "";
|
||||
var apiUrl = $"{_configuration["API"]}org/profile/keycloak/position";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
PersonalId = x.Id,
|
||||
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
|
||||
IdCard = x.CitizenId,
|
||||
ProfilePhoto = x.Id,
|
||||
PositionCandidate = x.PositionCandidate == null ? null : x.PositionCandidate.Name,
|
||||
PositionCandidateId = x.PositionCandidate == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionCandidate.Id,
|
||||
// OrganizationName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||
PosNumber = x.PosNumber,
|
||||
PosPath = x.PosPath,
|
||||
organizationName = x.organizationName,
|
||||
orgTreeShortName = x.orgTreeShortName,
|
||||
ReportingDate = x.ReportingDate,
|
||||
BmaOfficer = x.IsOfficer,
|
||||
StatusId = x.PlacementStatus,
|
||||
Draft = x.Draft,
|
||||
ExamNumber = x.ExamNumber,
|
||||
Deferment = x.IsRelief,
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
node = x.node,
|
||||
nodeId = x.nodeId,
|
||||
posmasterId = x.posmasterId,
|
||||
positionId = x.positionId,
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
ContainDate = x.RecruitDate,
|
||||
OrganizationPositionId = x.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationPosition.Id,
|
||||
// PosNoId = x.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionNumber.Id,
|
||||
// PositionId = x.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionPath.Id,
|
||||
PositionLevelId = x.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionLevel.Id,
|
||||
PositionLineId = x.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionLine.Id,
|
||||
PositionPathSideId = x.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionPathSide.Id,
|
||||
PositionTypeId = x.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionType.Id,
|
||||
SalaryAmount = x.Amount,
|
||||
MouthSalaryAmount = x.MouthSalaryAmount,
|
||||
PositionSalaryAmount = x.PositionSalaryAmount,
|
||||
}).OrderBy(x => x.ExamNumber).ToListAsync();
|
||||
|
||||
var result = new List<dynamic>();
|
||||
foreach (var p in data)
|
||||
{
|
||||
var _data = new
|
||||
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;
|
||||
// return Success(new {rootId=rootId,child1Id=child1Id,child2Id=child2Id,child3Id=child3Id,child4Id=child4Id });
|
||||
var data = await _context.PlacementProfiles
|
||||
.Where(x => x.Placement.Id == examId)
|
||||
.Where(x => x.Draft == true)
|
||||
.Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id)))))
|
||||
.Select(x => new
|
||||
{
|
||||
p.PersonalId,
|
||||
p.FullName,
|
||||
p.IdCard,
|
||||
p.ProfilePhoto,
|
||||
p.PositionCandidate,
|
||||
p.PositionCandidateId,
|
||||
// p.OrganizationName,
|
||||
p.OrganizationShortName,
|
||||
p.PosNumber,
|
||||
p.PosPath,
|
||||
p.organizationName,
|
||||
p.orgTreeShortName,
|
||||
p.ReportingDate,
|
||||
BmaOfficer = await _documentService.CheckBmaOfficer(p.IdCard),
|
||||
p.StatusId,
|
||||
p.Draft,
|
||||
p.ExamNumber,
|
||||
p.Deferment,
|
||||
PersonalId = x.Id,
|
||||
Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id,
|
||||
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
|
||||
IdCard = x.CitizenId,
|
||||
ExamNumber = x.ExamNumber,
|
||||
posmasterId = x.posmasterId,
|
||||
root = x.root,
|
||||
rootId = x.rootId,
|
||||
rootShortName = x.rootShortName,
|
||||
child1 = x.child1,
|
||||
child1Id = x.child1Id,
|
||||
child1ShortName = x.child1ShortName,
|
||||
child2 = x.child2,
|
||||
child2Id = x.child2Id,
|
||||
child2ShortName = x.child2ShortName,
|
||||
child3 = x.child3,
|
||||
child3Id = x.child3Id,
|
||||
child3ShortName = x.child3ShortName,
|
||||
child4 = x.child4,
|
||||
child4Id = x.child4Id,
|
||||
child4ShortName = x.child4ShortName,
|
||||
orgRevisionId = x.orgRevisionId,
|
||||
positionId = x.positionId,
|
||||
posMasterNo = x.posMasterNo,
|
||||
positionName = x.positionName,
|
||||
positionField = x.positionField,
|
||||
posTypeId = x.posTypeId,
|
||||
posTypeName = x.posTypeName,
|
||||
posLevelId = x.posLevelId,
|
||||
posLevelName = x.posLevelName,
|
||||
PositionCandidate = x.PositionCandidate == null ? null : x.PositionCandidate.Name,
|
||||
PositionCandidateId = x.PositionCandidate == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionCandidate.Id,
|
||||
ReportingDate = x.ReportingDate,
|
||||
StatusId = x.PlacementStatus,
|
||||
Draft = x.Draft,
|
||||
typeCommand = x.typeCommand,
|
||||
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
|
||||
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
|
||||
}).OrderBy(x => x.ExamNumber).ToListAsync();
|
||||
|
||||
p.ContainDate,
|
||||
p.OrganizationPositionId,
|
||||
// p.PosNoId,
|
||||
// p.PositionId,
|
||||
p.PositionLevelId,
|
||||
p.PositionLineId,
|
||||
p.PositionPathSideId,
|
||||
p.PositionTypeId,
|
||||
p.SalaryAmount,
|
||||
p.MouthSalaryAmount,
|
||||
p.PositionSalaryAmount,
|
||||
p.node,
|
||||
p.nodeId,
|
||||
p.posmasterId,
|
||||
p.positionId,
|
||||
};
|
||||
result.Add(_data);
|
||||
var result = new List<dynamic>();
|
||||
foreach (var p in data)
|
||||
{
|
||||
var _data = new
|
||||
{
|
||||
p.PersonalId,
|
||||
Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar),
|
||||
p.FullName,
|
||||
p.IdCard,
|
||||
p.ExamNumber,
|
||||
p.posmasterId,
|
||||
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,
|
||||
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.orgRevisionId,
|
||||
p.positionId,
|
||||
p.posMasterNo,
|
||||
p.positionName,
|
||||
p.positionField,
|
||||
p.posTypeId,
|
||||
p.posTypeName,
|
||||
p.posLevelId,
|
||||
p.posLevelName,
|
||||
p.PositionCandidate,
|
||||
p.PositionCandidateId,
|
||||
p.ReportingDate,
|
||||
BmaOfficer = p.IdCard == null ? null : await _documentService.CheckBmaOfficer(p.IdCard),
|
||||
p.StatusId,
|
||||
p.Draft,
|
||||
p.typeCommand,
|
||||
p.posLevelCandidateId,
|
||||
p.posTypeCandidateId,
|
||||
};
|
||||
result.Add(_data);
|
||||
}
|
||||
return Success(result);
|
||||
}
|
||||
return Success(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -673,7 +712,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpPost("pass")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePositionByPerson([FromBody] PersonSelectPositionRequest req)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(req.PersonalId);
|
||||
var person = await _context.PlacementProfiles.FindAsync(req.personalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
if (person.Draft == true)
|
||||
|
|
@ -691,7 +730,6 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
// person.MouthSalaryAmount = req.MouthSalaryAmount;
|
||||
// person.PositionSalaryAmount = req.PositionSalaryAmount;
|
||||
// person.RecruitDate = req.ReportingDate;
|
||||
// person.ReportingDate = req.ReportingDate;
|
||||
|
||||
var apiUrl = $"{_configuration["API"]}org/find/all";
|
||||
|
||||
|
|
@ -728,7 +766,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
}
|
||||
|
||||
person.Draft = false;
|
||||
|
||||
person.typeCommand = req.typeCommand == null ? null : req.typeCommand.Trim().ToUpper();
|
||||
person.ReportingDate = req.reportingDate;
|
||||
person.posmasterId = req.posmasterId;
|
||||
person.node = req.node;
|
||||
person.nodeId = req.nodeId;
|
||||
person.orgRevisionId = req.orgRevisionId;
|
||||
person.positionId = req.positionId;
|
||||
person.posMasterNo = req.posMasterNo;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ using BMA.EHR.Placement.Service.Requests;
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
|
|
@ -26,18 +28,21 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public PlacementOfficerController(PlacementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -45,6 +50,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
|
||||
|
|
@ -176,27 +182,18 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
|
||||
{
|
||||
var profile = await _context.Profiles
|
||||
.Include(x => x.PositionLevel)
|
||||
.Include(x => x.PositionType)
|
||||
.Include(x => x.PosNo)
|
||||
.Include(x => x.Salaries)
|
||||
.Include(x => x.Position)
|
||||
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var placementOfficer = new PlacementOfficer
|
||||
{
|
||||
Profile = profile,
|
||||
// Profile = profile,
|
||||
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
|
||||
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||
// Date = req.Date,
|
||||
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
|
||||
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
|
||||
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||
|
||||
Status = "WAITTING",
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
|
|
@ -205,6 +202,40 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
var rootId = "";
|
||||
var child1Id = "";
|
||||
var child2Id = "";
|
||||
var child3Id = "";
|
||||
var child4Id = "";
|
||||
var apiUrl = $"{_configuration["API"]}org/profile/keycloak/position";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
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);
|
||||
|
||||
placementOfficer.root = org.result.root;
|
||||
placementOfficer.rootId = org.result.rootId;
|
||||
placementOfficer.rootShortName = org.result.rootShortName;
|
||||
placementOfficer.child1 = org.result.child1;
|
||||
placementOfficer.child1Id = org.result.child1Id;
|
||||
placementOfficer.child1ShortName = org.result.child1ShortName;
|
||||
placementOfficer.child2 = org.result.child2;
|
||||
placementOfficer.child2Id = org.result.child2Id;
|
||||
placementOfficer.child2ShortName = org.result.child2ShortName;
|
||||
placementOfficer.child3 = org.result.child3;
|
||||
placementOfficer.child3Id = org.result.child3Id;
|
||||
placementOfficer.child3ShortName = org.result.child3ShortName;
|
||||
placementOfficer.child4 = org.result.child4;
|
||||
placementOfficer.child4Id = org.result.child4Id;
|
||||
placementOfficer.child4ShortName = org.result.child4ShortName;
|
||||
}
|
||||
await _context.PlacementOfficers.AddAsync(placementOfficer);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ namespace BMA.EHR.Placement.Service.Requests
|
|||
{
|
||||
public class PersonSelectPositionRequest
|
||||
{
|
||||
public Guid? PersonalId { get; set; }
|
||||
public DateTime? ContainDate { get; set; }
|
||||
public DateTime? ReportingDate { get; set; }
|
||||
public Guid? PosNoId { get; set; }
|
||||
// public Guid? PositionId { get; set; }
|
||||
public Guid? PositionLevelId { get; set; }
|
||||
|
|
@ -22,22 +20,23 @@ namespace BMA.EHR.Placement.Service.Requests
|
|||
public string? orgTreeShortName { get; set; }
|
||||
public string? posPath { get; set; }
|
||||
public int? posNumber { get; set; }
|
||||
public int? node { get; set; }
|
||||
public Guid? nodeId { get; set; }
|
||||
public Guid? posmasterId { get; set; }
|
||||
// public Guid? positionId { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string? posmasterId { get; set; }
|
||||
public Guid? personalId { get; set; }
|
||||
public DateTime? reportingDate { get; set; }
|
||||
public int? node { get; set; }
|
||||
public Guid? nodeId { get; set; }
|
||||
public string? orgRevisionId { get; set; }
|
||||
public string? positionId { get; set; }
|
||||
public int? posMasterNo { get; set; }
|
||||
public string? positionId { get; set; }
|
||||
public string? positionName { get; set; }
|
||||
public string? positionField { get; set; }
|
||||
public string? posTypeId { get; set; }
|
||||
public string? posTypeName { get; set; }
|
||||
public string? posLevelId { get; set; }
|
||||
public string? posLevelName { get; set; }
|
||||
public string? typeCommand { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue