diff --git a/Controllers/RecruitReportController.cs b/Controllers/RecruitReportController.cs
index aca0aab..5cd07d8 100644
--- a/Controllers/RecruitReportController.cs
+++ b/Controllers/RecruitReportController.cs
@@ -306,6 +306,79 @@ namespace BMA.EHR.Report.Service.Controllers
}
}
+ ///
+ /// แสดงรายชื่อแบ่งตามตำแหน่ง (สอบแข่งขัน)
+ ///
+ /// รหัสรอบการสอบ
+ ///
+ /// เมื่อแสดงรายงานสำเร็จ
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("candidate-new/{id:length(36)}")]
+ [AllowAnonymous]
+ public async Task> GetCandidateNewListReportAsync(Guid id)
+ {
+ try
+ {
+ var data = await _context.Recruits.AsQueryable()
+ .Include(x => x.RecruitImport)
+ .Include(x => x.Payments)
+ .Include(x => x.Documents)
+ .ThenInclude(x => x.DocumentFile)
+ .Where(x => x.RecruitImport.Id == id)
+ .OrderBy(x => x.ExamId)
+ .Select(p => new
+ {
+ FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
+ PositionName = p.PositionName,
+ Remark = p.Remark != null ? p.Remark.ToThaiNumber() : "",
+ RefNo1 = p.Payments.Select(x => x.RefNo1).FirstOrDefault() != null
+ ? p.Payments.Select(x => x.RefNo1).FirstOrDefault().ToThaiNumber()
+ : "",
+ ExamName =
+ $"ครั้งที่ {p.RecruitImport.Order.ToString().ToThaiNumber()}/{p.RecruitImport.Year.ToThaiYear().ToString().ToThaiNumber()}",
+ }).ToListAsync();
+
+ if (data.Count == 0) return Error("ไม่พบข้อมูลในระบบ");
+
+ var examName = data[0].ExamName;
+
+ var groupData = data
+ .GroupBy(x => x.PositionName)
+ .Select(g => new
+ {
+ PositionName = $"ตำแหน่ง {g.Key}",
+ Total = $"จำนวน {g.Count().ToString().ToThaiNumber()} ราย",
+ Persons = g.Select((x, index) => new
+ {
+ No = (index + 1).ToString().ToThaiNumber(),
+ RefNo1 = x.RefNo1,
+ FullName = x.FullName,
+ Remark = x.Remark
+ }).ToList()
+ })
+ .ToList();
+
+ var _data = new
+ {
+ template = "rptCandidateList-New",
+ reportName = $"รายชื่อแบ่งตามตำแหน่ง(สอบแข่งขัน)",
+ data = new
+ {
+ examName = examName,
+ data = groupData
+ }
+ };
+ return Success(_data);
+
+ }
+ catch (Exception ex)
+ {
+ return Error(ex);
+ }
+ }
+
[HttpGet("pass/{id:length(36)}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]