Compare commits
16 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f8effe7e4 | ||
|
|
081c00b869 | ||
|
|
f1fc324828 | ||
|
|
cba02a4f6e | ||
|
|
208ad63abf | ||
|
|
d2f21a9181 | ||
|
|
c4a6b6d1df | ||
|
|
16015cf3ef | ||
|
|
06b62df43a | ||
|
|
022b68b496 | ||
|
|
0908d6083d | ||
|
|
caa0bccd79 | ||
|
|
fcc1018f80 | ||
|
|
75718a955d | ||
|
|
41dd23217c | ||
|
|
bb0b296086 |
13 changed files with 6665 additions and 151 deletions
|
|
@ -1365,7 +1365,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
District = workSheet?.Cells[row, 54]?.GetValue<string>() ?? "",
|
District = workSheet?.Cells[row, 54]?.GetValue<string>() ?? "",
|
||||||
Amphur = workSheet?.Cells[row, 55]?.GetValue<string>() ?? "",
|
Amphur = workSheet?.Cells[row, 55]?.GetValue<string>() ?? "",
|
||||||
Province = workSheet?.Cells[row, 56]?.GetValue<string>() ?? "",
|
Province = workSheet?.Cells[row, 56]?.GetValue<string>() ?? "",
|
||||||
ZipCode = workSheet?.Cells[row, 57]?.GetValue<string>() ?? "",
|
ZipCode = (workSheet?.Cells[row, 57]?.GetValue<string>() ?? "").Trim(),
|
||||||
Telephone = workSheet?.Cells[row, 58]?.GetValue<string>() ?? "",
|
Telephone = workSheet?.Cells[row, 58]?.GetValue<string>() ?? "",
|
||||||
Mobile = "",
|
Mobile = "",
|
||||||
Address1 = $"{(workSheet?.Cells[row, 61]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 62]?.GetValue<string>() ?? "")}",
|
Address1 = $"{(workSheet?.Cells[row, 61]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 62]?.GetValue<string>() ?? "")}",
|
||||||
|
|
@ -1375,7 +1375,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
District1 = workSheet?.Cells[row, 66]?.GetValue<string>() ?? "",
|
District1 = workSheet?.Cells[row, 66]?.GetValue<string>() ?? "",
|
||||||
Amphur1 = workSheet?.Cells[row, 67]?.GetValue<string>() ?? "",
|
Amphur1 = workSheet?.Cells[row, 67]?.GetValue<string>() ?? "",
|
||||||
Province1 = workSheet?.Cells[row, 68]?.GetValue<string>() ?? "",
|
Province1 = workSheet?.Cells[row, 68]?.GetValue<string>() ?? "",
|
||||||
ZipCode1 = workSheet?.Cells[row, 69]?.GetValue<string>() ?? "",
|
ZipCode1 = (workSheet?.Cells[row, 69]?.GetValue<string>() ?? "").Trim(),
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
CreatedUserId = UserId ?? "",
|
CreatedUserId = UserId ?? "",
|
||||||
CreatedFullName = FullName ?? "System Administrator",
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
|
|
@ -1399,7 +1399,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
TermBranch = workSheet?.Cells[row, 113]?.GetValue<string>() ?? "",
|
TermBranch = workSheet?.Cells[row, 113]?.GetValue<string>() ?? "",
|
||||||
TellerId = workSheet?.Cells[row, 114]?.GetValue<string>() ?? "",
|
TellerId = workSheet?.Cells[row, 114]?.GetValue<string>() ?? "",
|
||||||
CreditDebit = workSheet?.Cells[row, 115]?.GetValue<string>() ?? "",
|
CreditDebit = workSheet?.Cells[row, 115]?.GetValue<string>() ?? "",
|
||||||
PaymentType = workSheet?.Cells[row, 116]?.GetValue<string>(),
|
PaymentType = workSheet?.Cells[row, 116]?.GetValue<string>() ?? "",
|
||||||
ChequeNo = workSheet?.Cells[row, 117]?.GetValue<string>() ?? "",
|
ChequeNo = workSheet?.Cells[row, 117]?.GetValue<string>() ?? "",
|
||||||
Amount = (decimal)workSheet?.Cells[row, 118]?.GetValue<decimal>(),
|
Amount = (decimal)workSheet?.Cells[row, 118]?.GetValue<decimal>(),
|
||||||
ChqueBankCode = workSheet?.Cells[row, 119]?.GetValue<string>() ?? "",
|
ChqueBankCode = workSheet?.Cells[row, 119]?.GetValue<string>() ?? "",
|
||||||
|
|
@ -1604,15 +1604,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
|
|
||||||
r.ExamId = workSheet?.Cells[row, 2]?.GetValue<string>();
|
r.ExamId = workSheet?.Cells[row, 2]?.GetValue<string>();
|
||||||
|
|
||||||
//var recruit = await _context.Disables.AsQueryable()
|
|
||||||
// .Include(x => x.PeriodExam)
|
|
||||||
// .Where(x => x.PeriodExam == rec_import && x.ExamId == r.ExamId)
|
|
||||||
// .FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
// ใช้ dictionary lookup แทน query DB ทีละรอบ
|
// ใช้ dictionary lookup แทน query DB ทีละรอบ
|
||||||
if (!string.IsNullOrEmpty(r.ExamId) && recruitsDict.TryGetValue(r.ExamId, out var recruit))
|
if (!string.IsNullOrEmpty(r.ExamId) && recruitsDict.TryGetValue(r.ExamId, out var recruit))
|
||||||
{
|
{
|
||||||
r.CitizenId = workSheet?.Cells[row, 3]?.GetValue<string>();
|
r.CitizenId = workSheet?.Cells[row, 3]?.GetValue<string>()?.Trim();
|
||||||
|
|
||||||
// ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง
|
// ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง
|
||||||
r.FullA = 200;
|
r.FullA = 200;
|
||||||
|
|
@ -1633,24 +1628,20 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
r.FullScore = 300;
|
r.FullScore = 300;
|
||||||
r.TotalScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 13]?.GetValue<string>()) ? 0.00 : Math.Round(workSheet.Cells[row, 13].GetValue<double>(), 2);
|
r.TotalScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 13]?.GetValue<string>()) ? 0.00 : Math.Round(workSheet.Cells[row, 13].GetValue<double>(), 2);
|
||||||
|
|
||||||
if (workSheet?.Cells[row, 7]?.GetValue<string>() == "ขาดสอบ")
|
var examStatusCol7 = workSheet?.Cells[row, 7]?.GetValue<string>()?.Trim();
|
||||||
{
|
var examStatusCol14 = workSheet?.Cells[row, 14]?.GetValue<string>()?.Trim();
|
||||||
r.ExamStatus = "ขส.";
|
r.ExamStatus =
|
||||||
}
|
examStatusCol7 == "ขาดสอบ" ? "ขส." :
|
||||||
else if (workSheet?.Cells[row, 14]?.GetValue<string>() == "ได้")
|
examStatusCol14 == "ได้" ? "ผ่าน" :
|
||||||
{
|
examStatusCol14 == "ตก" ? "ไม่ผ่าน" : "-";
|
||||||
r.ExamStatus = "ผ่าน";
|
|
||||||
}
|
|
||||||
else if (workSheet?.Cells[row, 14]?.GetValue<string>() == "ตก")
|
|
||||||
{
|
|
||||||
r.ExamStatus = "ไม่ผ่าน";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r.ExamStatus = "-";
|
|
||||||
}
|
|
||||||
|
|
||||||
r.RemarkScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 15]?.GetValue<string>()) ? string.Empty : workSheet?.Cells[row, 15]?.GetValue<string>();
|
r.RemarkScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 15]?.GetValue<string>()) ? string.Empty : workSheet?.Cells[row, 15]?.GetValue<string>();
|
||||||
|
|
||||||
|
var examAttr = workSheet?.Cells[row, 16]?.GetValue<string>()?.Trim();
|
||||||
|
r.ExamAttribute =
|
||||||
|
examAttr == "ผ่าน" ? "มีคุณสมบัติ" :
|
||||||
|
examAttr == "ไม่ผ่าน" ? "ไม่มีคุณสมบัติ" : "";
|
||||||
|
|
||||||
r.Major = workSheet.Name;
|
r.Major = workSheet.Name;
|
||||||
|
|
||||||
r.CreatedAt = DateTime.Now;
|
r.CreatedAt = DateTime.Now;
|
||||||
|
|
@ -2091,10 +2082,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
: "",
|
: "",
|
||||||
examScore = x.score == null ? 0.0 : x.score.TotalScore,
|
examScore = x.score == null ? 0.0 : x.score.TotalScore,
|
||||||
examResult = x.score == null ? "" : x.score.ExamStatus,
|
examResult = x.score == null ? "" : x.score.ExamStatus,
|
||||||
examAttribute = x.disable.Certificates.Any() && x.disable.Certificates.First().IssueDate != null
|
//examAttribute = x.disable.Certificates.Any() && x.disable.Certificates.First().IssueDate != null
|
||||||
? _disableService.CheckValidCertificate(x.disable.Certificates.First().IssueDate, 5)
|
// ? _disableService.CheckValidCertificate(x.disable.Certificates.First().IssueDate, 5)
|
||||||
? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ"
|
// ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ"
|
||||||
: "ไม่มีคุณสมบัติ",
|
// : "ไม่มีคุณสมบัติ",
|
||||||
|
|
||||||
|
examAttribute = x.score != null && !string.IsNullOrEmpty(x.score.ExamAttribute) &&
|
||||||
|
(x.score.ExamAttribute == "มีคุณสมบัติ" || x.score.ExamAttribute == "ไม่มีคุณสมบัติ")
|
||||||
|
? x.score.ExamAttribute : "",
|
||||||
|
|
||||||
remark = x.disable.Remark,
|
remark = x.disable.Remark,
|
||||||
isSpecial = x.disable.Isspecial == "Y" ? x.disable.Isspecial : "",
|
isSpecial = x.disable.Isspecial == "Y" ? x.disable.Isspecial : "",
|
||||||
applyDate = x.disable.ApplyDate.HasValue && x.disable.ApplyDate.Value != DateTime.MinValue
|
applyDate = x.disable.ApplyDate.HasValue && x.disable.ApplyDate.Value != DateTime.MinValue
|
||||||
|
|
@ -2191,8 +2187,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
.Where(x => x.ExamId == examId)
|
.Where(x => x.ExamId == examId)
|
||||||
.Join(_context.DisableScores.AsQueryable()
|
.Join(_context.DisableScores.AsQueryable()
|
||||||
.Include(x => x.ScoreImport),
|
.Include(x => x.ScoreImport),
|
||||||
rc => new { /*rc.PeriodExam.Year,*/ rc.ExamId },
|
rc => new { PeriodExamId = rc.PeriodExam.Id, rc.ExamId },
|
||||||
sc => new { /*sc.ScoreImport.Year,*/ sc.ExamId },
|
sc => new { PeriodExamId = sc.ScoreImport.PeriodExamId, sc.ExamId },
|
||||||
(p, sr) => new
|
(p, sr) => new
|
||||||
{
|
{
|
||||||
ExamID = p.ExamId,
|
ExamID = p.ExamId,
|
||||||
|
|
@ -2214,11 +2210,16 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
: ""
|
: ""
|
||||||
: "",
|
: "",
|
||||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||||
ExamAttribute = p.Certificates.Count > 0 ?
|
// ExamAttribute = p.Certificates.Count > 0 ?
|
||||||
_disableService.CheckValidCertificate(p.Certificates.First().IssueDate, 5)
|
// _disableService.CheckValidCertificate(p.Certificates.First().IssueDate, 5)
|
||||||
? "มีคุณสมบัติ"
|
// ? "มีคุณสมบัติ"
|
||||||
: "ไม่มีคุณสมบัติ"
|
// : "ไม่มีคุณสมบัติ"
|
||||||
: "ไม่มีคุณสมบัติ",
|
// : "ไม่มีคุณสมบัติ",
|
||||||
|
|
||||||
|
ExamAttribute = sr != null && !string.IsNullOrEmpty(sr.ExamAttribute) &&
|
||||||
|
(sr.ExamAttribute == "มีคุณสมบัติ" || sr.ExamAttribute == "ไม่มีคุณสมบัติ")
|
||||||
|
? sr.ExamAttribute : "",
|
||||||
|
|
||||||
IsSpecial = p.Isspecial,
|
IsSpecial = p.Isspecial,
|
||||||
Remark = p.Remark,
|
Remark = p.Remark,
|
||||||
University = p.Educations.First().University,
|
University = p.Educations.First().University,
|
||||||
|
|
|
||||||
|
|
@ -749,6 +749,56 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ดาวน์โหลดรายชื่อผู้มีสิทธิ์สอบ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านโหลดผู้สมัครสอบสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("download/candidate-exam/{examId:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> DownloadCandidateExamAsync(string examId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = await _periodExamService.DownloadCandidateExamAsync(examId);
|
||||||
|
return Success(data);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ดาวน์โหลดรายชื่อผู้สอบคัดเลือกได้
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านโหลดผู้สมัครสอบสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("download/pass-exam/{examId:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> DownloadPassExamAsync(string examId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = await _periodExamService.DownloadPassExamAsync(examId);
|
||||||
|
return Success(data);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// โหลดผู้สมัครสอบ
|
/// โหลดผู้สมัครสอบ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Nest;
|
using Nest;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net.Http.Headers;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
@ -19,7 +18,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
|
||||||
private string Uri = "";
|
private string Uri = "";
|
||||||
private string IndexFormat = "";
|
private string IndexFormat = "";
|
||||||
private string SystemName = "";
|
private string SystemName = "";
|
||||||
private string APIKey = "";
|
|
||||||
|
|
||||||
public RequestLoggingMiddleware(RequestDelegate next, IConfiguration configuration)
|
public RequestLoggingMiddleware(RequestDelegate next, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
|
@ -32,65 +30,48 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
|
||||||
SystemName = "recruiting";
|
SystemName = "recruiting";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task<string> GetExternalAPIAsync(string apiPath, string accessToken, string apiKey)
|
/// <summary>
|
||||||
|
/// แกะ JWT token เพื่อดึง claims ต่างๆ
|
||||||
|
/// </summary>
|
||||||
|
private JwtSecurityToken? ParseToken(string token)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var client = new HttpClient())
|
var tokenHandler = new JwtSecurityTokenHandler();
|
||||||
{
|
var jwtToken = tokenHandler.ReadJwtToken(token.Replace("Bearer ", ""));
|
||||||
// Set timeout to 30 seconds instead of default 100 seconds
|
return jwtToken;
|
||||||
client.Timeout = TimeSpan.FromSeconds(30);
|
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
|
|
||||||
client.DefaultRequestHeaders.Add("api_key", apiKey);
|
|
||||||
|
|
||||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
|
|
||||||
var _res = await client.GetAsync(apiPath, cts.Token);
|
|
||||||
if (_res.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
return _result;
|
|
||||||
}
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (TaskCanceledException)
|
catch
|
||||||
{
|
{
|
||||||
// Log timeout but don't throw - return empty result instead
|
return null;
|
||||||
Console.WriteLine($"API call timed out: {apiPath}");
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// Log other exceptions but don't throw - return empty result instead
|
|
||||||
Console.WriteLine($"API call failed: {apiPath}, Error: {ex.Message}");
|
|
||||||
return string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<GetProfileByKeycloakIdLocal?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
|
/// <summary>
|
||||||
|
/// ดึงค่า claim จาก token โดยลองชื่อหลายแบบ
|
||||||
|
/// </summary>
|
||||||
|
private string? GetClaimValue(JwtSecurityToken? token, params string[] claimNames)
|
||||||
{
|
{
|
||||||
try
|
if (token == null) return null;
|
||||||
{
|
|
||||||
//var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak/{keycloakId}";
|
|
||||||
var apiPath = $"{_configuration["API"]}/org/dotnet/user-logs/{keycloakId}";
|
|
||||||
var apiKey = _configuration["API_KEY"] ?? "";
|
|
||||||
|
|
||||||
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
foreach (var name in claimNames)
|
||||||
if (!string.IsNullOrEmpty(apiResult))
|
|
||||||
{
|
|
||||||
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultLocal>(apiResult);
|
|
||||||
if (raw != null)
|
|
||||||
return raw.Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
// Log exception but don't throw - return null instead
|
var claim = token.Claims.FirstOrDefault(c => c.Type == name);
|
||||||
Console.WriteLine($"GetProfileByKeycloakIdAsync failed for {keycloakId}: {ex.Message}");
|
if (claim != null)
|
||||||
return null;
|
return claim.Value;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ดึงค่า Guid claim จาก token
|
||||||
|
/// </summary>
|
||||||
|
private Guid? GetGuidClaim(JwtSecurityToken? token, params string[] claimNames)
|
||||||
|
{
|
||||||
|
var value = GetClaimValue(token, claimNames);
|
||||||
|
if (Guid.TryParse(value, out var guid))
|
||||||
|
return guid;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Invoke(HttpContext context)
|
public async Task Invoke(HttpContext context)
|
||||||
|
|
@ -155,19 +136,22 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
|
||||||
// เปลี่ยน stream ของ Response เพื่อให้สามารถอ่านได้
|
// เปลี่ยน stream ของ Response เพื่อให้สามารถอ่านได้
|
||||||
context.Response.Body = memoryStream;
|
context.Response.Body = memoryStream;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var keycloakId = context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? Guid.Empty.ToString("D");
|
var keycloakId = context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? Guid.Empty.ToString("D");
|
||||||
var token = context.Request.Headers["Authorization"];
|
var tokenHeader = context.Request.Headers["Authorization"].ToString();
|
||||||
|
|
||||||
var pf = await GetProfileByKeycloakIdAsync(Guid.Parse(keycloakId), token);
|
// แกะ JWT token เพื่อดึง claims ต่างๆ
|
||||||
var _userFullname = string.Empty;
|
var jwtToken = ParseToken(tokenHeader);
|
||||||
var _userName = string.Empty;
|
|
||||||
if (keycloakId != "00000000-0000-0000-0000-000000000000" && pf == null)
|
// ดึงข้อมูลจาก claims โดยลองชื่อหลายแบบ (camelCase, snake_case, ฯลฯ)
|
||||||
{
|
var prefix = GetClaimValue(jwtToken, "prefix", "Prefix", "PREFIX");
|
||||||
_userFullname = context.User?.FindFirst("name")?.Value;
|
var firstName = GetClaimValue(jwtToken, "given_name", "firstname", "firstName", "FirstName", "FIRSTNAME");
|
||||||
_userName = context.User?.FindFirst("preferred_username")?.Value;
|
var lastName = GetClaimValue(jwtToken, "family_name", "lastname", "lastName", "LastName", "LASTNAME");
|
||||||
}
|
var preferredUsername = GetClaimValue(jwtToken, "preferred_username", "preferred_username", "PreferredUsername");
|
||||||
|
var orgRootDnaId = GetGuidClaim(jwtToken, "orgRootDnaId", "org_root_dna_id", "OrgRootDnaId", "rootDnaId");
|
||||||
|
var orgChild1DnaId = GetGuidClaim(jwtToken, "orgChild1DnaId", "org_child1_dna", "OrgChild1Dna", "child1DnaId");
|
||||||
|
var orgChild2DnaId = GetGuidClaim(jwtToken, "orgChild2DnaId", "org_child2_dna", "OrgChild2Dna", "child2DnaId");
|
||||||
|
var orgChild3DnaId = GetGuidClaim(jwtToken, "orgChild3DnaId", "org_child3_dna", "OrgChild3Dna", "child3DnaId");
|
||||||
|
var orgChild4DnaId = GetGuidClaim(jwtToken, "orgChild4DnaId", "org_child4_dna", "OrgChild4Dna", "child4DnaId");
|
||||||
|
|
||||||
await _next(context); // ดำเนินการต่อไปยัง Middleware อื่น ๆ
|
await _next(context); // ดำเนินการต่อไปยัง Middleware อื่น ๆ
|
||||||
|
|
||||||
|
|
@ -254,8 +238,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
|
||||||
{
|
{
|
||||||
logType = logType,
|
logType = logType,
|
||||||
ip = context.Connection.RemoteIpAddress?.ToString(),
|
ip = context.Connection.RemoteIpAddress?.ToString(),
|
||||||
//rootId = pf == null ? null : pf.RootId,
|
rootId = orgRootDnaId?.ToString("D"),
|
||||||
rootId = pf == null ? null : pf.RootDnaId,
|
|
||||||
systemName = SystemName,
|
systemName = SystemName,
|
||||||
startTimeStamp = startTime.ToString("o"),
|
startTimeStamp = startTime.ToString("o"),
|
||||||
endTimeStamp = endTime.ToString("o"),
|
endTimeStamp = endTime.ToString("o"),
|
||||||
|
|
@ -269,8 +252,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
|
||||||
output = responseBodyJson,
|
output = responseBodyJson,
|
||||||
|
|
||||||
userId = keycloakId,
|
userId = keycloakId,
|
||||||
userName = pf != null ? $"{pf?.Prefix ?? ""}{pf?.FirstName ?? ""} {pf?.LastName ?? ""}" : _userFullname ?? "",
|
userName = $"{prefix ?? ""}{firstName ?? ""} {lastName ?? ""}".Trim(),
|
||||||
user = pf != null ? pf?.CitizenId ?? "" : _userName ?? ""
|
user = preferredUsername ?? ""
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -295,47 +278,4 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetProfileByKeycloakIdLocal
|
|
||||||
{
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
|
|
||||||
public string? Prefix { get; set; }
|
|
||||||
public string? FirstName { get; set; }
|
|
||||||
public string? LastName { get; set; }
|
|
||||||
public string? CitizenId { get; set; }
|
|
||||||
|
|
||||||
public string? Root { get; set; }
|
|
||||||
public string? Child1 { get; set; }
|
|
||||||
public string? Child2 { get; set; }
|
|
||||||
public string? Child3 { get; set; }
|
|
||||||
public string? Child4 { get; set; }
|
|
||||||
public Guid? RootId { get; set; }
|
|
||||||
public Guid? Child1Id { get; set; }
|
|
||||||
public Guid? Child2Id { get; set; }
|
|
||||||
public Guid? Child3Id { get; set; }
|
|
||||||
public Guid? Child4Id { get; set; }
|
|
||||||
public Guid? RootDnaId { get; set; }
|
|
||||||
public Guid? Child1DnaId { get; set; }
|
|
||||||
public Guid? Child2DnaId { get; set; }
|
|
||||||
public Guid? Child3DnaId { get; set; }
|
|
||||||
public Guid? Child4DnaId { get; set; }
|
|
||||||
public double? Amount { get; set; }
|
|
||||||
public double? PositionSalaryAmount { get; set; }
|
|
||||||
public string? Commander { get; set; }
|
|
||||||
|
|
||||||
public Guid? CommanderId { get; set; }
|
|
||||||
|
|
||||||
public Guid? CommanderKeycloak { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GetProfileByKeycloakIdResultLocal
|
|
||||||
{
|
|
||||||
public string Message { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int Status { get; set; } = -1;
|
|
||||||
|
|
||||||
public GetProfileByKeycloakIdLocal? Result { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1296,13 +1296,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
||||||
|
|
||||||
b.Property<string>("ZipCode")
|
b.Property<string>("ZipCode")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(5)
|
.HasMaxLength(10)
|
||||||
.HasColumnType("varchar(5)");
|
.HasColumnType("varchar(10)");
|
||||||
|
|
||||||
b.Property<string>("ZipCode1")
|
b.Property<string>("ZipCode1")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(5)
|
.HasMaxLength(10)
|
||||||
.HasColumnType("varchar(5)");
|
.HasColumnType("varchar(10)");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
|
@ -1883,6 +1883,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
||||||
.HasColumnOrder(101)
|
.HasColumnOrder(101)
|
||||||
.HasComment("User Id ที่สร้างข้อมูล");
|
.HasComment("User Id ที่สร้างข้อมูล");
|
||||||
|
|
||||||
|
b.Property<string>("ExamAttribute")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("varchar(50)")
|
||||||
|
.HasComment("สถานะคัดกรองคุณสมบัติ");
|
||||||
|
|
||||||
b.Property<string>("ExamId")
|
b.Property<string>("ExamId")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
|
|
|
||||||
3153
Migrations/20260310044710_update_table_DisableScore_add_field_ExamAttribute.Designer.cs
generated
Normal file
3153
Migrations/20260310044710_update_table_DisableScore_add_field_ExamAttribute.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,32 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class update_table_DisableScore_add_field_ExamAttribute : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ExamAttribute",
|
||||||
|
table: "DisableScores",
|
||||||
|
type: "varchar(50)",
|
||||||
|
maxLength: 50,
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "",
|
||||||
|
comment: "สถานะคัดกรองคุณสมบัติ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ExamAttribute",
|
||||||
|
table: "DisableScores");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3153
Migrations/20260324084215_update_DisableAddress.Designer.cs
generated
Normal file
3153
Migrations/20260324084215_update_DisableAddress.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
66
Migrations/20260324084215_update_DisableAddress.cs
Normal file
66
Migrations/20260324084215_update_DisableAddress.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class update_DisableAddress : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "ZipCode1",
|
||||||
|
table: "DisableAddresses",
|
||||||
|
type: "varchar(10)",
|
||||||
|
maxLength: 10,
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "varchar(5)",
|
||||||
|
oldMaxLength: 5)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "ZipCode",
|
||||||
|
table: "DisableAddresses",
|
||||||
|
type: "varchar(10)",
|
||||||
|
maxLength: 10,
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "varchar(5)",
|
||||||
|
oldMaxLength: 5)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "ZipCode1",
|
||||||
|
table: "DisableAddresses",
|
||||||
|
type: "varchar(5)",
|
||||||
|
maxLength: 5,
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "varchar(10)",
|
||||||
|
oldMaxLength: 10)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "ZipCode",
|
||||||
|
table: "DisableAddresses",
|
||||||
|
type: "varchar(5)",
|
||||||
|
maxLength: 5,
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "varchar(10)",
|
||||||
|
oldMaxLength: 10)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
|
||||||
[MaxLength(200)]
|
[MaxLength(200)]
|
||||||
public string Province { get; set; }//
|
public string Province { get; set; }//
|
||||||
|
|
||||||
[MaxLength(5)]
|
[MaxLength(10)]
|
||||||
public string ZipCode { get; set; }//
|
public string ZipCode { get; set; }//
|
||||||
|
|
||||||
[MaxLength(200)]
|
[MaxLength(200)]
|
||||||
|
|
@ -55,7 +55,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
|
||||||
[MaxLength(200)]
|
[MaxLength(200)]
|
||||||
public string Province1 { get; set; }//
|
public string Province1 { get; set; }//
|
||||||
|
|
||||||
[MaxLength(5)]
|
[MaxLength(10)]
|
||||||
public string ZipCode1 { get; set; }//
|
public string ZipCode1 { get; set; }//
|
||||||
|
|
||||||
public Disable Disable { get; set; }
|
public Disable Disable { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
|
||||||
[Comment("หมายเหตุจากลำดับที่สอบได้")]
|
[Comment("หมายเหตุจากลำดับที่สอบได้")]
|
||||||
public string RemarkExamOrder { get; set; } = string.Empty;
|
public string RemarkExamOrder { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[MaxLength(50), Comment("สถานะคัดกรองคุณสมบัติ")]
|
||||||
|
public string ExamAttribute { get; set; } = string.Empty;
|
||||||
|
|
||||||
public ScoreImport ScoreImport { get; set; }
|
public ScoreImport ScoreImport { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||||
public string? RejectDetail { get; set; }
|
public string? RejectDetail { get; set; }
|
||||||
|
|
||||||
public bool? IsShowExamInfo { get; set; }
|
public bool? IsShowExamInfo { get; set; }
|
||||||
|
|
||||||
|
public bool? IsShowResult { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1978,7 +1978,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
if (candidate == null)
|
if (candidate == null)
|
||||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||||
|
|
||||||
return new CandidateStatusResponse { Status = candidate.Status, RejectDetail = candidate.RejectDetail, IsShowExamInfo = candidate.IsShowExamInfo };
|
bool IsShowResult = true;
|
||||||
|
if (exam.AnnouncementDate != null)
|
||||||
|
{
|
||||||
|
var showResultEndDate = exam.AnnouncementDate.Value.Date.AddDays(15);
|
||||||
|
IsShowResult = DateTime.Now.Date <= showResultEndDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CandidateStatusResponse {
|
||||||
|
Status = candidate.Status,
|
||||||
|
RejectDetail = candidate.RejectDetail,
|
||||||
|
IsShowExamInfo = candidate.IsShowExamInfo,
|
||||||
|
IsShowResult = IsShowResult,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UserCheckCandidateService(string examId, string positionId, string status)
|
public async Task UserCheckCandidateService(string examId, string positionId, string status)
|
||||||
|
|
|
||||||
|
|
@ -1625,6 +1625,101 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<dynamic> DownloadCandidateExamAsync(string examId)
|
||||||
|
{
|
||||||
|
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||||
|
.Where(x => x.CheckDisability == false)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||||
|
|
||||||
|
if (periodExam == null)
|
||||||
|
throw new Exception(GlobalMessages.ExamNotFound);
|
||||||
|
|
||||||
|
var data = await _context.Candidates.AsQueryable()
|
||||||
|
.Include(x => x.PeriodExam)
|
||||||
|
.Where(x => x.PeriodExam == periodExam)
|
||||||
|
.Where(x => x.Status != "register")
|
||||||
|
.Where(x => x.ExamIdenNumber != null && x.ExamIdenNumber != "")
|
||||||
|
.OrderBy(x => x.ExamIdenNumber)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
ExamId = p.ExamIdenNumber == null ? null : (p.ExamIdenNumber.ToThaiNumber()),
|
||||||
|
FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
|
||||||
|
PositionName = "",
|
||||||
|
ExamName =
|
||||||
|
($"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}").ToThaiNumber(),
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
if (data.Count == 0)
|
||||||
|
throw new Exception("ไม่พบข้อมูลในระบบ");
|
||||||
|
|
||||||
|
var examName = data[0].ExamName;
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
template = "rptCandidateList",
|
||||||
|
reportName = $"รายชื่อผู้มีสิทธิ์สอบ_{data.First().ExamName}",
|
||||||
|
data = new
|
||||||
|
{
|
||||||
|
examName = examName,
|
||||||
|
data = data
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<dynamic> DownloadPassExamAsync(string examId)
|
||||||
|
{
|
||||||
|
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||||
|
.Where(x => x.CheckDisability == false)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||||
|
|
||||||
|
if (periodExam == null)
|
||||||
|
throw new Exception(GlobalMessages.ExamNotFound);
|
||||||
|
|
||||||
|
var candidates = await _context.Candidates.AsQueryable()
|
||||||
|
.Include(x => x.PeriodExam)
|
||||||
|
.ThenInclude(x => x.ScoreImport)
|
||||||
|
.Where(x => x.PeriodExam == periodExam)
|
||||||
|
.Where(x => x.Status != "register")
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var data = candidates.Select((p, idx) => new
|
||||||
|
{
|
||||||
|
SeatNumber = p.SeatNumber == null ? "-" : (p.SeatNumber.ToThaiNumber()),
|
||||||
|
CitizenId = p.CitizenId == null ? "-" : (p.CitizenId.ToThaiNumber()),
|
||||||
|
FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
|
||||||
|
DateOfBirth = p.DateOfBirth == null ? "-" : (p.DateOfBirth.Value.ToThaiShortDate()),
|
||||||
|
ExamName = ($"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}").ToThaiNumber(),
|
||||||
|
Number = p.Number == null ? (idx + 1).ToString().ToThaiNumber() : p.Number.ToThaiNumber(),
|
||||||
|
FullA = "๐",
|
||||||
|
SumA = "๐",
|
||||||
|
FullB = p.PointTotalB == null ? "-" : p.PointTotalB.ToString(),
|
||||||
|
SumB = p.PointB == null ? "-" : p.PointB.ToString(),
|
||||||
|
FullC = p.PointTotalC == null ? "-" : p.PointTotalC.ToString(),
|
||||||
|
SumC = p.PointC == null ? "-" : p.PointC.ToString(),
|
||||||
|
SumScore = ((Convert.ToInt32(p.PointB ?? "0") + Convert.ToInt32(p.PointC ?? "0")).ToString()).ToThaiNumber(),
|
||||||
|
ExamResult = p.Pass,
|
||||||
|
ExamThaiId = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber.ToThaiNumber(),
|
||||||
|
ExamId = p.ExamIdenNumber,
|
||||||
|
})
|
||||||
|
.OrderBy(x => x.ExamId)
|
||||||
|
.Where(x => x.ExamResult?.Trim() == "ได้")
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (data.Count == 0)
|
||||||
|
throw new Exception("ไม่พบข้อมูลในระบบ");
|
||||||
|
|
||||||
|
var examName = data[0].ExamName;
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
template = "rptPassExamList",
|
||||||
|
reportName = $"รายชื่อผู้สอบแข่งขันได้_{periodExam.Name} ครั้งที่ {periodExam.Round}/{periodExam.Year.Value.ToThaiYear()}",
|
||||||
|
data = new
|
||||||
|
{
|
||||||
|
examName = examName,
|
||||||
|
data = data
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<PeriodExam> GetsPaymentExamAsync(string examId)
|
public async Task<PeriodExam> GetsPaymentExamAsync(string examId)
|
||||||
{
|
{
|
||||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue