รายงาน ก.ก.1 (ลูกจ้างประจำ)
This commit is contained in:
parent
926f02c16f
commit
cb7ddb5040
5 changed files with 182 additions and 0 deletions
|
|
@ -390,6 +390,188 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// แสดงรายงาน กก.1 (ลูกจ้างประจำ)
|
||||
/// </summary>
|
||||
/// <param name="id">รหัสข้อมูลลูกจ้างประจำ</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("kk1-employee/{id:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetKK1EmpReport(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var rptFile0 = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Profile", $"rptKK1_Emp_Page0.trdp");
|
||||
ReportPackager reportPackager0 = new ReportPackager();
|
||||
Telerik.Reporting.Report? report0 = null;
|
||||
using (var sourceStream0 = System.IO.File.OpenRead(rptFile0))
|
||||
{
|
||||
report0 = (Telerik.Reporting.Report)reportPackager0.UnpackageDocument(sourceStream0);
|
||||
}
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Profile", $"rptKK1_Emp_Page1.trdp");
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||
}
|
||||
var CitizenId = "";
|
||||
var FullName = "";
|
||||
var OcFullPath = "";
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile-employee/kk1/{id}";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
{
|
||||
return Error("ไม่พบข้อมูลนี้ในระบบ", 404);
|
||||
}
|
||||
|
||||
report0.DataSource = org.result.Profile;
|
||||
var tblInsignia = (Telerik.Reporting.Table)report0.Items["detailSection1"].Items["tblInsignia"];
|
||||
tblInsignia.DataSource = org.result.Insignia;
|
||||
|
||||
var tblLeave = (Telerik.Reporting.Table)report0.Items["detailSection1"].Items["tblLeave"];
|
||||
tblLeave.DataSource = org.result.Leave;
|
||||
|
||||
report.DataSource = org.result.Profile;
|
||||
// binding to table
|
||||
var tblCertificate = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblCertificate"];
|
||||
tblCertificate.DataSource = org.result.Cert;
|
||||
|
||||
var tblTraining = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblTraining"];
|
||||
tblTraining.DataSource = org.result.Training;
|
||||
|
||||
var tblDiscipline = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblDiscipline"];
|
||||
tblDiscipline.DataSource = org.result.Discipline;
|
||||
|
||||
var tblEducation = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblEducation"];
|
||||
tblEducation.DataSource = org.result.Education;
|
||||
var salary = org.result.Salary;
|
||||
CitizenId = org.result.Profile[0].CitizenId;
|
||||
FullName = org.result.Profile[0].FullName;
|
||||
OcFullPath = org.result.Profile[0].OcFullPath;
|
||||
|
||||
System.Collections.Hashtable deviceInfo0 = new System.Collections.Hashtable();
|
||||
InstanceReportSource instanceReportSource0 = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report0
|
||||
};
|
||||
|
||||
ReportProcessor reportProcessor0 = new ReportProcessor(_configuration);
|
||||
RenderingResult result0 = reportProcessor0.RenderReport("PDF", instanceReportSource0, deviceInfo0);
|
||||
var content0 = result0.DocumentBytes;
|
||||
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report
|
||||
};
|
||||
|
||||
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
|
||||
// byte array waiting for merge pdf
|
||||
var content = result.DocumentBytes;
|
||||
|
||||
var rptFile2 = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Profile", $"rptKK1_Emp_Page2.trdp");
|
||||
|
||||
ReportPackager reportPackager2 = new ReportPackager();
|
||||
Telerik.Reporting.Report? report2 = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile2))
|
||||
{
|
||||
report2 = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||
}
|
||||
|
||||
report2.ReportParameters["FullName"].Value = FullName;
|
||||
report2.ReportParameters["OcFullPath"].Value = OcFullPath;
|
||||
|
||||
// binding to table
|
||||
var tblSalary = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["tblSalary"];
|
||||
tblSalary.DataSource = salary;
|
||||
|
||||
System.Collections.Hashtable deviceInfo2 = new System.Collections.Hashtable();
|
||||
|
||||
InstanceReportSource instanceReportSource2 = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report2
|
||||
};
|
||||
|
||||
|
||||
ReportProcessor reportProcessor2 = new ReportProcessor(_configuration);
|
||||
RenderingResult result2 = reportProcessor2.RenderReport("PDF", instanceReportSource2, deviceInfo2);
|
||||
|
||||
// byte array waiting for merge pdf
|
||||
var content2 = result2.DocumentBytes;
|
||||
|
||||
// merge pdf
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
using (PdfDocument pdf = new PdfDocument(new PdfWriter(ms).SetSmartMode(true)))
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(content0))
|
||||
{
|
||||
using (PdfReader reader = new PdfReader(memoryStream))
|
||||
{
|
||||
PdfDocument srcDoc = new PdfDocument(reader);
|
||||
srcDoc.CopyPagesTo(1, srcDoc.GetNumberOfPages(), pdf);
|
||||
}
|
||||
}
|
||||
|
||||
// Create reader from bytes
|
||||
using (MemoryStream memoryStream = new MemoryStream(content))
|
||||
{
|
||||
// Create reader from bytes
|
||||
using (PdfReader reader = new PdfReader(memoryStream))
|
||||
{
|
||||
PdfDocument srcDoc = new PdfDocument(reader);
|
||||
srcDoc.CopyPagesTo(1, srcDoc.GetNumberOfPages(), pdf);
|
||||
}
|
||||
}
|
||||
|
||||
// Create reader from bytes
|
||||
if (content2 != null)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(content2))
|
||||
{
|
||||
// Create reader from bytes
|
||||
using (PdfReader reader = new PdfReader(memoryStream))
|
||||
{
|
||||
PdfDocument srcDoc = new PdfDocument(reader);
|
||||
srcDoc.CopyPagesTo(1, srcDoc.GetNumberOfPages(), pdf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pdf.Close();
|
||||
}
|
||||
|
||||
var fileContent = ms.ToArray();
|
||||
return File(fileContent, "application/pdf", $"กก_1_{CitizenId}.pdf");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// แสดงรายงาน กพ.7
|
||||
|
|
|
|||
BIN
Report/Profile/rptKK1_Emp_Page0.trdp
Normal file
BIN
Report/Profile/rptKK1_Emp_Page0.trdp
Normal file
Binary file not shown.
BIN
Report/Profile/rptKK1_Emp_Page1.trdp
Normal file
BIN
Report/Profile/rptKK1_Emp_Page1.trdp
Normal file
Binary file not shown.
BIN
Report/Profile/rptKK1_Emp_Page2.trdp
Normal file
BIN
Report/Profile/rptKK1_Emp_Page2.trdp
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue