ปรับ Report Resign, Deceased

This commit is contained in:
Bright 2024-08-02 17:45:47 +07:00
parent 197f8f7150
commit 6bb5c90964
3 changed files with 69 additions and 57 deletions

View file

@ -258,7 +258,7 @@ namespace BMA.EHR.Application.Repositories.Reports
// string FirstName = string.IsNullOrEmpty(data.FirstName.ToString()) ? string.Empty : data.FirstName.ToString();
// string LastName = string.IsNullOrEmpty(data.LastName.ToString()) ? string.Empty : data.LastName.ToString();
// string FullName = $"{Prefix} {FirstName} {LastName}";
string Date = string.IsNullOrEmpty(data.Date.ToString()) ? "วันที่ - เดือน - พ.ศ. -" : DateTime.Parse(data.Date.ToString()).ToThaiFullDate().ToString().ToThaiNumber();
string Date = string.IsNullOrEmpty(data.Date.ToString()) ? "-" : DateTime.Parse(data.Date.ToString()).ToThaiFullDate().ToString().ToThaiNumber();
string CurrentDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).ToThaiFullDate().ToString().ToThaiNumber();
return new
{
@ -282,8 +282,8 @@ namespace BMA.EHR.Application.Repositories.Reports
data.posMasterNo,
data.posLevelName,
data.posTypeName,
data.Number,
data.Location,
Number = data.Number != null ? data.Number.ToThaiNumber() : "-",
Location = data.Location != null ? data.Location.ToThaiNumber() : "-",
data.Reason,
Position = data.position,
};
@ -334,8 +334,8 @@ namespace BMA.EHR.Application.Repositories.Reports
return new
{
Oc = oc,
Number = $"กท /{data.CreatedAt.Year.ToThaiYear()}",
Date = data.CreatedAt.ToThaiFullDate().ToString().ToThaiNumber(),
Number = $"กท /{(data.CreatedAt.Year.ToThaiYear()).ToString().ToThaiNumber()}",
Date = data.CreatedAt.ToThaiFullDate2().ToString().ToThaiNumber(),
Subject = "ข้าราชการถึงแก่กรรม",
Send = "หัวหน้าสำนักงาน ก.ก.",
};

View file

@ -73,8 +73,8 @@ namespace BMA.EHR.Report.Service.Controllers
try
{
var head = await _repository.GetHeadRetirementDeceasedAsync(id);
var data = await _repository.GetRetirementDeceasedAsync(id);
if (data != null || head != null)
var detail = await _repository.GetRetirementDeceasedAsync(id);
if (detail != null && head != null)
{
var mergeData = new
{
@ -83,13 +83,13 @@ namespace BMA.EHR.Report.Service.Controllers
Date = head.GetType().GetProperty("Date").GetValue(head),
Subject = head.GetType().GetProperty("Subject").GetValue(head),
Send = head.GetType().GetProperty("Send").GetValue(head),
FullName = data.GetType().GetProperty("FullName").GetValue(data),
Position = data.GetType().GetProperty("Position").GetValue(data),
Reason = data.GetType().GetProperty("Reason").GetValue(data),
DeceasedDate = data.GetType().GetProperty("Date").GetValue(data),
CurrentDate = data.GetType().GetProperty("CurrentDate").GetValue(data),
DeceasedNumber = data.GetType().GetProperty("Number").GetValue(data),
Location = data.GetType().GetProperty("Location").GetValue(data),
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())
@ -99,22 +99,29 @@ namespace BMA.EHR.Report.Service.Controllers
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
}
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
//var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp");
//ReportPackager reportPacker = new ReportPackager();
//Telerik.Reporting.Report? report = null;
//using (var sourceStream = System.IO.File.OpenRead(rptFile))
//{
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
//}
//report.DataSource = mergeData;
//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);
//return File(result.DocumentBytes, mimeType, $"รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม.{exportType.Trim().ToLower()}");
var data = new
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
}
report.DataSource = mergeData;
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = report,
template = "deceased",
reportName = "docx-report",
data = mergeData
};
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
return File(result.DocumentBytes, mimeType, $"รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม.{exportType.Trim().ToLower()}");
return Success(data);
}
else
{

View file

@ -57,12 +57,11 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("33/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetResign33ConvertReportAsync(string id= "08dbca15-bb57-4b2e-8435-69116599421b", string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetResign33ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
Guid ids = Guid.Parse(id);
var resign = await _service.GetResignByUser(ids);
var resign = await _service.GetResignByUser(id);
if (resign == null)
return NotFound();
@ -75,37 +74,43 @@ namespace BMA.EHR.Report.Service.Controllers
}
//var FullName = resign.GetType().GetProperty("FirstName").GetValue(resign);
var rptFile1 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-2.trdp");
//var rptFile1 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-1.trdp");
//var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-2.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report1 = null;
Telerik.Reporting.Report? report2 = null;
//ReportPackager reportPacker = new ReportPackager();
//Telerik.Reporting.Report? report1 = null;
//Telerik.Reporting.Report? report2 = null;
using (var sourceStream1 = System.IO.File.OpenRead(rptFile1))
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//using (var sourceStream1 = System.IO.File.OpenRead(rptFile1))
//using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//{
// report1 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream1);
// report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
//}
//report1.DataSource = resign;
//var reportBook = new ReportBook();
//reportBook.Reports.Add(report1);
//reportBook.Reports.Add(report2);
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//InstanceReportSource instanceReportSource = new InstanceReportSource()
//{
// ReportDocument = reportBook,
//};
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
//return File(result.DocumentBytes, mimeType, $"แบบฟอร์มหนังสือขอลาออกจากราชการ.{exportType.Trim().ToLower()}");
var data = new
{
report1 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream1);
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
}
report1.DataSource = resign;
var reportBook = new ReportBook();
reportBook.Reports.Add(report1);
reportBook.Reports.Add(report2);
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = reportBook,
template = "resign",
reportName = "docx-report",
data = resign
};
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
return File(result.DocumentBytes, mimeType, $"แบบฟอร์มหนังสือขอลาออกจากราชการ.{exportType.Trim().ToLower()}");
return Success(data);
}
catch
{