รายงานผู้มีสิทธฺสอบ และรายงานคะแนนสอบ
This commit is contained in:
parent
9911b7432b
commit
0906690285
5 changed files with 375 additions and 88 deletions
|
|
@ -90,9 +90,15 @@
|
||||||
<None Update="Report\Recruit\rptCertificate2.trdp">
|
<None Update="Report\Recruit\rptCertificate2.trdp">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Report\Recruit\rptCandidateList.trdp">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="Report\Recruit\rptExamResult.trdp">
|
<None Update="Report\Recruit\rptExamResult.trdp">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Report\Recruit\rptPassExamList.trdp">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,145 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("candidate/{id:length(36)}")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetCandidateListReportAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = await _context.Disables.AsQueryable()
|
||||||
|
.Include(x => x.PeriodExam)
|
||||||
|
.Where(x => x.PeriodExam.Id == id)
|
||||||
|
.OrderBy(x => x.ExamId)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
ExamId = p.ExamId,
|
||||||
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||||
|
PositionName = p.PositionName,
|
||||||
|
ExamName =
|
||||||
|
$"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}",
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptCandidateList.trdp");
|
||||||
|
ReportPackager reportPackager = new ReportPackager();
|
||||||
|
Telerik.Reporting.Report report = null;
|
||||||
|
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||||
|
{
|
||||||
|
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
report.DataSource = data;
|
||||||
|
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||||
|
|
||||||
|
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||||
|
{
|
||||||
|
ReportDocument = report
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||||
|
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||||
|
|
||||||
|
var content = result.DocumentBytes;
|
||||||
|
return File(content, "application/pdf", $"รายชื่อผู้มีสิทธิ์สอบ_{data.First().ExamName}.pdf");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("pass/{id:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetPassExamListReportAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = await _context.Disables.AsQueryable()
|
||||||
|
.Include(x => x.PeriodExam)
|
||||||
|
.ThenInclude(x => x.ScoreImport)
|
||||||
|
.Include(x => x.Documents)
|
||||||
|
.ThenInclude(x => x.DocumentFile)
|
||||||
|
|
||||||
|
|
||||||
|
.Join(_context.DisableScores.AsQueryable()
|
||||||
|
.Include(x => x.ScoreImport)
|
||||||
|
.Where(x => x.ScoreImport.PeriodExamId == id)
|
||||||
|
.Where(x => x.ExamStatus == "ผ่าน"),
|
||||||
|
rc => new { id = rc.PeriodExam.Id, examId = rc.ExamId },
|
||||||
|
sc => new { id = sc.ScoreImport.PeriodExamId, examId = sc.ExamId },
|
||||||
|
(p, sr) => new
|
||||||
|
{
|
||||||
|
Id = p.PeriodExam.Id,
|
||||||
|
ExamId = p.ExamId,
|
||||||
|
CitizenId = p.CitizenId,
|
||||||
|
p.Prefix,
|
||||||
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||||
|
DateOfBirth = p.DateOfBirth.ToThaiShortDate(),
|
||||||
|
Gender = p.Gendor,
|
||||||
|
Degree = p.Educations.First().Degree,
|
||||||
|
Major = p.Educations.First().Major,
|
||||||
|
|
||||||
|
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||||
|
|
||||||
|
University = p.Educations.First().University,
|
||||||
|
PositionName = p.PositionName,
|
||||||
|
ExamName = $"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}",
|
||||||
|
|
||||||
|
|
||||||
|
Number = sr == null ? "" : sr.Number,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FullA = sr == null ? 0 : sr.FullA,
|
||||||
|
SumA = sr == null ? 0 : sr.SumA,
|
||||||
|
FullB = sr == null ? 0 : sr.FullB,
|
||||||
|
SumB = sr == null ? 0 : sr.SumB,
|
||||||
|
FullC = sr == null ? 0 : sr.FullC,
|
||||||
|
SumC = sr == null ? 0 : sr.SumC,
|
||||||
|
SumScore = sr == null ? 0 : sr.SumA + sr.SumB + sr.SumC,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
.OrderBy(x => x.Number)
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Where(x => x.ExamResult == "ผ่าน")
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptPassExamList.trdp");
|
||||||
|
ReportPackager reportPackager = new ReportPackager();
|
||||||
|
Telerik.Reporting.Report report = null;
|
||||||
|
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||||
|
{
|
||||||
|
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
report.DataSource = data;
|
||||||
|
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||||
|
|
||||||
|
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||||
|
{
|
||||||
|
ReportDocument = report
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||||
|
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||||
|
|
||||||
|
var content = result.DocumentBytes;
|
||||||
|
return File(content, "application/pdf", $"รายชื่อผู้สอบแข่งขันได้_{data.First().ExamName}.pdf");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,148 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("candidate/{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetCandidateListReportAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = await _context.Recruits.AsQueryable()
|
||||||
|
.Include(x => x.RecruitImport)
|
||||||
|
.Include(x => x.Documents)
|
||||||
|
.ThenInclude(x => x.DocumentFile)
|
||||||
|
.Where(x => x.RecruitImport.Id == id)
|
||||||
|
.OrderBy(x => x.ExamId)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
ExamId = p.ExamId,
|
||||||
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||||
|
PositionName = p.PositionName,
|
||||||
|
ExamName =
|
||||||
|
$"{p.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order}/{p.RecruitImport.Year.ToThaiYear()}",
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptCandidateList.trdp");
|
||||||
|
ReportPackager reportPackager = new ReportPackager();
|
||||||
|
Telerik.Reporting.Report report = null;
|
||||||
|
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||||
|
{
|
||||||
|
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
report.DataSource = data;
|
||||||
|
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||||
|
|
||||||
|
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||||
|
{
|
||||||
|
ReportDocument = report
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||||
|
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||||
|
|
||||||
|
var content = result.DocumentBytes;
|
||||||
|
return File(content, "application/pdf", $"รายชื่อผู้มีสิทธิ์สอบ_{data.First().ExamName}.pdf");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("pass/{id:length(36)}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetPassExamListReportAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = await _context.Recruits.AsQueryable()
|
||||||
|
.Include(x => x.RecruitImport)
|
||||||
|
.ThenInclude(x => x.ScoreImport)
|
||||||
|
.Include(x => x.Documents)
|
||||||
|
.ThenInclude(x => x.DocumentFile)
|
||||||
|
|
||||||
|
|
||||||
|
.Join(_context.RecruitScores.AsQueryable()
|
||||||
|
.Include(x => x.ScoreImport)
|
||||||
|
.Where(x => x.ScoreImport.RecruitImportId == id)
|
||||||
|
.Where(x => x.ExamStatus == "ผ่าน"),
|
||||||
|
rc => new { id = rc.RecruitImport.Id, examId = rc.ExamId },
|
||||||
|
sc => new { id = sc.ScoreImport.RecruitImportId, examId = sc.ExamId },
|
||||||
|
(p, sr) => new
|
||||||
|
{
|
||||||
|
Id = p.RecruitImport.Id,
|
||||||
|
ExamId = p.ExamId,
|
||||||
|
CitizenId = p.CitizenId,
|
||||||
|
p.Prefix,
|
||||||
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||||
|
DateOfBirth = p.DateOfBirth.ToThaiShortDate(),
|
||||||
|
Gender = p.Gendor,
|
||||||
|
Degree = p.Educations.First().Degree,
|
||||||
|
Major = p.Educations.First().Major,
|
||||||
|
|
||||||
|
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||||
|
|
||||||
|
University = p.Educations.First().University,
|
||||||
|
PositionName = p.PositionName,
|
||||||
|
ExamName = $"{p.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order}/{p.RecruitImport.Year.ToThaiYear()}",
|
||||||
|
|
||||||
|
|
||||||
|
Number = sr == null ? "" : sr.Number,
|
||||||
|
ExamCount = _recruitService.GetExamCount(p.CitizenId),
|
||||||
|
ScoreExpire = p.RecruitImport.AnnouncementDate == null ? "" : p.RecruitImport.AnnouncementDate.Value.AddYears(2).ToThaiShortDate(),
|
||||||
|
|
||||||
|
|
||||||
|
FullA = sr == null ? 0 : sr.FullA,
|
||||||
|
SumA = sr == null ? 0 : sr.SumA,
|
||||||
|
FullB = sr == null ? 0 : sr.FullB,
|
||||||
|
SumB = sr == null ? 0 : sr.SumB,
|
||||||
|
FullC = sr == null ? 0 : sr.FullC,
|
||||||
|
SumC = sr == null ? 0 : sr.SumC,
|
||||||
|
SumScore = sr == null ? 0 : sr.SumA + sr.SumB + sr.SumC,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
.OrderBy(x => x.Number)
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Where(x => x.ExamResult == "ผ่าน")
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptPassExamList.trdp");
|
||||||
|
ReportPackager reportPackager = new ReportPackager();
|
||||||
|
Telerik.Reporting.Report report = null;
|
||||||
|
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||||
|
{
|
||||||
|
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
report.DataSource = data;
|
||||||
|
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||||
|
|
||||||
|
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||||
|
{
|
||||||
|
ReportDocument = report
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||||
|
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||||
|
|
||||||
|
var content = result.DocumentBytes;
|
||||||
|
return File(content, "application/pdf", $"รายชื่อผู้สอบแข่งขันได้_{data.First().ExamName}.pdf");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
Report/Recruit/rptCandidateList.trdp
Normal file
BIN
Report/Recruit/rptCandidateList.trdp
Normal file
Binary file not shown.
BIN
Report/Recruit/rptPassExamList.trdp
Normal file
BIN
Report/Recruit/rptPassExamList.trdp
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue