diff --git a/Controllers/ProfileReportController.cs b/Controllers/ProfileReportController.cs
index 935fd5a..37226be 100644
--- a/Controllers/ProfileReportController.cs
+++ b/Controllers/ProfileReportController.cs
@@ -390,6 +390,188 @@ namespace BMA.EHR.Report.Service.Controllers
}
}
+ ///
+ /// แสดงรายงาน กก.1 (ลูกจ้างประจำ)
+ ///
+ /// รหัสข้อมูลลูกจ้างประจำ
+ ///
+ /// เมื่อแสดงรายงานสำเร็จ
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("kk1-employee/{id:length(36)}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> 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(_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);
+ }
+ }
///
/// แสดงรายงาน กพ.7
diff --git a/Report/Profile/rptKK1_Emp_Page0.trdp b/Report/Profile/rptKK1_Emp_Page0.trdp
new file mode 100644
index 0000000..17cb61c
Binary files /dev/null and b/Report/Profile/rptKK1_Emp_Page0.trdp differ
diff --git a/Report/Profile/rptKK1_Emp_Page1.trdp b/Report/Profile/rptKK1_Emp_Page1.trdp
new file mode 100644
index 0000000..dc9a705
Binary files /dev/null and b/Report/Profile/rptKK1_Emp_Page1.trdp differ
diff --git a/Report/Profile/rptKK1_Emp_Page2.trdp b/Report/Profile/rptKK1_Emp_Page2.trdp
new file mode 100644
index 0000000..8428a2f
Binary files /dev/null and b/Report/Profile/rptKK1_Emp_Page2.trdp differ
diff --git a/Report/Profile/rptKK1_Page2.trdp b/Report/Profile/rptKK1_Page2.trdp
index 6a30cb0..2fe7e57 100644
Binary files a/Report/Profile/rptKK1_Page2.trdp and b/Report/Profile/rptKK1_Page2.trdp differ