เพิ่มคำสั่งยกเลิกลา

This commit is contained in:
Kittapath 2024-07-18 20:37:17 +07:00
parent bcf0c0bfdb
commit 033fc915d0
12 changed files with 19309 additions and 88 deletions

View file

@ -2849,6 +2849,111 @@ namespace BMA.EHR.Report.Service.Controllers
}
#endregion
#region " C-PM-40 "
private async Task</*byte[]*/dynamic> GenerateCommandReportType40_Attachment(Guid commandId, string exportType, string token)
{
try
{
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType40AttachmentAsync(commandId, token);
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
CommandExcecuteDate = command.CommandExcecuteDate,
data = data,
};
}
catch
{
throw;
}
}
#endregion
#region " C-PM-41 "
private async Task</*byte[]*/dynamic> GenerateCommandReportType41_Cover(Guid commandId, string exportType)
{
try
{
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
ConclusionRegisterNo = raw_data.ConclusionRegisterNo == null ? "" : raw_data.ConclusionRegisterNo.ToThaiNumber(),
ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3().ToThaiNumber(),
ConclusionResultNo = raw_data.ConclusionResultNo == null ? "" : raw_data.ConclusionResultNo.ToThaiNumber(),
ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3().ToThaiNumber(),
PositionList = "",
Count = raw_data.Receivers.Count.ToString().ToThaiNumber(),
CommandAffectDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
AuthorizedUserFullName = raw_data.AuthorizedUserFullName,
AuthorizedPosition = raw_data.AuthorizedPosition,
Subject = $"เรื่อง {raw_data.CommandSubject}",
};
return command;
}
catch
{
throw;
}
}
private async Task</*byte[]*/dynamic> GenerateCommandReportType41_Attachment(Guid commandId, string exportType)
{
try
{
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType41AttachmentAsync(commandId);
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
CommandExcecuteDate = command.CommandExcecuteDate,
data = data,
};
}
catch
{
throw;
}
}
#endregion
#region " C-PM-25 "
private async Task<dynamic> GenerateCommandReportType25_Cover(Guid commandId, string exportType, string token)
@ -5792,6 +5897,200 @@ namespace BMA.EHR.Report.Service.Controllers
}
#endregion
#region " C-PM-40 คำสั่งปรับโครงสร้าง "
/// <summary>
/// คำสั่ง C-PM-40 คำสั่งปรับโครงสร้าง
/// </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-40/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType40CoverReport(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;
}
var cmd = await _repository.GetByIdAsync(id);
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType33_Cover(id, exportType);
var data = new
{
template = "C-PM-40",
reportName = "docx-report",
data = contentData
};
return Success(data);
}
catch
{
throw;
}
}
/// <summary>
/// เอกสารแนบท้าย C-PM-40 คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย)
/// </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-40/attachment/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType40AttachmentReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
var cmd = await _repository.GetByIdAsync(id);
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
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 token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType40_Attachment(id, exportType, token);
var data = new
{
template = "C-PM-40-attachment",
reportName = "docx-report",
data = contentData
};
return Success(data);
}
catch
{
throw;
}
}
#endregion
#region " C-PM-41 คำสั่งยกเลิกการลาออก "
/// <summary>
/// คำสั่ง C-PM-41 คำสั่งยกเลิกการลาออก
/// </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-41/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType41CoverReportAsync(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 cmd = await _repository.GetByIdAsync(id);
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType41_Cover(id, exportType);
//return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "C-PM-41",
reportName = "docx-report",
data = contentData
};
return Success(data);
}
catch
{
throw;
}
}
/// <summary>
/// เอกสารแนบท้าย C-PM-41 คำสั่งยกเลิกการลาออก
/// </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-41/attachment/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType41AttachmentReportAsync(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 cmd = await _repository.GetByIdAsync(id);
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType41_Attachment(id, exportType);
//return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "C-PM-41-attachment",
reportName = "docx-report",
data = contentData
};
return Success(data);
}
catch
{
throw;
}
}
#endregion
#endregion
}
}