สมัครสอบตามตำแหน่ง

This commit is contained in:
Kittapath 2023-04-06 03:06:17 +07:00
parent bed23f911a
commit 43898213b2
25 changed files with 9062 additions and 307 deletions

View file

@ -617,7 +617,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
/// <response code="200">เมื่อเจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("check-register/{candidate:length(36)}")]
[HttpPut("check-register/{candidateId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
@ -643,7 +643,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
/// <response code="200">เมื่อเจ้าหน้าที่ตรวจคุณสมบัติผู้สมัครไม่ผ่านและให้สมัครใหม่สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("reject-register/{candidate:length(36)}")]
[HttpPut("reject-register/{candidateId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
@ -669,7 +669,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
/// <response code="200">เมื่อเจ้าหน้าที่ตรวจการชำระเงินสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("check-payment/{candidate:length(36)}")]
[HttpPut("check-payment/{candidateId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
@ -695,7 +695,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
/// <response code="200">เมื่อเจ้าหน้าที่บันทึกสถานที่สอบสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("pass-seat/{candidate:length(36)}")]
[HttpGet("pass-seat/{candidateId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
@ -721,7 +721,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
/// <response code="200">เมื่อเจ้าหน้าที่บันทึกคะแนนสอบสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("pass-point/{candidate:length(36)}")]
[HttpGet("pass-point/{candidateId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]

View file

@ -1,3 +1,4 @@
using BMA.EHR.Recurit.Exam.Service.Core;
using BMA.EHR.Recurit.Exam.Service.Models;
using BMA.EHR.Recurit.Exam.Service.Request;
using BMA.EHR.Recurit.Exam.Service.Response;
@ -58,6 +59,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
}
/// <summary>
/// ข้อมูลสถานะจ่ายเงิน
/// <param name="examId">รหัสรอบสมัคร</param>
/// </summary>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลสถานะจ่ายเงินสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("status-payment/{examId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetsStatusPaymentAsync(string examId)
{
try
{
var items = await _periodExamService.GetsStatusPaymentAsync(examId);
return Success(items);
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// ข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบ
/// </summary>
@ -189,31 +216,31 @@ 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>
// [HttpGet("payment/{examId:length(36)}")]
// [ProducesResponseType(StatusCodes.Status200OK)]
// [ProducesResponseType(StatusCodes.Status401Unauthorized)]
// [ProducesResponseType(StatusCodes.Status500InternalServerError)]
// public async Task<ActionResult<ResponseObject>> GetsCandidateCheckPaymentAsync(string examId)
// {
// try
// {
// var items = await _periodExamService.GetsCandidateByStatusAsync(examId, "checkPayment");
/// <summary>
/// ข้อมูลชำระเงิน
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลชำระเงินสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("payment/{examId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetsPaymentExamAsync(string examId)
{
try
{
var items = await _periodExamService.GetsPaymentExamAsync(examId);
// return Success(items);
// }
// catch (Exception ex)
// {
// return Error(ex);
// }
// }
return Success(items);
}
catch (Exception ex)
{
return Error(ex);
}
}
// /// <summary>
// /// รายชื่อผู้สมัครสอบรอ จัดการเลขที่นั่งสอบ
@ -422,6 +449,131 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
return Error(ex);
}
}
/// <summary>
/// อัพเดทข้อมูลที่นั่งสอบ
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านอัพเดทข้อมูลที่นั่งสอบสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("upload-seat/{examId:length(36)}"), DisableRequestSizeLimit]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> UploadSeatCandidateAsync(string examId)
{
try
{
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
{
return Error(GlobalMessages.NoFileToUpload);
}
var file = Request.Form.Files[0];
if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
{
return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
}
await _periodExamService.UploadSeatCandidateAsync(examId, file);
return Success();
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// อัพเดทข้อมูลคะแนน
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านอัพเดทข้อมูลคะแนนสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("upload-point/{examId:length(36)}"), DisableRequestSizeLimit]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> UploadPointCandidateAsync(string examId)
{
try
{
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
{
return Error(GlobalMessages.NoFileToUpload);
}
var file = Request.Form.Files[0];
if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
{
return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
}
await _periodExamService.UploadPointCandidateAsync(examId, file);
return Success();
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// โหลดผู้สมัครสอบ
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านโหลดผู้สมัครสอบสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("download/{examId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> DownloadCandidateAsync(string examId)
{
try
{
var stream = await _periodExamService.DownloadCandidateAsync(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>
/// <param name="positionId">รหัสตำแหน่ง</param>
/// </summary>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลตำแหน่งสมัครสอบสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("position/{examId:length(36)}/{positionId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetsNamePositionAsync(string examId, string positionId)
{
try
{
var items = await _periodExamService.GetsNamePositionAsync(examId, positionId);
return Success(items);
}
catch (Exception ex)
{
return Error(ex);
}
}
#endregion
}
}

View file

@ -159,6 +159,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnType("varchar(200)")
.HasComment("อีเมล");
b.Property<string>("ExamIdenNumber")
.HasColumnType("longtext")
.HasComment("เลขประจำตัวสอบ");
b.Property<string>("FatherFirstName")
.HasMaxLength(100)
.HasColumnType("varchar(100)")
@ -310,6 +314,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
b.Property<Guid>("PeriodExamId")
.HasColumnType("char(36)");
b.Property<string>("Point")
.HasColumnType("longtext")
.HasComment("คะแนน");
b.Property<Guid?>("PositionExamId")
.HasColumnType("char(36)");
b.Property<Guid?>("PrefixId")
.HasColumnType("char(36)");
@ -388,6 +399,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
b.HasIndex("PeriodExamId");
b.HasIndex("PositionExamId");
b.HasIndex("PrefixId");
b.HasIndex("ProfileImgId");
@ -946,6 +959,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnOrder(8)
.HasComment("รอบการสอบ");
b.Property<bool>("SetSeat")
.HasColumnType("tinyint(1)")
.HasComment("เช็คอัพคะแนน");
b.Property<int?>("Year")
.HasColumnType("int")
.HasComment("ปีงบประมาณ");
@ -1013,6 +1030,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnType("longtext")
.HasComment("ชื่อตำแหน่ง");
b.Property<string>("TypeId")
.HasColumnType("longtext")
.HasComment("Id ประเภทแบบฟอร์ม");
b.Property<string>("TypeName")
.HasColumnType("longtext")
.HasComment("ชื่อประเภทแบบฟอร์ม");
@ -1359,7 +1380,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.BankExam", b =>
{
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam")
.WithMany()
.WithMany("BankExam")
.HasForeignKey("PeriodExamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -1406,11 +1427,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasForeignKey("PaymentImgId");
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam")
.WithMany()
.WithMany("Candidate")
.HasForeignKey("PeriodExamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PositionExam", "PositionExam")
.WithMany()
.HasForeignKey("PositionExamId");
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Prefix", "Prefix")
.WithMany()
.HasForeignKey("PrefixId");
@ -1455,6 +1480,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
b.Navigation("PeriodExam");
b.Navigation("PositionExam");
b.Navigation("Prefix");
b.Navigation("ProfileImg");
@ -1529,7 +1556,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PositionExam", b =>
{
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam")
.WithMany()
.WithMany("PositionExam")
.HasForeignKey("PeriodExamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -1551,6 +1578,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
b.Navigation("SubDistricts");
});
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", b =>
{
b.Navigation("BankExam");
b.Navigation("Candidate");
b.Navigation("PositionExam");
});
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.Province", b =>
{
b.Navigation("Districts");

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,50 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class UpdatetableCandidateaddbank2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "PositionExamId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateIndex(
name: "IX_Candidates_PositionExamId",
table: "Candidates",
column: "PositionExamId");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_PositionExams_PositionExamId",
table: "Candidates",
column: "PositionExamId",
principalTable: "PositionExams",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Candidates_PositionExams_PositionExamId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_PositionExamId",
table: "Candidates");
migrationBuilder.DropColumn(
name: "PositionExamId",
table: "Candidates");
}
}
}

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 UpdatetableCandidateaddExamIdenNumber : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ExamIdenNumber",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "เลขประจำตัวสอบ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Point",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "คะแนน")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ExamIdenNumber",
table: "Candidates");
migrationBuilder.DropColumn(
name: "Point",
table: "Candidates");
}
}
}

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 UpdatetableCandidateaddExamIdenNumber2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "SetSeat",
table: "Candidates",
type: "tinyint(1)",
nullable: false,
defaultValue: false,
comment: "เช็คอัพคะแนน");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "SetSeat",
table: "Candidates");
}
}
}

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 UpdatetableCandidateaddsetseat : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "SetSeat",
table: "Candidates");
migrationBuilder.AddColumn<bool>(
name: "SetSeat",
table: "PeriodExams",
type: "tinyint(1)",
nullable: false,
defaultValue: false,
comment: "เช็คอัพคะแนน");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "SetSeat",
table: "PeriodExams");
migrationBuilder.AddColumn<bool>(
name: "SetSeat",
table: "Candidates",
type: "tinyint(1)",
nullable: false,
defaultValue: false,
comment: "เช็คอัพคะแนน");
}
}
}

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 UpdatetableCandidateaddidpositiontpye : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "TypeId",
table: "PositionExams",
type: "longtext",
nullable: true,
comment: "Id ประเภทแบบฟอร์ม")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "TypeId",
table: "PositionExams");
}
}
}

View file

@ -19,9 +19,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
[Required, MaxLength(20), Comment("สถานะผู้สมัคร")]
public string Status { get; set; } = "register";
[Comment("เลขประจำตัวสอบ")]
public string? ExamIdenNumber { get; set; }
[Comment("เลขที่นั่งสอบ")]
public string? SeatNumber { get; set; }
[Comment("คะแนน")]
public string? Point { get; set; }
[Comment("Id รูปโปรไฟล์")]
public virtual Document? ProfileImg { get; set; }
@ -178,8 +184,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
[MaxLength(20), Comment("โทรศัพท์ บริษัท")]
public string? OccupationTelephone { get; set; }
[Comment("เหตุผลการไม่อนุมัติ")]
public string? RejectDetail { get; set; }
}
}

View file

@ -65,5 +65,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
[Comment("เช็คอัพคะแนน")]
public bool SetSeat { get; set; } = false;
[Comment("รายชื่อคนสม้ครในรอบ")]
public List<Candidate> Candidate { get; set; } = new List<Candidate>();
[Comment("ตำแหน่งสมัคร")]
public List<PositionExam> PositionExam { get; set; } = new List<PositionExam>();
[Comment("ช่องทางชำระเงิน")]
public List<BankExam> BankExam { get; set; } = new List<BankExam>();
}
}

View file

@ -16,6 +16,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
[Comment("ชื่อตำแหน่ง")]
public string? PositionName { get; set; }
[Comment("Id ประเภทแบบฟอร์ม")]
public string? TypeId { get; set; }
[Comment("ชื่อประเภทแบบฟอร์ม")]
public string? TypeName { get; set; }
}

View file

@ -4,6 +4,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
{
public class RequestBankExam
{
public Guid? Id { get; set; }
public string? AccountNumber { get; set; }
public string? BankName { get; set; }
public string? AccountName { get; set; }

View file

@ -0,0 +1,13 @@
using System.Net;
using BMA.EHR.Recurit.Exam.Service.Models;
namespace BMA.EHR.Recurit.Exam.Service.Request
{
public class RequestImportSeat
{
public string? CitizenId { get; set; }
public string? ExamIdenNumber { get; set; }
public string? SeatNumber { get; set; }
public string? Point { get; set; }
}
}

View file

@ -4,8 +4,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
{
public class RequestPositionExam
{
public Guid? Id { get; set; }
public Guid? PositionId { get; set; }
public string? PositionName { get; set; }
public string? TypeId { get; set; }
public string? TypeName { get; set; }
}
}

View file

@ -0,0 +1,11 @@
using System.Net;
using BMA.EHR.Recurit.Exam.Service.Models;
namespace BMA.EHR.Recurit.Exam.Service.Request
{
public class RequestPositionName
{
public string? Name { get; set; }
public PositionExam? Posiiton { get; set; }
}
}

View file

@ -0,0 +1,12 @@
using System.Net;
using BMA.EHR.Recurit.Exam.Service.Models;
namespace BMA.EHR.Recurit.Exam.Service.Request
{
public class RequestStatusExam
{
public string? Name { get; set; }
public bool Status { get; set; }
public bool SetSeat { get; set; }
}
}

View file

@ -6,7 +6,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
public class RequestStatusRegistry
{
public bool Consend { get; set; }
public bool Poition { get; set; }
public bool Position { get; set; }
public string? Status { get; set; }
public PositionExam? PositionExam { get; set; }
}

View file

@ -78,7 +78,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -148,7 +148,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -216,7 +216,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -288,7 +288,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -337,7 +337,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -369,7 +369,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -402,7 +402,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -442,7 +442,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -475,7 +475,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -506,7 +506,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -523,7 +523,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
Consend = candidate != null,
Status = candidate == null ? null : candidate.Status,
PositionExam = candidatePosition?.PositionExam
PositionExam = candidatePosition?.PositionExam,
Position = candidatePosition == null ? false : true
};
}
@ -538,10 +539,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
var _candidate = await _context.Candidates.AsQueryable()
.FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId);
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -555,6 +557,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
var candidate = new Candidate
{
PeriodExam = exam,
PositionExam = position,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
@ -1211,7 +1214,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
@ -1229,6 +1232,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
public async Task UserCheckCandidateService(string examId, string positionId, string status)
{
var exam = await _context.PeriodExams.AsQueryable()
.Include(x => x.PositionExam)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (exam == null)
@ -1240,11 +1244,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (positionId != "00000000-0000-0000-0000-000000000000")
{
var position = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId));
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == exam);
if (position == null)
throw new Exception(GlobalMessages.PositionExamNotFound);
var candidateDelete = await _context.Candidates.AsQueryable()
.Where(x => x.PeriodExam == exam && x.UserId == UserId && x.PositionExam != position)
.ToListAsync();
_context.Candidates.RemoveRange(candidateDelete);
candidate = await _context.Candidates.AsQueryable()
.FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId && x.PositionExam == position);
}
@ -1269,6 +1279,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (candidate.PeriodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var periodExam = await _context.PeriodExams.AsQueryable()
.Include(x => x.Candidate)
.FirstOrDefaultAsync(x => x.Id == candidate.PeriodExam.Id);
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
if (status != "rejectDelete")
{
candidate.Status = status;
@ -1280,6 +1297,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
candidate.Status = "checkSeat";
}
if (candidate.Status == "checkSeat")
{
var num = periodExam.Candidate.Count() + 1;
candidate.ExamIdenNumber = "CDC-" + num;
}
}
else
{

View file

@ -1,10 +1,13 @@
using System.Security.Claims;
using System.Text.Json;
using BMA.EHR.Recurit.Exam.Service.Core;
using BMA.EHR.Recurit.Exam.Service.Data;
using BMA.EHR.Recurit.Exam.Service.Models;
using BMA.EHR.Recurit.Exam.Service.Request;
using BMA.EHR.Recurit.Exam.Service.Response;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json.Linq;
using OfficeOpenXml;
namespace BMA.EHR.Recurit.Exam.Service.Services
{
@ -42,13 +45,57 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
if (showAll)
return await _context.PeriodExams.AsQueryable()
.Include(x => x.PositionExam)
.Include(x => x.BankExam)
.OrderBy(d => d.Name)
.ToListAsync();
else
return await _context.PeriodExams.AsQueryable()
.Where(p => p.IsActive)
.OrderBy(d => d.Name)
.ToListAsync();
.Include(x => x.PositionExam)
.Include(x => x.BankExam)
.Where(p => p.IsActive)
.OrderBy(d => d.Name)
.Select(x => new PeriodExam
{
AnnouncementEndDate = x.AnnouncementEndDate,
AnnouncementStartDate = x.AnnouncementStartDate,
CheckDisability = x.CheckDisability,
CheckDocument = x.CheckDocument,
Detail = x.Detail,
Fee = x.Fee,
Id = x.Id,
IsActive = x.IsActive,
Name = x.Name,
Note = x.Note,
OrganizationCodeId = x.OrganizationCodeId,
OrganizationCodeName = x.OrganizationCodeName,
OrganizationId = x.OrganizationId,
OrganizationName = x.OrganizationName,
PaymentEndDate = x.PaymentEndDate,
PaymentKrungThai = x.PaymentKrungThai,
PaymentStartDate = x.PaymentStartDate,
RegisterEndDate = x.RegisterEndDate,
RegisterStartDate = x.RegisterStartDate,
Round = x.Round,
SetSeat = x.SetSeat,
Year = x.Year,
BankExam = x.BankExam.OrderBy(o => o.CreatedAt).Select(b => new BankExam
{
Id = b.Id,
AccountName = b.AccountName,
AccountNumber = b.AccountNumber,
BankName = b.BankName,
}).ToList(),
PositionExam = x.PositionExam.OrderBy(o => o.CreatedAt).Select(b => new PositionExam
{
Id = b.Id,
TypeId = b.TypeId,
TypeName = b.TypeName,
PositionId = b.PositionId,
PositionName = b.PositionName,
}).ToList(),
})
.ToListAsync();
}
public async Task<PeriodExam?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
@ -62,6 +109,49 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
return periodExam;
}
public async Task<RequestStatusExam?> GetsStatusPaymentAsync(string examId, bool showAll = true)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
return new RequestStatusExam
{
Name = periodExam.Name,
Status = DateTime.Now > periodExam.PaymentEndDate,
SetSeat = periodExam.SetSeat,
};
}
public async Task<RequestPositionName?> GetsNamePositionAsync(string examId, string positionId)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Include(x => x.PositionExam)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
if (positionId != "00000000-0000-0000-0000-000000000000")
{
return new RequestPositionName
{
Name = periodExam.Name,
Posiiton = periodExam.PositionExam.FirstOrDefault(x => x.Id == Guid.Parse(positionId) && x.PeriodExam == periodExam),
};
}
else
{
return new RequestPositionName
{
Name = periodExam.Name,
Posiiton = null,
};
}
}
public async Task CreateAsync(RequestPeriodExam inserted)
{
var periodExam = new PeriodExam
@ -118,6 +208,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
PeriodExam = periodExam,
PositionId = position.PositionId,
PositionName = position.PositionName,
TypeId = position.TypeId,
TypeName = position.TypeName,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
@ -137,6 +228,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
public async Task UpdateAsync(string examId, RequestPeriodExam updated)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Include(x => x.BankExam)
.Include(x => x.PositionExam)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
@ -161,13 +254,100 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
periodExam.PaymentKrungThai = updated.PaymentKrungThai;
periodExam.Detail = updated.Detail;
periodExam.Note = updated.Note;
periodExam.CreatedAt = DateTime.Now;
periodExam.CreatedUserId = UserId ?? "";
periodExam.LastUpdatedAt = DateTime.Now;
periodExam.LastUpdateUserId = UserId ?? "";
periodExam.CreatedFullName = FullName ?? "";
periodExam.LastUpdateFullName = FullName ?? "";
foreach (var bank in periodExam.BankExam)
{
var bankData = updated.BankExam
.FirstOrDefault(x => x.Id == bank.Id);
if (bankData != null)
{
bank.AccountName = bankData.AccountName;
bank.AccountNumber = bankData.AccountNumber;
bank.BankName = bankData.BankName;
bank.LastUpdatedAt = DateTime.Now;
bank.LastUpdateUserId = UserId ?? "";
bank.LastUpdateFullName = FullName ?? "";
}
else
{
var bankDelete = await _context.BankExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == bank.Id);
if (bankDelete != null)
_context.BankExams.Remove(bankDelete);
}
}
foreach (var position in periodExam.PositionExam)
{
var positionData = updated.PositionExam
.FirstOrDefault(x => x.Id == position.Id);
if (positionData != null)
{
position.PositionId = positionData.PositionId;
position.PositionName = positionData.PositionName;
position.TypeId = positionData.TypeId;
position.TypeName = positionData.TypeName;
position.LastUpdatedAt = DateTime.Now;
position.LastUpdateUserId = UserId ?? "";
position.LastUpdateFullName = FullName ?? "";
}
else
{
var positionDelete = await _context.PositionExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == position.Id);
if (positionDelete != null)
_context.PositionExams.Remove(positionDelete);
}
}
var bankAdd = updated.BankExam
.Where(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
.ToList();
foreach (var bank in bankAdd)
{
var bankExam = new BankExam
{
PeriodExam = periodExam,
AccountName = bank.AccountName,
AccountNumber = bank.AccountNumber,
BankName = bank.BankName,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
LastUpdateUserId = UserId ?? "",
CreatedFullName = FullName ?? "",
LastUpdateFullName = FullName ?? "",
};
await _context.BankExams.AddAsync(bankExam);
}
var positionAdd = updated.PositionExam
.Where(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
.ToList();
foreach (var position in positionAdd)
{
var positionExam = new PositionExam
{
PeriodExam = periodExam,
PositionId = position.PositionId,
PositionName = position.PositionName,
TypeId = position.TypeId,
TypeName = position.TypeName,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
LastUpdateUserId = UserId ?? "",
CreatedFullName = FullName ?? "",
LastUpdateFullName = FullName ?? "",
};
await _context.PositionExams.AddAsync(positionExam);
}
await _context.SaveChangesAsync();
}
@ -322,7 +502,171 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.ToListAsync();
}
private async Task<List<RequestImportSeat>> ReadExcelCandidate(IFormFile formFile)
{
var list = new List<RequestImportSeat>();
using (var stream = new MemoryStream())
{
await formFile.CopyToAsync(stream);
using (var package = new ExcelPackage(stream))
{
for (int i = 0; i < package.Workbook.Worksheets.Count(); i++)
{
ExcelWorksheet worksheet = package.Workbook.Worksheets[i];
var rowCount = worksheet.Dimension.Rows;
for (int row = 2; row <= rowCount; row++)
{
System.Diagnostics.Debug.WriteLine(worksheet);
if (worksheet.Cells[row, 1].Value != null)
{
list.Add(new RequestImportSeat
{
CitizenId = worksheet.Cells[row, 1].Value != null ? worksheet.Cells[row, 1].Value.ToString() : "-",
ExamIdenNumber = worksheet.Cells[row, 2].Value != null ? worksheet.Cells[row, 2].Value.ToString() : "-",
SeatNumber = worksheet.Cells[row, 3].Value != null ? worksheet.Cells[row, 3].Value.ToString() : "-",
Point = worksheet.Cells[row, 4].Value != null ? worksheet.Cells[row, 4].Value.ToString() : "-",
});
}
}
}
}
}
return list;
}
public async Task UploadSeatCandidateAsync(string examId, IFormFile excels)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidates = await _context.Candidates
.AsQueryable()
.Where(x => x.PeriodExam == periodExam)
.ToListAsync();
var items = await ReadExcelCandidate(excels);
foreach (var candidate in candidates)
{
var item = items.FirstOrDefault(x => x.CitizenId == candidate.CitizenId && x.ExamIdenNumber == candidate.ExamIdenNumber);
if (item != null)
{
if (candidate.Status == "checkSeat")
{
candidate.SeatNumber = item.SeatNumber;
candidate.Status = "checkPoint";
}
else
{
candidate.Status = "waiver";
}
}
else
{
candidate.Status = "waiver";
}
periodExam.SetSeat = true;
}
await _context.SaveChangesAsync();
}
public async Task UploadPointCandidateAsync(string examId, IFormFile excels)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidates = await _context.Candidates
.AsQueryable()
.Where(x => x.PeriodExam == periodExam)
.ToListAsync();
var items = await ReadExcelCandidate(excels);
foreach (var candidate in candidates)
{
var item = items.FirstOrDefault(x => x.CitizenId == candidate.CitizenId && x.ExamIdenNumber == candidate.ExamIdenNumber);
if (item != null)
{
if (candidate.Status == "checkPoint")
{
candidate.Point = item.Point;
candidate.Status = "done";
}
else
{
candidate.Status = "waiver";
}
}
else
{
candidate.Status = "waiver";
}
periodExam.SetSeat = true;
}
await _context.SaveChangesAsync();
}
public async Task<MemoryStream> DownloadCandidateAsync(string examId)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidates = await _context.Candidates
.AsQueryable()
.Where(x => x.PeriodExam == periodExam)
.ToListAsync();
var stream = new MemoryStream();
using (var package = new ExcelPackage(stream))
{
var summarySheet = package.Workbook.Worksheets.Add("Candidate");
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 = "คะแนน";
int row = 2;
foreach (var item in candidates)
{
summarySheet.Cells[row, 1].Value = item.CitizenId;
summarySheet.Cells[row, 2].Value = item.ExamIdenNumber;
summarySheet.Cells[row, 3].Value = item.SeatNumber;
summarySheet.Cells[row, 4].Value = item.Point;
row++;
}
summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
package.Save();
}
stream.Position = 0;
return stream;
}
public async Task<IEnumerable<BankExam?>> GetsPaymentExamAsync(string examId)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Include(x => x.BankExam)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
return periodExam.BankExam;
}
#endregion
}
}

File diff suppressed because it is too large Load diff