Merge branch 'develop' into working

This commit is contained in:
Suphonchai Phoonsawat 2023-09-15 09:53:05 +07:00
commit a62e71268c
29 changed files with 914 additions and 410 deletions

View file

@ -57,7 +57,7 @@ namespace BMA.EHR.Report.Service.Controllers
/// <summary>
/// 36-บันทึกเวียนแจ้งการถึงแก่กรรม
/// </summary>
/// <param name="id">id </param>
/// <param name="id">Id รายการบันทึกเวียนแจ้งการถึงแก่กรรม</param>
/// <param name="exportType">pdf, docx หรือ xlsx</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
@ -68,9 +68,25 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var head = await _repository.GetHeadRetirementDeceasedAsync(id);
var data = await _repository.GetRetirementDeceasedAsync(id);
if (data != null)
if (data != 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 = 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),
};
var mimeType = "";
switch (exportType.Trim().ToLower())
{
@ -86,7 +102,7 @@ namespace BMA.EHR.Report.Service.Controllers
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
}
report.DataSource = data;
report.DataSource = mergeData;
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
@ -94,7 +110,76 @@ namespace BMA.EHR.Report.Service.Controllers
};
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
return File(result.DocumentBytes, mimeType, $"deceased.{exportType.Trim().ToLower()}");
return File(result.DocumentBytes, mimeType, $"รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม.{exportType.Trim().ToLower()}");
}
else
{
return NotFound();
}
}
catch
{
throw;
}
}
/// <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("copy/36/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetDeceasedReportCopyAsync(Guid id, string exportType = "pdf")
{
try
{
var head = await _repository.GetHeadRetirementDeceasedAsync(id);
var data = await _repository.GetRetirementDeceasedAsync(id);
if (data != 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 = 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),
};
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 = 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()}");
}
else
{

View file

@ -1,22 +1,10 @@
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Application.Repositories.Reports;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
using Swashbuckle.AspNetCore.Annotations;
using DocumentFormat.OpenXml.Drawing;
using Telerik.Reporting;
using Telerik.Reporting.Processing;
using System.IO;
using Newtonsoft.Json;
using BMA.EHR.Application.Responses;
using static BMA.EHR.Application.Responses.EvaluateRecordAssignResponse;
using static BMA.EHR.Application.Responses.ProbationAssignResponse;
using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Wordprocessing;
namespace BMA.EHR.Report.Service.Controllers
{
@ -819,7 +807,7 @@ namespace BMA.EHR.Report.Service.Controllers
Check_Moral2Level2 = moral2.col2,
Check_Moral2Level3 = moral2.col3,
Check_Moral2Level4 = moral2.col4,
Check_Moral2Level5 = moral2.col4,
Check_Moral2Level5 = moral2.col5,
Check_Moral3Level1 = moral3.col1,
Check_Moral3Level2 = moral3.col2,
Check_Moral3Level3 = moral3.col3,
@ -1033,7 +1021,7 @@ namespace BMA.EHR.Report.Service.Controllers
Check_Moral2Level2 = moral2.col2,
Check_Moral2Level3 = moral2.col3,
Check_Moral2Level4 = moral2.col4,
Check_Moral2Level5 = moral2.col4,
Check_Moral2Level5 = moral2.col5,
Check_Moral3Level1 = moral3.col1,
Check_Moral3Level2 = moral3.col2,
Check_Moral3Level3 = moral3.col3,
@ -1091,6 +1079,7 @@ namespace BMA.EHR.Report.Service.Controllers
develop_other_training_percent = evaluate.develop_other_training_percent,
develop_total_percent = evaluate.develop_total_percent,
develop_result = evaluate.develop_result,
evaluate_result = evaluate.evaluate_result,
});
var tblEvaluateAssign1 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table2"];
@ -1101,7 +1090,7 @@ namespace BMA.EHR.Report.Service.Controllers
tblEvaluateAssign3.DataSource = _Evaluate;
var tblEvaluateAssign4 = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table3"];
tblEvaluateAssign4.DataSource = _Evaluate;
report2.DataSource = _Evaluate;
var reportBook = new ReportBook();
reportBook.Reports.Add(report);
reportBook.Reports.Add(report2);

View file

@ -42,14 +42,10 @@ namespace BMA.EHR.Report.Service.Controllers
public async Task<ActionResult<ResponseObject>> GetProfileRetirement([FromRoute] Guid Id, string exportType = "pdf")
{
var retire = await _service.GetProfileRetirementdAsync(Id);
if (retire == null)
if (retire != null)
{
return NotFound();
}
else
{
var reportfile = "";
var returnfile = "";
var reportfile = string.Empty;
var returnfile = string.Empty;
exportType = exportType.Trim();
switch (retire.GetType().GetProperty("Type").GetValue(retire))
{
@ -89,9 +85,10 @@ namespace BMA.EHR.Report.Service.Controllers
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
}
//Add Parameter
report.ReportParameters["Year"].Value = retire.GetType().GetProperty("Year").GetValue(retire);
report.ReportParameters["Total"].Value = retire.GetType().GetProperty("Total").GetValue(retire);
report.DataSource = retire;
////Add Parameter
//report.ReportParameters["Year"].Value = retire.GetType().GetProperty("Year").GetValue(retire);
//report.ReportParameters["Total"].Value = retire.GetType().GetProperty("Total").GetValue(retire);
var _profileList = new List<dynamic>();
@ -123,6 +120,10 @@ namespace BMA.EHR.Report.Service.Controllers
var content = result.DocumentBytes;
return File(content, $"application/{exportType}", returnfile);
}
else
{
return NotFound();
}
}
#endregion
}

View file

@ -26,10 +26,10 @@
}
},
"MinIO": {
"Endpoint": "https://s3.frappet.com/",
"Endpoint": "https://s3cluster.frappet.com/",
"AccessKey": "frappet",
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
"SecretKey": "FPTadmin2357",
"BucketName": "bma-ehr-fpt"
},
"Protocol": "HTTPS",
"telerikReporting": {