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

View file

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

View file

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