เพิ่มapi dashboard exam
This commit is contained in:
parent
ac3d2c9d26
commit
eb567349b4
10 changed files with 1956 additions and 261 deletions
|
|
@ -695,6 +695,32 @@ 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>
|
||||
[HttpGet("dashboard/{examId:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetsDashboardPaymentExamAsync(string examId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var items = await _periodExamService.GetsDashboardPaymentExamAsync(examId);
|
||||
|
||||
return Success(items);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -598,6 +598,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
|||
.HasColumnType("longtext")
|
||||
.HasComment("ประเภทอาชีพที่ทำงานมาก่อน");
|
||||
|
||||
b.Property<bool?>("Pass")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("ผลสมัครสอบ");
|
||||
|
||||
b.Property<Guid?>("PaymentImgId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
|
|
|
|||
1539
Migrations/20230419161736_update table exam add pass.Designer.cs
generated
Normal file
1539
Migrations/20230419161736_update table exam add pass.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
29
Migrations/20230419161736_update table exam add pass.cs
Normal file
29
Migrations/20230419161736_update table exam add pass.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class updatetableexamaddpass : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "Pass",
|
||||
table: "Candidates",
|
||||
type: "tinyint(1)",
|
||||
nullable: true,
|
||||
comment: "ผลสมัครสอบ");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Pass",
|
||||
table: "Candidates");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -226,5 +226,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
|||
[Comment("เหตุผลการไม่อนุมัติ")]
|
||||
public string? RejectDetail { get; set; }
|
||||
|
||||
[Comment("ผลสมัครสอบ")]
|
||||
public bool? Pass { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
|
|||
public string? ExamIdenNumber { get; set; }
|
||||
public string? SeatNumber { get; set; }
|
||||
public string? Point { get; set; }
|
||||
public bool? Pass { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
Response/DashboardResponseItem.cs
Normal file
12
Response/DashboardResponseItem.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||
{
|
||||
public class DashboardResponseItem
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
|
||||
public int? Count { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -484,14 +484,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
// if (periodExam.Positions.Count() == 0)
|
||||
// {
|
||||
// periodExam.Positions.Add(new HomePageLinkResponseItem
|
||||
// {
|
||||
// Title = "x.Name",
|
||||
// Url = $"{Configuration.GetValue<string>("Domain")}/exam/{periodExam.Id}/00000000-0000-0000-0000-000000000000"
|
||||
// });
|
||||
// }
|
||||
if (periodExam.Positions.Count() <= 0)
|
||||
{
|
||||
periodExam.Positions.Add(new HomePageLinkResponseItem
|
||||
{
|
||||
Title = "สมัครสอบ",
|
||||
Path = $"{periodExam.Id}/00000000-0000-0000-0000-000000000000",
|
||||
});
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
foreach (var item in periodExam.Images)
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
{
|
||||
return await _context.PeriodExams.AsQueryable()
|
||||
.Where(p => p.IsActive)
|
||||
.Where(p => type.ToUpper() == "ALL" ? (p.AnnouncementExam == true || p.AnnouncementExam == false) : (type.ToUpper() == "EXAM" ? p.AnnouncementExam == false : p.AnnouncementExam == true))
|
||||
.Where(p => type.ToUpper() == "ALL" ? (p.AnnouncementExam == true || p.AnnouncementExam == false) : (type.ToUpper() == "EXAM" ? p.AnnouncementExam == true : p.AnnouncementExam == false))
|
||||
.OrderByDescending(d => d.CreatedAt)
|
||||
.Select(x => new PeriodExamCandidateResponseItem
|
||||
{
|
||||
|
|
@ -757,6 +757,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
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() : "-",
|
||||
Pass = worksheet.Cells[row, 4].Value != null ? (worksheet.Cells[row, 4].Value.ToString() == "1" ? true : false) : null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -830,6 +831,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
if (candidate.Status == "checkPoint" || candidate.Status == "done")
|
||||
{
|
||||
candidate.Point = item.Point;
|
||||
candidate.Pass = item.Pass;
|
||||
candidate.Status = "done";
|
||||
}
|
||||
else
|
||||
|
|
@ -884,6 +886,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
summarySheet.Cells[1, 2].Value = "เลขประจำตัวสอบ";
|
||||
summarySheet.Cells[1, 3].Value = "เลขที่นั่งสอบ";
|
||||
summarySheet.Cells[1, 4].Value = "คะแนน";
|
||||
summarySheet.Cells[1, 5].Value = "ผลการสอบ";
|
||||
int row = 2;
|
||||
|
||||
foreach (var item in candidates)
|
||||
|
|
@ -892,6 +895,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
summarySheet.Cells[row, 2].Value = item.ExamIdenNumber;
|
||||
summarySheet.Cells[row, 3].Value = item.SeatNumber;
|
||||
summarySheet.Cells[row, 4].Value = item.Point;
|
||||
summarySheet.Cells[row, 5].Value = item.Pass;
|
||||
row++;
|
||||
}
|
||||
summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
|
||||
|
|
@ -919,6 +923,83 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
return periodExam;
|
||||
}
|
||||
|
||||
public async Task<List<DashboardResponseItem>> GetsDashboardPaymentExamAsync(string examId)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.Candidate)
|
||||
.Where(x => x.Id == Guid.Parse(examId))
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
var dashboard = new List<DashboardResponseItem>
|
||||
{
|
||||
new DashboardResponseItem
|
||||
{
|
||||
Id = 1,
|
||||
Name = "ผู้สมัครสอบ",
|
||||
Count = periodExam.Candidate.Count()
|
||||
},
|
||||
new DashboardResponseItem
|
||||
{
|
||||
Id = 2,
|
||||
Name = "ผ่านการสอบ",
|
||||
Count = periodExam.Candidate.Where(x=>x.Pass == true).Count()
|
||||
},
|
||||
new DashboardResponseItem
|
||||
{
|
||||
Id = 3,
|
||||
Name = "ไม่ผ่านการสอบ",
|
||||
Count = periodExam.Candidate.Where(x=>x.Pass == false).Count()
|
||||
},
|
||||
new DashboardResponseItem
|
||||
{
|
||||
Id = 4,
|
||||
Name = "เพศชาย",
|
||||
Count = periodExam.Candidate.Where(x=>x.PrefixName != null && x.PrefixName.Contains("ชาย")).Count()
|
||||
},
|
||||
new DashboardResponseItem
|
||||
{
|
||||
Id = 5,
|
||||
Name = "เพศหญิง",
|
||||
Count = periodExam.Candidate.Where(x=>x.PrefixName != null && x.PrefixName.Contains("หญิง")).Count()
|
||||
},
|
||||
new DashboardResponseItem
|
||||
{
|
||||
Id = 6,
|
||||
Name = "เพศอื่นๆ",
|
||||
Count = periodExam.Candidate.Count() -periodExam.Candidate.Where(x=>x.PrefixName != null && x.PrefixName.Contains("ชาย")).Count()-periodExam.Candidate.Where(x=>x.PrefixName != null && x.PrefixName.Contains("หญิง")).Count()
|
||||
},
|
||||
// new DashboardResponseItem
|
||||
// {
|
||||
// Id = 7,
|
||||
// Name = "จังหวัด",
|
||||
// Count = provinceItem.ProvinceCount
|
||||
// },
|
||||
// new DashboardResponseItem
|
||||
// {
|
||||
// Id = 8,
|
||||
// Name = "เขต/อำเภอ",
|
||||
// Count = provinceItem.DistrictCount
|
||||
// },
|
||||
// new DashboardResponseItem
|
||||
// {
|
||||
// Id = 9,
|
||||
// Name = "แขวง/ตำบล",
|
||||
// Count = provinceItem.SubDistrictCount
|
||||
// },
|
||||
// new DashboardResponseItem
|
||||
// {
|
||||
// Id = 10,
|
||||
// Name = "รหัสไปรษณีย์",
|
||||
// Count = provinceItem.ZipCodeCount
|
||||
// },
|
||||
};
|
||||
|
||||
return dashboard;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue