แก้คำสั่ง

This commit is contained in:
Kittapath 2024-06-24 09:33:18 +07:00
parent 0495d0f647
commit e47eca3235
7 changed files with 20199 additions and 5340 deletions

View file

@ -151,6 +151,7 @@ namespace BMA.EHR.Placement.Service.Controllers
StatusId = x.PlacementStatus,
Draft = x.Draft,
typeCommand = x.typeCommand,
IsOfficer = x.IsOfficer,
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
}).OrderBy(x => x.ExamNumber).ToListAsync();
@ -197,7 +198,7 @@ namespace BMA.EHR.Placement.Service.Controllers
p.PositionCandidate,
p.PositionCandidateId,
p.ReportingDate,
BmaOfficer = p.IdCard == null ? null : await _documentService.CheckBmaOfficer(p.IdCard),
BmaOfficer = p.IsOfficer == true ? "OFFICER" : null,
p.StatusId,
p.Draft,
p.typeCommand,
@ -275,6 +276,7 @@ namespace BMA.EHR.Placement.Service.Controllers
StatusId = x.PlacementStatus,
Draft = x.Draft,
typeCommand = x.typeCommand,
IsOfficer = x.IsOfficer,
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
}).OrderBy(x => x.ExamNumber).ToListAsync();
@ -321,7 +323,7 @@ namespace BMA.EHR.Placement.Service.Controllers
p.PositionCandidate,
p.PositionCandidateId,
p.ReportingDate,
BmaOfficer = p.IdCard == null ? null : await _documentService.CheckBmaOfficer(p.IdCard),
BmaOfficer = p.IsOfficer == true ? "OFFICER" : null,
p.StatusId,
p.Draft,
p.typeCommand,
@ -448,7 +450,7 @@ namespace BMA.EHR.Placement.Service.Controllers
ExamRound = x.ExamRound,
Pass = x.Pass,
IsProperty = x.IsProperty == null ? null : Newtonsoft.Json.JsonConvert.DeserializeObject<List<PersonPropertyRequest>>(x.IsProperty),
BmaOfficer = "",
BmaOfficer = x.IsOfficer == true ? "OFFICER" : null,
PlacementProfileDocs = x.PlacementProfileDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
}).FirstOrDefaultAsync(x => x.PersonalId == personalId);
@ -525,7 +527,7 @@ namespace BMA.EHR.Placement.Service.Controllers
data.ExamRound,
data.Pass,
data.IsProperty,
BmaOfficer = data.IdCard == null ? null : await _documentService.CheckBmaOfficer(data.IdCard),
BmaOfficer = data.BmaOfficer,
Docs = placementProfileDocs,
};
return Success(_data);
@ -568,24 +570,47 @@ 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);
var placement = await _context.Placements
.Where(x => x.Id == examId)
.Select(x => new
{
Total = x.PlacementProfiles.Where(p => ocIdList.Contains(p.OrganizationPosition.Organization.Id)).Count(),
UnContain = x.PlacementProfiles.Where(p => ocIdList.Contains(p.OrganizationPosition.Organization.Id)).Where(p => p.PlacementStatus.Trim().ToUpper() == "UN-CONTAIN").Count(),
PrepareContain = x.PlacementProfiles.Where(p => ocIdList.Contains(p.OrganizationPosition.Organization.Id)).Where(p => p.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN").Count(),
Contain = x.PlacementProfiles.Where(p => ocIdList.Contains(p.OrganizationPosition.Organization.Id)).Where(p => p.PlacementStatus.Trim().ToUpper() == "CONTAIN").Count(),
Disclaim = x.PlacementProfiles.Where(p => ocIdList.Contains(p.OrganizationPosition.Organization.Id)).Where(p => p.PlacementStatus.Trim().ToUpper() == "DISCLAIM").Count(),
}).FirstOrDefaultAsync();
if (placement == null)
return Error(GlobalMessages.DataNotFound, 404);
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();
return Success(placement);
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 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);
var placement = await _context.Placements
.Where(x => x.Id == examId)
.Select(x => new
{
Total = x.PlacementProfiles.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))))).Count(),
UnContain = x.PlacementProfiles.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))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "UN-CONTAIN").Count(),
PrepareContain = x.PlacementProfiles.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))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN").Count(),
Contain = x.PlacementProfiles.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))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "CONTAIN").Count(),
Disclaim = x.PlacementProfiles.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))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "DISCLAIM").Count(),
}).FirstOrDefaultAsync();
if (placement == null)
return Error(GlobalMessages.DataNotFound, 404);
return Success(placement);
}
}
}