เพิ่มโหลดวันที่จ่ายเงินผู้สมัคร
This commit is contained in:
parent
e8cb94c541
commit
1223720994
8 changed files with 3272 additions and 287 deletions
|
|
@ -804,6 +804,34 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
return Error(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/payment/{examId:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> DownloadCandidatePaymentAllAsync(string examId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var stream = await _periodExamService.DownloadCandidatePaymentAllAsync(examId);
|
||||||
|
|
||||||
|
string excelName = $"Candidate_Payment_{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx";
|
||||||
|
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", excelName);
|
||||||
|
// return Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -631,6 +631,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("ผลสมัครสอบ");
|
.HasComment("ผลสมัครสอบ");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("PaymentDate")
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasComment("วันที่ชำระเงิน");
|
||||||
|
|
||||||
b.Property<Guid?>("PaymentImgId")
|
b.Property<Guid?>("PaymentImgId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
|
|
|
||||||
2867
Migrations/20230608021817_update table candidate add paymentdate.Designer.cs
generated
Normal file
2867
Migrations/20230608021817_update table candidate add paymentdate.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class updatetablecandidateaddpaymentdate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
|
name: "PaymentDate",
|
||||||
|
table: "Candidates",
|
||||||
|
type: "datetime(6)",
|
||||||
|
nullable: true,
|
||||||
|
comment: "วันที่ชำระเงิน");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PaymentDate",
|
||||||
|
table: "Candidates");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -255,5 +255,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
||||||
[MaxLength(40), Comment("วันที่สมัคร")]
|
[MaxLength(40), Comment("วันที่สมัคร")]
|
||||||
public DateTime? RegisterDate { get; set; }
|
public DateTime? RegisterDate { get; set; }
|
||||||
|
|
||||||
|
[Comment("วันที่ชำระเงิน")]
|
||||||
|
public DateTime? PaymentDate { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1804,6 +1804,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
|
||||||
var num = periodExam.Count() + 1;
|
var num = periodExam.Count() + 1;
|
||||||
candidate.ExamIdenNumber = "CDC-" + num;
|
candidate.ExamIdenNumber = "CDC-" + num;
|
||||||
|
candidate.PaymentDate = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -884,17 +884,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
// {
|
// {
|
||||||
list.Add(new RequestImportSeat
|
list.Add(new RequestImportSeat
|
||||||
{
|
{
|
||||||
Number = worksheet.Cells[row, 2].Value != null ? worksheet.Cells[row, 1].Value.ToString() : null,
|
Number = worksheet.Cells[row, 4].Value != null ? worksheet.Cells[row, 4].Value.ToString() : null,
|
||||||
CitizenId = worksheet.Cells[row, 3].Value != null ? worksheet.Cells[row, 2].Value.ToString() : null,
|
CitizenId = worksheet.Cells[row, 5].Value != null ? worksheet.Cells[row, 5].Value.ToString() : null,
|
||||||
ExamIdenNumber = worksheet.Cells[row, 4].Value != null ? worksheet.Cells[row, 3].Value.ToString() : null,
|
ExamIdenNumber = worksheet.Cells[row, 6].Value != null ? worksheet.Cells[row, 6].Value.ToString() : null,
|
||||||
SeatNumber = worksheet.Cells[row, 5].Value != null ? worksheet.Cells[row, 4].Value.ToString() : null,
|
SeatNumber = worksheet.Cells[row, 7].Value != null ? worksheet.Cells[row, 7].Value.ToString() : null,
|
||||||
PointTotalB = worksheet.Cells[row, 6].Value != null ? worksheet.Cells[row, 5].Value.ToString() : null,
|
PointTotalB = worksheet.Cells[row, 8].Value != null ? worksheet.Cells[row, 8].Value.ToString() : null,
|
||||||
PointB = worksheet.Cells[row, 7].Value != null ? worksheet.Cells[row, 6].Value.ToString() : null,
|
PointB = worksheet.Cells[row, 9].Value != null ? worksheet.Cells[row, 9].Value.ToString() : null,
|
||||||
ResultB = worksheet.Cells[row, 8].Value != null ? worksheet.Cells[row, 7].Value.ToString() : null,
|
ResultB = worksheet.Cells[row, 10].Value != null ? worksheet.Cells[row, 10].Value.ToString() : null,
|
||||||
PointTotalC = worksheet.Cells[row, 9].Value != null ? worksheet.Cells[row, 8].Value.ToString() : null,
|
PointTotalC = worksheet.Cells[row, 11].Value != null ? worksheet.Cells[row, 11].Value.ToString() : null,
|
||||||
PointC = worksheet.Cells[row, 10].Value != null ? worksheet.Cells[row, 9].Value.ToString() : null,
|
PointC = worksheet.Cells[row, 12].Value != null ? worksheet.Cells[row, 12].Value.ToString() : null,
|
||||||
ResultC = worksheet.Cells[row, 11].Value != null ? worksheet.Cells[row, 10].Value.ToString() : null,
|
ResultC = worksheet.Cells[row, 13].Value != null ? worksheet.Cells[row, 13].Value.ToString() : null,
|
||||||
Pass = worksheet.Cells[row, 12].Value != null ? (worksheet.Cells[row, 11].Value.ToString()) : null,
|
Pass = worksheet.Cells[row, 14].Value != null ? (worksheet.Cells[row, 14].Value.ToString()) : null,
|
||||||
});
|
});
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
@ -1062,34 +1062,38 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
summarySheet.TabColor = System.Drawing.Color.Black;
|
summarySheet.TabColor = System.Drawing.Color.Black;
|
||||||
// summarySheet.DefaultRowHeight = 17;
|
// summarySheet.DefaultRowHeight = 17;
|
||||||
summarySheet.Row(1).Style.Font.Bold = true;
|
summarySheet.Row(1).Style.Font.Bold = true;
|
||||||
summarySheet.Cells[1, 1].Value = "วันเและเวลาที่สมัคร";
|
summarySheet.Cells[1, 1].Value = "ชำระค่าธรรมเนียม";
|
||||||
summarySheet.Cells[1, 2].Value = "ลำดับที่สอบได้";
|
summarySheet.Cells[1, 2].Value = "วันเวลาชำระ";
|
||||||
summarySheet.Cells[1, 3].Value = "เลขบัตรประชาชน";
|
summarySheet.Cells[1, 3].Value = "วันและเวลาที่สมัคร";
|
||||||
summarySheet.Cells[1, 4].Value = "เลขประจำตัวสอบ";
|
summarySheet.Cells[1, 4].Value = "ลำดับที่สอบได้";
|
||||||
summarySheet.Cells[1, 5].Value = "เลขที่นั่งสอบ";
|
summarySheet.Cells[1, 5].Value = "เลขบัตรประชาชน";
|
||||||
summarySheet.Cells[1, 6].Value = "คะแนนเต็มภาค ข";
|
summarySheet.Cells[1, 6].Value = "เลขประจำตัวสอบ";
|
||||||
summarySheet.Cells[1, 7].Value = "คะแนนภาค ข";
|
summarySheet.Cells[1, 7].Value = "เลขที่นั่งสอบ";
|
||||||
summarySheet.Cells[1, 8].Value = "ผลสอบภาค ข";
|
summarySheet.Cells[1, 8].Value = "คะแนนเต็มภาค ข";
|
||||||
summarySheet.Cells[1, 9].Value = "คะแนนเต็มภาค ค";
|
summarySheet.Cells[1, 9].Value = "คะแนนภาค ข";
|
||||||
summarySheet.Cells[1, 10].Value = "คะแนนภาค ค";
|
summarySheet.Cells[1, 10].Value = "ผลสอบภาค ข";
|
||||||
summarySheet.Cells[1, 11].Value = "ผลสอบภาค ค";
|
summarySheet.Cells[1, 11].Value = "คะแนนเต็มภาค ค";
|
||||||
summarySheet.Cells[1, 12].Value = "ผลการสอบ";
|
summarySheet.Cells[1, 12].Value = "คะแนนภาค ค";
|
||||||
|
summarySheet.Cells[1, 13].Value = "ผลสอบภาค ค";
|
||||||
|
summarySheet.Cells[1, 14].Value = "ผลการสอบ";
|
||||||
int row = 2;
|
int row = 2;
|
||||||
|
|
||||||
foreach (var item in candidates)
|
foreach (var item in candidates)
|
||||||
{
|
{
|
||||||
summarySheet.Cells[row, 1].Value = item.RegisterDate;
|
summarySheet.Cells[row, 1].Value = item.PaymentDate == null ? "ยังไม่ชำระเงิน" : "ชำระแล้ว";
|
||||||
summarySheet.Cells[row, 2].Value = item.Number;
|
summarySheet.Cells[row, 2].Value = item.PaymentDate == null ? "" : item.PaymentDate.Value.ToThaiShortDateTime();
|
||||||
summarySheet.Cells[row, 3].Value = item.CitizenId;
|
summarySheet.Cells[row, 3].Value = item.RegisterDate == null ? "" : item.RegisterDate.Value.ToThaiShortDateTime();
|
||||||
summarySheet.Cells[row, 4].Value = item.ExamIdenNumber;
|
summarySheet.Cells[row, 4].Value = item.Number;
|
||||||
summarySheet.Cells[row, 5].Value = item.SeatNumber;
|
summarySheet.Cells[row, 5].Value = item.CitizenId;
|
||||||
summarySheet.Cells[row, 6].Value = item.PointTotalB;
|
summarySheet.Cells[row, 6].Value = item.ExamIdenNumber;
|
||||||
summarySheet.Cells[row, 7].Value = item.PointB;
|
summarySheet.Cells[row, 7].Value = item.SeatNumber;
|
||||||
summarySheet.Cells[row, 8].Value = item.ResultB;
|
summarySheet.Cells[row, 8].Value = item.PointTotalB;
|
||||||
summarySheet.Cells[row, 9].Value = item.PointTotalC;
|
summarySheet.Cells[row, 9].Value = item.PointB;
|
||||||
summarySheet.Cells[row, 10].Value = item.PointC;
|
summarySheet.Cells[row, 10].Value = item.ResultB;
|
||||||
summarySheet.Cells[row, 11].Value = item.ResultC;
|
summarySheet.Cells[row, 11].Value = item.PointTotalC;
|
||||||
summarySheet.Cells[row, 12].Value = item.Pass;
|
summarySheet.Cells[row, 12].Value = item.PointC;
|
||||||
|
summarySheet.Cells[row, 13].Value = item.ResultC;
|
||||||
|
summarySheet.Cells[row, 14].Value = item.Pass;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
|
summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
|
||||||
|
|
@ -1649,6 +1653,54 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
stream.Position = 0;
|
stream.Position = 0;
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<MemoryStream> DownloadCandidatePaymentAllAsync(string examId)
|
||||||
|
{
|
||||||
|
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||||
|
.Where(x => x.CheckDisability == false)
|
||||||
|
.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)
|
||||||
|
.Select(c => new
|
||||||
|
{
|
||||||
|
CitizenId = c.CitizenId,
|
||||||
|
FullName = $"{c.PrefixName}{c.FirstName} {c.LastName}",
|
||||||
|
PaymentDate = c.PaymentDate,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
using (var package = new ExcelPackage(stream))
|
||||||
|
{
|
||||||
|
var summarySheet = package.Workbook.Worksheets.Add("Payment");
|
||||||
|
summarySheet.TabColor = System.Drawing.Color.Black;
|
||||||
|
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.FullName;
|
||||||
|
summarySheet.Cells[row, 3].Value = item.PaymentDate == null ? "ยังไม่ชำระเงิน" : "ชำระแล้ว";
|
||||||
|
summarySheet.Cells[row, 4].Value = item.PaymentDate == null ? "" : item.PaymentDate.Value;
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
|
||||||
|
package.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue