Compare commits
18 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37601e2e18 | ||
|
|
bc4c6a2ea7 | ||
|
|
a226f1623d | ||
|
|
09e12ea888 | ||
|
|
8cde71829c | ||
|
|
d90b46f3f4 | ||
|
|
8d7bc9c9b7 | ||
|
|
0ab3445ad0 | ||
|
|
c507d7be06 | ||
|
|
b11f64143d | ||
|
|
71dd411dc6 | ||
|
|
35e17cefd1 | ||
|
|
2f8effe7e4 | ||
|
|
081c00b869 | ||
|
|
f1fc324828 | ||
|
|
cba02a4f6e | ||
|
|
208ad63abf | ||
|
|
d2f21a9181 |
11 changed files with 595 additions and 181 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -475,3 +475,5 @@ $RECYCLE.BIN/
|
||||||
|
|
||||||
# Windows shortcuts
|
# Windows shortcuts
|
||||||
*.lnk
|
*.lnk
|
||||||
|
|
||||||
|
.claude
|
||||||
|
|
@ -86,6 +86,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
private string? RootDnaId => _httpContextAccessor?.HttpContext?.User?.FindFirst("orgRootDnaId")?.Value;
|
||||||
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -487,6 +488,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
Note = req.Note,
|
Note = req.Note,
|
||||||
AnnouncementDate = req.AnnouncementDate,
|
AnnouncementDate = req.AnnouncementDate,
|
||||||
CheckDisability = true,
|
CheckDisability = true,
|
||||||
|
OrganizationId = req.rootDnaId,
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
CreatedUserId = UserId ?? "",
|
CreatedUserId = UserId ?? "",
|
||||||
CreatedFullName = FullName ?? "System Administrator",
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
|
|
@ -499,7 +501,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||||
var _res = await client.SendAsync(_req);
|
var _res = await client.SendAsync(_req);
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
|
@ -668,8 +670,16 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
{
|
{
|
||||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
}
|
}
|
||||||
|
string role = jsonData["result"]?.ToString() ?? string.Empty;
|
||||||
|
string rootDnaId = string.Empty;
|
||||||
|
if (role != "OWNER")
|
||||||
|
{
|
||||||
|
rootDnaId = RootDnaId?.ToString() ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
var data = await _context.PeriodExams.AsQueryable()
|
var data = await _context.PeriodExams.AsQueryable()
|
||||||
.Where(x => x.CheckDisability == true)
|
.Where(x => x.CheckDisability == true)
|
||||||
|
.Where(x => string.IsNullOrEmpty(rootDnaId) || x.OrganizationId == Guid.Parse(rootDnaId))
|
||||||
.Include(x => x.ImportFile)
|
.Include(x => x.ImportFile)
|
||||||
.Include(x => x.Disables)
|
.Include(x => x.Disables)
|
||||||
.Include(x => x.ScoreImport)
|
.Include(x => x.ScoreImport)
|
||||||
|
|
@ -2178,89 +2188,176 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = await _context.Disables.AsQueryable()
|
#region old
|
||||||
|
//var data = await _context.Disables.AsQueryable()
|
||||||
|
// .Include(x => x.PeriodExam)
|
||||||
|
// .Include(x => x.Documents)
|
||||||
|
// .ThenInclude(x => x.DocumentFile)
|
||||||
|
// .Where(x => x.PeriodExam.Id == id)
|
||||||
|
// .Where(x => x.PeriodExam.CheckDisability == true)
|
||||||
|
// .Where(x => x.ExamId == examId)
|
||||||
|
// .Join(_context.DisableScores.AsQueryable()
|
||||||
|
// .Include(x => x.ScoreImport),
|
||||||
|
// rc => new { PeriodExamId = rc.PeriodExam.Id, rc.ExamId },
|
||||||
|
// sc => new { PeriodExamId = sc.ScoreImport.PeriodExamId, sc.ExamId },
|
||||||
|
// (p, sr) => new
|
||||||
|
// {
|
||||||
|
// ExamID = p.ExamId,
|
||||||
|
// ProfileID = p.CitizenId,
|
||||||
|
// p.Prefix,
|
||||||
|
// FullName = $"{p.FirstName} {p.LastName}",
|
||||||
|
// DateOfBirth = p.DateOfBirth.HasValue && p.DateOfBirth.Value != DateTime.MinValue
|
||||||
|
// ? p.DateOfBirth.Value.ToThaiShortDate()
|
||||||
|
// : "",
|
||||||
|
// Gender = p.Gendor,
|
||||||
|
// Degree = p.Educations.First().Degree,
|
||||||
|
// Major = p.Educations.First().Major,
|
||||||
|
// CertificateNo = p.Certificates.Count > 0
|
||||||
|
// ? p.Certificates.First().CertificateNo ?? ""
|
||||||
|
// : "",
|
||||||
|
// CertificateIssueDate = p.Certificates.Count > 0
|
||||||
|
// ? p.Certificates.First().IssueDate != DateTime.MinValue
|
||||||
|
// ? p.Certificates.First().IssueDate.ToThaiShortDate()
|
||||||
|
// : ""
|
||||||
|
// : "",
|
||||||
|
// ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||||
|
// ExamAttribute = sr != null && !string.IsNullOrEmpty(sr.ExamAttribute) &&
|
||||||
|
// (sr.ExamAttribute == "มีคุณสมบัติ" || sr.ExamAttribute == "ไม่มีคุณสมบัติ")
|
||||||
|
// ? sr.ExamAttribute : "",
|
||||||
|
// IsSpecial = p.Isspecial,
|
||||||
|
// Remark = p.Remark,
|
||||||
|
// University = p.Educations.First().University,
|
||||||
|
// PositionName = p.PositionName,
|
||||||
|
// PositionType = p.PositionType,
|
||||||
|
// PositionLevel = p.PositionLevel,
|
||||||
|
// ExamName = p.PeriodExam!.Name,
|
||||||
|
// ExamOrder = p.PeriodExam.Round,
|
||||||
|
// ExamYear = p.PeriodExam.Year == null ? 0 : p.PeriodExam.Year.Value.ToThaiYear(),
|
||||||
|
// Score = sr == null ? 0.0 : sr.TotalScore,
|
||||||
|
// Number = sr == null ? "" : sr.Number,
|
||||||
|
// ExamCount = _disableService.GetExamCount(p.CitizenId),
|
||||||
|
// ScoreExpire = p.PeriodExam.AnnouncementDate == null
|
||||||
|
// ? ""
|
||||||
|
// : p.PeriodExam.AnnouncementDate != DateTime.MinValue
|
||||||
|
// ? p.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate()
|
||||||
|
// : "",
|
||||||
|
// typeTest = p.typeTest,
|
||||||
|
// ScoreResult = sr == null ? null : new
|
||||||
|
// {
|
||||||
|
// ScoreAFull = sr.FullA,
|
||||||
|
// ScoreA = sr.SumA,
|
||||||
|
// ScoreBFull = sr.FullB,
|
||||||
|
// ScoreB = sr.SumB,
|
||||||
|
// ScoreAB = sr.SumAB,
|
||||||
|
// ScoreCFull = sr.FullC,
|
||||||
|
// ScoreC = sr.SumC,
|
||||||
|
// ScoreDFull = sr.FullD,
|
||||||
|
// ScoreD = sr.SumD,
|
||||||
|
// ScoreCD = sr.SumCD,
|
||||||
|
// ScoreSumFull = sr.FullScore,
|
||||||
|
// ScoreSum = sr.TotalScore,
|
||||||
|
// ExamResult = sr.ExamStatus
|
||||||
|
// },
|
||||||
|
// Attachments = p.Documents.Select(a => new
|
||||||
|
// {
|
||||||
|
// FileName = a.DocumentFile.FileName,
|
||||||
|
// DocumentId = a.DocumentFile.Id
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// .FirstOrDefaultAsync();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// 1. Query Disable (ข้อมูลผู้สอบ)
|
||||||
|
var disable = await _context.Disables.AsQueryable()
|
||||||
.Include(x => x.PeriodExam)
|
.Include(x => x.PeriodExam)
|
||||||
.Include(x => x.Documents)
|
.Include(x => x.Documents)
|
||||||
.ThenInclude(x => x.DocumentFile)
|
.ThenInclude(x => x.DocumentFile)
|
||||||
|
.Include(x => x.Educations)
|
||||||
|
.Include(x => x.Certificates)
|
||||||
|
.Where(x => x.PeriodExam != null)
|
||||||
.Where(x => x.PeriodExam.Id == id)
|
.Where(x => x.PeriodExam.Id == id)
|
||||||
.Where(x => x.PeriodExam.CheckDisability == true)
|
.Where(x => x.PeriodExam.CheckDisability == true)
|
||||||
.Where(x => x.ExamId == examId)
|
.Where(x => x.ExamId == examId)
|
||||||
.Join(_context.DisableScores.AsQueryable()
|
.FirstOrDefaultAsync();
|
||||||
.Include(x => x.ScoreImport),
|
|
||||||
rc => new { PeriodExamId = rc.PeriodExam.Id, rc.ExamId },
|
if (disable == null)
|
||||||
sc => new { PeriodExamId = sc.ScoreImport.PeriodExamId, sc.ExamId },
|
return Success();
|
||||||
(p, sr) => new
|
|
||||||
|
// 2. Query DisableScore (ข้อมูลคะแนน) — แยกต่างหาก ไม่มีก็ผ่าน
|
||||||
|
var score = await _context.DisableScores.AsQueryable()
|
||||||
|
.Include(x => x.ScoreImport)
|
||||||
|
.Where(x => x.ScoreImport != null)
|
||||||
|
.Where(x => x.ScoreImport.PeriodExamId == id)
|
||||||
|
.Where(x => x.ExamId == examId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
// 3. รวมผลลัพธ์ก่อน return
|
||||||
|
var data = new
|
||||||
{
|
{
|
||||||
ExamID = p.ExamId,
|
ExamID = disable.ExamId,
|
||||||
ProfileID = p.CitizenId,
|
ProfileID = disable.CitizenId,
|
||||||
p.Prefix,
|
disable.Prefix,
|
||||||
FullName = $"{p.FirstName} {p.LastName}",
|
FullName = $"{disable.FirstName} {disable.LastName}",
|
||||||
DateOfBirth = p.DateOfBirth.HasValue && p.DateOfBirth.Value != DateTime.MinValue
|
DateOfBirth = disable.DateOfBirth.HasValue && disable.DateOfBirth.Value != DateTime.MinValue
|
||||||
? p.DateOfBirth.Value.ToThaiShortDate()
|
? disable.DateOfBirth.Value.ToThaiShortDate()
|
||||||
: "",
|
: "",
|
||||||
Gender = p.Gendor,
|
Gender = disable.Gendor,
|
||||||
Degree = p.Educations.First().Degree,
|
Degree = disable.Educations.First().Degree,
|
||||||
Major = p.Educations.First().Major,
|
Major = disable.Educations.First().Major,
|
||||||
CertificateNo = p.Certificates.Count > 0
|
CertificateNo = disable.Certificates.Count > 0
|
||||||
? p.Certificates.First().CertificateNo ?? ""
|
? disable.Certificates.First().CertificateNo ?? ""
|
||||||
: "",
|
: "",
|
||||||
CertificateIssueDate = p.Certificates.Count > 0
|
CertificateIssueDate = disable.Certificates.Count > 0
|
||||||
? p.Certificates.First().IssueDate != DateTime.MinValue
|
? disable.Certificates.First().IssueDate != DateTime.MinValue
|
||||||
? p.Certificates.First().IssueDate.ToThaiShortDate()
|
? disable.Certificates.First().IssueDate.ToThaiShortDate()
|
||||||
: ""
|
: ""
|
||||||
: "",
|
: "",
|
||||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
ExamResult = score == null ? "" : score.ExamStatus,
|
||||||
// ExamAttribute = p.Certificates.Count > 0 ?
|
|
||||||
// _disableService.CheckValidCertificate(p.Certificates.First().IssueDate, 5)
|
|
||||||
// ? "มีคุณสมบัติ"
|
|
||||||
// : "ไม่มีคุณสมบัติ"
|
|
||||||
// : "ไม่มีคุณสมบัติ",
|
|
||||||
|
|
||||||
ExamAttribute = sr != null && !string.IsNullOrEmpty(sr.ExamAttribute) &&
|
ExamAttribute = score != null && !string.IsNullOrEmpty(score.ExamAttribute) &&
|
||||||
(sr.ExamAttribute == "มีคุณสมบัติ" || sr.ExamAttribute == "ไม่มีคุณสมบัติ")
|
(score.ExamAttribute == "มีคุณสมบัติ" || score.ExamAttribute == "ไม่มีคุณสมบัติ")
|
||||||
? sr.ExamAttribute : "",
|
? score.ExamAttribute : "",
|
||||||
|
|
||||||
IsSpecial = p.Isspecial,
|
IsSpecial = disable.Isspecial,
|
||||||
Remark = p.Remark,
|
Remark = disable.Remark,
|
||||||
University = p.Educations.First().University,
|
University = disable.Educations.First().University,
|
||||||
PositionName = p.PositionName,
|
PositionName = disable.PositionName,
|
||||||
PositionType = p.PositionType,
|
PositionType = disable.PositionType,
|
||||||
PositionLevel = p.PositionLevel,
|
PositionLevel = disable.PositionLevel,
|
||||||
ExamName = p.PeriodExam!.Name,
|
ExamName = disable.PeriodExam!.Name,
|
||||||
ExamOrder = p.PeriodExam.Round,
|
ExamOrder = disable.PeriodExam.Round,
|
||||||
ExamYear = p.PeriodExam.Year == null ? 0 : p.PeriodExam.Year.Value.ToThaiYear(),
|
ExamYear = disable.PeriodExam.Year == null ? 0 : disable.PeriodExam.Year.Value.ToThaiYear(),
|
||||||
Score = sr == null ? 0.0 : sr.TotalScore,
|
Score = score == null ? 0.0 : score.TotalScore,
|
||||||
Number = sr == null ? "" : sr.Number,
|
Number = score == null ? "" : score.Number,
|
||||||
ExamCount = _disableService.GetExamCount(p.CitizenId),
|
ExamCount = _disableService.GetExamCount(disable.CitizenId),
|
||||||
ScoreExpire = p.PeriodExam.AnnouncementDate == null
|
ScoreExpire = disable.PeriodExam.AnnouncementDate == null
|
||||||
? ""
|
? ""
|
||||||
: p.PeriodExam.AnnouncementDate != DateTime.MinValue
|
: disable.PeriodExam.AnnouncementDate != DateTime.MinValue
|
||||||
? p.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate()
|
? disable.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate()
|
||||||
: "",
|
: "",
|
||||||
typeTest = p.typeTest,
|
typeTest = disable.typeTest,
|
||||||
ScoreResult = sr == null ? null : new
|
ScoreResult = score == null ? null : new
|
||||||
{
|
{
|
||||||
ScoreAFull = sr.FullA,
|
ScoreAFull = score.FullA,
|
||||||
ScoreA = sr.SumA,
|
ScoreA = score.SumA,
|
||||||
ScoreBFull = sr.FullB,
|
ScoreBFull = score.FullB,
|
||||||
ScoreB = sr.SumB,
|
ScoreB = score.SumB,
|
||||||
ScoreAB = sr.SumAB,
|
ScoreAB = score.SumAB,
|
||||||
ScoreCFull = sr.FullC,
|
ScoreCFull = score.FullC,
|
||||||
ScoreC = sr.SumC,
|
ScoreC = score.SumC,
|
||||||
ScoreDFull = sr.FullD,
|
ScoreDFull = score.FullD,
|
||||||
ScoreD = sr.SumD,
|
ScoreD = score.SumD,
|
||||||
ScoreCD = sr.SumCD,
|
ScoreCD = score.SumCD,
|
||||||
ScoreSumFull = sr.FullScore,
|
ScoreSumFull = score.FullScore,
|
||||||
ScoreSum = sr.TotalScore,
|
ScoreSum = score.TotalScore,
|
||||||
ExamResult = sr.ExamStatus
|
ExamResult = score.ExamStatus
|
||||||
},
|
},
|
||||||
Attachments = p.Documents.Select(a => new
|
Attachments = disable.Documents.Select(a => new
|
||||||
{
|
{
|
||||||
FileName = a.DocumentFile.FileName,
|
FileName = a.DocumentFile.FileName,
|
||||||
DocumentId = a.DocumentFile.Id
|
DocumentId = a.DocumentFile.Id
|
||||||
})
|
})
|
||||||
})
|
};
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
return Success(data);
|
return Success(data);
|
||||||
}
|
}
|
||||||
|
|
@ -2451,7 +2548,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// โอนคนสรรหาไปบรรจุ
|
/// โอนคนสรรหาไปบรรจุ (คัดเลือกอื่นๆ)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสรอบสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
@ -2496,49 +2593,106 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = await _context.Disables.AsQueryable()
|
#region old
|
||||||
.Include(x => x.PeriodExam)
|
//var data = await _context.Disables.AsQueryable()
|
||||||
.Where(x => x.PeriodExam!.Id == id)
|
// .Include(x => x.PeriodExam)
|
||||||
.Where(x => x.ExamId == examId)
|
// .Where(x => x.PeriodExam!.Id == id)
|
||||||
.Join(_context.DisableScores.AsQueryable()
|
// .Where(x => x.ExamId == examId)
|
||||||
.Include(x => x.ScoreImport),
|
// .Join(_context.DisableScores.AsQueryable()
|
||||||
rc => new { rc.PeriodExam!.Id, rc.ExamId },
|
// .Include(x => x.ScoreImport),
|
||||||
sc => new { Id = sc.ScoreImport!.PeriodExamId, sc.ExamId },
|
// rc => new { rc.PeriodExam!.Id, rc.ExamId },
|
||||||
(p, sr) => new
|
// sc => new { Id = sc.ScoreImport!.PeriodExamId, sc.ExamId },
|
||||||
{
|
// (p, sr) => new
|
||||||
ExamID = p.ExamId != null ? p.ExamId.ToThaiNumber() : "",
|
// {
|
||||||
CitizenId = p.CitizenId != null ? p.CitizenId.ToThaiNumber() : "",
|
// ExamID = p.ExamId != null ? p.ExamId.ToThaiNumber() : "",
|
||||||
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
// CitizenId = p.CitizenId != null ? p.CitizenId.ToThaiNumber() : "",
|
||||||
DateOfBirth = p.DateOfBirth.HasValue && p.DateOfBirth.Value != DateTime.MinValue
|
// FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||||
? p.DateOfBirth.Value.ToThaiShortDate().ToThaiNumber()
|
// DateOfBirth = p.DateOfBirth.HasValue && p.DateOfBirth.Value != DateTime.MinValue
|
||||||
: "",
|
// ? p.DateOfBirth.Value.ToThaiShortDate().ToThaiNumber()
|
||||||
Gender = p.Gendor,
|
// : "",
|
||||||
Degree = p.Educations.First().Degree,
|
// Gender = p.Gendor,
|
||||||
Major = p.Educations.First().Major,
|
// Degree = p.Educations.First().Degree,
|
||||||
University = p.Educations.First().University,
|
// Major = p.Educations.First().Major,
|
||||||
PositionName = p.PositionName,
|
// University = p.Educations.First().University,
|
||||||
ExamName = $"{p.PeriodExam!.Name} ครั้งที่ {p.PeriodExam.Round}/{(p.PeriodExam.Year > 2500 ? p.PeriodExam.Year : (p.PeriodExam.Year + 543))}".ToThaiNumber(),
|
// PositionName = p.PositionName,
|
||||||
|
// ExamName = $"{p.PeriodExam!.Name} ครั้งที่ {p.PeriodExam.Round}/{(p.PeriodExam.Year > 2500 ? p.PeriodExam.Year : (p.PeriodExam.Year + 543))}".ToThaiNumber(),
|
||||||
|
//
|
||||||
|
// ExamCount = _disableService.GetExamCount(p.CitizenId).ToString().ToThaiNumber(),
|
||||||
|
// type = p.typeTest == "bangkok" ? "กทม." : p.typeTest == "ocsc" ? "ก.พ." : "",
|
||||||
|
// FA = sr.FullA != null ? sr.FullA.ToString().ToThaiNumber() : "",
|
||||||
|
// SA = sr.SumA != null ? sr.SumA.ToString().ToThaiNumber() : "",
|
||||||
|
// FC = sr.FullC != null ? sr.FullC.ToString().ToThaiNumber() : "",
|
||||||
|
// SC = sr.SumC != null ? sr.SumC.ToString().ToThaiNumber() : "",
|
||||||
|
// FD = sr.FullD != null ? sr.FullD.ToString().ToThaiNumber() : "",
|
||||||
|
// SD = sr.SumD != null ? sr.SumD.ToString().ToThaiNumber() : "",
|
||||||
|
// F = sr.FullScore != null ? sr.FullScore.ToString().ToThaiNumber() : "",
|
||||||
|
// T = sr.TotalScore != null ? sr.TotalScore.ToString().ToThaiNumber() : "",
|
||||||
|
// Result = sr.ExamStatus,
|
||||||
|
// Number = sr.Number != null ? sr.Number.ToString().ToThaiNumber() : "",
|
||||||
|
// Expire = p.PeriodExam.AnnouncementDate == null
|
||||||
|
// ? ""
|
||||||
|
// : p.PeriodExam.AnnouncementDate != DateTime.MinValue
|
||||||
|
// ? p.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate().ToString().ToThaiNumber()
|
||||||
|
// : "",
|
||||||
|
// })
|
||||||
|
// .FirstOrDefaultAsync();
|
||||||
|
#endregion
|
||||||
|
|
||||||
ExamCount = _disableService.GetExamCount(p.CitizenId).ToString().ToThaiNumber(),
|
// 1. Query Disable (ข้อมูลผู้สอบ)
|
||||||
type = p.typeTest == "bangkok" ? "กทม." : p.typeTest == "ocsc" ? "ก.พ." : "",
|
var disable = await _context.Disables.AsQueryable()
|
||||||
FA = sr.FullA != null ? sr.FullA.ToString().ToThaiNumber() : "",
|
.Include(x => x.PeriodExam)
|
||||||
SA = sr.SumA != null ? sr.SumA.ToString().ToThaiNumber() : "",
|
.Include(x => x.Educations)
|
||||||
FC = sr.FullC != null ? sr.FullC.ToString().ToThaiNumber() : "",
|
.Where(x => x.PeriodExam != null)
|
||||||
SC = sr.SumC != null ? sr.SumC.ToString().ToThaiNumber() : "",
|
.Where(x => x.PeriodExam.Id == id)
|
||||||
FD = sr.FullD != null ? sr.FullD.ToString().ToThaiNumber() : "",
|
.Where(x => x.ExamId == examId)
|
||||||
SD = sr.SumD != null ? sr.SumD.ToString().ToThaiNumber() : "",
|
|
||||||
F = sr.FullScore != null ? sr.FullScore.ToString().ToThaiNumber() : "",
|
|
||||||
T = sr.TotalScore != null ? sr.TotalScore.ToString().ToThaiNumber() : "",
|
|
||||||
Result = sr.ExamStatus,
|
|
||||||
Number = sr.Number != null ? sr.Number.ToString().ToThaiNumber() : "",
|
|
||||||
Expire = p.PeriodExam.AnnouncementDate == null
|
|
||||||
? ""
|
|
||||||
: p.PeriodExam.AnnouncementDate != DateTime.MinValue
|
|
||||||
? p.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate().ToString().ToThaiNumber()
|
|
||||||
: "",
|
|
||||||
})
|
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
if (disable == null)
|
||||||
|
return Success();
|
||||||
|
|
||||||
|
// 2. Query DisableScore (ข้อมูลคะแนน) — แยกต่างหาก ไม่มีก็ผ่าน
|
||||||
|
var score = await _context.DisableScores.AsQueryable()
|
||||||
|
.Include(x => x.ScoreImport)
|
||||||
|
.Where(x => x.ScoreImport != null)
|
||||||
|
.Where(x => x.ScoreImport.PeriodExamId == id)
|
||||||
|
.Where(x => x.ExamId == examId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
// 3. รวมผลลัพธ์
|
||||||
|
var data = new
|
||||||
|
{
|
||||||
|
ExamID = disable.ExamId != null ? disable.ExamId.ToThaiNumber() : "",
|
||||||
|
CitizenId = disable.CitizenId != null ? disable.CitizenId.ToThaiNumber() : "",
|
||||||
|
FullName = $"{disable.Prefix}{disable.FirstName} {disable.LastName}",
|
||||||
|
DateOfBirth = disable.DateOfBirth.HasValue && disable.DateOfBirth.Value != DateTime.MinValue
|
||||||
|
? disable.DateOfBirth.Value.ToThaiShortDate().ToThaiNumber()
|
||||||
|
: "",
|
||||||
|
Gender = disable.Gendor,
|
||||||
|
Degree = disable.Educations.First().Degree,
|
||||||
|
Major = disable.Educations.First().Major,
|
||||||
|
University = disable.Educations.First().University,
|
||||||
|
PositionName = disable.PositionName,
|
||||||
|
ExamName = $"{disable.PeriodExam!.Name} ครั้งที่ {disable.PeriodExam.Round}/{(disable.PeriodExam.Year > 2500 ? disable.PeriodExam.Year : (disable.PeriodExam.Year + 543))}".ToThaiNumber(),
|
||||||
|
|
||||||
|
ExamCount = _disableService.GetExamCount(disable.CitizenId!).ToString().ToThaiNumber(),
|
||||||
|
type = disable.typeTest == "bangkok" ? "กทม." : disable.typeTest == "ocsc" ? "ก.พ." : "",
|
||||||
|
FA = score != null ? score.FullA.ToString().ToThaiNumber() : "",
|
||||||
|
SA = score != null ? score.SumA.ToString().ToThaiNumber() : "",
|
||||||
|
FC = score != null ? score.FullC.ToString().ToThaiNumber() : "",
|
||||||
|
SC = score != null ? score.SumC.ToString().ToThaiNumber() : "",
|
||||||
|
FD = score != null ? score.FullD.ToString().ToThaiNumber() : "",
|
||||||
|
SD = score != null ? score.SumD.ToString().ToThaiNumber() : "",
|
||||||
|
F = score != null ? score.FullScore.ToString().ToThaiNumber() : "",
|
||||||
|
T = score != null ? score.TotalScore.ToString().ToThaiNumber() : "",
|
||||||
|
Result = score != null ? score.ExamStatus : "",
|
||||||
|
Number = score != null && score.Number != null ? score.Number.ToString().ToThaiNumber() : "",
|
||||||
|
Expire = disable.PeriodExam.AnnouncementDate == null
|
||||||
|
? ""
|
||||||
|
: disable.PeriodExam.AnnouncementDate != DateTime.MinValue
|
||||||
|
? disable.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate().ToString().ToThaiNumber()
|
||||||
|
: "",
|
||||||
|
};
|
||||||
|
|
||||||
var result = new
|
var result = new
|
||||||
{
|
{
|
||||||
template = "recruit-exam",
|
template = "recruit-exam",
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -952,7 +1002,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// โอนคนสรรหาไปบรรจุ
|
/// โอนคนสรรหาไปบรรจุ (สอบคัดเลือก)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="examId">รหัสรอบสมัคร</param>
|
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Nest;
|
using Nest;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
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;
|
||||||
|
|
@ -29,6 +30,49 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
|
||||||
SystemName = "recruiting";
|
SystemName = "recruiting";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// แกะ JWT token เพื่อดึง claims ต่างๆ
|
||||||
|
/// </summary>
|
||||||
|
private JwtSecurityToken? ParseToken(string token)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var tokenHandler = new JwtSecurityTokenHandler();
|
||||||
|
var jwtToken = tokenHandler.ReadJwtToken(token.Replace("Bearer ", ""));
|
||||||
|
return jwtToken;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ดึงค่า claim จาก token โดยลองชื่อหลายแบบ
|
||||||
|
/// </summary>
|
||||||
|
private string? GetClaimValue(JwtSecurityToken? token, params string[] claimNames)
|
||||||
|
{
|
||||||
|
if (token == null) return null;
|
||||||
|
|
||||||
|
foreach (var name in claimNames)
|
||||||
|
{
|
||||||
|
var claim = token.Claims.FirstOrDefault(c => c.Type == name);
|
||||||
|
if (claim != 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)
|
||||||
{
|
{
|
||||||
|
|
@ -92,28 +136,22 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
|
||||||
// เปลี่ยน stream ของ Response เพื่อให้สามารถอ่านได้
|
// เปลี่ยน stream ของ Response เพื่อให้สามารถอ่านได้
|
||||||
context.Response.Body = memoryStream;
|
context.Response.Body = memoryStream;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Extract all required data from JWT token claims
|
|
||||||
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 tokenHeader = context.Request.Headers["Authorization"].ToString();
|
||||||
|
|
||||||
var prefix = context.User?.FindFirst("prefix")?.Value;
|
// แกะ JWT token เพื่อดึง claims ต่างๆ
|
||||||
var firstName = context.User?.FindFirst("given_name")?.Value;
|
var jwtToken = ParseToken(tokenHeader);
|
||||||
var lastName = context.User?.FindFirst("family_name")?.Value;
|
|
||||||
var preferredUsername = context.User?.FindFirst("preferred_username")?.Value;
|
|
||||||
|
|
||||||
var orgRootDnaId = context.User?.FindFirst("orgRootDnaId")?.Value;
|
// ดึงข้อมูลจาก claims โดยลองชื่อหลายแบบ (camelCase, snake_case, ฯลฯ)
|
||||||
var orgChild1DnaId = context.User?.FindFirst("orgChild1DnaId")?.Value;
|
var prefix = GetClaimValue(jwtToken, "prefix", "Prefix", "PREFIX");
|
||||||
var orgChild2DnaId = context.User?.FindFirst("orgChild2DnaId")?.Value;
|
var firstName = GetClaimValue(jwtToken, "given_name", "firstname", "firstName", "FirstName", "FIRSTNAME");
|
||||||
var orgChild3DnaId = context.User?.FindFirst("orgChild3DnaId")?.Value;
|
var lastName = GetClaimValue(jwtToken, "family_name", "lastname", "lastName", "LastName", "LASTNAME");
|
||||||
var orgChild4DnaId = context.User?.FindFirst("orgChild4DnaId")?.Value;
|
var preferredUsername = GetClaimValue(jwtToken, "preferred_username", "preferred_username", "PreferredUsername");
|
||||||
|
var orgRootDnaId = GetGuidClaim(jwtToken, "orgRootDnaId", "org_root_dna_id", "OrgRootDnaId", "rootDnaId");
|
||||||
// Parse Guid values safely
|
var orgChild1DnaId = GetGuidClaim(jwtToken, "orgChild1DnaId", "org_child1_dna", "OrgChild1Dna", "child1DnaId");
|
||||||
Guid? rootDnaId = Guid.TryParse(orgRootDnaId, out var rid) ? rid : null;
|
var orgChild2DnaId = GetGuidClaim(jwtToken, "orgChild2DnaId", "org_child2_dna", "OrgChild2Dna", "child2DnaId");
|
||||||
Guid? child1DnaId = Guid.TryParse(orgChild1DnaId, out var c1) ? c1 : null;
|
var orgChild3DnaId = GetGuidClaim(jwtToken, "orgChild3DnaId", "org_child3_dna", "OrgChild3Dna", "child3DnaId");
|
||||||
Guid? child2DnaId = Guid.TryParse(orgChild2DnaId, out var c2) ? c2 : null;
|
var orgChild4DnaId = GetGuidClaim(jwtToken, "orgChild4DnaId", "org_child4_dna", "OrgChild4Dna", "child4DnaId");
|
||||||
Guid? child3DnaId = Guid.TryParse(orgChild3DnaId, out var c3) ? c3 : null;
|
|
||||||
Guid? child4DnaId = Guid.TryParse(orgChild4DnaId, out var c4) ? c4 : null;
|
|
||||||
|
|
||||||
await _next(context); // ดำเนินการต่อไปยัง Middleware อื่น ๆ
|
await _next(context); // ดำเนินการต่อไปยัง Middleware อื่น ๆ
|
||||||
|
|
||||||
|
|
@ -200,7 +238,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
|
||||||
{
|
{
|
||||||
logType = logType,
|
logType = logType,
|
||||||
ip = context.Connection.RemoteIpAddress?.ToString(),
|
ip = context.Connection.RemoteIpAddress?.ToString(),
|
||||||
rootId = rootDnaId,
|
rootId = orgRootDnaId?.ToString("D"),
|
||||||
systemName = SystemName,
|
systemName = SystemName,
|
||||||
startTimeStamp = startTime.ToString("o"),
|
startTimeStamp = startTime.ToString("o"),
|
||||||
endTimeStamp = endTime.ToString("o"),
|
endTimeStamp = endTime.ToString("o"),
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
||||||
[Required, MaxLength(150), Column(Order = 1), Comment("เขต/อำเภอ")]
|
[Required, MaxLength(150), Column(Order = 1), Comment("เขต/อำเภอ")]
|
||||||
public string name { get; set; } = string.Empty;
|
public string name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Column(Order = 2), Comment("รหัสอ้างอิงจังหวัด")]
|
||||||
|
public Guid? provinceId { get; set; } = null;
|
||||||
|
|
||||||
// [Column(Order = 2), Comment("สถานะการใช้งาน")]
|
// [Column(Order = 2), Comment("สถานะการใช้งาน")]
|
||||||
// public bool IsActive { get; set; } = true;
|
// public bool IsActive { get; set; } = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
||||||
[MaxLength(10), Column(Order = 2), Comment("รหัสไปรษณีย์")]
|
[MaxLength(10), Column(Order = 2), Comment("รหัสไปรษณีย์")]
|
||||||
public string? zipCode { get; set; } = null;
|
public string? zipCode { get; set; } = null;
|
||||||
|
|
||||||
|
[Column(Order = 3), Comment("รหัสอ้างอิงอำเภอ")]
|
||||||
|
public Guid? districtId { get; set; } = null;
|
||||||
|
|
||||||
// [Column(Order = 3), Comment("สถานะการใช้งาน")]
|
// [Column(Order = 3), Comment("สถานะการใช้งาน")]
|
||||||
// public bool IsActive { get; set; } = true;
|
// public bool IsActive { get; set; } = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
var req = await client.GetAsync(apiPath);
|
var req = await client.GetAsync(apiPath);
|
||||||
var res = await req.Content.ReadAsStringAsync();
|
var res = await req.Content.ReadAsStringAsync();
|
||||||
return res;
|
return res;
|
||||||
|
|
|
||||||
|
|
@ -82,5 +82,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Request.Disables
|
||||||
/// วันที่ประกาศผลสอบ
|
/// วันที่ประกาศผลสอบ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime AnnouncementDate { get; set; }
|
public DateTime AnnouncementDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// รหัส DNA หน่วยงาน
|
||||||
|
/// </summary>
|
||||||
|
public Guid? rootDnaId { 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)
|
||||||
|
|
@ -2651,7 +2663,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token?.Replace("Bearer ", ""));
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token?.Replace("Bearer ", ""));
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
var _res = await client.PostAsJsonAsync(apiUrl, new
|
var _res = await client.PostAsJsonAsync(apiUrl, new
|
||||||
{
|
{
|
||||||
citizenId
|
citizenId
|
||||||
|
|
|
||||||
|
|
@ -1232,30 +1232,57 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
if (candidate.Status == "checkSeat")
|
if (candidate.Status == "checkSeat")
|
||||||
{
|
{
|
||||||
candidate.SeatNumber = item.SeatNumber;
|
candidate.SeatNumber = item.SeatNumber;
|
||||||
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
// var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
||||||
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: ติดตามประกาศทาง Website";
|
// var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: ติดตามประกาศทาง Website";
|
||||||
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
// try
|
||||||
|
// {
|
||||||
|
// if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"[MailError] ส่ง email ไม่สำเร็จ: {candidate.Email} | {ex.Message}");
|
||||||
|
// if (ex.InnerException != null)
|
||||||
|
// Console.WriteLine($"[MailError] Inner: {ex.InnerException.Message}");
|
||||||
|
// }
|
||||||
candidate.Status = "checkPoint";
|
candidate.Status = "checkPoint";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (candidate.Status != "waiver")
|
// if (candidate.Status != "waiver")
|
||||||
{
|
// {
|
||||||
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
// var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
||||||
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
|
// var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
|
||||||
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
// try
|
||||||
}
|
// {
|
||||||
|
// if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"[MailError] ส่ง email ไม่สำเร็จ: {candidate.Email} | {ex.Message}");
|
||||||
|
// if (ex.InnerException != null)
|
||||||
|
// Console.WriteLine($"[MailError] Inner: {ex.InnerException.Message}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
candidate.Status = "waiver";
|
candidate.Status = "waiver";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (candidate.Status != "waiver")
|
// if (candidate.Status != "waiver")
|
||||||
{
|
// {
|
||||||
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
// var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
||||||
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
|
// var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
|
||||||
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
// try
|
||||||
}
|
// {
|
||||||
|
// if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"[MailError] ส่ง email ไม่สำเร็จ: {candidate.Email} | {ex.Message}");
|
||||||
|
// if (ex.InnerException != null)
|
||||||
|
// Console.WriteLine($"[MailError] Inner: {ex.InnerException.Message}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
candidate.Status = "waiver";
|
candidate.Status = "waiver";
|
||||||
}
|
}
|
||||||
periodExam.SetSeat = true;
|
periodExam.SetSeat = true;
|
||||||
|
|
@ -1309,30 +1336,30 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
candidate.Pass = item.Pass;
|
candidate.Pass = item.Pass;
|
||||||
candidate.ExamReason = item.ExamReason;
|
candidate.ExamReason = item.ExamReason;
|
||||||
candidate.Number = item.Number;
|
candidate.Number = item.Number;
|
||||||
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
// var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
||||||
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สอบคัดเลือกสำเร็จ <br />" + "ผลการสอบของท่าน คือ " + candidate.Pass;
|
// var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สอบคัดเลือกสำเร็จ <br />" + "ผลการสอบของท่าน คือ " + candidate.Pass;
|
||||||
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
// if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
||||||
candidate.Status = "done";
|
candidate.Status = "done";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (candidate.Status != "waiver")
|
// if (candidate.Status != "waiver")
|
||||||
{
|
// {
|
||||||
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
// var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
||||||
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
|
// var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
|
||||||
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
// if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
||||||
}
|
// }
|
||||||
// candidate.Status = "waiver";
|
// candidate.Status = "waiver";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (candidate.Status != "waiver")
|
// if (candidate.Status != "waiver")
|
||||||
{
|
// {
|
||||||
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
// var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
|
||||||
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
|
// var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
|
||||||
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
// if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
||||||
}
|
// }
|
||||||
// candidate.Status = "waiver";
|
// candidate.Status = "waiver";
|
||||||
}
|
}
|
||||||
periodExam.SetSeat = true;
|
periodExam.SetSeat = true;
|
||||||
|
|
@ -1625,6 +1652,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()
|
||||||
|
|
@ -2860,7 +2982,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||||
var _res = await client.SendAsync(_req);
|
var _res = await client.SendAsync(_req);
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
|
@ -3055,7 +3177,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
throw new Exception(GlobalMessages.ExamNotFound);
|
throw new Exception(GlobalMessages.ExamNotFound);
|
||||||
|
|
||||||
var _placement = await _contextMetadata.Placements.AsQueryable()
|
var _placement = await _contextMetadata.Placements.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.PlacementType.Name == "คัดเลือกคนพิการ" && x.RefId == periodExam.Id);
|
.FirstOrDefaultAsync(x => x.PlacementType.Name == "คัดเลือกอื่นๆ" && x.RefId == periodExam.Id);
|
||||||
if (_placement != null)
|
if (_placement != null)
|
||||||
throw new Exception("รอบการสอบนี้ได้ทำการบรรจุไปแล้ว");
|
throw new Exception("รอบการสอบนี้ได้ทำการบรรจุไปแล้ว");
|
||||||
|
|
||||||
|
|
@ -3073,7 +3195,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
Round = periodExam.Round?.ToString() ?? "",
|
Round = periodExam.Round?.ToString() ?? "",
|
||||||
Year = (int)(periodExam.Year ?? 0),
|
Year = (int)(periodExam.Year ?? 0),
|
||||||
Number = await _context.Disables.AsQueryable().Where(x => x.PeriodExam == periodExam).CountAsync(),
|
Number = await _context.Disables.AsQueryable().Where(x => x.PeriodExam == periodExam).CountAsync(),
|
||||||
PlacementType = placementTypesCache.FirstOrDefault(x => x.Name.Trim().ToUpper().Contains("คัดเลือกคนพิการ")) ?? placementTypesCache.First(),
|
PlacementType = placementTypesCache.FirstOrDefault(x => x.Name.Trim().ToUpper().Contains("คัดเลือกอื่นๆ")) ?? placementTypesCache.First(),
|
||||||
StartDate = accountStartDate,
|
StartDate = accountStartDate,
|
||||||
EndDate = accountStartDate.AddYears(2).AddDays(-1),
|
EndDate = accountStartDate.AddYears(2).AddDays(-1),
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
|
|
@ -3197,6 +3319,28 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
positionNameWithoutLevel = positionNameWithoutLevel.Replace(posLevelName, "").Trim();
|
positionNameWithoutLevel = positionNameWithoutLevel.Replace(posLevelName, "").Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lookup province, district, subDistrict IDs with parent filtering
|
||||||
|
var registProvinceId = provincesCache.FirstOrDefault(x => x.name == firstAddress?.Province)?.Id;
|
||||||
|
var registDistrictId = districtsCache.FirstOrDefault(x => x.name == firstAddress?.Amphur && x.provinceId == registProvinceId)?.Id;
|
||||||
|
var registSubDistrictId = subDistrictsCache.FirstOrDefault(x => x.name == firstAddress?.District && x.districtId == registDistrictId)?.Id;
|
||||||
|
var currentProvinceId = provincesCache.FirstOrDefault(x => x.name == firstAddress?.Province1)?.Id;
|
||||||
|
var currentDistrictId = districtsCache.FirstOrDefault(x => x.name == firstAddress?.Amphur1 && x.provinceId == currentProvinceId)?.Id;
|
||||||
|
var currentSubDistrictId = subDistrictsCache.FirstOrDefault(x => x.name == firstAddress?.District1 && x.districtId == currentDistrictId)?.Id;
|
||||||
|
|
||||||
|
// log warning when address lookup fails
|
||||||
|
if (registProvinceId == null && !string.IsNullOrWhiteSpace(firstAddress?.Province))
|
||||||
|
Console.WriteLine($"[WARN] Regist province not found: {firstAddress?.Province}");
|
||||||
|
if (registDistrictId == null && !string.IsNullOrWhiteSpace(firstAddress?.Amphur))
|
||||||
|
Console.WriteLine($"[WARN] Regist district not found: {firstAddress?.Amphur}, Province: {firstAddress?.Province}");
|
||||||
|
if (registSubDistrictId == null && !string.IsNullOrWhiteSpace(firstAddress?.District))
|
||||||
|
Console.WriteLine($"[WARN] Regist subdistrict not found: {firstAddress?.District}, District: {firstAddress?.Amphur}");
|
||||||
|
if (currentProvinceId == null && !string.IsNullOrWhiteSpace(firstAddress?.Province1))
|
||||||
|
Console.WriteLine($"[WARN] Current province not found: {firstAddress?.Province1}");
|
||||||
|
if (currentDistrictId == null && !string.IsNullOrWhiteSpace(firstAddress?.Amphur1))
|
||||||
|
Console.WriteLine($"[WARN] Current district not found: {firstAddress?.Amphur1}, Province: {firstAddress?.Province1}");
|
||||||
|
if (currentSubDistrictId == null && !string.IsNullOrWhiteSpace(firstAddress?.District1))
|
||||||
|
Console.WriteLine($"[WARN] Current subdistrict not found: {firstAddress?.District1}, District: {firstAddress?.Amphur1}");
|
||||||
|
|
||||||
var placementProfile = new PlacementProfile
|
var placementProfile = new PlacementProfile
|
||||||
{
|
{
|
||||||
Placement = placement,
|
Placement = placement,
|
||||||
|
|
@ -3218,15 +3362,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
Telephone = firstAddress?.Telephone ?? "",
|
Telephone = firstAddress?.Telephone ?? "",
|
||||||
MobilePhone = firstAddress?.Mobile ?? "",
|
MobilePhone = firstAddress?.Mobile ?? "",
|
||||||
RegistAddress = registAddress,
|
RegistAddress = registAddress,
|
||||||
RegistProvinceId = provincesCache.FirstOrDefault(x => x.name == firstAddress?.Province)?.Id,
|
RegistProvinceId = registProvinceId,
|
||||||
RegistDistrictId = districtsCache.FirstOrDefault(x => x.name == firstAddress?.District)?.Id,
|
RegistDistrictId = registDistrictId,
|
||||||
RegistSubDistrictId = subDistrictsCache.FirstOrDefault(x => x.name == firstAddress?.Soi)?.Id,
|
RegistSubDistrictId = registSubDistrictId,
|
||||||
RegistZipCode = firstAddress?.ZipCode ?? "",
|
RegistZipCode = firstAddress?.ZipCode ?? "",
|
||||||
RegistSame = false,
|
RegistSame = false,
|
||||||
CurrentAddress = currentAddress,
|
CurrentAddress = currentAddress,
|
||||||
CurrentProvinceId = provincesCache.FirstOrDefault(x => x.name == firstAddress?.Province1)?.Id,
|
CurrentProvinceId = currentProvinceId,
|
||||||
CurrentDistrictId = districtsCache.FirstOrDefault(x => x.name == firstAddress?.District1)?.Id,
|
CurrentDistrictId = currentDistrictId,
|
||||||
CurrentSubDistrictId = subDistrictsCache.FirstOrDefault(x => x.name == firstAddress?.Soi1)?.Id,
|
CurrentSubDistrictId = currentSubDistrictId,
|
||||||
CurrentZipCode = firstAddress?.ZipCode1,
|
CurrentZipCode = firstAddress?.ZipCode1,
|
||||||
Marry = candidate.Marry?.Contains("สมรส") ?? false,
|
Marry = candidate.Marry?.Contains("สมรส") ?? false,
|
||||||
OccupationPositionType = "other",
|
OccupationPositionType = "other",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue