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

This commit is contained in:
harid 2025-11-18 13:21:57 +07:00
parent f20abe032d
commit 876b085dd2
11 changed files with 3261 additions and 2 deletions

View file

@ -818,6 +818,35 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
/// <summary>
/// เจ้าหน้าอัพเดตสถานะ เปิดให้ดาวน์โหลดใบสมัคร แสดงสถานที่สอบ และเลขประจำตัวสอบ
/// </summary>
/// <param name="candidateId">รหัสใบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อเจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("check-showExamInfo")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> CheckShowExamInfoService(RequestApproves item)
{
try
{
if (item.CandidateId != null)
{
await _candidateService.AdminCheckShowExamInfoService(item.CandidateId);
}
return Success();
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// เจ้าหน้าที่ย้อนสถานะเป็นตรวจสอบข้อมูล
/// </summary>

View file

@ -500,6 +500,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnOrder(1)
.HasComment("ชื่อจริง");
b.Property<bool>("IsShowExamInfo")
.HasColumnType("tinyint(1)")
.HasComment("สถานะ เปิดให้ดาวน์โหลดใบสมัคร แสดงสถานที่สอบ และเลขประจำตัวสอบ");
b.Property<string>("Knowledge")
.HasColumnType("longtext")
.HasComment("ความสามารถพิเศษ");

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class update_table_candidate_add_field_IsShowExamInfo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsShowExamInfo",
table: "Candidates",
type: "tinyint(1)",
nullable: false,
defaultValue: false,
comment: "สถานะ เปิดให้ดาวน์โหลดใบสมัคร แสดงสถานที่สอบ และเลขประจำตัวสอบ");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsShowExamInfo",
table: "Candidates");
}
}
}

View file

@ -315,6 +315,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
[Comment("โทรศัพท์ บุคคลที่สามารถติดต่อได้")]
public string? ContactTel { get; set; }
[Comment("สถานะ เปิดให้ดาวน์โหลดใบสมัคร แสดงสถานที่สอบ และเลขประจำตัวสอบ")]
public bool IsShowExamInfo { get; set; } = false;
public virtual List<Education> Educations { get; set; } = new List<Education>();
public virtual List<Career> Careers { get; set; } = new List<Career>();

View file

@ -39,5 +39,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
public string? HighDegree { get; set; }
public DateTime? AnnouncementDate { get; set; }
public Guid? Id { get; set; }
public bool? IsShowExamInfo { get; set; }
}
}

View file

@ -10,5 +10,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
public int? Year { get; set; }
public string? Position { get; set; }
public string? PositionLevel { get; set; }
public string? EducationLevel { get; set; }
}
}

View file

@ -16,5 +16,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
public PositionExam? PositionExam { get; set; }
public DateTime? RegisterEndDate { get; set; }
public DateTime? RegisterStartDate { get; set; }
public int? graduationYearLock { get; set; }
}
}

View file

@ -7,5 +7,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public string? Status { get; set; }
public string? RejectDetail { get; set; }
public bool? IsShowExamInfo { get; set; }
}
}

View file

@ -667,6 +667,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
CanRegister = exam.RegisterStartDate == null || exam.RegisterEndDate == null ? true : DateOnly.FromDateTime(exam.RegisterStartDate.Value) <= DateOnly.FromDateTime(DateTime.Now) && DateOnly.FromDateTime(exam.RegisterEndDate.Value) >= DateOnly.FromDateTime(DateTime.Now),
RegisterEndDate = exam.RegisterEndDate,
RegisterStartDate = exam.RegisterStartDate,
graduationYearLock = exam.GraduationYearLock,
};
}
@ -1966,7 +1967,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
return new CandidateStatusResponse { Status = candidate.Status, RejectDetail = candidate.RejectDetail };
return new CandidateStatusResponse { Status = candidate.Status, RejectDetail = candidate.RejectDetail, IsShowExamInfo = candidate.IsShowExamInfo };
}
public async Task UserCheckCandidateService(string examId, string positionId, string status)
@ -2177,6 +2178,41 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
await _context.SaveChangesAsync();
}
public async Task AdminCheckShowExamInfoService(string[] candidateId)
{
//var _num = 0;
foreach (var _candidateId in candidateId)
{
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.PeriodExam)
.Include(x => x.PositionExam)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(_candidateId));
if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound);
if (candidate.Status.Trim().ToUpper() != "CHECKREGISTER")
continue;
if (candidate.PeriodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var periodExam = await _context.Candidates.AsQueryable()
.Where(x => x.PeriodExam == candidate.PeriodExam)
.Where(x => x.PositionExam == candidate.PositionExam)
.Where(x => x.ExamIdenNumber != null)
.Where(x => x.Status != "register")
.OrderByDescending(d => d.CreatedAt)
.ToListAsync();
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
candidate.IsShowExamInfo = true;
//++_num;
}
await _context.SaveChangesAsync();
}
public async Task AdminRejectToCheckCandidateService(Guid candidateId, string? reason)
{
var candidate = await _context.Candidates.AsQueryable()
@ -2329,6 +2365,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Position = positionName,
PositionLevel = positionLevelName,
HighDegree = highDegree,
IsShowExamInfo = candidate.IsShowExamInfo,
};
}

View file

@ -319,6 +319,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Year = periodExam.Year,
Position = positionExam.PositionName,
PositionLevel = positionExam.PositionLevelName,
EducationLevel = positionExam.EducationLevel,
};
}
else
@ -330,6 +331,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Year = periodExam.Year,
Position = null,
PositionLevel = null,
EducationLevel = positionExam.EducationLevel,
};
}
}
@ -366,7 +368,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
CompanyCode = inserted.CompanyCode,
Reason = inserted.Reason,
RefNo1 = inserted.RefNo1,
GraduationYearLock = inserted.GraduationYearLock,
GraduationYearLock = inserted.GraduationYearLock ?? 3,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
@ -806,6 +808,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Status = x.Status,
PositionLevelName = x.PositionExam == null ? null : x.PositionExam.PositionLevelName,
PositionName = x.PositionExam == null ? null : x.PositionExam.PositionName,
IsShowExamInfo = x.IsShowExamInfo,
})
.Skip((page - 1) * pageSize)
.Take(pageSize)
@ -887,6 +890,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Status = x.Status,
PositionLevelName = x.PositionExam == null ? null : x.PositionExam.PositionLevelName,
PositionName = x.PositionExam == null ? null : x.PositionExam.PositionName,
IsShowExamInfo = x.IsShowExamInfo,
})
.ToListAsync();
var _candidate = await _context.Candidates.AsQueryable()