diff --git a/.gitignore b/.gitignore index a479b56..3b4a194 100644 --- a/.gitignore +++ b/.gitignore @@ -475,3 +475,5 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk + +.claude \ No newline at end of file diff --git a/Controllers/DisableController.cs b/Controllers/DisableController.cs index 446c397..cb6804a 100644 --- a/Controllers/DisableController.cs +++ b/Controllers/DisableController.cs @@ -86,6 +86,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.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"]; #endregion @@ -487,6 +488,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers Note = req.Note, AnnouncementDate = req.AnnouncementDate, CheckDisability = true, + OrganizationId = req.rootDnaId, CreatedAt = DateTime.Now, CreatedUserId = UserId ?? "", CreatedFullName = FullName ?? "System Administrator", @@ -499,7 +501,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers using (var client = new HttpClient()) { 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 _res = await client.SendAsync(_req); var _result = await _res.Content.ReadAsStringAsync(); @@ -668,8 +670,16 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers { 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() .Where(x => x.CheckDisability == true) + .Where(x => string.IsNullOrEmpty(rootDnaId) || x.OrganizationId == Guid.Parse(rootDnaId)) .Include(x => x.ImportFile) .Include(x => x.Disables) .Include(x => x.ScoreImport) @@ -1365,7 +1375,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers District = workSheet?.Cells[row, 54]?.GetValue() ?? "", Amphur = workSheet?.Cells[row, 55]?.GetValue() ?? "", Province = workSheet?.Cells[row, 56]?.GetValue() ?? "", - ZipCode = workSheet?.Cells[row, 57]?.GetValue() ?? "", + ZipCode = (workSheet?.Cells[row, 57]?.GetValue() ?? "").Trim(), Telephone = workSheet?.Cells[row, 58]?.GetValue() ?? "", Mobile = "", Address1 = $"{(workSheet?.Cells[row, 61]?.GetValue() ?? "")} {(workSheet?.Cells[row, 62]?.GetValue() ?? "")}", @@ -1375,7 +1385,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers District1 = workSheet?.Cells[row, 66]?.GetValue() ?? "", Amphur1 = workSheet?.Cells[row, 67]?.GetValue() ?? "", Province1 = workSheet?.Cells[row, 68]?.GetValue() ?? "", - ZipCode1 = workSheet?.Cells[row, 69]?.GetValue() ?? "", + ZipCode1 = (workSheet?.Cells[row, 69]?.GetValue() ?? "").Trim(), CreatedAt = DateTime.Now, CreatedUserId = UserId ?? "", CreatedFullName = FullName ?? "System Administrator", @@ -1399,7 +1409,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers TermBranch = workSheet?.Cells[row, 113]?.GetValue() ?? "", TellerId = workSheet?.Cells[row, 114]?.GetValue() ?? "", CreditDebit = workSheet?.Cells[row, 115]?.GetValue() ?? "", - PaymentType = workSheet?.Cells[row, 116]?.GetValue(), + PaymentType = workSheet?.Cells[row, 116]?.GetValue() ?? "", ChequeNo = workSheet?.Cells[row, 117]?.GetValue() ?? "", Amount = (decimal)workSheet?.Cells[row, 118]?.GetValue(), ChqueBankCode = workSheet?.Cells[row, 119]?.GetValue() ?? "", @@ -1604,11 +1614,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers r.ExamId = workSheet?.Cells[row, 2]?.GetValue(); - //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 ทีละรอบ if (!string.IsNullOrEmpty(r.ExamId) && recruitsDict.TryGetValue(r.ExamId, out var recruit)) { @@ -1633,26 +1638,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers r.FullScore = 300; r.TotalScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 13]?.GetValue()) ? 0.00 : Math.Round(workSheet.Cells[row, 13].GetValue(), 2); - if (workSheet?.Cells[row, 7]?.GetValue() == "ขาดสอบ") - { - r.ExamStatus = "ขส."; - } - else if (workSheet?.Cells[row, 14]?.GetValue() == "ได้") - { - r.ExamStatus = "ผ่าน"; - } - else if (workSheet?.Cells[row, 14]?.GetValue() == "ตก") - { - r.ExamStatus = "ไม่ผ่าน"; - } - else - { - r.ExamStatus = "-"; - } + var examStatusCol7 = workSheet?.Cells[row, 7]?.GetValue()?.Trim(); + var examStatusCol14 = workSheet?.Cells[row, 14]?.GetValue()?.Trim(); + r.ExamStatus = + examStatusCol7 == "ขาดสอบ" ? "ขส." : + examStatusCol14 == "ได้" ? "ผ่าน" : + examStatusCol14 == "ตก" ? "ไม่ผ่าน" : "-"; r.RemarkScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 15]?.GetValue()) ? string.Empty : workSheet?.Cells[row, 15]?.GetValue(); - r.ExamAttribute = (workSheet?.Cells[row, 16]?.GetValue()?.Trim() == "ผ่าน") ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ"; + var examAttr = workSheet?.Cells[row, 16]?.GetValue()?.Trim(); + r.ExamAttribute = + examAttr == "ผ่าน" ? "มีคุณสมบัติ" : + examAttr == "ไม่ผ่าน" ? "ไม่มีคุณสมบัติ" : ""; r.Major = workSheet.Name; @@ -2098,11 +2096,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers // ? _disableService.CheckValidCertificate(x.disable.Certificates.First().IssueDate, 5) // ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ" // : "ไม่มีคุณสมบัติ", - examAttribute = x.score == null - ? "ไม่มีคุณสมบัติ" - : string.IsNullOrEmpty(x.score.ExamAttribute) - ? "ไม่มีคุณสมบัติ" - : x.score.ExamAttribute, + + examAttribute = x.score != null && !string.IsNullOrEmpty(x.score.ExamAttribute) && + (x.score.ExamAttribute == "มีคุณสมบัติ" || x.score.ExamAttribute == "ไม่มีคุณสมบัติ") + ? x.score.ExamAttribute : "", + remark = x.disable.Remark, isSpecial = x.disable.Isspecial == "Y" ? x.disable.Isspecial : "", applyDate = x.disable.ApplyDate.HasValue && x.disable.ApplyDate.Value != DateTime.MinValue @@ -2190,90 +2188,177 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers { 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.Documents) .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.CheckDisability == true) .Where(x => x.ExamId == examId) - .Join(_context.DisableScores.AsQueryable() - .Include(x => x.ScoreImport), - rc => new { /*rc.PeriodExam.Year,*/ rc.ExamId }, - sc => new { /*sc.ScoreImport.Year,*/ 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 = p.Certificates.Count > 0 ? - // _disableService.CheckValidCertificate(p.Certificates.First().IssueDate, 5) - // ? "มีคุณสมบัติ" - // : "ไม่มีคุณสมบัติ" - // : "ไม่มีคุณสมบัติ", - ExamAttribute = sr == null - ? "ไม่มีคุณสมบัติ" - : string.IsNullOrEmpty(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(); + 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. รวมผลลัพธ์ก่อน return + var data = new + { + ExamID = disable.ExamId, + ProfileID = disable.CitizenId, + disable.Prefix, + FullName = $"{disable.FirstName} {disable.LastName}", + DateOfBirth = disable.DateOfBirth.HasValue && disable.DateOfBirth.Value != DateTime.MinValue + ? disable.DateOfBirth.Value.ToThaiShortDate() + : "", + Gender = disable.Gendor, + Degree = disable.Educations.First().Degree, + Major = disable.Educations.First().Major, + CertificateNo = disable.Certificates.Count > 0 + ? disable.Certificates.First().CertificateNo ?? "" + : "", + CertificateIssueDate = disable.Certificates.Count > 0 + ? disable.Certificates.First().IssueDate != DateTime.MinValue + ? disable.Certificates.First().IssueDate.ToThaiShortDate() + : "" + : "", + ExamResult = score == null ? "" : score.ExamStatus, + + ExamAttribute = score != null && !string.IsNullOrEmpty(score.ExamAttribute) && + (score.ExamAttribute == "มีคุณสมบัติ" || score.ExamAttribute == "ไม่มีคุณสมบัติ") + ? score.ExamAttribute : "", + + IsSpecial = disable.Isspecial, + Remark = disable.Remark, + University = disable.Educations.First().University, + PositionName = disable.PositionName, + PositionType = disable.PositionType, + PositionLevel = disable.PositionLevel, + ExamName = disable.PeriodExam!.Name, + ExamOrder = disable.PeriodExam.Round, + ExamYear = disable.PeriodExam.Year == null ? 0 : disable.PeriodExam.Year.Value.ToThaiYear(), + Score = score == null ? 0.0 : score.TotalScore, + Number = score == null ? "" : score.Number, + ExamCount = _disableService.GetExamCount(disable.CitizenId), + ScoreExpire = disable.PeriodExam.AnnouncementDate == null + ? "" + : disable.PeriodExam.AnnouncementDate != DateTime.MinValue + ? disable.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate() + : "", + typeTest = disable.typeTest, + ScoreResult = score == null ? null : new + { + ScoreAFull = score.FullA, + ScoreA = score.SumA, + ScoreBFull = score.FullB, + ScoreB = score.SumB, + ScoreAB = score.SumAB, + ScoreCFull = score.FullC, + ScoreC = score.SumC, + ScoreDFull = score.FullD, + ScoreD = score.SumD, + ScoreCD = score.SumCD, + ScoreSumFull = score.FullScore, + ScoreSum = score.TotalScore, + ExamResult = score.ExamStatus + }, + Attachments = disable.Documents.Select(a => new + { + FileName = a.DocumentFile.FileName, + DocumentId = a.DocumentFile.Id + }) + }; + return Success(data); } catch (Exception ex) @@ -2463,7 +2548,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers } /// - /// โอนคนสรรหาไปบรรจุ + /// โอนคนสรรหาไปบรรจุ (คัดเลือกอื่นๆ) /// /// รหัสรอบสมัคร /// @@ -2508,49 +2593,106 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers { try { - var data = await _context.Disables.AsQueryable() - .Include(x => x.PeriodExam) - .Where(x => x.PeriodExam!.Id == id) - .Where(x => x.ExamId == examId) - .Join(_context.DisableScores.AsQueryable() - .Include(x => x.ScoreImport), - rc => new { rc.PeriodExam!.Id, rc.ExamId }, - 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() : "", - FullName = $"{p.Prefix}{p.FirstName} {p.LastName}", - DateOfBirth = p.DateOfBirth.HasValue && p.DateOfBirth.Value != DateTime.MinValue - ? p.DateOfBirth.Value.ToThaiShortDate().ToThaiNumber() - : "", - Gender = p.Gendor, - Degree = p.Educations.First().Degree, - Major = p.Educations.First().Major, - University = p.Educations.First().University, - PositionName = p.PositionName, - ExamName = $"{p.PeriodExam!.Name} ครั้งที่ {p.PeriodExam.Round}/{(p.PeriodExam.Year > 2500 ? p.PeriodExam.Year : (p.PeriodExam.Year + 543))}".ToThaiNumber(), + #region old + //var data = await _context.Disables.AsQueryable() + // .Include(x => x.PeriodExam) + // .Where(x => x.PeriodExam!.Id == id) + // .Where(x => x.ExamId == examId) + // .Join(_context.DisableScores.AsQueryable() + // .Include(x => x.ScoreImport), + // rc => new { rc.PeriodExam!.Id, rc.ExamId }, + // 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() : "", + // FullName = $"{p.Prefix}{p.FirstName} {p.LastName}", + // DateOfBirth = p.DateOfBirth.HasValue && p.DateOfBirth.Value != DateTime.MinValue + // ? p.DateOfBirth.Value.ToThaiShortDate().ToThaiNumber() + // : "", + // Gender = p.Gendor, + // Degree = p.Educations.First().Degree, + // Major = p.Educations.First().Major, + // University = p.Educations.First().University, + // 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(), - 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() - : "", - }) + // 1. Query Disable (ข้อมูลผู้สอบ) + var disable = await _context.Disables.AsQueryable() + .Include(x => x.PeriodExam) + .Include(x => x.Educations) + .Where(x => x.PeriodExam != null) + .Where(x => x.PeriodExam.Id == id) + .Where(x => x.ExamId == examId) .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 { template = "recruit-exam", diff --git a/Controllers/PeriodExamController.cs b/Controllers/PeriodExamController.cs index b52b0f6..db6edb9 100644 --- a/Controllers/PeriodExamController.cs +++ b/Controllers/PeriodExamController.cs @@ -749,6 +749,56 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers } } + /// + /// ดาวน์โหลดรายชื่อผู้มีสิทธิ์สอบ + /// + /// รหัสรอบสมัคร + /// + /// เมื่อทำการอ่านโหลดผู้สมัครสอบสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("download/candidate-exam/{examId:length(36)}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> DownloadCandidateExamAsync(string examId) + { + try + { + var data = await _periodExamService.DownloadCandidateExamAsync(examId); + return Success(data); + } + catch (Exception ex) + { + return Error(ex); + } + } + + /// + /// ดาวน์โหลดรายชื่อผู้สอบคัดเลือกได้ + /// + /// รหัสรอบสมัคร + /// + /// เมื่อทำการอ่านโหลดผู้สมัครสอบสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("download/pass-exam/{examId:length(36)}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> DownloadPassExamAsync(string examId) + { + try + { + var data = await _periodExamService.DownloadPassExamAsync(examId); + return Success(data); + } + catch (Exception ex) + { + return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน"); + } + } + /// /// โหลดผู้สมัครสอบ /// @@ -952,7 +1002,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers } /// - /// โอนคนสรรหาไปบรรจุ + /// โอนคนสรรหาไปบรรจุ (สอบคัดเลือก) /// /// รหัสรอบสมัคร /// diff --git a/Core/RequestLoggingMiddleware.cs b/Core/RequestLoggingMiddleware.cs index 402c77e..a39a4d9 100644 --- a/Core/RequestLoggingMiddleware.cs +++ b/Core/RequestLoggingMiddleware.cs @@ -1,9 +1,8 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Nest; -using Newtonsoft.Json; using System.Diagnostics; -using System.Net.Http.Headers; +using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using System.Text.Encodings.Web; using System.Text.Json; @@ -19,7 +18,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Core private string Uri = ""; private string IndexFormat = ""; private string SystemName = ""; - private string APIKey = ""; public RequestLoggingMiddleware(RequestDelegate next, IConfiguration configuration) { @@ -32,65 +30,48 @@ namespace BMA.EHR.Recurit.Exam.Service.Core SystemName = "recruiting"; } - protected async Task GetExternalAPIAsync(string apiPath, string accessToken, string apiKey) + /// + /// แกะ JWT token เพื่อดึง claims ต่างๆ + /// + private JwtSecurityToken? ParseToken(string token) { try { - using (var client = new HttpClient()) - { - // Set timeout to 30 seconds instead of default 100 seconds - 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; - } + var tokenHandler = new JwtSecurityTokenHandler(); + var jwtToken = tokenHandler.ReadJwtToken(token.Replace("Bearer ", "")); + return jwtToken; } - catch (TaskCanceledException) + catch { - // Log timeout but don't throw - return empty result instead - 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; + return null; } } - public async Task GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken) + /// + /// ดึงค่า claim จาก token โดยลองชื่อหลายแบบ + /// + private string? GetClaimValue(JwtSecurityToken? token, params string[] claimNames) { - try - { - //var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak/{keycloakId}"; - var apiPath = $"{_configuration["API"]}/org/dotnet/user-logs/{keycloakId}"; - var apiKey = _configuration["API_KEY"] ?? ""; + if (token == null) return null; - var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey); - if (!string.IsNullOrEmpty(apiResult)) - { - var raw = JsonConvert.DeserializeObject(apiResult); - if (raw != null) - return raw.Result; - } - - return null; - } - catch (Exception ex) + foreach (var name in claimNames) { - // Log exception but don't throw - return null instead - Console.WriteLine($"GetProfileByKeycloakIdAsync failed for {keycloakId}: {ex.Message}"); - return null; + var claim = token.Claims.FirstOrDefault(c => c.Type == name); + if (claim != null) + return claim.Value; } + return null; + } + + /// + /// ดึงค่า Guid claim จาก token + /// + 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) @@ -155,19 +136,22 @@ namespace BMA.EHR.Recurit.Exam.Service.Core // เปลี่ยน stream ของ Response เพื่อให้สามารถอ่านได้ context.Response.Body = memoryStream; - - 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); - var _userFullname = string.Empty; - var _userName = string.Empty; - if (keycloakId != "00000000-0000-0000-0000-000000000000" && pf == null) - { - _userFullname = context.User?.FindFirst("name")?.Value; - _userName = context.User?.FindFirst("preferred_username")?.Value; - } + // แกะ JWT token เพื่อดึง claims ต่างๆ + var jwtToken = ParseToken(tokenHeader); + + // ดึงข้อมูลจาก claims โดยลองชื่อหลายแบบ (camelCase, snake_case, ฯลฯ) + var prefix = GetClaimValue(jwtToken, "prefix", "Prefix", "PREFIX"); + var firstName = GetClaimValue(jwtToken, "given_name", "firstname", "firstName", "FirstName", "FIRSTNAME"); + 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 อื่น ๆ @@ -254,8 +238,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Core { logType = logType, ip = context.Connection.RemoteIpAddress?.ToString(), - //rootId = pf == null ? null : pf.RootId, - rootId = pf == null ? null : pf.RootDnaId, + rootId = orgRootDnaId?.ToString("D"), systemName = SystemName, startTimeStamp = startTime.ToString("o"), endTimeStamp = endTime.ToString("o"), @@ -269,8 +252,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Core output = responseBodyJson, userId = keycloakId, - userName = pf != null ? $"{pf?.Prefix ?? ""}{pf?.FirstName ?? ""} {pf?.LastName ?? ""}" : _userFullname ?? "", - user = pf != null ? pf?.CitizenId ?? "" : _userName ?? "" + userName = $"{prefix ?? ""}{firstName ?? ""} {lastName ?? ""}".Trim(), + user = preferredUsername ?? "" }; @@ -295,47 +278,4 @@ namespace BMA.EHR.Recurit.Exam.Service.Core 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; } - } } diff --git a/Data/Migrations/ApplicationDbContextModelSnapshot.cs b/Data/Migrations/ApplicationDbContextModelSnapshot.cs index 193458a..62950df 100644 --- a/Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1296,13 +1296,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations b.Property("ZipCode") .IsRequired() - .HasMaxLength(5) - .HasColumnType("varchar(5)"); + .HasMaxLength(10) + .HasColumnType("varchar(10)"); b.Property("ZipCode1") .IsRequired() - .HasMaxLength(5) - .HasColumnType("varchar(5)"); + .HasMaxLength(10) + .HasColumnType("varchar(10)"); b.HasKey("Id"); diff --git a/Migrations/20260324084215_update_DisableAddress.Designer.cs b/Migrations/20260324084215_update_DisableAddress.Designer.cs new file mode 100644 index 0000000..c97a27e --- /dev/null +++ b/Migrations/20260324084215_update_DisableAddress.Designer.cs @@ -0,0 +1,3153 @@ +// +using System; +using BMA.EHR.Recurit.Exam.Service.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Recurit.Exam.Service.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20260324084215_update_DisableAddress")] + partial class update_DisableAddress + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.BankExam", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AccountName") + .HasColumnType("longtext") + .HasComment("ชื่อบัญชี"); + + b.Property("AccountNumber") + .HasColumnType("longtext") + .HasComment("เลขบัญชี"); + + b.Property("BankName") + .HasColumnType("longtext") + .HasComment("ธนาคาร"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("PeriodExamId"); + + b.ToTable("BankExams"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.CMSAgency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CMSCandidateId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Link") + .HasColumnType("longtext") + .HasComment("ลิงค์"); + + b.Property("Name") + .HasColumnType("longtext") + .HasComment("ชื่อลิงค์"); + + b.HasKey("Id"); + + b.HasIndex("CMSCandidateId"); + + b.ToTable("CMSAgencys"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.CMSCandidate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("About") + .HasColumnType("longtext") + .HasComment("ข้อมูลเกี่ยวกับเรา"); + + b.Property("Address") + .HasColumnType("longtext") + .HasComment("ที่อยู่ปัจจุบัน"); + + b.Property("BannerImgId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .HasColumnType("longtext") + .HasComment("ข้อมูลเว็บโดยย่อ"); + + b.Property("DistrictId") + .HasColumnType("char(36)") + .HasComment("Id อำเภอ"); + + b.Property("DistrictName") + .HasColumnType("longtext") + .HasComment("อำเภอ"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LogoImgId") + .HasColumnType("char(36)"); + + b.Property("NameEn") + .HasColumnType("longtext") + .HasComment("ชื่อเว็บภาษาอังกฤษ"); + + b.Property("NameTh") + .HasColumnType("longtext") + .HasComment("ชื่อเว็บภาษาไทย"); + + b.Property("ProvinceId") + .HasColumnType("char(36)") + .HasComment("Id จังหวัด"); + + b.Property("ProvinceName") + .HasColumnType("longtext") + .HasComment("จังหวัด"); + + b.Property("ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อ"); + + b.Property("SubDistrictId") + .HasColumnType("char(36)") + .HasComment("Id ตำบล"); + + b.Property("SubDistrictName") + .HasColumnType("longtext") + .HasComment("ตำบล"); + + b.Property("Telephone") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("โทรศัพท์"); + + b.Property("ZipCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)") + .HasComment("รหัสไปรษณีย์"); + + b.HasKey("Id"); + + b.HasIndex("BannerImgId"); + + b.HasIndex("LogoImgId"); + + b.ToTable("CMSCandidates"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.CMSGovernment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CMSCandidateId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Link") + .HasColumnType("longtext") + .HasComment("ลิงค์"); + + b.Property("Name") + .HasColumnType("longtext") + .HasComment("ชื่อลิงค์"); + + b.HasKey("Id"); + + b.HasIndex("CMSCandidateId"); + + b.ToTable("CMSGovernments"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Candidate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CitizenDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ออกบัตร"); + + b.Property("CitizenDistrictId") + .HasColumnType("char(36)") + .HasComment("Id เขตที่ออกบัตรประชาชน"); + + b.Property("CitizenDistrictName") + .HasColumnType("longtext") + .HasComment("เขตที่ออกบัตรประชาชน"); + + b.Property("CitizenId") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CitizenProvinceId") + .HasColumnType("char(36)") + .HasComment("Id จังหวัดที่ออกบัตรประชาชน"); + + b.Property("CitizenProvinceName") + .HasColumnType("longtext") + .HasComment("จังหวัดที่ออกบัตรประชาชน"); + + b.Property("ContactFirstname") + .HasColumnType("longtext") + .HasComment("ชื่อ บุคคลที่สามารถติดต่อได้"); + + b.Property("ContactLastname") + .HasColumnType("longtext") + .HasComment("สกุล บุคคลที่สามารถติดต่อได้"); + + b.Property("ContactPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้า บุคคลที่สามารถติดต่อได้"); + + b.Property("ContactPrefixName") + .HasColumnType("longtext") + .HasComment("คำนำหน้า บุคคลที่สามารถติดต่อได้"); + + b.Property("ContactRelations") + .HasColumnType("longtext") + .HasComment("เกี่ยวข้องเป็น บุคคลที่สามารถติดต่อได้"); + + b.Property("ContactTel") + .HasColumnType("longtext") + .HasComment("โทรศัพท์ บุคคลที่สามารถติดต่อได้"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("CurrentAddress") + .HasColumnType("longtext") + .HasComment("ที่อยู่ปัจจุบัน"); + + b.Property("CurrentDistrictId") + .HasColumnType("char(36)") + .HasComment("Id อำเภอที่อยู่ปัจจุบัน"); + + b.Property("CurrentDistrictName") + .HasColumnType("longtext") + .HasComment("อำเภอที่อยู่ปัจจุบัน"); + + b.Property("CurrentProvinceId") + .HasColumnType("char(36)") + .HasComment("Id จังหวัดที่อยู่ปัจจุบัน"); + + b.Property("CurrentProvinceName") + .HasColumnType("longtext") + .HasComment("จังหวัดที่อยู่ปัจจุบัน"); + + b.Property("CurrentSubDistrictId") + .HasColumnType("char(36)") + .HasComment("Id ตำบลที่อยู่ปัจจุบัน"); + + b.Property("CurrentSubDistrictName") + .HasColumnType("longtext") + .HasComment("ตำบลที่อยู่ปัจจุบัน"); + + b.Property("CurrentZipCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)") + .HasComment("รหัสไปรษณีย์ที่อยู่ปัจจุบัน"); + + b.Property("DateOfBirth") + .HasMaxLength(40) + .HasColumnType("datetime(6)") + .HasComment("วันเกิด"); + + b.Property("Email") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("อีเมล"); + + b.Property("ExamIdenNumber") + .HasColumnType("longtext") + .HasComment("เลขประจำตัวสอบ"); + + b.Property("ExamReason") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("FatherFirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อจริงบิดา"); + + b.Property("FatherLastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลบิดา"); + + b.Property("FatherNationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติบิดา"); + + b.Property("FatherOccupation") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("อาชีพบิดา"); + + b.Property("FatherPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าชื่อบิดา"); + + b.Property("FatherPrefixName") + .HasColumnType("longtext") + .HasComment("คำนำหน้าชื่อบิดา"); + + b.Property("FirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อจริง"); + + b.Property("IsShowExamInfo") + .HasColumnType("tinyint(1)") + .HasComment("สถานะ เปิดให้ดาวน์โหลดใบสมัคร แสดงสถานที่สอบ และเลขประจำตัวสอบ"); + + b.Property("Knowledge") + .HasColumnType("longtext") + .HasComment("ความสามารถพิเศษ"); + + b.Property("LastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(2) + .HasComment("นามสกุล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Marry") + .HasColumnType("tinyint(1)") + .HasComment("คู่สมรส"); + + b.Property("MarryFirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อจริงคู่สมรส"); + + b.Property("MarryLastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลคู่สมรส"); + + b.Property("MarryNationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติคู่สมรส"); + + b.Property("MarryOccupation") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("อาชีพคู่สมรส"); + + b.Property("MarryPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าชื่อคู่สมรส"); + + b.Property("MarryPrefixName") + .HasColumnType("longtext") + .HasComment("คำนำหน้าชื่อคู่สมรส"); + + b.Property("MobilePhone") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("โทรศัพท์มือถือ"); + + b.Property("MotherFirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อจริงมารดา"); + + b.Property("MotherLastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลมารดา"); + + b.Property("MotherNationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติมารดา"); + + b.Property("MotherOccupation") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("อาชีพมารดา"); + + b.Property("MotherPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าชื่อมารดา"); + + b.Property("MotherPrefixName") + .HasColumnType("longtext") + .HasComment("คำนำหน้าชื่อมารดา"); + + b.Property("Nationality") + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(3) + .HasComment("สัญชาติ"); + + b.Property("Number") + .HasColumnType("longtext") + .HasComment("ลำดับที่สอบได้"); + + b.Property("OccupationGroup") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน กลุ่ม/ฝ่าย"); + + b.Property("OccupationOrg") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน ชื่อตำแหน่ง"); + + b.Property("OccupationPile") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน กอง"); + + b.Property("OccupationPosition") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน สังกัด"); + + b.Property("OccupationPositionType") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน ประเภทราชการ"); + + b.Property("OccupationSalary") + .HasColumnType("double") + .HasComment("ตำแหน่งปัจจุบัน เงินเดือน"); + + b.Property("OccupationTelephone") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("ตำแหน่งปัจจุบัน เบอร์โทรที่ทำงาน"); + + b.Property("Pass") + .HasColumnType("longtext") + .HasComment("ผลสมัครสอบ"); + + b.Property("PaymentDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ชำระเงิน"); + + b.Property("PaymentImgId") + .HasColumnType("char(36)"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.Property("PointA") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ก"); + + b.Property("PointB") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ข"); + + b.Property("PointC") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ค"); + + b.Property("PointPath1A") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ก ความสามารถในการคิดวิเคราะห์"); + + b.Property("PointPath1C") + .HasColumnType("longtext") + .HasComment("คะแนนภาค คทดสอบสมรรถนะหลัก"); + + b.Property("PointPath2A") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ก ภาษาอังกฤษ"); + + b.Property("PointPath2C") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ค สัมภาษณ์"); + + b.Property("PointPath3A") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ก ความรู้และลักษณะการเป็นข้าราชการที่ดี"); + + b.Property("PointPerA") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ก เปอร์เซนต์"); + + b.Property("PointPerB") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ข เปอร์เซนต์"); + + b.Property("PointPerC") + .HasColumnType("longtext") + .HasComment("คะแนนภาค ค เปอร์เซนต์"); + + b.Property("PointTotalA") + .HasColumnType("longtext") + .HasComment("คะแนนเต็มภาค ก"); + + b.Property("PointTotalB") + .HasColumnType("longtext") + .HasComment("คะแนนเต็มภาค ข"); + + b.Property("PointTotalC") + .HasColumnType("longtext") + .HasComment("คะแนนเต็มภาค ค"); + + b.Property("PositionExamId") + .HasColumnType("char(36)"); + + b.Property("PrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าชื่อ"); + + b.Property("PrefixName") + .HasColumnType("longtext") + .HasComment("คำนำหน้าชื่อ"); + + b.Property("ProfileImgId") + .HasColumnType("char(36)"); + + b.Property("RegistAddress") + .HasColumnType("longtext") + .HasComment("ที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistDistrictId") + .HasColumnType("char(36)") + .HasComment("Id อำเภอที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistDistrictName") + .HasColumnType("longtext") + .HasComment("อำเภอที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistProvinceId") + .HasColumnType("char(36)") + .HasComment("Id จังหวัดที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistProvinceName") + .HasColumnType("longtext") + .HasComment("จังหวัดที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistSame") + .HasColumnType("tinyint(1)") + .HasComment("ที่อยู่ปัจจุบันเหมือนที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistSubDistrictId") + .HasColumnType("char(36)") + .HasComment("Id ตำบลที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistSubDistrictName") + .HasColumnType("longtext") + .HasComment("ตำบลที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistZipCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)") + .HasComment("รหัสไปรษณีย์ที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegisterDate") + .HasMaxLength(40) + .HasColumnType("datetime(6)") + .HasComment("วันที่สมัคร"); + + b.Property("RejectDetail") + .HasColumnType("longtext") + .HasComment("เหตุผลการไม่อนุมัติ"); + + b.Property("RelationshipId") + .HasColumnType("char(36)") + .HasComment("Id สถานภาพ"); + + b.Property("RelationshipName") + .HasColumnType("longtext") + .HasComment("สถานภาพ"); + + b.Property("ReligionId") + .HasColumnType("char(36)") + .HasComment("Id ศาสนา"); + + b.Property("ReligionName") + .HasColumnType("longtext") + .HasComment("ศาสนา"); + + b.Property("ResultA") + .HasColumnType("longtext") + .HasComment("ผลสอบภาค ก"); + + b.Property("ResultB") + .HasColumnType("longtext") + .HasComment("ผลสอบภาค ข"); + + b.Property("ResultC") + .HasColumnType("longtext") + .HasComment("ผลสอบภาค ค"); + + b.Property("Review") + .HasColumnType("longtext") + .HasComment("ข้อแนะนำ"); + + b.Property("ReviewPoint") + .HasColumnType("int") + .HasComment("คะแนนความพึงพอใจ"); + + b.Property("SeatNumber") + .HasColumnType("longtext") + .HasComment("เลขที่นั่งสอบ"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("สถานะผู้สมัคร"); + + b.Property("Telephone") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("โทรศัพท์"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasComment("User Id ผู้สมัคร"); + + b.HasKey("Id"); + + b.HasIndex("PaymentImgId"); + + b.HasIndex("PeriodExamId"); + + b.HasIndex("PositionExamId"); + + b.HasIndex("ProfileImgId"); + + b.ToTable("Candidates"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.CandidateDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CandidateId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.HasKey("Id"); + + b.HasIndex("CandidateId"); + + b.HasIndex("DocumentId"); + + b.ToTable("CandidateDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Career", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CandidateId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DurationEnd") + .HasColumnType("datetime(6)") + .HasColumnOrder(2) + .HasComment("ระยะเวลาสิ้นสุด"); + + b.Property("DurationStart") + .HasColumnType("datetime(6)") + .HasColumnOrder(1) + .HasComment("ระยะเวลาเริ่ม"); + + b.Property("Group") + .HasColumnType("longtext") + .HasColumnOrder(4) + .HasComment("กลุ่ม/ฝ่าย"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Org") + .HasColumnType("longtext") + .HasColumnOrder(6) + .HasComment("สังกัด"); + + b.Property("Pile") + .HasColumnType("longtext") + .HasColumnOrder(5) + .HasComment("กอง"); + + b.Property("Position") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(3) + .HasComment("ชื่อตำแหน่ง"); + + b.Property("RangeDate") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(7) + .HasComment("ระยะเวลา"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(8) + .HasComment("ประเภท"); + + b.HasKey("Id"); + + b.HasIndex("CandidateId"); + + b.ToTable("Careers"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.Disable", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApplyDate") + .HasColumnType("datetime(6)"); + + b.Property("CitizenCardExpireDate") + .HasColumnType("datetime(6)"); + + b.Property("CitizenCardIssuer") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CitizenId") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("varchar(13)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateOfBirth") + .HasColumnType("datetime(6)"); + + b.Property("ExamId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("Gendor") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("HddPosition") + .HasColumnType("longtext") + .HasComment("บัญชีสอบ"); + + b.Property("Isspecial") + .IsRequired() + .HasMaxLength(1) + .HasColumnType("varchar(1)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Marry") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("National") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.Property("PositionLevel") + .HasColumnType("longtext"); + + b.Property("PositionName") + .HasColumnType("longtext"); + + b.Property("PositionType") + .HasColumnType("longtext"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Qualified") + .IsRequired() + .HasMaxLength(1) + .HasColumnType("varchar(1)"); + + b.Property("Race") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RefNo") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Religion") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Remark") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("typeTest") + .HasColumnType("longtext") + .HasComment("ประเภทการสอบภาค ก."); + + b.HasKey("Id"); + + b.HasIndex("PeriodExamId"); + + b.ToTable("Disables"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Address1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Amphur") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Amphur1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DisableId") + .HasColumnType("char(36)"); + + b.Property("District") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("District1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Moo") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Moo1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Province") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Province1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Road") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Road1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Soi") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Soi1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Telephone") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("ZipCode1") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("DisableId"); + + b.ToTable("DisableAddresses"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableCertificate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CertificateNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("DisableId") + .HasColumnType("char(36)"); + + b.Property("ExpiredDate") + .HasColumnType("datetime(6)"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.HasKey("Id"); + + b.HasIndex("DisableId"); + + b.ToTable("DisableCertificates"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DisableId") + .HasColumnType("char(36)"); + + b.Property("DocumentFileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.HasKey("Id"); + + b.HasIndex("DisableId"); + + b.HasIndex("DocumentFileId"); + + b.ToTable("DisableDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableEducation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BachelorDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Degree") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("DisableId") + .HasColumnType("char(36)"); + + b.Property("GPA") + .HasColumnType("double"); + + b.Property("HighDegree") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Major") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("MajorGroupId") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("MajorGroupName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Specialist") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("University") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("DisableId"); + + b.ToTable("DisableEducations"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableImportHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(1) + .HasComment("รายละเอียดการนำเข้า"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("PeriodExamId"); + + b.ToTable("DisableImportHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableOccupation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DisableId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Occupation") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Position") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Telephone") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("WorkAge") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Workplace") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("DisableId"); + + b.ToTable("DisableOccupations"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisablePayment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AccountNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("BankCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ChqueBankCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CompanyCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("CreditDebit") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CustomerName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("DisableId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PaymentId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("PaymentType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("RefNo1") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TellerId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TermBranch") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TextFile") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TransDate") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TransTime") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("DisableId"); + + b.ToTable("DisablePayments"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableScore", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ABStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง ผลประเมิน"); + + b.Property("AStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง ผลประเมิน"); + + b.Property("BStatus") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("ภาคความเหมาะสมกับตำแหน่ง ผลประเมิน"); + + b.Property("CitizenId") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("varchar(13)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ExamAttribute") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("สถานะคัดกรองคุณสมบัติ"); + + b.Property("ExamId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("เลขประจำตัวสอบ"); + + b.Property("ExamStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("สอบได้ / ตก / ขาดสอบ"); + + b.Property("FullA") + .HasColumnType("int") + .HasComment("ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง คะแนนเต็ม"); + + b.Property("FullB") + .HasColumnType("int"); + + b.Property("FullC") + .HasColumnType("int") + .HasComment("ภาคความเหมาะสมกับตำแหน่ง ทดสอบสมรรถนะ+ทดสอบจิตวิทยาฯ คะแนนเต็ม"); + + b.Property("FullD") + .HasColumnType("int") + .HasComment("ภาคความเหมาะสมกับตำแหน่ง สัมภาษณ์ คะแนนเต็ม"); + + b.Property("FullScore") + .HasColumnType("int") + .HasComment("คะแนนเต็ม"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Major") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("ลำดับที่สอบได้"); + + b.Property("PercentageA") + .HasColumnType("double") + .HasComment("ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง ร้อยละ"); + + b.Property("PercentageB") + .HasColumnType("double"); + + b.Property("PercentageC") + .HasColumnType("double") + .HasComment("ภาคความเหมาะสมกับตำแหน่ง ร้อยละ"); + + b.Property("RemarkExamOrder") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเหตุจากลำดับที่สอบได้"); + + b.Property("RemarkScore") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเหตุจากบัญชีรวมคะแนน"); + + b.Property("ScoreImportId") + .HasColumnType("char(36)"); + + b.Property("SumA") + .HasColumnType("double") + .HasComment("ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง คะแนนรวม"); + + b.Property("SumAB") + .HasColumnType("double") + .HasComment("ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง คะแนนรวม"); + + b.Property("SumB") + .HasColumnType("double"); + + b.Property("SumC") + .HasColumnType("double") + .HasComment("ภาคความเหมาะสมกับตำแหน่ง ทดสอบสมรรถนะ+ทดสอบจิตวิทยาฯ คะแนนรวม"); + + b.Property("SumCD") + .HasColumnType("double") + .HasComment("ภาคความเหมาะสมกับตำแหน่ง คะแนนรวมทดสอบสมรรถนะ+ทดสอบจิตวิทยาฯ และสัมภาษณ์"); + + b.Property("SumD") + .HasColumnType("double") + .HasComment("ภาคความเหมาะสมกับตำแหน่ง สัมภาษณ์ คะแนนรวม"); + + b.Property("TotalScore") + .HasColumnType("double") + .HasComment("คะแนนรวม"); + + b.HasKey("Id"); + + b.HasIndex("ScoreImportId"); + + b.ToTable("DisableScores"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.ScoreImport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ImportFileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.Property("Year") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ImportFileId"); + + b.HasIndex("PeriodExamId") + .IsUnique(); + + b.ToTable("ScoreImports"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Education", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CandidateId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EducationEndDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่สำเร็จการศึกษา"); + + b.Property("EducationLevelExamId") + .HasColumnType("char(36)") + .HasComment("Id วุฒิที่ใช้สมัครสอบ"); + + b.Property("EducationLevelExamName") + .HasColumnType("longtext") + .HasComment("วุฒิที่ใช้สมัครสอบ"); + + b.Property("EducationLevelHighId") + .HasColumnType("char(36)") + .HasComment("Id วุฒิการศึกษาสูงสุด"); + + b.Property("EducationLevelHighName") + .HasColumnType("longtext") + .HasComment("วุฒิการศึกษาสูงสุด"); + + b.Property("EducationLocation") + .HasColumnType("longtext") + .HasComment("ชื่อสถานศึกษา"); + + b.Property("EducationMajor") + .HasColumnType("longtext") + .HasComment("สาขาวิชา/วิชาเอก"); + + b.Property("EducationName") + .HasColumnType("longtext") + .HasComment("ชื่อปริญญา"); + + b.Property("EducationScores") + .HasColumnType("longtext") + .HasComment("คะแนนเฉลี่ยสะสม"); + + b.Property("EducationType") + .HasColumnType("longtext") + .HasComment("ประเภทสถานศึกษา"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.HasKey("Id"); + + b.HasIndex("CandidateId"); + + b.ToTable("Educations"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AnnouncementDate") + .HasColumnType("datetime(6)") + .HasColumnOrder(5) + .HasComment("วันประกาศผลสอบ"); + + b.Property("AnnouncementEndDate") + .HasColumnType("datetime(6)") + .HasColumnOrder(7) + .HasComment("วันสิ้นสุดประกาศ"); + + b.Property("AnnouncementExam") + .HasColumnType("tinyint(1)") + .HasComment("ประกาศนี้มีสมัครสอบคัดเลือก"); + + b.Property("AnnouncementStartDate") + .HasColumnType("datetime(6)") + .HasColumnOrder(6) + .HasComment("วันเริ่มประกาศ"); + + b.Property("AuthName") + .HasColumnType("longtext"); + + b.Property("AuthPosition") + .HasColumnType("longtext"); + + b.Property("Category") + .HasColumnType("longtext") + .HasComment("สำนัก"); + + b.Property("CheckDisability") + .HasColumnType("tinyint(1)") + .HasComment("คนพิการ"); + + b.Property("CheckDocument") + .HasColumnType("tinyint(1)") + .HasComment("ตรวจสอบเอกสารหลังประกาศผลสอบ"); + + b.Property("CompanyCode") + .HasColumnType("longtext") + .HasComment("Company code"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Detail") + .HasColumnType("longtext") + .HasComment("รายละเอียดสมัครสอบ"); + + b.Property("EditorCondition") + .HasColumnType("longtext") + .HasComment("รายละเอียดเงื่อนไขการสมัคร"); + + b.Property("EditorConfirm") + .HasColumnType("longtext") + .HasComment("รายละเอียดคำรับรอง"); + + b.Property("ExamDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่สอบ"); + + b.Property("Fee") + .HasColumnType("float") + .HasComment("ค่าธรรมเนียม"); + + b.Property("GraduationYearLock") + .HasColumnType("int") + .HasComment("ล็อกวันที่สำเร็จการศึกษา (ปี)"); + + b.Property("ImportFileId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)") + .HasColumnOrder(8) + .HasComment("ชื่อการสอบ"); + + b.Property("Note") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("OrganizationCodeId") + .HasColumnType("char(36)") + .HasComment("Id รหัสส่วนราชการ"); + + b.Property("OrganizationCodeName") + .HasColumnType("longtext") + .HasComment("ชื่อรหัสส่วนราชการ"); + + b.Property("OrganizationId") + .HasColumnType("char(36)") + .HasComment("Id หน่วยงาน"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน"); + + b.Property("PaymentEndDate") + .HasColumnType("datetime(6)") + .HasColumnOrder(4) + .HasComment("วันสิ้นสุดชำระเงิน"); + + b.Property("PaymentKrungThai") + .HasColumnType("longtext") + .HasComment("ชำระเงินผ่านกรุงไทย"); + + b.Property("PaymentStartDate") + .HasColumnType("datetime(6)") + .HasColumnOrder(3) + .HasComment("วันเริ่มชำระเงิน"); + + b.Property("Reason") + .HasColumnType("text") + .HasComment("หมายเหตุ"); + + b.Property("RefNo1") + .HasColumnType("longtext") + .HasComment("Ref No1"); + + b.Property("RegisterEndDate") + .HasColumnType("datetime(6)") + .HasColumnOrder(2) + .HasComment("วันสิ้นสุดสมัครสอบ"); + + b.Property("RegisterStartDate") + .HasColumnType("datetime(6)") + .HasColumnOrder(1) + .HasComment("วันเริ่มสมัครสอบ"); + + b.Property("Remark") + .HasColumnType("text") + .HasComment("remark"); + + b.Property("Round") + .HasColumnType("int") + .HasColumnOrder(9) + .HasComment("รอบการสอบ"); + + b.Property("SetSeat") + .HasColumnType("tinyint(1)") + .HasComment("เช็คอัพคะแนน"); + + b.Property("Year") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.HasKey("Id"); + + b.HasIndex("ImportFileId"); + + b.ToTable("PeriodExams"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamBarCode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PeriodExamId"); + + b.ToTable("PeriodExamBarCodes"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PeriodExamId"); + + b.ToTable("PeriodExamDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PeriodExamId"); + + b.ToTable("PeriodExamImages"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamQrCode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PeriodExamId"); + + b.ToTable("PeriodExamQrCodes"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PositionExam", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Code") + .HasColumnType("longtext") + .HasComment("รหัสประจำตำแหน่งที่สอบ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EducationLevel") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("ขีดจำกัดวุฒิการศึกษา"); + + b.Property("HighDegree") + .HasColumnType("tinyint(1)") + .HasComment("ปริญญาบัตรขึ้นไป"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PeriodExamId") + .HasColumnType("char(36)"); + + b.Property("PositionId") + .HasColumnType("char(36)") + .HasComment("Id ตำแหน่ง"); + + b.Property("PositionLevelId") + .HasColumnType("char(36)") + .HasComment("Id ระดับ"); + + b.Property("PositionLevelName") + .HasColumnType("longtext") + .HasComment("ชื่อระดับ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่ง"); + + b.Property("TypeId") + .HasColumnType("longtext") + .HasComment("Id ประเภทแบบฟอร์ม"); + + b.Property("TypeName") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทแบบฟอร์ม"); + + b.HasKey("Id"); + + b.HasIndex("PeriodExamId"); + + b.ToTable("PositionExams"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.BankExam", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithMany("BankExam") + .HasForeignKey("PeriodExamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PeriodExam"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.CMSAgency", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.CMSCandidate", "CMSCandidate") + .WithMany("CMSAgencys") + .HasForeignKey("CMSCandidateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CMSCandidate"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.CMSCandidate", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "BannerImg") + .WithMany() + .HasForeignKey("BannerImgId"); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "LogoImg") + .WithMany() + .HasForeignKey("LogoImgId"); + + b.Navigation("BannerImg"); + + b.Navigation("LogoImg"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.CMSGovernment", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.CMSCandidate", "CMSCandidate") + .WithMany("CMSGovernments") + .HasForeignKey("CMSCandidateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CMSCandidate"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Candidate", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "PaymentImg") + .WithMany() + .HasForeignKey("PaymentImgId"); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithMany("Candidate") + .HasForeignKey("PeriodExamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PositionExam", "PositionExam") + .WithMany() + .HasForeignKey("PositionExamId"); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "ProfileImg") + .WithMany() + .HasForeignKey("ProfileImgId"); + + b.Navigation("PaymentImg"); + + b.Navigation("PeriodExam"); + + b.Navigation("PositionExam"); + + b.Navigation("ProfileImg"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.CandidateDocument", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Candidate", "Candidate") + .WithMany() + .HasForeignKey("CandidateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Candidate"); + + b.Navigation("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Career", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Candidate", "Candidate") + .WithMany("Careers") + .HasForeignKey("CandidateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Candidate"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.Disable", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithMany("Disables") + .HasForeignKey("PeriodExamId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("PeriodExam"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableAddress", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Disables.Disable", "Disable") + .WithMany("Addresses") + .HasForeignKey("DisableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Disable"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableCertificate", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Disables.Disable", "Disable") + .WithMany("Certificates") + .HasForeignKey("DisableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Disable"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableDocument", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Disables.Disable", "Disable") + .WithMany("Documents") + .HasForeignKey("DisableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "DocumentFile") + .WithMany() + .HasForeignKey("DocumentFileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Disable"); + + b.Navigation("DocumentFile"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableEducation", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Disables.Disable", "Disable") + .WithMany("Educations") + .HasForeignKey("DisableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Disable"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableImportHistory", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithMany("ImportHostories") + .HasForeignKey("PeriodExamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PeriodExam"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableOccupation", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Disables.Disable", "Disable") + .WithMany("Occupations") + .HasForeignKey("DisableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Disable"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisablePayment", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Disables.Disable", "Disable") + .WithMany("Payments") + .HasForeignKey("DisableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Disable"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.DisableScore", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Disables.ScoreImport", "ScoreImport") + .WithMany("Scores") + .HasForeignKey("ScoreImportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoreImport"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.ScoreImport", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "ImportFile") + .WithMany() + .HasForeignKey("ImportFileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithOne("ScoreImport") + .HasForeignKey("BMA.EHR.Recurit.Exam.Service.Models.Disables.ScoreImport", "PeriodExamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ImportFile"); + + b.Navigation("PeriodExam"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Education", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Candidate", "Candidate") + .WithMany("Educations") + .HasForeignKey("CandidateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Candidate"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "ImportFile") + .WithMany() + .HasForeignKey("ImportFileId"); + + b.Navigation("ImportFile"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamBarCode", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithMany("PeriodExamBarCodes") + .HasForeignKey("PeriodExamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("PeriodExam"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamDocument", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithMany("PeriodExamDocuments") + .HasForeignKey("PeriodExamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("PeriodExam"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamImage", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithMany("PeriodExamImages") + .HasForeignKey("PeriodExamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("PeriodExam"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamQrCode", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithMany("PeriodExamQrCodes") + .HasForeignKey("PeriodExamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("PeriodExam"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PositionExam", b => + { + b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam") + .WithMany("PositionExam") + .HasForeignKey("PeriodExamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PeriodExam"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.CMSCandidate", b => + { + b.Navigation("CMSAgencys"); + + b.Navigation("CMSGovernments"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Candidate", b => + { + b.Navigation("Careers"); + + b.Navigation("Educations"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.Disable", b => + { + b.Navigation("Addresses"); + + b.Navigation("Certificates"); + + b.Navigation("Documents"); + + b.Navigation("Educations"); + + b.Navigation("Occupations"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Disables.ScoreImport", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", b => + { + b.Navigation("BankExam"); + + b.Navigation("Candidate"); + + b.Navigation("Disables"); + + b.Navigation("ImportHostories"); + + b.Navigation("PeriodExamBarCodes"); + + b.Navigation("PeriodExamDocuments"); + + b.Navigation("PeriodExamImages"); + + b.Navigation("PeriodExamQrCodes"); + + b.Navigation("PositionExam"); + + b.Navigation("ScoreImport"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20260324084215_update_DisableAddress.cs b/Migrations/20260324084215_update_DisableAddress.cs new file mode 100644 index 0000000..2d6ead5 --- /dev/null +++ b/Migrations/20260324084215_update_DisableAddress.cs @@ -0,0 +1,66 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Recurit.Exam.Service.Migrations +{ + /// + public partial class update_DisableAddress : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + 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( + 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"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + 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( + 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"); + } + } +} diff --git a/Models/Disable/DisableAddress.cs b/Models/Disable/DisableAddress.cs index fbab66b..3b75d02 100644 --- a/Models/Disable/DisableAddress.cs +++ b/Models/Disable/DisableAddress.cs @@ -25,7 +25,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables [MaxLength(200)] public string Province { get; set; }// - [MaxLength(5)] + [MaxLength(10)] public string ZipCode { get; set; }// [MaxLength(200)] @@ -55,7 +55,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables [MaxLength(200)] public string Province1 { get; set; }// - [MaxLength(5)] + [MaxLength(10)] public string ZipCode1 { get; set; }// public Disable Disable { get; set; } diff --git a/Models/District.cs b/Models/District.cs index 6240c7d..655e51c 100644 --- a/Models/District.cs +++ b/Models/District.cs @@ -9,6 +9,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models [Required, MaxLength(150), Column(Order = 1), Comment("เขต/อำเภอ")] public string name { get; set; } = string.Empty; + [Column(Order = 2), Comment("รหัสอ้างอิงจังหวัด")] + public Guid? provinceId { get; set; } = null; + // [Column(Order = 2), Comment("สถานะการใช้งาน")] // public bool IsActive { get; set; } = true; diff --git a/Models/SubDistrict.cs b/Models/SubDistrict.cs index 0610c37..b2185f4 100644 --- a/Models/SubDistrict.cs +++ b/Models/SubDistrict.cs @@ -12,6 +12,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models [MaxLength(10), Column(Order = 2), Comment("รหัสไปรษณีย์")] public string? zipCode { get; set; } = null; + [Column(Order = 3), Comment("รหัสอ้างอิงอำเภอ")] + public Guid? districtId { get; set; } = null; + // [Column(Order = 3), Comment("สถานะการใช้งาน")] // public bool IsActive { get; set; } = true; diff --git a/Repositories/PermissionRepository.cs b/Repositories/PermissionRepository.cs index afc84af..52b70cd 100644 --- a/Repositories/PermissionRepository.cs +++ b/Repositories/PermissionRepository.cs @@ -51,7 +51,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services using (var client = new HttpClient()) { 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 res = await req.Content.ReadAsStringAsync(); return res; diff --git a/Request/Disables/PostDisableImportRequest.cs b/Request/Disables/PostDisableImportRequest.cs index 232bc33..2eab546 100644 --- a/Request/Disables/PostDisableImportRequest.cs +++ b/Request/Disables/PostDisableImportRequest.cs @@ -82,5 +82,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Request.Disables /// วันที่ประกาศผลสอบ /// public DateTime AnnouncementDate { get; set; } + + /// + /// รหัส DNA หน่วยงาน + /// + public Guid? rootDnaId { get; set; } } } diff --git a/Response/CandidateStatusResponse.cs b/Response/CandidateStatusResponse.cs index e36d0a7..ac6b699 100644 --- a/Response/CandidateStatusResponse.cs +++ b/Response/CandidateStatusResponse.cs @@ -9,5 +9,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Response public string? RejectDetail { get; set; } public bool? IsShowExamInfo { get; set; } + + public bool? IsShowResult { get; set; } + } } diff --git a/Services/CandidateService.cs b/Services/CandidateService.cs index fc1ba9f..2319b65 100644 --- a/Services/CandidateService.cs +++ b/Services/CandidateService.cs @@ -1978,7 +1978,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Services if (candidate == null) 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) @@ -2651,7 +2663,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services using (var client = new HttpClient()) { 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 { citizenId diff --git a/Services/PeriodExamService.cs b/Services/PeriodExamService.cs index aeefa24..2d417e5 100644 --- a/Services/PeriodExamService.cs +++ b/Services/PeriodExamService.cs @@ -1232,30 +1232,57 @@ namespace BMA.EHR.Recurit.Exam.Service.Services if (candidate.Status == "checkSeat") { candidate.SeatNumber = item.SeatNumber; - var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; - var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: ติดตามประกาศทาง Website"; - if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); + // var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; + // var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: ติดตามประกาศทาง Website"; + // 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"; } else { - if (candidate.Status != "waiver") - { - var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; - var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ"; - if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); - } + // if (candidate.Status != "waiver") + // { + // var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; + // var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ"; + // 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"; } } else { - if (candidate.Status != "waiver") - { - var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; - var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ"; - if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); - } + // if (candidate.Status != "waiver") + // { + // var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; + // var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ"; + // 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"; } periodExam.SetSeat = true; @@ -1309,30 +1336,30 @@ namespace BMA.EHR.Recurit.Exam.Service.Services candidate.Pass = item.Pass; candidate.ExamReason = item.ExamReason; candidate.Number = item.Number; - var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; - var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สอบคัดเลือกสำเร็จ
" + "ผลการสอบของท่าน คือ " + candidate.Pass; - if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); + // var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; + // var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สอบคัดเลือกสำเร็จ
" + "ผลการสอบของท่าน คือ " + candidate.Pass; + // if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); candidate.Status = "done"; } else { - if (candidate.Status != "waiver") - { - var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; - var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ"; - if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); - } + // if (candidate.Status != "waiver") + // { + // var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; + // var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ"; + // if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); + // } // candidate.Status = "waiver"; } } else { - if (candidate.Status != "waiver") - { - var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; - var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ"; - if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); - } + // if (candidate.Status != "waiver") + // { + // var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name; + // var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ"; + // if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email); + // } // candidate.Status = "waiver"; } periodExam.SetSeat = true; @@ -1625,6 +1652,101 @@ namespace BMA.EHR.Recurit.Exam.Service.Services }; } + public async Task 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 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 GetsPaymentExamAsync(string examId) { var periodExam = await _context.PeriodExams.AsQueryable() @@ -2860,7 +2982,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services using (var client = new HttpClient()) { 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 _res = await client.SendAsync(_req); var _result = await _res.Content.ReadAsStringAsync(); @@ -3055,7 +3177,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services throw new Exception(GlobalMessages.ExamNotFound); 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) throw new Exception("รอบการสอบนี้ได้ทำการบรรจุไปแล้ว"); @@ -3073,7 +3195,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services Round = periodExam.Round?.ToString() ?? "", Year = (int)(periodExam.Year ?? 0), 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, EndDate = accountStartDate.AddYears(2).AddDays(-1), CreatedAt = DateTime.Now, @@ -3197,6 +3319,28 @@ namespace BMA.EHR.Recurit.Exam.Service.Services 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 { Placement = placement, @@ -3218,15 +3362,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Services Telephone = firstAddress?.Telephone ?? "", MobilePhone = firstAddress?.Mobile ?? "", RegistAddress = registAddress, - RegistProvinceId = provincesCache.FirstOrDefault(x => x.name == firstAddress?.Province)?.Id, - RegistDistrictId = districtsCache.FirstOrDefault(x => x.name == firstAddress?.District)?.Id, - RegistSubDistrictId = subDistrictsCache.FirstOrDefault(x => x.name == firstAddress?.Soi)?.Id, + RegistProvinceId = registProvinceId, + RegistDistrictId = registDistrictId, + RegistSubDistrictId = registSubDistrictId, RegistZipCode = firstAddress?.ZipCode ?? "", RegistSame = false, CurrentAddress = currentAddress, - CurrentProvinceId = provincesCache.FirstOrDefault(x => x.name == firstAddress?.Province1)?.Id, - CurrentDistrictId = districtsCache.FirstOrDefault(x => x.name == firstAddress?.District1)?.Id, - CurrentSubDistrictId = subDistrictsCache.FirstOrDefault(x => x.name == firstAddress?.Soi1)?.Id, + CurrentProvinceId = currentProvinceId, + CurrentDistrictId = currentDistrictId, + CurrentSubDistrictId = currentSubDistrictId, CurrentZipCode = firstAddress?.ZipCode1, Marry = candidate.Marry?.Contains("สมรส") ?? false, OccupationPositionType = "other",