สอบคัดเลือกโหลดสรุปข้อมูลการสอบ
This commit is contained in:
parent
1d4043a50e
commit
4b07fe7409
3 changed files with 250 additions and 134 deletions
|
|
@ -13,7 +13,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
[ApiVersion("1.0")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
[AllowAnonymous]
|
||||
// [Authorize]
|
||||
[SwaggerTag("จัดการข้อมูลรอบการสอบ เพื่อนำไปใช้งานในระบบ")]
|
||||
public class PeriodExamController : BaseController
|
||||
{
|
||||
|
|
@ -698,6 +699,34 @@ 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>
|
||||
[HttpPut("download/dashboard/{examId:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetsDashboardExamAsync(string examId, RequestCandidateDashboard item)
|
||||
{
|
||||
try
|
||||
{
|
||||
var stream = await _periodExamService.GetsDashboardExamAsync(item, examId);
|
||||
|
||||
string excelName = $"Candidate_{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx";
|
||||
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", excelName);
|
||||
// return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ข้อมูลตำแหน่งสมัครสอบ
|
||||
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||
|
|
|
|||
10
Request/RequestCandidateDashboard.cs
Normal file
10
Request/RequestCandidateDashboard.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System.Net;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Request
|
||||
{
|
||||
public class RequestCandidateDashboard
|
||||
{
|
||||
public DateTime DateStart { get; set; }
|
||||
public DateTime DateEnd { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1130,56 +1130,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
// var _candidates = (from c in _context.Candidates
|
||||
// where c.PeriodExam == periodExam
|
||||
// select new
|
||||
// {
|
||||
// Id = c.Id,
|
||||
// Status = c.Status,
|
||||
// CitizenId = c.CitizenId,
|
||||
// FullName = $"{c.PrefixName}{c.FirstName} {c.LastName}",
|
||||
// Nationality = c.Nationality,
|
||||
// DateOfBirth = c.DateOfBirth == null ? "" : c.DateOfBirth.Value.Date.ToThaiShortDate(),
|
||||
// Age = c.DateOfBirth == null ? "" : c.DateOfBirth.Value.Date.CalculateGovAgeStr(0, 0),
|
||||
// RelationshipName = c.RelationshipName,
|
||||
// Telephone = c.Telephone,
|
||||
// MobilePhone = c.MobilePhone,
|
||||
// Email = c.Email,
|
||||
// Knowledge = c.Knowledge,
|
||||
// RegistAddress = c.RegistAddress,
|
||||
// RegistProvinceName = c.RegistProvinceName,
|
||||
// RegistDistrictName = c.RegistDistrictName,
|
||||
// RegistSubDistrictName = c.RegistSubDistrictName,
|
||||
// RegistZipCode = c.RegistZipCode,
|
||||
// CurrentAddress = c.CurrentAddress,
|
||||
// CurrentProvinceName = c.CurrentProvinceName,
|
||||
// CurrentDistrictName = c.CurrentDistrictName,
|
||||
// CurrentSubDistrictName = c.CurrentSubDistrictName,
|
||||
// CurrentZipCode = c.CurrentZipCode,
|
||||
// MarryFullName = $"{c.MarryPrefixName}{c.MarryFirstName} {c.MarryLastName}",
|
||||
// FatherFullName = $"{c.FatherPrefixName}{c.FatherFirstName} {c.FatherLastName}",
|
||||
// MotherFullName = $"{c.MotherPrefixName}{c.MotherFirstName} {c.MotherLastName}",
|
||||
// OccupationType = c.OccupationType,
|
||||
// OccupationPosition = c.OccupationPosition,
|
||||
// OccupationCompany = c.OccupationCompany,
|
||||
// OccupationDepartment = c.OccupationDepartment,
|
||||
// OccupationEmail = c.OccupationEmail,
|
||||
// OccupationTelephone = c.OccupationTelephone,
|
||||
|
||||
|
||||
// Number = c.Number,
|
||||
// ExamIdenNumber = c.ExamIdenNumber,
|
||||
// SeatNumber = c.SeatNumber,
|
||||
// PointTotalB = c.PointTotalB,
|
||||
// PointB = c.PointB,
|
||||
// ResultB = c.ResultB,
|
||||
// PointTotalC = c.PointTotalC,
|
||||
// PointC = c.PointC,
|
||||
// ResultC = c.ResultC,
|
||||
// Pass = c.Pass,
|
||||
// }
|
||||
// ).ToList();
|
||||
|
||||
var candidates = await _context.Candidates
|
||||
.AsQueryable()
|
||||
.OrderBy(x => x.ExamIdenNumber)
|
||||
|
|
@ -1229,6 +1179,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
PointC = c.PointC,
|
||||
ResultC = c.ResultC,
|
||||
Pass = c.Pass,
|
||||
CreatedAt = c.CreatedAt,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
|
@ -1291,52 +1242,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
summarySheet.Cells[1, 50].Value = "คะแนนภาค ค";
|
||||
summarySheet.Cells[1, 51].Value = "ผลสอบภาค ค";
|
||||
summarySheet.Cells[1, 52].Value = "ผลการสอบ";
|
||||
summarySheet.Cells[1, 53].Value = "วันที่สมัคร";
|
||||
int row = 2;
|
||||
|
||||
foreach (var item in candidates)
|
||||
{
|
||||
summarySheet.Cells[row, 1].Value = GenerateStatusCandidate(item.Status);
|
||||
summarySheet.Cells[row, 2].Value = item.CitizenId;
|
||||
summarySheet.Cells[row, 3].Value = item.FullName;
|
||||
summarySheet.Cells[row, 4].Value = item.Nationality;
|
||||
summarySheet.Cells[row, 5].Value = item.DateOfBirth;
|
||||
summarySheet.Cells[row, 6].Value = item.Age;
|
||||
summarySheet.Cells[row, 7].Value = item.RelationshipName;
|
||||
summarySheet.Cells[row, 8].Value = item.Telephone;
|
||||
summarySheet.Cells[row, 9].Value = item.MobilePhone;
|
||||
summarySheet.Cells[row, 10].Value = item.Email;
|
||||
summarySheet.Cells[row, 11].Value = item.Knowledge;
|
||||
summarySheet.Cells[row, 12].Value = item.RegistAddress;
|
||||
summarySheet.Cells[row, 13].Value = item.RegistProvinceName;
|
||||
summarySheet.Cells[row, 14].Value = item.RegistDistrictName;
|
||||
summarySheet.Cells[row, 15].Value = item.RegistSubDistrictName;
|
||||
summarySheet.Cells[row, 16].Value = item.RegistZipCode;
|
||||
summarySheet.Cells[row, 17].Value = item.CurrentAddress;
|
||||
summarySheet.Cells[row, 18].Value = item.CurrentProvinceName;
|
||||
summarySheet.Cells[row, 19].Value = item.CurrentDistrictName;
|
||||
summarySheet.Cells[row, 20].Value = item.CurrentSubDistrictName;
|
||||
summarySheet.Cells[row, 21].Value = item.CurrentZipCode;
|
||||
summarySheet.Cells[row, 22].Value = item.MarryFullName;
|
||||
summarySheet.Cells[row, 23].Value = item.FatherFullName;
|
||||
summarySheet.Cells[row, 24].Value = item.MotherFullName;
|
||||
summarySheet.Cells[row, 25].Value = GenerateStatusOccupation(item.OccupationType);
|
||||
summarySheet.Cells[row, 26].Value = item.OccupationPosition;
|
||||
summarySheet.Cells[row, 27].Value = item.OccupationCompany;
|
||||
summarySheet.Cells[row, 28].Value = item.OccupationDepartment;
|
||||
summarySheet.Cells[row, 29].Value = item.OccupationEmail;
|
||||
summarySheet.Cells[row, 30].Value = item.OccupationTelephone;
|
||||
|
||||
summarySheet.Cells[row, 43].Value = item.Number;
|
||||
summarySheet.Cells[row, 44].Value = item.ExamIdenNumber;
|
||||
summarySheet.Cells[row, 45].Value = item.SeatNumber;
|
||||
summarySheet.Cells[row, 46].Value = item.PointTotalB;
|
||||
summarySheet.Cells[row, 47].Value = item.PointB;
|
||||
summarySheet.Cells[row, 48].Value = item.ResultB;
|
||||
summarySheet.Cells[row, 49].Value = item.PointTotalC;
|
||||
summarySheet.Cells[row, 50].Value = item.PointC;
|
||||
summarySheet.Cells[row, 51].Value = item.ResultC;
|
||||
summarySheet.Cells[row, 52].Value = item.Pass;
|
||||
row++;
|
||||
var educations = await _context.Educations
|
||||
.AsQueryable()
|
||||
.OrderBy(x => x.DurationStart)
|
||||
|
|
@ -1391,6 +1301,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
summarySheet.Cells[row, 50].Value = item.PointC;
|
||||
summarySheet.Cells[row, 51].Value = item.ResultC;
|
||||
summarySheet.Cells[row, 52].Value = item.Pass;
|
||||
summarySheet.Cells[row, 53].Value = item.CreatedAt.Date.ToThaiShortDate();
|
||||
row++;
|
||||
}
|
||||
var careers = await _context.Careers
|
||||
|
|
@ -1447,6 +1358,53 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
summarySheet.Cells[row, 50].Value = item.PointC;
|
||||
summarySheet.Cells[row, 51].Value = item.ResultC;
|
||||
summarySheet.Cells[row, 52].Value = item.Pass;
|
||||
summarySheet.Cells[row, 53].Value = item.CreatedAt.Date.ToThaiShortDate();
|
||||
row++;
|
||||
}
|
||||
if (educations.Count() == 0 && careers.Count() == 0)
|
||||
{
|
||||
summarySheet.Cells[row, 1].Value = GenerateStatusCandidate(item.Status);
|
||||
summarySheet.Cells[row, 2].Value = item.CitizenId;
|
||||
summarySheet.Cells[row, 3].Value = item.FullName;
|
||||
summarySheet.Cells[row, 4].Value = item.Nationality;
|
||||
summarySheet.Cells[row, 5].Value = item.DateOfBirth;
|
||||
summarySheet.Cells[row, 6].Value = item.Age;
|
||||
summarySheet.Cells[row, 7].Value = item.RelationshipName;
|
||||
summarySheet.Cells[row, 8].Value = item.Telephone;
|
||||
summarySheet.Cells[row, 9].Value = item.MobilePhone;
|
||||
summarySheet.Cells[row, 10].Value = item.Email;
|
||||
summarySheet.Cells[row, 11].Value = item.Knowledge;
|
||||
summarySheet.Cells[row, 12].Value = item.RegistAddress;
|
||||
summarySheet.Cells[row, 13].Value = item.RegistProvinceName;
|
||||
summarySheet.Cells[row, 14].Value = item.RegistDistrictName;
|
||||
summarySheet.Cells[row, 15].Value = item.RegistSubDistrictName;
|
||||
summarySheet.Cells[row, 16].Value = item.RegistZipCode;
|
||||
summarySheet.Cells[row, 17].Value = item.CurrentAddress;
|
||||
summarySheet.Cells[row, 18].Value = item.CurrentProvinceName;
|
||||
summarySheet.Cells[row, 19].Value = item.CurrentDistrictName;
|
||||
summarySheet.Cells[row, 20].Value = item.CurrentSubDistrictName;
|
||||
summarySheet.Cells[row, 21].Value = item.CurrentZipCode;
|
||||
summarySheet.Cells[row, 22].Value = item.MarryFullName;
|
||||
summarySheet.Cells[row, 23].Value = item.FatherFullName;
|
||||
summarySheet.Cells[row, 24].Value = item.MotherFullName;
|
||||
summarySheet.Cells[row, 25].Value = GenerateStatusOccupation(item.OccupationType);
|
||||
summarySheet.Cells[row, 26].Value = item.OccupationPosition;
|
||||
summarySheet.Cells[row, 27].Value = item.OccupationCompany;
|
||||
summarySheet.Cells[row, 28].Value = item.OccupationDepartment;
|
||||
summarySheet.Cells[row, 29].Value = item.OccupationEmail;
|
||||
summarySheet.Cells[row, 30].Value = item.OccupationTelephone;
|
||||
|
||||
summarySheet.Cells[row, 43].Value = item.Number;
|
||||
summarySheet.Cells[row, 44].Value = item.ExamIdenNumber;
|
||||
summarySheet.Cells[row, 45].Value = item.SeatNumber;
|
||||
summarySheet.Cells[row, 46].Value = item.PointTotalB;
|
||||
summarySheet.Cells[row, 47].Value = item.PointB;
|
||||
summarySheet.Cells[row, 48].Value = item.ResultB;
|
||||
summarySheet.Cells[row, 49].Value = item.PointTotalC;
|
||||
summarySheet.Cells[row, 50].Value = item.PointC;
|
||||
summarySheet.Cells[row, 51].Value = item.ResultC;
|
||||
summarySheet.Cells[row, 52].Value = item.Pass;
|
||||
summarySheet.Cells[row, 53].Value = item.CreatedAt.Date.ToThaiShortDate();
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1458,51 +1416,170 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
return stream;
|
||||
}
|
||||
|
||||
// public async Task<MemoryStream> GetsDashboardExamAsync(string examId)
|
||||
// {
|
||||
// var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
// .FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
public async Task<MemoryStream> GetsDashboardExamAsync(RequestCandidateDashboard item, string examId)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
// if (periodExam == null)
|
||||
// throw new Exception(GlobalMessages.ExamNotFound);
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
// var stream = new MemoryStream();
|
||||
// using (var package = new ExcelPackage(stream))
|
||||
// {
|
||||
// var summarySheet = package.Workbook.Worksheets.Add("Dashboard");
|
||||
// summarySheet.TabColor = System.Drawing.Color.Black;
|
||||
// // summarySheet.DefaultRowHeight = 17;
|
||||
// summarySheet.Row(1).Style.Font.Bold = true;
|
||||
// summarySheet.Cells[1, 1].Value = "จำนวนผู้สมัครคัดเลือกทั้งหมด";
|
||||
// summarySheet.Cells[1, 2].Value = "จำนวนผู้มีสิทธิ์เข้ารับคัดเลือกทั้งหมด";
|
||||
// summarySheet.Cells[1, 3].Value = "จำนวนผู้เข้ารับการคัดเลือกทั้งหมด";
|
||||
// summarySheet.Cells[1, 4].Value = "ผ่านการสอบ";
|
||||
// summarySheet.Cells[1, 5].Value = "ไม่ผ่านการสอบ";
|
||||
// summarySheet.Cells[1, 6].Value = "คะแนนภาค ข";
|
||||
// summarySheet.Cells[1, 7].Value = "ผลสอบภาค ข";
|
||||
// summarySheet.Cells[1, 8].Value = "คะแนนเต็มภาค ค";
|
||||
// summarySheet.Cells[1, 9].Value = "คะแนนภาค ค";
|
||||
// summarySheet.Cells[1, 10].Value = "ผลสอบภาค ค";
|
||||
// summarySheet.Cells[1, 11].Value = "ผลการสอบ";
|
||||
var candidates = await _context.Candidates
|
||||
.AsQueryable()
|
||||
.OrderBy(x => x.ExamIdenNumber)
|
||||
.Where(x => x.CreatedAt.Date <= item.DateEnd.Date)
|
||||
.Where(x => x.CreatedAt.Date >= item.DateStart.Date)
|
||||
.Where(x => x.PeriodExam == periodExam)
|
||||
.Select(c => new
|
||||
{
|
||||
Id = c.Id,
|
||||
Status = c.Status,
|
||||
CitizenId = c.CitizenId,
|
||||
FullName = $"{c.PrefixName}{c.FirstName} {c.LastName}",
|
||||
Nationality = c.Nationality,
|
||||
DateOfBirth = c.DateOfBirth == null ? "" : c.DateOfBirth.Value.Date.ToThaiShortDate(),
|
||||
Age = c.DateOfBirth == null ? 0 : DateTime.Now.Date.Year - c.DateOfBirth.Value.Date.Year,
|
||||
RelationshipName = c.RelationshipName,
|
||||
Telephone = c.Telephone,
|
||||
MobilePhone = c.MobilePhone,
|
||||
Email = c.Email,
|
||||
Knowledge = c.Knowledge,
|
||||
RegistAddress = c.RegistAddress,
|
||||
RegistProvinceName = c.RegistProvinceName,
|
||||
RegistDistrictName = c.RegistDistrictName,
|
||||
RegistSubDistrictName = c.RegistSubDistrictName,
|
||||
RegistZipCode = c.RegistZipCode,
|
||||
CurrentAddress = c.CurrentAddress,
|
||||
CurrentProvinceName = c.CurrentProvinceName,
|
||||
CurrentDistrictName = c.CurrentDistrictName,
|
||||
CurrentSubDistrictName = c.CurrentSubDistrictName,
|
||||
CurrentZipCode = c.CurrentZipCode,
|
||||
MarryFullName = $"{c.MarryPrefixName}{c.MarryFirstName} {c.MarryLastName}",
|
||||
FatherFullName = $"{c.FatherPrefixName}{c.FatherFirstName} {c.FatherLastName}",
|
||||
MotherFullName = $"{c.MotherPrefixName}{c.MotherFirstName} {c.MotherLastName}",
|
||||
OccupationType = c.OccupationType,
|
||||
OccupationPosition = c.OccupationPosition,
|
||||
OccupationCompany = c.OccupationCompany,
|
||||
OccupationDepartment = c.OccupationDepartment,
|
||||
OccupationEmail = c.OccupationEmail,
|
||||
OccupationTelephone = c.OccupationTelephone,
|
||||
Number = c.Number,
|
||||
ExamIdenNumber = c.ExamIdenNumber,
|
||||
SeatNumber = c.SeatNumber,
|
||||
PointTotalB = c.PointTotalB,
|
||||
PointB = c.PointB,
|
||||
ResultB = c.ResultB,
|
||||
PointTotalC = c.PointTotalC,
|
||||
PointC = c.PointC,
|
||||
ResultC = c.ResultC,
|
||||
Pass = c.Pass,
|
||||
CreatedAt = c.CreatedAt,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// summarySheet.Cells[2, 1].Value = periodExam;
|
||||
// summarySheet.Cells[2, 2].Value = periodExam;
|
||||
// summarySheet.Cells[2, 3].Value = periodExam;
|
||||
// summarySheet.Cells[2, 4].Value = periodExam;
|
||||
// summarySheet.Cells[2, 5].Value = periodExam;
|
||||
// summarySheet.Cells[2, 6].Value = periodExam;
|
||||
// summarySheet.Cells[2, 7].Value = periodExam;
|
||||
// summarySheet.Cells[2, 8].Value = periodExam;
|
||||
// summarySheet.Cells[2, 9].Value = periodExam;
|
||||
// summarySheet.Cells[2, 10].Value = periodExam;
|
||||
// summarySheet.Cells[2, 11].Value = periodExam;
|
||||
// summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
|
||||
// package.Save();
|
||||
// }
|
||||
var stream = new MemoryStream();
|
||||
using (var package = new ExcelPackage(stream))
|
||||
{
|
||||
var summarySheet = package.Workbook.Worksheets.Add("Dashboard");
|
||||
summarySheet.TabColor = System.Drawing.Color.Black;
|
||||
// summarySheet.DefaultRowHeight = 17;
|
||||
summarySheet.Column(1).Style.Font.Bold = true;
|
||||
summarySheet.Row(4).Style.Font.Bold = true;
|
||||
summarySheet.Cells[1, 3].Style.Font.Bold = true;
|
||||
int rowName = 2;
|
||||
int rowCount = 2;
|
||||
summarySheet.Cells[1, 1].Value = "ตั้งแต่";
|
||||
summarySheet.Cells[1, 2].Value = item.DateStart.Date.ToThaiShortDate();
|
||||
summarySheet.Cells[1, 3].Value = "ถึง";
|
||||
summarySheet.Cells[1, 4].Value = item.DateEnd.Date.ToThaiShortDate();
|
||||
summarySheet.Cells[2, 1].Value = "ชื่อรอบการสอบ/ชื่อประกาศ";
|
||||
summarySheet.Cells[2, 2].Value = periodExam.Name;
|
||||
summarySheet.Cells[3, 1].Value = "ครั้งที่";
|
||||
summarySheet.Cells[3, 2].Value = $"{periodExam.Round}/{periodExam.Year + 543}";
|
||||
if (candidates.Count() > 0)
|
||||
{
|
||||
summarySheet.Cells[5, 1].Value = "จำนวน";
|
||||
// summarySheet.Cells[1, 6].Value = "คะแนนภาค ข";
|
||||
// summarySheet.Cells[1, 7].Value = "ผลสอบภาค ข";
|
||||
// summarySheet.Cells[1, 8].Value = "คะแนนเต็มภาค ค";
|
||||
// summarySheet.Cells[1, 9].Value = "คะแนนภาค ค";
|
||||
// summarySheet.Cells[1, 10].Value = "ผลสอบภาค ค";
|
||||
// summarySheet.Cells[1, 11].Value = "ผลการสอบ";
|
||||
var educations = await _context.Educations
|
||||
.AsQueryable()
|
||||
.Where(x => x.Candidate.PeriodExam == periodExam)
|
||||
.Where(x => x.Candidate.CreatedAt.Date <= item.DateEnd.Date)
|
||||
.Where(x => x.Candidate.CreatedAt.Date >= item.DateStart.Date)
|
||||
.GroupBy(x => x.EducationLevelName)
|
||||
.Select(x => new
|
||||
{
|
||||
Name = x.Key,
|
||||
Count = x.Count(),
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// stream.Position = 0;
|
||||
// return stream;
|
||||
// }
|
||||
foreach (var education in educations)
|
||||
{
|
||||
summarySheet.Cells[4, rowName].Value = education.Name;
|
||||
summarySheet.Cells[5, rowCount].Value = education.Count;
|
||||
rowName++;
|
||||
rowCount++;
|
||||
}
|
||||
var careers = await _context.Careers
|
||||
.AsQueryable()
|
||||
.Where(x => x.Candidate.PeriodExam == periodExam)
|
||||
.Where(x => x.Candidate.CreatedAt.Date <= item.DateEnd.Date)
|
||||
.Where(x => x.Candidate.CreatedAt.Date >= item.DateStart.Date)
|
||||
.GroupBy(x => x.Name)
|
||||
.Select(x => new
|
||||
{
|
||||
Name = x.Key,
|
||||
Count = x.Count(),
|
||||
})
|
||||
.ToListAsync();
|
||||
foreach (var career in careers)
|
||||
{
|
||||
summarySheet.Cells[4, rowName].Value = career.Name;
|
||||
summarySheet.Cells[5, rowCount].Value = career.Count;
|
||||
rowName++;
|
||||
rowCount++;
|
||||
}
|
||||
summarySheet.Cells[4, rowName].Value = "อายุ 1-20 ปี";
|
||||
summarySheet.Cells[5, rowCount].Value = candidates.Where(x => x.Age >= 1 && x.Age <= 20).Count();
|
||||
rowName++;
|
||||
rowCount++;
|
||||
summarySheet.Cells[4, rowName].Value = "อายุ 21-45 ปี";
|
||||
summarySheet.Cells[5, rowCount].Value = candidates.Where(x => x.Age >= 21 && x.Age <= 45).Count();
|
||||
rowName++;
|
||||
rowCount++;
|
||||
summarySheet.Cells[4, rowName].Value = "อายุ 46-60 ปี";
|
||||
summarySheet.Cells[5, rowCount].Value = candidates.Where(x => x.Age >= 46 && x.Age <= 60).Count();
|
||||
rowName++;
|
||||
rowCount++;
|
||||
summarySheet.Cells[4, rowName].Value = "อายุ 61-70 ปี";
|
||||
summarySheet.Cells[5, rowCount].Value = candidates.Where(x => x.Age >= 61 && x.Age <= 70).Count();
|
||||
rowName++;
|
||||
rowCount++;
|
||||
summarySheet.Cells[4, rowName].Value = "อายุ 71-80 ปี";
|
||||
summarySheet.Cells[5, rowCount].Value = candidates.Where(x => x.Age >= 71 && x.Age <= 80).Count();
|
||||
rowName++;
|
||||
rowCount++;
|
||||
summarySheet.Cells[4, rowName].Value = "อายุ 80 ปีขึ้นไป";
|
||||
summarySheet.Cells[5, rowCount].Value = candidates.Where(x => x.Age >= 81).Count();
|
||||
rowName++;
|
||||
rowCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
summarySheet.Cells[5, 1].Value = "ไม่มีผู้สมัครสอบในช่วงเวลานี้";
|
||||
}
|
||||
summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
|
||||
package.Save();
|
||||
}
|
||||
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue