Merge branch 'develop' into working
This commit is contained in:
commit
1134267acf
7 changed files with 20233 additions and 5365 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -90,13 +90,14 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||||
|
|
||||||
private Guid OcId
|
private Guid OcId
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (UserId != null || UserId != "")
|
if (UserId != null || UserId != "")
|
||||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), token);
|
||||||
else
|
else
|
||||||
return Guid.Empty;
|
return Guid.Empty;
|
||||||
}
|
}
|
||||||
|
|
@ -4859,6 +4860,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
FirstName = p.FirstName,
|
FirstName = p.FirstName,
|
||||||
LastName = p.LastName,
|
LastName = p.LastName,
|
||||||
OrganizationName = p.OrganizationName,
|
OrganizationName = p.OrganizationName,
|
||||||
|
ReceiveUserId = p.ProfileId.ToString(),
|
||||||
PositionName = p.Position
|
PositionName = p.Position
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -5395,11 +5397,22 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<ActionResult<ResponseObject>> GetCommandOrganizationAsync()
|
public async Task<ActionResult<ResponseObject>> GetCommandOrganizationAsync([FromHeader] string authorization)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = await _repository.GetCommandOrgAsync();
|
var token = string.Empty;
|
||||||
|
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
|
||||||
|
{
|
||||||
|
// we have a valid AuthenticationHeaderValue that has the following details:
|
||||||
|
|
||||||
|
var scheme = headerValue.Scheme;
|
||||||
|
token = headerValue.Parameter;
|
||||||
|
|
||||||
|
// scheme will be "Bearer"
|
||||||
|
// parmameter will be the token itself.
|
||||||
|
}
|
||||||
|
var data = await _repository.GetCommandOrgAsync(token);
|
||||||
|
|
||||||
return Success(data);
|
return Success(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,9 @@ namespace BMA.EHR.Domain.Models.Placement
|
||||||
public string? RemarkHorizontal { get; set; }
|
public string? RemarkHorizontal { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Comment("profileId")]
|
||||||
|
public string? profileId { get; set; }
|
||||||
[Comment("ระดับโครงสร้าง")]
|
[Comment("ระดับโครงสร้าง")]
|
||||||
public int? node { get; set; }
|
public int? node { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
17953
BMA.EHR.Infrastructure/Migrations/20240622123348_update table CommandReceiver add Profile.Designer.cs
generated
Normal file
17953
BMA.EHR.Infrastructure/Migrations/20240622123348_update table CommandReceiver add Profile.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,30 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class updatetableCommandReceiveraddProfile : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "profileId",
|
||||||
|
table: "PlacementProfiles",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "profileId")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "profileId",
|
||||||
|
table: "PlacementProfiles");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12487,6 +12487,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("id อัตรากำลัง");
|
.HasComment("id อัตรากำลัง");
|
||||||
|
|
||||||
|
b.Property<string>("profileId")
|
||||||
|
.HasColumnType("longtext")
|
||||||
|
.HasComment("profileId");
|
||||||
|
|
||||||
b.Property<string>("root")
|
b.Property<string>("root")
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("ชื่อหน่วยงาน root");
|
.HasComment("ชื่อหน่วยงาน root");
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
StatusId = x.PlacementStatus,
|
StatusId = x.PlacementStatus,
|
||||||
Draft = x.Draft,
|
Draft = x.Draft,
|
||||||
typeCommand = x.typeCommand,
|
typeCommand = x.typeCommand,
|
||||||
|
IsOfficer = x.IsOfficer,
|
||||||
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
|
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
|
||||||
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
|
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
|
||||||
}).OrderBy(x => x.ExamNumber).ToListAsync();
|
}).OrderBy(x => x.ExamNumber).ToListAsync();
|
||||||
|
|
@ -197,7 +198,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
p.PositionCandidate,
|
p.PositionCandidate,
|
||||||
p.PositionCandidateId,
|
p.PositionCandidateId,
|
||||||
p.ReportingDate,
|
p.ReportingDate,
|
||||||
BmaOfficer = p.IdCard == null ? null : await _documentService.CheckBmaOfficer(p.IdCard),
|
BmaOfficer = p.IsOfficer == true ? "OFFICER" : null,
|
||||||
p.StatusId,
|
p.StatusId,
|
||||||
p.Draft,
|
p.Draft,
|
||||||
p.typeCommand,
|
p.typeCommand,
|
||||||
|
|
@ -275,6 +276,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
StatusId = x.PlacementStatus,
|
StatusId = x.PlacementStatus,
|
||||||
Draft = x.Draft,
|
Draft = x.Draft,
|
||||||
typeCommand = x.typeCommand,
|
typeCommand = x.typeCommand,
|
||||||
|
IsOfficer = x.IsOfficer,
|
||||||
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
|
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
|
||||||
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
|
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
|
||||||
}).OrderBy(x => x.ExamNumber).ToListAsync();
|
}).OrderBy(x => x.ExamNumber).ToListAsync();
|
||||||
|
|
@ -321,7 +323,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
p.PositionCandidate,
|
p.PositionCandidate,
|
||||||
p.PositionCandidateId,
|
p.PositionCandidateId,
|
||||||
p.ReportingDate,
|
p.ReportingDate,
|
||||||
BmaOfficer = p.IdCard == null ? null : await _documentService.CheckBmaOfficer(p.IdCard),
|
BmaOfficer = p.IsOfficer == true ? "OFFICER" : null,
|
||||||
p.StatusId,
|
p.StatusId,
|
||||||
p.Draft,
|
p.Draft,
|
||||||
p.typeCommand,
|
p.typeCommand,
|
||||||
|
|
@ -448,7 +450,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
ExamRound = x.ExamRound,
|
ExamRound = x.ExamRound,
|
||||||
Pass = x.Pass,
|
Pass = x.Pass,
|
||||||
IsProperty = x.IsProperty == null ? null : Newtonsoft.Json.JsonConvert.DeserializeObject<List<PersonPropertyRequest>>(x.IsProperty),
|
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 }),
|
PlacementProfileDocs = x.PlacementProfileDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||||
}).FirstOrDefaultAsync(x => x.PersonalId == personalId);
|
}).FirstOrDefaultAsync(x => x.PersonalId == personalId);
|
||||||
|
|
||||||
|
|
@ -525,7 +527,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
data.ExamRound,
|
data.ExamRound,
|
||||||
data.Pass,
|
data.Pass,
|
||||||
data.IsProperty,
|
data.IsProperty,
|
||||||
BmaOfficer = data.IdCard == null ? null : await _documentService.CheckBmaOfficer(data.IdCard),
|
BmaOfficer = data.BmaOfficer,
|
||||||
Docs = placementProfileDocs,
|
Docs = placementProfileDocs,
|
||||||
};
|
};
|
||||||
return Success(_data);
|
return Success(_data);
|
||||||
|
|
@ -568,24 +570,47 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var profileOrg = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId ?? "00000000-0000-0000-0000-000000000000"));
|
var rootId = "";
|
||||||
if (profileOrg == null)
|
var child1Id = "";
|
||||||
return Error(GlobalMessages.DataNotFound, 404);
|
var child2Id = "";
|
||||||
var ocIdList = _documentService.GetAllIdByRoot(profileOrg.OcId);
|
var child3Id = "";
|
||||||
var placement = await _context.Placements
|
var child4Id = "";
|
||||||
.Where(x => x.Id == examId)
|
var apiUrl = $"{_configuration["API"]}org/profile/keycloak/position";
|
||||||
.Select(x => new
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
Total = x.PlacementProfiles.Where(p => ocIdList.Contains(p.OrganizationPosition.Organization.Id)).Count(),
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
UnContain = x.PlacementProfiles.Where(p => ocIdList.Contains(p.OrganizationPosition.Organization.Id)).Where(p => p.PlacementStatus.Trim().ToUpper() == "UN-CONTAIN").Count(),
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||||
PrepareContain = x.PlacementProfiles.Where(p => ocIdList.Contains(p.OrganizationPosition.Organization.Id)).Where(p => p.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN").Count(),
|
var _res = await client.SendAsync(_req);
|
||||||
Contain = x.PlacementProfiles.Where(p => ocIdList.Contains(p.OrganizationPosition.Organization.Id)).Where(p => p.PlacementStatus.Trim().ToUpper() == "CONTAIN").Count(),
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue