diff --git a/Controllers/HrDevelopment.Controller.cs b/Controllers/HrDevelopment.Controller.cs new file mode 100644 index 0000000..8fa1382 --- /dev/null +++ b/Controllers/HrDevelopment.Controller.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using FastReport; +using FastReport.Export.Csv; +using FastReport.Export.Mht; +using FastReport.Export.OoXML; +using FastReport.Export.Pdf; +using Microsoft.AspNetCore.Mvc; +using rmutr_report.Models; +using rmutr_report.Models.Hr; +using rmutr_report.Models.HrDevelopment; +using rmutr_report.Models.Hrrecruit; +using Swashbuckle.AspNetCore.Annotations; + +namespace rmutr_report.Controllers +{ + [SwaggerTag("สำหรับรายงาน งานพัฒนา")] + public class HrDevelopment : Controller + { + readonly Setting _setting; + + public HrDevelopment(Setting setting) + { + this._setting = setting; + } + + [HttpPost, Route("reports/passer_join_project/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult Gethr1Report([FromRoute] string type, [FromBody] List _hr) + { + // foreach (var deatil in _hr) + // { + // foreach (var x in deatil.data) + // { + // if (x.quantity_person != null) + // { + // var total = deatil.data.Select(r => r.quantity_person).Sum(t=>t.Value); + // deatil.total_1 = total; + // } + // else + // { + // deatil.total_1 = 0; + // } + // if (x.quantity_trained != null) + // { + // var total = deatil.data.Select(r => r.quantity_trained).Sum(t=>t.Value); + // deatil.total_2 = total; + // }else + // { + // deatil.total_2 = 0; + // } + // } + // } + // var hr1 = new List() {_hr}; + Report report = new Report(); + report.Load(_setting.report_path + "passer_join_project.frx"); + report.RegisterData(_hr, "passer_join_project"); + report.Prepare(); + + MemoryStream stream = new MemoryStream(); + switch (type) + { + case "pdf": + PDFExport pdf = new PDFExport(); + report.Export(pdf, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "application/pdf"); + + case "xls": case "xlsx": + Excel2007Export excel = new Excel2007Export(); + report.Export(excel, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "application/vnd.ms-excel"); + break; + case "mht": + MHTExport mht = new MHTExport(); + report.Export(mht, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "multipart/related"); + break; + case "csv": + CSVExport csv = new CSVExport(); + report.Export(csv, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "text/csv"); + break; + } + + return Ok(); + } + [HttpPost, Route("reports/passer_join_project_agency/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult Gethr2Report([FromRoute] string type, [FromBody] List _hr) + { + Report report = new Report(); + report.Load(_setting.report_path + "passer_join_project_agency.frx"); + report.RegisterData(_hr, "passer_join_project_agency"); + report.Prepare(); + + MemoryStream stream = new MemoryStream(); + switch (type) + { + case "pdf": + PDFExport pdf = new PDFExport(); + report.Export(pdf, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "application/pdf"); + + case "xls": case "xlsx": + Excel2007Export excel = new Excel2007Export(); + report.Export(excel, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "application/vnd.ms-excel"); + break; + case "mht": + MHTExport mht = new MHTExport(); + report.Export(mht, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "multipart/related"); + break; + case "csv": + CSVExport csv = new CSVExport(); + report.Export(csv, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "text/csv"); + break; + } + + return Ok(); + } + } +} \ No newline at end of file diff --git a/Models/HrDevelopment/passer_join_project.cs b/Models/HrDevelopment/passer_join_project.cs new file mode 100644 index 0000000..f8f7c31 --- /dev/null +++ b/Models/HrDevelopment/passer_join_project.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models.HrDevelopment +{ + public class passer_join_project + { + public string header_name { get; set; } + public int? total_1 { get; set; } + public int? total_2 { get; set; } + public List data { get; set; } + } + + public class passer_join_project_detail + { + public string agency_name_th { get; set; } + public int? quantity_person { get; set; } + public int? quantity_trained { get; set; } + + } +} \ No newline at end of file diff --git a/Models/HrDevelopment/passer_join_project_agency.cs b/Models/HrDevelopment/passer_join_project_agency.cs new file mode 100644 index 0000000..877ad37 --- /dev/null +++ b/Models/HrDevelopment/passer_join_project_agency.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models.HrDevelopment +{ + public class passer_join_project_agency + { + public string agency_name_th { get; set; } + public List data { get; set; } + } + + public class passer_join_project_agency_detail + { + public string pertype { get; set; } + public List data_detail { get; set; } + } + + public class passer_join_project_agency_data_detail + { + public string display_name_th { get; set; } + public int? quantity_project { get; set; } + public string project_name { get; set; } + public string course_organizer { get; set; } + public string project_date { get; set; } + public string project_time { get; set; } + public string location { get; set; } + public decimal? registration_fee { get; set; } + public string complete_date { get; set; } + } +} \ No newline at end of file diff --git a/wwwroot/reports/passer_join_project.frx b/wwwroot/reports/passer_join_project.frx new file mode 100644 index 0000000..c44b20e --- /dev/null +++ b/wwwroot/reports/passer_join_project.frx @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/reports/passer_join_project_agency.frx b/wwwroot/reports/passer_join_project_agency.frx new file mode 100644 index 0000000..74926bc --- /dev/null +++ b/wwwroot/reports/passer_join_project_agency.frx @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +