Report C-PM-11, C-PM-12, C-PM-21 (Template เท่านั้น)
This commit is contained in:
parent
55a0f5c6ed
commit
7b4d0e1ae6
5 changed files with 250 additions and 12 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
using BMA.EHR.Application.Common.Interfaces;
|
using Amazon.Runtime.Internal.Transform;
|
||||||
|
using Amazon.S3.Model.Internal.MarshallTransformations;
|
||||||
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
using BMA.EHR.Application.Responses.Reports;
|
using BMA.EHR.Application.Responses.Reports;
|
||||||
using BMA.EHR.Domain.Extensions;
|
using BMA.EHR.Domain.Extensions;
|
||||||
using BMA.EHR.Domain.Models.Commands.Core;
|
using BMA.EHR.Domain.Models.Commands.Core;
|
||||||
|
|
@ -460,6 +462,76 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<CommandType11Response>> GetCommandType11Async(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var raw_data = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.Include(c => c.Command)
|
||||||
|
.Where(c => c.Command.Id == id)
|
||||||
|
.Select(r => new CommandType11Response
|
||||||
|
{
|
||||||
|
CommandNo = r.Command.CommandNo,
|
||||||
|
CommandYear = r.Command.CommandYear,
|
||||||
|
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(),
|
||||||
|
IssuerOrganizationName = r.Command.IssuerOrganizationName,
|
||||||
|
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
|
||||||
|
AuthorizedPosition = r.Command.AuthorizedPosition,
|
||||||
|
CitizenId = r.CitizenId,
|
||||||
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||||
|
PlacementCommandIssuer = r.Command.PlacementCommandIssuer,
|
||||||
|
PlacementCommandNo = r.Command.PlacementCommandNo,
|
||||||
|
PlacementCommandDate = r.Command.PlacementCommandDate == null ? "" : r.Command.PlacementCommandDate.Value.ToThaiFullDate3()
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (raw_data == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
return raw_data;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<CommandType11Response>> GetCommandType12Async(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var raw_data = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.Include(c => c.Command)
|
||||||
|
.Where(c => c.Command.Id == id)
|
||||||
|
.Select(r => new CommandType11Response
|
||||||
|
{
|
||||||
|
CommandNo = r.Command.CommandNo,
|
||||||
|
CommandYear = r.Command.CommandYear,
|
||||||
|
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(),
|
||||||
|
IssuerOrganizationName = r.Command.IssuerOrganizationName,
|
||||||
|
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
|
||||||
|
AuthorizedPosition = r.Command.AuthorizedPosition,
|
||||||
|
CitizenId = r.CitizenId,
|
||||||
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||||
|
PlacementCommandIssuer = r.Command.PlacementCommandIssuer,
|
||||||
|
PlacementCommandNo = r.Command.PlacementCommandNo,
|
||||||
|
PlacementCommandDate = r.Command.PlacementCommandDate == null ? "" : r.Command.PlacementCommandDate.Value.ToThaiFullDate3()
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (raw_data == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
return raw_data;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<CommandType15Response>> GetCommandType15AttachmentAsync(Guid id)
|
public async Task<List<CommandType15Response>> GetCommandType15AttachmentAsync(Guid id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
namespace BMA.EHR.Application.Responses.Reports
|
||||||
|
{
|
||||||
|
public class CommandType11Response
|
||||||
|
{
|
||||||
|
public string CommandNo { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string CommandYear { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string IssuerOrganizationName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string CommandAffectDate { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string AuthorizedUserFullName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string AuthorizedPosition { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string CitizenId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string FullName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PlacementCommandIssuer { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PlacementCommandNo { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PlacementCommandDate { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -70,7 +70,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString(),
|
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString(),
|
||||||
IssuerOrganizationName = raw_data.IssuerOrganizationName,
|
IssuerOrganizationName = raw_data.IssuerOrganizationName,
|
||||||
ConclusionRegisterNo = raw_data.ConclusionRegisterNo,
|
ConclusionRegisterNo = raw_data.ConclusionRegisterNo,
|
||||||
ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "": raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3(),
|
ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3(),
|
||||||
ConclusionResultNo = raw_data.ConclusionResultNo,
|
ConclusionResultNo = raw_data.ConclusionResultNo,
|
||||||
ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3(),
|
ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3(),
|
||||||
PositionList = "",
|
PositionList = "",
|
||||||
|
|
@ -92,7 +92,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
report.DataSource = command;
|
report.DataSource = command;
|
||||||
|
|
||||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||||
if(exportType == "docx")
|
if (exportType == "docx")
|
||||||
deviceInfo["OutputFormat"] = "DOCX";
|
deviceInfo["OutputFormat"] = "DOCX";
|
||||||
|
|
||||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||||
|
|
@ -1196,6 +1196,100 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region " C-PM-11 "
|
||||||
|
|
||||||
|
private async Task<byte[]> GenerateCommandReportType11_Cover(Guid commandId, string exportType)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _repository.GetByIdAsync(commandId);
|
||||||
|
if (command == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await _commandReportRepository.GetCommandType11Async(commandId);
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"11-คำสั่งให้ข้าราชการที่ผ่านการประเมิน รับราชการต่อไป.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(exportType, instanceReportSource, deviceInfo);
|
||||||
|
|
||||||
|
var content = result.DocumentBytes;
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " C-PM-12 "
|
||||||
|
|
||||||
|
private async Task<byte[]> GenerateCommandReportType12_Cover(Guid commandId, string exportType)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _repository.GetByIdAsync(commandId);
|
||||||
|
if (command == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await _commandReportRepository.GetCommandType11Async(commandId);
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"12-คำสั่งให้ข้าราชการที่ไม่ผ่านการประเมิน ออกจากราชการ.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(exportType, instanceReportSource, deviceInfo);
|
||||||
|
|
||||||
|
var content = result.DocumentBytes;
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region " C-PM-15 "
|
#region " C-PM-15 "
|
||||||
|
|
||||||
private async Task<byte[]> GenerateCommandReportType15_Cover(Guid commandId, string exportType)
|
private async Task<byte[]> GenerateCommandReportType15_Cover(Guid commandId, string exportType)
|
||||||
|
|
@ -1522,7 +1616,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||||
{
|
{
|
||||||
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
report.DataSource = data;
|
report.DataSource = data;
|
||||||
|
|
||||||
|
|
@ -2451,7 +2545,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
public IActionResult GetCommandType11CoverReport(Guid id, string exportType = "pdf")
|
public async Task<ActionResult<ResponseObject>> GetCommandType11CoverReportAsync(Guid id, string exportType = "pdf")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -2463,10 +2557,12 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"11-คำสั่งให้ข้าราชการที่ผ่านการประเมิน รับราชการต่อไป.trdp");
|
var cmd = await _repository.GetByIdAsync(id);
|
||||||
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
if (cmd == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
|
var contentData = await GenerateCommandReportType11_Cover(id, exportType);
|
||||||
|
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -2492,7 +2588,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
public IActionResult GetCommandType12CoverReport(Guid id, string exportType = "pdf")
|
public async Task<ActionResult<ResponseObject>> GetCommandType12CoverReportAsync(Guid id, string exportType = "pdf")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -2504,10 +2600,12 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"12-คำสั่งให้ข้าราชการที่ไม่ผ่านการประเมิน ออกจากราชการ.trdp");
|
var cmd = await _repository.GetByIdAsync(id);
|
||||||
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
if (cmd == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
|
var contentData = await GenerateCommandReportType12_Cover(id, exportType);
|
||||||
|
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -3009,6 +3107,47 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region " C-PM-21 คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// คำสั่ง C-PM-21 คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Record Id ของคำสั่ง</param>
|
||||||
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("c-pm-21/cover/{exportType}/{id}")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public IActionResult GetCommandType21CoverReport(Guid id, string exportType = "pdf")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var mimeType = "";
|
||||||
|
switch (exportType.Trim().ToLower())
|
||||||
|
{
|
||||||
|
case "pdf": mimeType = "application/pdf"; break;
|
||||||
|
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
||||||
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"20-คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ-2.trdp");
|
||||||
|
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
||||||
|
|
||||||
|
return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue