migrate + ปรับระบบสรรหาสอบคัดเลือก

This commit is contained in:
harid 2025-11-17 16:17:59 +07:00
parent 577c7b289e
commit f20abe032d
19 changed files with 6470 additions and 15 deletions

View file

@ -16,7 +16,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
[ApiController]
[Produces("application/json")]
[AllowAnonymous]
// [Authorize]
[Authorize]
[SwaggerTag("จัดการข้อมูลรอบการสอบ เพื่อนำไปใช้งานในระบบ")]
public class PeriodExamController : BaseController
{

View file

@ -25,5 +25,7 @@
public const string CMSNotFound = "ไม่พบข้อมูล CMS";
public const string OrganizationNotFound = "ไม่พบข้อมูลสังกัด";
public const string CitizanDupicate = "เลขบัตรประชาชนนี้ได้ทำการสมัครไว้แล้ว";
public const string CitizenIncomplete = "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก";
public const string CitizenIncorrect = "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง";
}
}

View file

@ -624,8 +624,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnType("longtext")
.HasComment("ตำแหน่งปัจจุบัน ประเภทราชการ");
b.Property<int?>("OccupationSalary")
.HasColumnType("int")
b.Property<double?>("OccupationSalary")
.HasColumnType("double")
.HasComment("ตำแหน่งปัจจุบัน เงินเดือน");
b.Property<string>("OccupationTelephone")
@ -2284,6 +2284,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnType("float")
.HasComment("ค่าธรรมเนียม");
b.Property<int?>("GraduationYearLock")
.HasColumnType("int")
.HasComment("ล็อกวันที่สำเร็จการศึกษา (ปี)");
b.Property<Guid?>("ImportFileId")
.HasColumnType("char(36)");
@ -2673,6 +2677,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("EducationLevel")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("ขีดจำกัดวุฒิการศึกษา");
b.Property<bool>("HighDegree")
.HasColumnType("tinyint(1)")
.HasComment("ปริญญาบัตรขึ้นไป");

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class update_tables_periodExam_and_positionExam : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "EducationLevel",
table: "PositionExams",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "ขีดจำกัดวุฒิการศึกษา")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "GraduationYearLock",
table: "PeriodExams",
type: "int",
nullable: true,
comment: "ล็อกวันที่สำเร็จการศึกษา (ปี)");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EducationLevel",
table: "PositionExams");
migrationBuilder.DropColumn(
name: "GraduationYearLock",
table: "PeriodExams");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class update_tables_candidates_change_datatype : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<double>(
name: "OccupationSalary",
table: "Candidates",
type: "double",
nullable: true,
comment: "ตำแหน่งปัจจุบัน เงินเดือน",
oldClrType: typeof(int),
oldType: "int",
oldNullable: true,
oldComment: "ตำแหน่งปัจจุบัน เงินเดือน");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "OccupationSalary",
table: "Candidates",
type: "int",
nullable: true,
comment: "ตำแหน่งปัจจุบัน เงินเดือน",
oldClrType: typeof(double),
oldType: "double",
oldNullable: true,
oldComment: "ตำแหน่งปัจจุบัน เงินเดือน");
}
}
}

View file

@ -266,7 +266,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
[Comment("ตำแหน่งปัจจุบัน กลุ่ม/ฝ่าย")]
public string? OccupationGroup { get; set; }
[Comment("ตำแหน่งปัจจุบัน เงินเดือน")]
public int? OccupationSalary { get; set; }
public double? OccupationSalary { get; set; }
[Comment("ตำแหน่งปัจจุบัน สังกัด")]
public string? OccupationPosition { get; set; }
[Comment("ตำแหน่งปัจจุบัน ประเภทราชการ")]

View file

@ -103,6 +103,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
public string? AuthName { get; set; }
public string? AuthPosition { get; set; }
[Comment("ล็อกวันที่สำเร็จการศึกษา (ปี)")]
public int? GraduationYearLock { get; set; } = 3;
[Comment("รายชื่อคนสม้ครในรอบ")]
public List<Candidate> Candidate { get; set; } = new List<Candidate>();

View file

@ -175,7 +175,7 @@ namespace BMA.EHR.Domain.Models.Placement
[Comment("ตำแหน่งปัจจุบัน กลุ่ม/ฝ่าย")]
public string? OccupationGroup { get; set; }
[Comment("ตำแหน่งปัจจุบัน เงินเดือน")]
public int? OccupationSalary { get; set; }
public double? OccupationSalary { get; set; }
[Comment("ตำแหน่งปัจจุบัน สังกัด")]
public string? OccupationPosition { get; set; }
[Comment("ตำแหน่งปัจจุบัน ประเภทราชการ")]

View file

@ -34,5 +34,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
[Comment("รหัสประจำตำแหน่งที่สอบ")]
public string? Code { get; set; }
[Comment("ขีดจำกัดวุฒิการศึกษา"), MaxLength(50)]
public string? EducationLevel { get; set; }
}
}

View file

@ -33,7 +33,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
public string? CompanyCode { get; set; }
public string? Reason { get; set; }
public string? RefNo1 { get; set; }
public int? GraduationYearLock { get; set; }
public List<FormFile>? Doc { get; set; }
public List<FormFile>? Image { get; set; }
public List<RequestBankExam> BankExam { get; set; } = new();

View file

@ -13,5 +13,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
public string? Code { get; set; }
public string? TypeId { get; set; }
public string? TypeName { get; set; }
public string? EducationLevel { get; set; }
}
}

View file

@ -4,6 +4,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public class CandidateContactResponseItem
{
public Guid? ContactPrefixId { get; set; }
public string? ContactPrefix { get; set; }
public string? ContactFirstname { get; set; }
public string? ContactLastname { get; set; }
public string? ContactRelations { get; set; }

View file

@ -6,7 +6,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public string? OccupationOrg { get; set; }
public string? OccupationPile { get; set; }
public string? OccupationGroup { get; set; }
public int? OccupationSalary { get; set; }
public double? OccupationSalary { get; set; }
public string? OccupationPosition { get; set; }
public string? OccupationPositionType { get; set; }
public string? OccupationTelephone { get; set; }

View file

@ -12,7 +12,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public DateTime? DateOfBirth { get; set; }
// public Models.Relationship? Relationship { get; set; }
public string? ReligionId { get; set; }
// public string? Religion { get; set; }
public string? ReligionName { get; set; }
public string? Email { get; set; } = string.Empty;
public string? CitizenId { get; set; } = string.Empty;
// public Models.Province? CitizenProvince { get; set; }
@ -73,7 +73,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public string? OccupationOrg { get; set; }
public string? OccupationPile { get; set; }
public string? OccupationGroup { get; set; }
public int? OccupationSalary { get; set; }
public double? OccupationSalary { get; set; }
public string? OccupationPosition { get; set; }
public string? OccupationPositionType { get; set; }
public string? OccupationTelephone { get; set; }
@ -88,6 +88,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public Guid? EducationLevelHighId { get; set; }
public Guid? ContactPrefixId { get; set; }
public string? ContactPrefixName { get; set; }
public string? ContactFirstname { get; set; }
public string? ContactLastname { get; set; }
public string? ContactRelations { get; set; }

View file

@ -38,6 +38,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public string? CompanyCode { get; set; }
public string? Reason { get; set; }
public string? RefNo1 { get; set; }
public int? GraduationYearLock { get; set; }
public List<Models.Candidate> Candidate { get; set; } = new List<Models.Candidate>();
public List<Models.PositionExam> PositionExam { get; set; } = new List<Models.PositionExam>();
public List<Models.BankExam> BankExam { get; set; } = new List<Models.BankExam>();

View file

@ -344,6 +344,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.Select(x => new CandidateContactResponseItem
{
ContactPrefixId = x.ContactPrefixId,
ContactPrefix = x.ContactPrefixName,
ContactFirstname = x.ContactFirstname,
ContactLastname = x.ContactLastname,
ContactRelations = x.ContactRelations,
@ -358,6 +359,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.Select(x => new CandidateContactResponseItem
{
ContactPrefixId = x.ContactPrefixId,
ContactPrefix = x.ContactPrefixName,
ContactFirstname = x.ContactFirstname,
ContactLastname = x.ContactLastname,
ContactRelations = x.ContactRelations,
@ -749,6 +751,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.PrefixId = prefix.Id;
candidate.PrefixName = prefix.name;
}
if (!string.IsNullOrEmpty(updated.Prefix))
{
candidate.PrefixName = updated.Prefix;
}
if (updated.ContactPrefixId != null)
{
@ -761,6 +767,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.ContactPrefixId = prefix.Id;
candidate.ContactPrefixName = prefix.name;
}
if (!string.IsNullOrEmpty(updated.ContactPrefixName))
{
candidate.ContactPrefixName = updated.ContactPrefixName;
}
if (updated.ReligionId != null)
{
@ -773,6 +783,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.ReligionId = religion.Id;
candidate.ReligionName = religion.name;
}
if (!string.IsNullOrEmpty(updated.ReligionName))
{
candidate.ReligionName = updated.ReligionName;
}
if (updated.RegistProvinceId != null)
{
@ -973,6 +987,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.PrefixId = prefix.Id;
candidate.PrefixName = prefix.name;
}
if (!string.IsNullOrEmpty(updated.Prefix))
{
candidate.PrefixName = updated.Prefix;
}
if (updated.ContactPrefixId != null)
{
@ -985,6 +1003,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.ContactPrefixId = prefix.Id;
candidate.ContactPrefixName = prefix.name;
}
if (!string.IsNullOrEmpty(updated.ContactPrefixName))
{
candidate.ContactPrefixName = updated.ContactPrefixName;
}
if (updated.ReligionId != null)
{
@ -997,6 +1019,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.ReligionId = religion.Id;
candidate.ReligionName = religion.name;
}
if (!string.IsNullOrEmpty(updated.ReligionName))
{
candidate.ReligionName = updated.ReligionName;
}
if (updated.RegistProvinceId != null)
{
@ -1197,6 +1223,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.PrefixId = prefix.Id;
candidate.PrefixName = prefix.name;
}
if (!string.IsNullOrEmpty(updated.Prefix))
{
candidate.PrefixName = updated.Prefix;
}
if (updated.RelationshipId != null)
{
@ -2447,6 +2477,35 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (exam == null)
throw new Exception(GlobalMessages.ExamNotFound);
if (citizenId.Length != 13)
throw new Exception(GlobalMessages.CitizenIncomplete);
int[] citizenIdDigits = citizenId.Select(c => int.Parse(c.ToString())).ToArray();
int cal =
citizenIdDigits[0] * 13 +
citizenIdDigits[1] * 12 +
citizenIdDigits[2] * 11 +
citizenIdDigits[3] * 10 +
citizenIdDigits[4] * 9 +
citizenIdDigits[5] * 8 +
citizenIdDigits[6] * 7 +
citizenIdDigits[7] * 6 +
citizenIdDigits[8] * 5 +
citizenIdDigits[9] * 4 +
citizenIdDigits[10] * 3 +
citizenIdDigits[11] * 2;
int calStp2 = cal % 11;
int chkDigit = 11 - calStp2;
if (chkDigit == 10)
chkDigit = 1;
else if (chkDigit == 11)
chkDigit = chkDigit % 10;
if (citizenIdDigits[12] != chkDigit)
throw new Exception(GlobalMessages.CitizenIncorrect);
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
@ -2456,18 +2515,18 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
throw new Exception(GlobalMessages.PositionExamNotFound);
var candidate1 = await _context.Candidates.AsQueryable()
.Where(x => x.PeriodExam == exam && x.UserId != UserId && x.PositionExam == position && x.CitizenId == citizenId)
.Where(x => x.PeriodExam == exam && x.UserId != UserId /*&& x.PositionExam == position*/ && x.CitizenId == citizenId)
.FirstOrDefaultAsync();
if (candidate1 != null)
throw new Exception(GlobalMessages.CitizanDupicate);
return;
}
var candidate2 = await _context.Candidates.AsQueryable()
.Where(x => x.PeriodExam == exam && x.UserId != UserId && x.CitizenId == citizenId)
.FirstOrDefaultAsync();
if (candidate2 != null)
throw new Exception(GlobalMessages.CitizanDupicate);
//var candidate2 = await _context.Candidates.AsQueryable()
// .Where(x => x.PeriodExam == exam && x.UserId != UserId && x.CitizenId == citizenId)
// .FirstOrDefaultAsync();
//if (candidate2 != null)
// throw new Exception(GlobalMessages.CitizanDupicate);
}
public async Task GetExamCandidateAsync(Guid id)

View file

@ -185,6 +185,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Round = x.Round,
SetSeat = x.SetSeat,
Year = x.Year,
GraduationYearLock = x.GraduationYearLock,
BankExam = x.BankExam.OrderBy(o => o.CreatedAt).Select(b => new BankExam
{
Id = b.Id,
@ -203,6 +204,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
PositionLevelName = b.PositionLevelName,
HighDegree = b.HighDegree,
Code = b.Code,
EducationLevel = b.EducationLevel,
}).ToList(),
Documents = x.PeriodExamDocuments.OrderBy(o => o.CreatedAt).Select(b => new FileListResponse
{
@ -364,6 +366,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
CompanyCode = inserted.CompanyCode,
Reason = inserted.Reason,
RefNo1 = inserted.RefNo1,
GraduationYearLock = inserted.GraduationYearLock,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
@ -406,6 +409,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Code = position.Code,
TypeId = position.TypeId,
TypeName = position.TypeName,
EducationLevel = position.EducationLevel,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
@ -464,6 +468,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
periodExam.CompanyCode = updated.CompanyCode;
periodExam.Reason = updated.Reason;
periodExam.RefNo1 = updated.RefNo1;
periodExam.GraduationYearLock = updated.GraduationYearLock;
periodExam.LastUpdatedAt = DateTime.Now;
periodExam.LastUpdateUserId = UserId ?? "";
periodExam.LastUpdateFullName = FullName ?? "";
@ -539,6 +544,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
position.Code = positionData.Code;
position.TypeId = positionData.TypeId;
position.TypeName = positionData.TypeName;
position.EducationLevel = positionData.EducationLevel;
position.LastUpdatedAt = DateTime.Now;
position.LastUpdateUserId = UserId ?? "";
position.LastUpdateFullName = FullName ?? "";
@ -573,6 +579,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Code = position.Code,
TypeId = position.TypeId,
TypeName = position.TypeName,
EducationLevel = position.EducationLevel,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,