Compare commits

..

16 commits
v1.0.0 ... dev

Author SHA1 Message Date
harid
2f8effe7e4 Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 49s
2026-05-12 16:25:05 +07:00
harid
081c00b869 fix เมื่อพ้นการสอบ 15 วัน ไม่ให้คลิกดูข้อมูลได้ #2485 2026-05-12 16:24:39 +07:00
harid
f1fc324828 Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 51s
2026-05-01 14:22:32 +07:00
harid
cba02a4f6e api รายงานรายชื่อผู้มีสิทธิ์สอบ, รายชื่อผู้สอบคัดเลือกได้ 2026-05-01 14:22:07 +07:00
harid
208ad63abf Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m7s
2026-04-28 10:02:43 +07:00
harid
d2f21a9181 fix #2367 2026-04-28 10:02:17 +07:00
harid
c4a6b6d1df Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m5s
2026-03-31 15:34:09 +07:00
harid
16015cf3ef fix สถานะผลการสอบ #2386 2026-03-31 15:33:31 +07:00
harid
06b62df43a Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m5s
2026-03-24 15:45:13 +07:00
harid
022b68b496 fix นำเข้าข้อมูลสรรหาแล้วแจ้ง error (สอบคัดเลือกอื่นๆ) #9 2026-03-24 15:44:51 +07:00
Suphonchai Phoonsawat
0908d6083d Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
2026-03-19 10:42:59 +07:00
Suphonchai Phoonsawat
caa0bccd79 Refactor RequestLoggingMiddleware to remove unused methods and streamline user data extraction 2026-03-19 10:32:13 +07:00
harid
fcc1018f80 Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m2s
2026-03-12 11:14:55 +07:00
harid
75718a955d fix กรณีไม่ได้กรอกข้อมูลตรวจสอบคุณสมบัติให้แสดงว่าง #2349 2026-03-12 11:13:43 +07:00
harid
41dd23217c Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m3s
2026-03-10 13:18:54 +07:00
harid
bb0b296086 Migrate เพิ่มฟิลด์สถานะคัดกรองคุณสมบัติ 2026-03-10 13:18:12 +07:00
13 changed files with 6665 additions and 151 deletions

View file

@ -1365,7 +1365,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
District = workSheet?.Cells[row, 54]?.GetValue<string>() ?? "",
Amphur = workSheet?.Cells[row, 55]?.GetValue<string>() ?? "",
Province = workSheet?.Cells[row, 56]?.GetValue<string>() ?? "",
ZipCode = workSheet?.Cells[row, 57]?.GetValue<string>() ?? "",
ZipCode = (workSheet?.Cells[row, 57]?.GetValue<string>() ?? "").Trim(),
Telephone = workSheet?.Cells[row, 58]?.GetValue<string>() ?? "",
Mobile = "",
Address1 = $"{(workSheet?.Cells[row, 61]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 62]?.GetValue<string>() ?? "")}",
@ -1375,7 +1375,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
District1 = workSheet?.Cells[row, 66]?.GetValue<string>() ?? "",
Amphur1 = workSheet?.Cells[row, 67]?.GetValue<string>() ?? "",
Province1 = workSheet?.Cells[row, 68]?.GetValue<string>() ?? "",
ZipCode1 = workSheet?.Cells[row, 69]?.GetValue<string>() ?? "",
ZipCode1 = (workSheet?.Cells[row, 69]?.GetValue<string>() ?? "").Trim(),
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
CreatedFullName = FullName ?? "System Administrator",
@ -1399,7 +1399,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
TermBranch = workSheet?.Cells[row, 113]?.GetValue<string>() ?? "",
TellerId = workSheet?.Cells[row, 114]?.GetValue<string>() ?? "",
CreditDebit = workSheet?.Cells[row, 115]?.GetValue<string>() ?? "",
PaymentType = workSheet?.Cells[row, 116]?.GetValue<string>(),
PaymentType = workSheet?.Cells[row, 116]?.GetValue<string>() ?? "",
ChequeNo = workSheet?.Cells[row, 117]?.GetValue<string>() ?? "",
Amount = (decimal)workSheet?.Cells[row, 118]?.GetValue<decimal>(),
ChqueBankCode = workSheet?.Cells[row, 119]?.GetValue<string>() ?? "",
@ -1604,15 +1604,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
r.ExamId = workSheet?.Cells[row, 2]?.GetValue<string>();
//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))
{
r.CitizenId = workSheet?.Cells[row, 3]?.GetValue<string>();
r.CitizenId = workSheet?.Cells[row, 3]?.GetValue<string>()?.Trim();
// ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง
r.FullA = 200;
@ -1633,24 +1628,20 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
r.FullScore = 300;
r.TotalScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 13]?.GetValue<string>()) ? 0.00 : Math.Round(workSheet.Cells[row, 13].GetValue<double>(), 2);
if (workSheet?.Cells[row, 7]?.GetValue<string>() == "ขาดสอบ")
{
r.ExamStatus = "ขส.";
}
else if (workSheet?.Cells[row, 14]?.GetValue<string>() == "ได้")
{
r.ExamStatus = "ผ่าน";
}
else if (workSheet?.Cells[row, 14]?.GetValue<string>() == "ตก")
{
r.ExamStatus = "ไม่ผ่าน";
}
else
{
r.ExamStatus = "-";
}
var examStatusCol7 = workSheet?.Cells[row, 7]?.GetValue<string>()?.Trim();
var examStatusCol14 = workSheet?.Cells[row, 14]?.GetValue<string>()?.Trim();
r.ExamStatus =
examStatusCol7 == "ขาดสอบ" ? "ขส." :
examStatusCol14 == "ได้" ? "ผ่าน" :
examStatusCol14 == "ตก" ? "ไม่ผ่าน" : "-";
r.RemarkScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 15]?.GetValue<string>()) ? string.Empty : workSheet?.Cells[row, 15]?.GetValue<string>();
var examAttr = workSheet?.Cells[row, 16]?.GetValue<string>()?.Trim();
r.ExamAttribute =
examAttr == "ผ่าน" ? "มีคุณสมบัติ" :
examAttr == "ไม่ผ่าน" ? "ไม่มีคุณสมบัติ" : "";
r.Major = workSheet.Name;
r.CreatedAt = DateTime.Now;
@ -2091,10 +2082,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
: "",
examScore = x.score == null ? 0.0 : x.score.TotalScore,
examResult = x.score == null ? "" : x.score.ExamStatus,
examAttribute = x.disable.Certificates.Any() && x.disable.Certificates.First().IssueDate != null
? _disableService.CheckValidCertificate(x.disable.Certificates.First().IssueDate, 5)
? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ"
: "ไม่มีคุณสมบัติ",
//examAttribute = x.disable.Certificates.Any() && x.disable.Certificates.First().IssueDate != null
// ? _disableService.CheckValidCertificate(x.disable.Certificates.First().IssueDate, 5)
// ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ"
// : "ไม่มีคุณสมบัติ",
examAttribute = x.score != null && !string.IsNullOrEmpty(x.score.ExamAttribute) &&
(x.score.ExamAttribute == "มีคุณสมบัติ" || x.score.ExamAttribute == "ไม่มีคุณสมบัติ")
? x.score.ExamAttribute : "",
remark = x.disable.Remark,
isSpecial = x.disable.Isspecial == "Y" ? x.disable.Isspecial : "",
applyDate = x.disable.ApplyDate.HasValue && x.disable.ApplyDate.Value != DateTime.MinValue
@ -2191,8 +2187,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
.Where(x => x.ExamId == examId)
.Join(_context.DisableScores.AsQueryable()
.Include(x => x.ScoreImport),
rc => new { /*rc.PeriodExam.Year,*/ rc.ExamId },
sc => new { /*sc.ScoreImport.Year,*/ sc.ExamId },
rc => new { PeriodExamId = rc.PeriodExam.Id, rc.ExamId },
sc => new { PeriodExamId = sc.ScoreImport.PeriodExamId, sc.ExamId },
(p, sr) => new
{
ExamID = p.ExamId,
@ -2214,11 +2210,16 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
: ""
: "",
ExamResult = sr == null ? "" : sr.ExamStatus,
ExamAttribute = p.Certificates.Count > 0 ?
_disableService.CheckValidCertificate(p.Certificates.First().IssueDate, 5)
? "มีคุณสมบัติ"
: "ไม่มีคุณสมบัติ"
: "ไม่มีคุณสมบัติ",
// ExamAttribute = p.Certificates.Count > 0 ?
// _disableService.CheckValidCertificate(p.Certificates.First().IssueDate, 5)
// ? "มีคุณสมบัติ"
// : "ไม่มีคุณสมบัติ"
// : "ไม่มีคุณสมบัติ",
ExamAttribute = sr != null && !string.IsNullOrEmpty(sr.ExamAttribute) &&
(sr.ExamAttribute == "มีคุณสมบัติ" || sr.ExamAttribute == "ไม่มีคุณสมบัติ")
? sr.ExamAttribute : "",
IsSpecial = p.Isspecial,
Remark = p.Remark,
University = p.Educations.First().University,

View file

@ -749,6 +749,56 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
/// <summary>
/// ดาวน์โหลดรายชื่อผู้มีสิทธิ์สอบ
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านโหลดผู้สมัครสอบสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("download/candidate-exam/{examId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> DownloadCandidateExamAsync(string examId)
{
try
{
var data = await _periodExamService.DownloadCandidateExamAsync(examId);
return Success(data);
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// ดาวน์โหลดรายชื่อผู้สอบคัดเลือกได้
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านโหลดผู้สมัครสอบสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("download/pass-exam/{examId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> DownloadPassExamAsync(string examId)
{
try
{
var data = await _periodExamService.DownloadPassExamAsync(examId);
return Success(data);
}
catch (Exception ex)
{
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
}
}
/// <summary>
/// โหลดผู้สมัครสอบ
/// </summary>

View file

@ -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<string> GetExternalAPIAsync(string apiPath, string accessToken, string apiKey)
/// <summary>
/// แกะ JWT token เพื่อดึง claims ต่างๆ
/// </summary>
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<GetProfileByKeycloakIdLocal?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
/// <summary>
/// ดึงค่า claim จาก token โดยลองชื่อหลายแบบ
/// </summary>
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<GetProfileByKeycloakIdResultLocal>(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;
}
/// <summary>
/// ดึงค่า Guid claim จาก token
/// </summary>
private Guid? GetGuidClaim(JwtSecurityToken? token, params string[] claimNames)
{
var value = GetClaimValue(token, claimNames);
if (Guid.TryParse(value, out var guid))
return guid;
return null;
}
public async Task Invoke(HttpContext context)
@ -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; }
}
}

View file

@ -1296,13 +1296,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
b.Property<string>("ZipCode")
.IsRequired()
.HasMaxLength(5)
.HasColumnType("varchar(5)");
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.Property<string>("ZipCode1")
.IsRequired()
.HasMaxLength(5)
.HasColumnType("varchar(5)");
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.HasKey("Id");
@ -1883,6 +1883,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("ExamAttribute")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("สถานะคัดกรองคุณสมบัติ");
b.Property<string>("ExamId")
.IsRequired()
.HasMaxLength(50)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class update_table_DisableScore_add_field_ExamAttribute : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ExamAttribute",
table: "DisableScores",
type: "varchar(50)",
maxLength: 50,
nullable: false,
defaultValue: "",
comment: "สถานะคัดกรองคุณสมบัติ")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ExamAttribute",
table: "DisableScores");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,66 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class update_DisableAddress : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ZipCode1",
table: "DisableAddresses",
type: "varchar(10)",
maxLength: 10,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(5)",
oldMaxLength: 5)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ZipCode",
table: "DisableAddresses",
type: "varchar(10)",
maxLength: 10,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(5)",
oldMaxLength: 5)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ZipCode1",
table: "DisableAddresses",
type: "varchar(5)",
maxLength: 5,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(10)",
oldMaxLength: 10)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ZipCode",
table: "DisableAddresses",
type: "varchar(5)",
maxLength: 5,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(10)",
oldMaxLength: 10)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

View file

@ -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; }

View file

@ -80,6 +80,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
[Comment("หมายเหตุจากลำดับที่สอบได้")]
public string RemarkExamOrder { get; set; } = string.Empty;
[MaxLength(50), Comment("สถานะคัดกรองคุณสมบัติ")]
public string ExamAttribute { get; set; } = string.Empty;
public ScoreImport ScoreImport { get; set; }
}
}

View file

@ -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; }
}
}

View file

@ -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)

View file

@ -1625,6 +1625,101 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
};
}
public async Task<dynamic> DownloadCandidateExamAsync(string examId)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Where(x => x.CheckDisability == false)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var data = await _context.Candidates.AsQueryable()
.Include(x => x.PeriodExam)
.Where(x => x.PeriodExam == periodExam)
.Where(x => x.Status != "register")
.Where(x => x.ExamIdenNumber != null && x.ExamIdenNumber != "")
.OrderBy(x => x.ExamIdenNumber)
.Select(p => new
{
ExamId = p.ExamIdenNumber == null ? null : (p.ExamIdenNumber.ToThaiNumber()),
FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
PositionName = "",
ExamName =
($"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}").ToThaiNumber(),
}).ToListAsync();
if (data.Count == 0)
throw new Exception("ไม่พบข้อมูลในระบบ");
var examName = data[0].ExamName;
return new
{
template = "rptCandidateList",
reportName = $"รายชื่อผู้มีสิทธิ์สอบ_{data.First().ExamName}",
data = new
{
examName = examName,
data = data
}
};
}
public async Task<dynamic> DownloadPassExamAsync(string examId)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Where(x => x.CheckDisability == false)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidates = await _context.Candidates.AsQueryable()
.Include(x => x.PeriodExam)
.ThenInclude(x => x.ScoreImport)
.Where(x => x.PeriodExam == periodExam)
.Where(x => x.Status != "register")
.ToListAsync();
var data = candidates.Select((p, idx) => new
{
SeatNumber = p.SeatNumber == null ? "-" : (p.SeatNumber.ToThaiNumber()),
CitizenId = p.CitizenId == null ? "-" : (p.CitizenId.ToThaiNumber()),
FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
DateOfBirth = p.DateOfBirth == null ? "-" : (p.DateOfBirth.Value.ToThaiShortDate()),
ExamName = ($"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}").ToThaiNumber(),
Number = p.Number == null ? (idx + 1).ToString().ToThaiNumber() : p.Number.ToThaiNumber(),
FullA = "",
SumA = "",
FullB = p.PointTotalB == null ? "-" : p.PointTotalB.ToString(),
SumB = p.PointB == null ? "-" : p.PointB.ToString(),
FullC = p.PointTotalC == null ? "-" : p.PointTotalC.ToString(),
SumC = p.PointC == null ? "-" : p.PointC.ToString(),
SumScore = ((Convert.ToInt32(p.PointB ?? "0") + Convert.ToInt32(p.PointC ?? "0")).ToString()).ToThaiNumber(),
ExamResult = p.Pass,
ExamThaiId = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber.ToThaiNumber(),
ExamId = p.ExamIdenNumber,
})
.OrderBy(x => x.ExamId)
.Where(x => x.ExamResult?.Trim() == "ได้")
.ToList();
if (data.Count == 0)
throw new Exception("ไม่พบข้อมูลในระบบ");
var examName = data[0].ExamName;
return new
{
template = "rptPassExamList",
reportName = $"รายชื่อผู้สอบแข่งขันได้_{periodExam.Name} ครั้งที่ {periodExam.Round}/{periodExam.Year.Value.ToThaiYear()}",
data = new
{
examName = examName,
data = data
}
};
}
public async Task<PeriodExam> GetsPaymentExamAsync(string examId)
{
var periodExam = await _context.PeriodExams.AsQueryable()