ต่อ api บุคคลที่สามารถติดต่อได้

This commit is contained in:
Kittapath 2023-10-06 01:28:37 +07:00
parent 20b031c29f
commit b8f12139e1
11 changed files with 3384 additions and 64 deletions

View file

@ -793,6 +793,21 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.FirstOrDefaultAsync();
}
public async Task<CandidateContactResponseItem?> GetsAsyncContact(string candidateId)
{
return await _context.Candidates.AsQueryable()
.Where(x => x.Id == Guid.Parse(candidateId))
.Select(x => new CandidateContactResponseItem
{
ContactPrefixId = x.ContactPrefixId,
ContactFirstname = x.ContactFirstname,
ContactLastname = x.ContactLastname,
ContactRelations = x.ContactRelations,
ContactTel = x.ContactTel,
})
.FirstOrDefaultAsync();
}
public async Task<CandidateAddressResponseItem?> GetsAsyncAddress(string candidateId)
{
return await _context.Candidates.AsQueryable()
@ -1063,7 +1078,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.Number = item.Number;
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สอบคัดเลือกสำเร็จ";
// if (candidate.Email != null&& candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
candidate.Status = "done";
}
else
@ -1072,7 +1087,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
// if (candidate.Email != null&& candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
}
// candidate.Status = "waiver";
}
@ -1083,7 +1098,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
// if (candidate.Email != null&& candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
}
// candidate.Status = "waiver";
}
@ -1287,37 +1302,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
Id = 3,
Name = "จำนวนผู้มีสิทธิ์เข้ารับคัดเลือกทั้งหมด",
Count = periodExam.Candidate.Where(x=>x.ExamIdenNumber != null).Count()
Count = periodExam.Candidate.Where(x=>x.Status!="register").Where(x=>x.ExamIdenNumber != null).Count()
},
new DashboardResponseItem
{
Id = 4,
Name = "จำนวนผู้เข้ารับการคัดเลือกทั้งหมด",
Count = periodExam.Candidate.Where(x=>x.SeatNumber != null).Count()
Count = periodExam.Candidate.Where(x=>x.Status!="register").Where(x=>x.SeatNumber != null).Count()
},
new DashboardResponseItem
{
Id = 5,
Name = "ผ่านการสอบ",
Count = periodExam.Candidate.Where(x=>x.Pass=="ผ่าน" || x.Pass=="ได้").Count()
Count = periodExam.Candidate.Where(x=>x.Status!="register").Where(x=>x.Pass=="ผ่าน" || x.Pass=="ได้").Count()
},
new DashboardResponseItem
{
Id = 6,
Name = "ไม่ผ่านการสอบ",
Count = periodExam.Candidate.Where(x=>x.Pass!=null && x.Pass!="ผ่าน" && x.Pass!="ได้").Count()
Count = periodExam.Candidate.Where(x=>x.Status!="register").Where(x=>x.Pass!=null && x.Pass!="ผ่าน" && x.Pass!="ได้").Count()
},
new DashboardResponseItem
{
Id = 7,
Name = "เพศชาย",
Count = periodExam.Candidate.Where(x=>x.PrefixName != null && x.PrefixName=="นาย").Count()
Count = periodExam.Candidate.Where(x=>x.Status!="register").Where(x=>x.PrefixName != null && x.PrefixName=="นาย").Count()
},
new DashboardResponseItem
{
Id = 8,
Name = "เพศหญิง",
Count = periodExam.Candidate.Where(x=>x.PrefixName != null && (x.PrefixName=="นาง" || x.PrefixName=="นางสาว")).Count()
Count = periodExam.Candidate.Where(x=>x.Status!="register").Where(x=>x.PrefixName != null && (x.PrefixName=="นาง" || x.PrefixName=="นางสาว")).Count()
},
// new DashboardResponseItem
// {
@ -1670,8 +1685,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
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.CreatedAt.Date <= item.DateEnd.Date)
// .Where(x => x.CreatedAt.Date >= item.DateStart.Date)
.Where(x => x.PeriodExam == periodExam)
.Where(x => x.Status != "register")
.Select(c => new
@ -1738,26 +1753,26 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
summarySheet.TabColor = System.Drawing.Color.Black;
// summarySheet.DefaultRowHeight = 17;
summarySheet.Column(1).Style.Font.Bold = true;
summarySheet.Row(4).Style.Font.Bold = true;
summarySheet.Row(4).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
summarySheet.Row(5).Style.Font.Bold = true;
summarySheet.Row(5).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
summarySheet.Row(6).Style.Font.Bold = true;
summarySheet.Cells[1, 3].Style.Font.Bold = true;
int rowName = 2;
int rowCount = 2;
int fixMerge = 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}";
summarySheet.Cells[4, 1].Value = "จำนวนผู้สมัคร";
summarySheet.Cells[4, 2].Value = candidates.Count().ToString();
// 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[1, 1].Value = "ชื่อรอบการสอบ/ชื่อประกาศ";
summarySheet.Cells[1, 2].Value = periodExam.Name;
summarySheet.Cells[2, 1].Value = "ครั้งที่";
summarySheet.Cells[2, 2].Value = $"{periodExam.Round}/{periodExam.Year + 543}";
summarySheet.Cells[3, 1].Value = "จำนวนผู้สมัคร";
summarySheet.Cells[3, 2].Value = candidates.Count().ToString();
if (candidates.Count() > 0)
{
summarySheet.Cells[7, 1].Value = "จำนวน";
summarySheet.Cells[6, 1].Value = "จำนวน";
// summarySheet.Cells[1, 6].Value = "คะแนนภาค ข";
// summarySheet.Cells[1, 7].Value = "ผลสอบภาค ข";
// summarySheet.Cells[1, 8].Value = "คะแนนเต็มภาค ค";
@ -1767,8 +1782,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
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)
.Where(x => x.Candidate.Status != "register")
// .Where(x => x.Candidate.CreatedAt.Date <= item.DateEnd.Date)
// .Where(x => x.Candidate.CreatedAt.Date >= item.DateStart.Date)
.GroupBy(x => x.EducationLevelExamName)
.Select(x => new
{
@ -1779,22 +1795,23 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
foreach (var education in educations)
{
summarySheet.Cells[6, rowName].Value = education.Name;
summarySheet.Cells[7, rowCount].Value = education.Count;
summarySheet.Cells[5, rowName].Value = education.Name;
summarySheet.Cells[6, rowCount].Value = education.Count;
rowName++;
rowCount++;
}
if (educations.Count() != 0)
{
summarySheet.Cells[5, fixMerge, 5, rowName - 1].Value = "วุฒิที่ใช้สมัครสอบ";
summarySheet.Cells[5, fixMerge, 5, rowName - 1].Merge = true;
summarySheet.Cells[4, fixMerge, 4, rowName - 1].Value = "วุฒิที่ใช้สมัครสอบ";
summarySheet.Cells[4, fixMerge, 4, rowName - 1].Merge = true;
fixMerge = 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)
.Where(x => x.Candidate.Status != "register")
// .Where(x => x.Candidate.CreatedAt.Date <= item.DateEnd.Date)
// .Where(x => x.Candidate.CreatedAt.Date >= item.DateStart.Date)
.GroupBy(x => x.Position)
.Select(x => new
{
@ -1804,47 +1821,47 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.ToListAsync();
foreach (var career in careers)
{
summarySheet.Cells[6, rowName].Value = career.Name;
summarySheet.Cells[7, rowCount].Value = career.Count;
summarySheet.Cells[5, rowName].Value = career.Name;
summarySheet.Cells[6, rowCount].Value = career.Count;
rowName++;
rowCount++;
}
if (careers.Count() != 0)
{
summarySheet.Cells[5, fixMerge, 5, rowName - 1].Value = "สถานที่ทำงาน/ฝึกงาน";
summarySheet.Cells[5, fixMerge, 5, rowName - 1].Merge = true;
summarySheet.Cells[4, fixMerge, 4, rowName - 1].Value = "สถานที่ทำงาน/ฝึกงาน";
summarySheet.Cells[4, fixMerge, 4, rowName - 1].Merge = true;
fixMerge = rowCount;
}
summarySheet.Cells[6, rowName].Value = "อายุ 1-20 ปี";
summarySheet.Cells[7, rowCount].Value = candidates.Where(x => x.Age >= 1 && x.Age <= 20).Count();
summarySheet.Cells[5, rowName].Value = "อายุ 1-20 ปี";
summarySheet.Cells[6, rowCount].Value = candidates.Where(x => x.Age >= 1 && x.Age <= 20).Count();
rowName++;
rowCount++;
summarySheet.Cells[6, rowName].Value = "อายุ 21-45 ปี";
summarySheet.Cells[7, rowCount].Value = candidates.Where(x => x.Age >= 21 && x.Age <= 45).Count();
summarySheet.Cells[5, rowName].Value = "อายุ 21-45 ปี";
summarySheet.Cells[6, rowCount].Value = candidates.Where(x => x.Age >= 21 && x.Age <= 45).Count();
rowName++;
rowCount++;
summarySheet.Cells[6, rowName].Value = "อายุ 46-60 ปี";
summarySheet.Cells[7, rowCount].Value = candidates.Where(x => x.Age >= 46 && x.Age <= 60).Count();
summarySheet.Cells[5, rowName].Value = "อายุ 46-60 ปี";
summarySheet.Cells[6, rowCount].Value = candidates.Where(x => x.Age >= 46 && x.Age <= 60).Count();
rowName++;
rowCount++;
summarySheet.Cells[6, rowName].Value = "อายุ 61-70 ปี";
summarySheet.Cells[7, rowCount].Value = candidates.Where(x => x.Age >= 61 && x.Age <= 70).Count();
summarySheet.Cells[5, rowName].Value = "อายุ 61-70 ปี";
summarySheet.Cells[6, rowCount].Value = candidates.Where(x => x.Age >= 61 && x.Age <= 70).Count();
rowName++;
rowCount++;
summarySheet.Cells[6, rowName].Value = "อายุ 71-80 ปี";
summarySheet.Cells[7, rowCount].Value = candidates.Where(x => x.Age >= 71 && x.Age <= 80).Count();
summarySheet.Cells[5, rowName].Value = "อายุ 71-80 ปี";
summarySheet.Cells[6, rowCount].Value = candidates.Where(x => x.Age >= 71 && x.Age <= 80).Count();
rowName++;
rowCount++;
summarySheet.Cells[6, rowName].Value = "อายุ 80 ปีขึ้นไป";
summarySheet.Cells[7, rowCount].Value = candidates.Where(x => x.Age >= 81).Count();
summarySheet.Cells[5, rowName].Value = "อายุ 80 ปีขึ้นไป";
summarySheet.Cells[6, rowCount].Value = candidates.Where(x => x.Age >= 81).Count();
rowName++;
rowCount++;
summarySheet.Cells[5, fixMerge, 5, rowName - 1].Value = "ช่วงอายุ";
summarySheet.Cells[5, fixMerge, 5, rowName - 1].Merge = true;
summarySheet.Cells[4, fixMerge, 4, rowName - 1].Value = "ช่วงอายุ";
summarySheet.Cells[4, fixMerge, 4, rowName - 1].Merge = true;
}
else
{
summarySheet.Cells[7, 1].Value = "ไม่มีผู้สมัครสอบในช่วงเวลานี้";
summarySheet.Cells[6, 1].Value = "ไม่มีผู้สมัครสอบในช่วงเวลานี้";
}
summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
package.Save();