no message

This commit is contained in:
kittapath 2024-10-28 16:01:48 +07:00
parent 5e4394fd33
commit b0765fa2ca
2 changed files with 277 additions and 251 deletions

View file

@ -143,259 +143,261 @@ namespace BMA.EHR.Placement.Service.Controllers
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
}
if (PlacementAdmin == true)
var rootId = "";
var child1Id = "";
var child2Id = "";
var child3Id = "";
var child4Id = "";
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position-act";
using (var client = new HttpClient())
{
var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new
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();
if (_res.IsSuccessStatusCode)
{
Id = x.Id,
PersonalId = x.Id,
x.profileId,
Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id,
FullName = $"{x.Prefix}{x.Firstname} {x.Lastname}",
Prefix = x.Prefix,
Firstname = x.Firstname,
Lastname = x.Lastname,
IdCard = x.CitizenId,
CitizenId = 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,
IsOfficer = x.IsOfficer,
IsRelief = x.IsRelief,
posLevelCandidateId = x.posLevelIdOld != null ? Guid.Parse(x.posLevelIdOld) : (x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id),
posTypeCandidateId = x.posTypeIdOld != null ? Guid.Parse(x.posTypeIdOld) : (x.PositionType == null ? (Guid?)null : x.PositionType.Id),
}).OrderBy(x => x.ExamNumber).ToListAsync();
var result = new List<dynamic>();
foreach (var p in data)
{
var _data = new
var org = JsonConvert.DeserializeObject<OrgRequestAct>(_result);
if (org.result.isOfficer == false)
{
p.Id,
p.PersonalId,
Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar),
p.FullName,
p.Prefix,
p.Firstname,
p.Lastname,
p.IdCard,
p.CitizenId,
p.profileId,
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.IsOfficer == true ? "OFFICER" : null,
p.StatusId,
p.Draft,
p.typeCommand,
p.IsRelief,
p.posLevelCandidateId,
p.posTypeCandidateId,
};
result.Add(_data);
}
return Success(result);
}
else
{
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 ", ""));
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;
// 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
{
Id = x.Id,
PersonalId = x.Id,
x.profileId,
Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id,
FullName = $"{x.Prefix}{x.Firstname} {x.Lastname}",
Prefix = x.Prefix,
Firstname = x.Firstname,
Lastname = x.Lastname,
IdCard = x.CitizenId,
CitizenId = 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,
IsOfficer = x.IsOfficer,
IsRelief = x.IsRelief,
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>();
foreach (var p in data)
{
var _data = new
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 data1 = 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.Id,
p.PersonalId,
Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar),
p.FullName,
p.Prefix,
p.Firstname,
p.Lastname,
p.IdCard,
p.CitizenId,
p.profileId,
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.IsOfficer == true ? "OFFICER" : null,
p.StatusId,
p.Draft,
p.typeCommand,
p.IsRelief,
p.posLevelCandidateId,
p.posTypeCandidateId,
};
result.Add(_data);
Id = x.Id,
PersonalId = x.Id,
x.profileId,
Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id,
FullName = $"{x.Prefix}{x.Firstname} {x.Lastname}",
Prefix = x.Prefix,
Firstname = x.Firstname,
Lastname = x.Lastname,
IdCard = x.CitizenId,
CitizenId = 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,
IsOfficer = x.IsOfficer,
IsRelief = x.IsRelief,
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
}).OrderBy(x => x.ExamNumber).ToListAsync();
var result1 = new List<dynamic>();
foreach (var p in data1)
{
var _data1 = new
{
p.Id,
p.PersonalId,
Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar),
p.FullName,
p.Prefix,
p.Firstname,
p.Lastname,
p.IdCard,
p.CitizenId,
p.profileId,
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.IsOfficer == true ? "OFFICER" : null,
p.StatusId,
p.Draft,
p.typeCommand,
p.IsRelief,
p.posLevelCandidateId,
p.posTypeCandidateId,
};
result1.Add(_data1);
}
return Success(result1);
}
else
{
var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new
{
Id = x.Id,
PersonalId = x.Id,
x.profileId,
Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id,
FullName = $"{x.Prefix}{x.Firstname} {x.Lastname}",
Prefix = x.Prefix,
Firstname = x.Firstname,
Lastname = x.Lastname,
IdCard = x.CitizenId,
CitizenId = 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,
IsOfficer = x.IsOfficer,
IsRelief = x.IsRelief,
posLevelCandidateId = x.posLevelIdOld != null ? Guid.Parse(x.posLevelIdOld) : (x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id),
posTypeCandidateId = x.posTypeIdOld != null ? Guid.Parse(x.posTypeIdOld) : (x.PositionType == null ? (Guid?)null : x.PositionType.Id),
}).OrderBy(x => x.ExamNumber).ToListAsync();
var result = new List<dynamic>();
foreach (var p in data)
{
var _data = new
{
p.Id,
p.PersonalId,
Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar),
p.FullName,
p.Prefix,
p.Firstname,
p.Lastname,
p.IdCard,
p.CitizenId,
p.profileId,
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.IsOfficer == true ? "OFFICER" : null,
p.StatusId,
p.Draft,
p.typeCommand,
p.IsRelief,
p.posLevelCandidateId,
p.posTypeCandidateId,
};
result.Add(_data);
}
return Success(result);
}
return Success(result);
}
}
return Success(new List<dynamic>());
}
[HttpGet("personal/{personalId:length(36)}")]
@ -1606,7 +1608,8 @@ namespace BMA.EHR.Placement.Service.Controllers
{
result.Add(r);
string? _null = null;
result.Add(new {
result.Add(new
{
No = _null,
FullName = r.RemarkHorizontal,
Education = _null,
@ -1905,7 +1908,8 @@ namespace BMA.EHR.Placement.Service.Controllers
{
result.Add(r);
string? _null = null;
result.Add(new {
result.Add(new
{
No = _null,
FullName = r.RemarkHorizontal,
Education = _null,
@ -2222,7 +2226,8 @@ namespace BMA.EHR.Placement.Service.Controllers
{
result.Add(r);
string? _null = null;
result.Add(new {
result.Add(new
{
No = _null,
FullName = r.RemarkHorizontal,
Education = _null,
@ -2444,7 +2449,8 @@ namespace BMA.EHR.Placement.Service.Controllers
{
result.Add(r);
string? _null = null;
result.Add(new {
result.Add(new
{
No = _null,
FullName = r.RemarkHorizontal,
Education = _null,
@ -2658,7 +2664,8 @@ namespace BMA.EHR.Placement.Service.Controllers
{
result.Add(r);
string? _null = null;
result.Add(new {
result.Add(new
{
No = _null,
FullName = r.RemarkHorizontal,
Education = _null,

View file

@ -0,0 +1,19 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Placement.Service.Requests
{
public class OrgRequestAct
{
public OrgRequestActData result { get; set; } = new();
}
public class OrgRequestActData
{
public bool? isOfficer { get; set; }
public string? rootId { get; set; }
public string? child1Id { get; set; }
public string? child2Id { get; set; }
public string? child3Id { get; set; }
public string? child4Id { get; set; }
}
}