ต่อ 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

@ -197,6 +197,33 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
/// <summary>
/// ข้อมูล บุคคลที่สามารถติดต่อได้
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <param name="positionId">Id ตำแหน่งสมัครสอบ</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการดึง ข้อมูล บุคคลที่สามารถติดต่อได้ สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("contact/{examId:length(36)}/{positionId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetsAsyncContact(string examId, string positionId)
{
try
{
var items = await _candidateService.GetsAsyncContact(examId, positionId);
return Success(items);
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// ข้อมูล ประวัติการทำงาน/ฝึกงาน ผู้สมัคร
/// </summary>
@ -445,6 +472,34 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
/// <summary>
/// อัพเดทข้อมูล บุคคลที่สามารถติดต่อได้
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <param name="positionId">Id ตำแหน่งสมัครสอบ</param>
/// <param name="candidateContact">อาชีพ</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอัพเดทข้อมูล บุคคลที่สามารถติดต่อได้ สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("contact/{examId:length(36)}/{positionId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> UpdateAsyncContact(string examId, string positionId, CandidateContactResponseItem candidateContact)
{
try
{
await _candidateService.UpdateAsyncContact(examId, positionId, candidateContact);
return Success();
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// สร้างข้อมูล ประวัติการทำงาน/ฝึกงาน ผู้สมัคร
/// </summary>

View file

@ -467,6 +467,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
/// <summary>
/// ข้อมูล บุคคลที่สามารถติดต่อได้
/// </summary>
/// <param name="candidate">รหัสผู้สมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการดึง ข้อมูล บุคคลที่สามารถติดต่อได้ สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("contact/{candidate:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetsAsyncContact(string candidate)
{
try
{
var items = await _periodExamService.GetsAsyncContact(candidate);
return Success(items);
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// ข้อมูล ประวัติการทำงาน/ฝึกงาน ผู้สมัคร
/// </summary>

View file

@ -392,6 +392,30 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnType("longtext")
.HasComment("จังหวัดที่ออกบัตรประชาชน");
b.Property<string>("ContactFirstname")
.HasColumnType("longtext")
.HasComment("ชื่อ บุคคลที่สามารถติดต่อได้");
b.Property<string>("ContactLastname")
.HasColumnType("longtext")
.HasComment("สกุล บุคคลที่สามารถติดต่อได้");
b.Property<Guid?>("ContactPrefixId")
.HasColumnType("char(36)")
.HasComment("Id คำนำหน้า บุคคลที่สามารถติดต่อได้");
b.Property<string>("ContactPrefixName")
.HasColumnType("longtext")
.HasComment("คำนำหน้า บุคคลที่สามารถติดต่อได้");
b.Property<string>("ContactRelations")
.HasColumnType("longtext")
.HasComment("เกี่ยวข้องเป็น บุคคลที่สามารถติดต่อได้");
b.Property<string>("ContactTel")
.HasColumnType("longtext")
.HasComment("โทรศัพท์ บุคคลที่สามารถติดต่อได้");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,91 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class UpdateTableCandidateaddcontact : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ContactFirstname",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "ชื่อ บุคคลที่สามารถติดต่อได้")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ContactLastname",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "สกุล บุคคลที่สามารถติดต่อได้")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<Guid>(
name: "ContactPrefixId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id คำนำหน้า บุคคลที่สามารถติดต่อได้",
collation: "ascii_general_ci");
migrationBuilder.AddColumn<string>(
name: "ContactPrefixName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "คำนำหน้า บุคคลที่สามารถติดต่อได้")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ContactRelations",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "เกี่ยวข้องเป็น บุคคลที่สามารถติดต่อได้")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ContactTel",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "โทรศัพท์ บุคคลที่สามารถติดต่อได้")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ContactFirstname",
table: "Candidates");
migrationBuilder.DropColumn(
name: "ContactLastname",
table: "Candidates");
migrationBuilder.DropColumn(
name: "ContactPrefixId",
table: "Candidates");
migrationBuilder.DropColumn(
name: "ContactPrefixName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "ContactRelations",
table: "Candidates");
migrationBuilder.DropColumn(
name: "ContactTel",
table: "Candidates");
}
}
}

View file

@ -295,6 +295,26 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
[Comment("วันที่ชำระเงิน")]
public DateTime? PaymentDate { get; set; }
[Comment("Id คำนำหน้า บุคคลที่สามารถติดต่อได้")]
public Guid? ContactPrefixId { get; set; }
[Comment("คำนำหน้า บุคคลที่สามารถติดต่อได้")]
public string? ContactPrefixName { get; set; }
[Comment("ชื่อ บุคคลที่สามารถติดต่อได้")]
public string? ContactFirstname { get; set; }
[Comment("สกุล บุคคลที่สามารถติดต่อได้")]
public string? ContactLastname { get; set; }
[Comment("เกี่ยวข้องเป็น บุคคลที่สามารถติดต่อได้")]
public string? ContactRelations { get; set; }
[Comment("โทรศัพท์ บุคคลที่สามารถติดต่อได้")]
public string? ContactTel { get; set; }
public virtual List<Education> Educations { get; set; } = new List<Education>();
}

View file

@ -4,7 +4,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
{
public class RequestCandidateDashboard
{
public DateTime DateStart { get; set; }
public DateTime DateEnd { get; set; }
public DateTime? DateStart { get; set; }
public DateTime? DateEnd { get; set; }
}
}

View file

@ -0,0 +1,12 @@

namespace BMA.EHR.Recurit.Exam.Service.Response
{
public class CandidateContactResponseItem
{
public Guid? ContactPrefixId { get; set; }
public string? ContactFirstname { get; set; }
public string? ContactLastname { get; set; }
public string? ContactRelations { get; set; }
public string? ContactTel { get; set; }
}
}

View file

@ -480,7 +480,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Positions = x.PositionExam.OrderBy(x => x.CreatedAt).Select(s => new HomePageLinkResponseItem
{
Id = s.Id.ToString(),
Title = s.PositionName == null ? x.Name : s.PositionName,
Title = $"{(s.PositionName == null ? x.Name : s.PositionName)}{(s.PositionLevelName == null ? "" : s.PositionLevelName)}",
Level = s.PositionLevelName == null ? "-" : s.PositionLevelName,
HighDegree = s.HighDegree == true ? "ปริญญาบัตรขึ้นไป" : "ต่ำกว่าปริญญาบัตร",
Path = $"{x.Id}/{s.Id}",
@ -489,7 +489,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
PositionsTrue = x.PositionExam.OrderBy(x => x.CreatedAt).Where(x => x.HighDegree == true).Select(s => new HomePageLinkResponseItem
{
Id = s.Id.ToString(),
Title = s.PositionName == null ? x.Name : s.PositionName,
Title = $"{(s.PositionName == null ? x.Name : s.PositionName)}{(s.PositionLevelName == null ? "" : s.PositionLevelName)}",
Level = s.PositionLevelName == null ? "-" : s.PositionLevelName,
HighDegree = s.HighDegree == true ? "ปริญญาบัตรขึ้นไป" : "ต่ำกว่าปริญญาบัตร",
Path = $"{x.Id}/{s.Id}",
@ -498,7 +498,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
PositionsFalse = x.PositionExam.OrderBy(x => x.CreatedAt).Where(x => x.HighDegree == false).Select(s => new HomePageLinkResponseItem
{
Id = s.Id.ToString(),
Title = s.PositionName == null ? x.Name : s.PositionName,
Title = $"{(s.PositionName == null ? x.Name : s.PositionName)}{(s.PositionLevelName == null ? "" : s.PositionLevelName)}",
Level = s.PositionLevelName == null ? "-" : s.PositionLevelName,
HighDegree = s.HighDegree == true ? "ปริญญาบัตรขึ้นไป" : "ต่ำกว่าปริญญาบัตร",
Path = $"{x.Id}/{s.Id}",

View file

@ -323,6 +323,51 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
}
}
public async Task<CandidateContactResponseItem?> GetsAsyncContact(string examId, string positionId)
{
var exam = await _context.PeriodExams.AsQueryable()
.Where(p => p.CheckDisability == false)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (exam == null)
throw new Exception(GlobalMessages.ExamNotFound);
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
return await _context.Candidates.AsQueryable()
.Where(x => x.PeriodExam == exam && x.UserId == UserId && x.PositionExam == position)
.Select(x => new CandidateContactResponseItem
{
ContactPrefixId = x.ContactPrefixId,
ContactFirstname = x.ContactFirstname,
ContactLastname = x.ContactLastname,
ContactRelations = x.ContactRelations,
ContactTel = x.ContactTel,
})
.FirstOrDefaultAsync();
}
else
{
return await _context.Candidates.AsQueryable()
.Where(x => x.PeriodExam == exam && x.UserId == UserId)
.Select(x => new CandidateContactResponseItem
{
ContactPrefixId = x.ContactPrefixId,
ContactFirstname = x.ContactFirstname,
ContactLastname = x.ContactLastname,
ContactRelations = x.ContactRelations,
ContactTel = x.ContactTel,
})
.FirstOrDefaultAsync();
}
}
public async Task<IEnumerable<Career?>> GetsAsyncCareer(string examId, string positionId)
{
var exam = await _context.PeriodExams.AsQueryable()
@ -1348,6 +1393,35 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
await _context.SaveChangesAsync();
}
public async Task UpdateAsyncContact(string examId, string positionId, CandidateContactResponseItem updated)
{
var candidateId = await CreateAsyncCandidate(examId, positionId);
var candidate = await _context.Candidates.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
if (candidate == null)
throw new Exception(GlobalMessages.ExamNotFound);
if (updated.ContactPrefixId != null)
{
var prefix = await _contextMetadata.Prefixes.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == updated.ContactPrefixId);
if (prefix == null)
throw new Exception(GlobalMessages.PrefixNotFound);
candidate.ContactPrefixId = prefix.Id;
candidate.ContactPrefixName = prefix.Name;
}
candidate.ContactFirstname = updated.ContactFirstname;
candidate.ContactLastname = updated.ContactLastname;
candidate.ContactRelations = updated.ContactRelations;
candidate.ContactTel = updated.ContactTel;
await _context.SaveChangesAsync();
}
public async Task UpdateAsyncDocument(string examId, string positionId, IFormFile file)
{
var candidateId = await CreateAsyncCandidate(examId, positionId);
@ -1748,6 +1822,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
throw new Exception("หมดเวลาช่วงสมัครสอบ");
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.PositionExam)
.Include(x => x.PeriodExam)
.FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId);
if (positionId != "00000000-0000-0000-0000-000000000000")
@ -1774,10 +1850,21 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (status == "checkRegister")
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + exam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: รอเจ้าหน้าที่ตรวจสอบข้อมูล";
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: รอยืนยันสถานะการสมัคร";
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
if (candidate.RegisterDate == null)
candidate.RegisterDate = DateTime.Now;
var periodExam = await _context.Candidates.AsQueryable()
.Where(x => x.PeriodExam == candidate.PeriodExam && x.PositionExam == candidate.PositionExam && x.ExamIdenNumber != null)
.OrderByDescending(d => d.CreatedAt)
.ToListAsync();
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var num = periodExam.Count() + 1;
candidate.ExamIdenNumber = candidate.PositionExam == null ? num.ToString() : candidate.PositionExam.Code + num.ToString("D5");
}
if (status == "checkPayment")
{
@ -1831,11 +1918,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
else if (status == "payment" && candidate.PeriodExam.Fee == 0)
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + candidate.PeriodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: รอเจ้าหน้าที่จัดที่นั่งสอบ";
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: ได้รับใบสมัครแล้ว";
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
candidate.Status = "checkSeat";
var num = periodExam.Count() + 1;
candidate.ExamIdenNumber = candidate.PositionExam == null ? num.ToString() : candidate.PositionExam.Code + num;
// var num = periodExam.Count() + 1;
// candidate.ExamIdenNumber = candidate.PositionExam == null ? num.ToString() : candidate.PositionExam.Code + num;
}
else if (status == "payment" && candidate.PeriodExam.Fee != 0)
{
@ -1846,10 +1933,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (candidate.Status == "checkSeat")
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + candidate.PeriodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: รอเจ้าหน้าที่จัดที่นั่งสอบ";
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: ได้รับใบสมัครแล้ว";
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
var num = periodExam.Count() + 1;
candidate.ExamIdenNumber = candidate.PositionExam == null ? num.ToString() : candidate.PositionExam.Code + num;
// var num = periodExam.Count() + 1;
// candidate.ExamIdenNumber = candidate.PositionExam == null ? num.ToString() : candidate.PositionExam.Code + num;
candidate.PaymentDate = DateTime.Now;
}
}
@ -1893,7 +1980,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (candidate.PeriodExam.Fee == 0)
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + candidate.PeriodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: รอเจ้าหน้าที่จัดที่นั่งสอบ";
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: ได้รับใบสมัครแล้ว";
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
candidate.Status = "checkSeat";
var num = periodExam.Count() + 1 + _num;

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