This commit is contained in:
parent
056a768ac9
commit
ce5f2e3389
1 changed files with 58 additions and 7 deletions
|
|
@ -3,10 +3,6 @@ using BMA.EHR.Application.Repositories.MessageQueue;
|
||||||
using BMA.EHR.Application.Repositories.Reports;
|
using BMA.EHR.Application.Repositories.Reports;
|
||||||
using BMA.EHR.Application.Responses;
|
using BMA.EHR.Application.Responses;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
using BMA.EHR.Domain.Extensions;
|
|
||||||
using BMA.EHR.Domain.Models.HR;
|
|
||||||
using BMA.EHR.Domain.Models.MetaData;
|
|
||||||
using BMA.EHR.Domain.Models.Notifications;
|
|
||||||
using BMA.EHR.Domain.Models.Retirement;
|
using BMA.EHR.Domain.Models.Retirement;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using BMA.EHR.Infrastructure.Persistence;
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
|
@ -18,10 +14,7 @@ using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
|
||||||
|
|
||||||
namespace BMA.EHR.Retirement.Service.Controllers
|
namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -747,5 +740,63 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 36-บันทึกเวียนแจ้งการถึงแก่กรรม
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">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("36/{exportType}/{id}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDeceasedReportAsync(Guid id, string exportType = "pdf")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var head = await _repositoryRetireReport.GetHeadRetirementDeceasedAsync(id);
|
||||||
|
var detail = await _repositoryRetireReport.GetRetirementDeceasedAsync(id);
|
||||||
|
if (detail != null && head != null)
|
||||||
|
{
|
||||||
|
var mergeData = new
|
||||||
|
{
|
||||||
|
Oc = head.GetType().GetProperty("Oc").GetValue(head),
|
||||||
|
Number = head.GetType().GetProperty("Number").GetValue(head),
|
||||||
|
Date = head.GetType().GetProperty("Date").GetValue(head),
|
||||||
|
Subject = head.GetType().GetProperty("Subject").GetValue(head),
|
||||||
|
Send = head.GetType().GetProperty("Send").GetValue(head),
|
||||||
|
FullName = detail.GetType().GetProperty("FullName").GetValue(detail),
|
||||||
|
Position = detail.GetType().GetProperty("Position").GetValue(detail),
|
||||||
|
Reason = detail.GetType().GetProperty("Reason").GetValue(detail),
|
||||||
|
DeceasedDate = detail.GetType().GetProperty("Date").GetValue(detail),
|
||||||
|
CurrentDate = detail.GetType().GetProperty("CurrentDate").GetValue(detail),
|
||||||
|
DeceasedNumber = detail.GetType().GetProperty("Number").GetValue(detail),
|
||||||
|
Location = detail.GetType().GetProperty("Location").GetValue(detail),
|
||||||
|
};
|
||||||
|
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 data = new
|
||||||
|
{
|
||||||
|
template = "deceased",
|
||||||
|
reportName = "docx-report",
|
||||||
|
data = mergeData
|
||||||
|
};
|
||||||
|
return Success(data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue