[MA] สรรหาสอบแข่งขัน ไฟล์รายชื่อต้องแบ่งตามตำแหน่ง #1530
This commit is contained in:
parent
d0d315d0f3
commit
2195624d6f
1 changed files with 73 additions and 0 deletions
|
|
@ -306,6 +306,79 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// แสดงรายชื่อแบ่งตามตำแหน่ง (สอบแข่งขัน)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">รหัสรอบการสอบ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("candidate-new/{id:length(36)}")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<ActionResult<ResponseObject>> 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)}")]
|
[HttpGet("pass/{id:length(36)}")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue