Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 51s

This commit is contained in:
harid 2026-05-01 14:22:32 +07:00
commit f1fc324828
2 changed files with 145 additions and 0 deletions

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

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