diff --git a/Controllers/RoThree.Controller.cs b/Controllers/RoThree.Controller.cs index 2ce84a4..7165d54 100644 --- a/Controllers/RoThree.Controller.cs +++ b/Controllers/RoThree.Controller.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using ClosedXML; using FastReport; using FastReport.Export.OoXML; using FastReport.Export.Pdf; @@ -67,7 +68,105 @@ namespace rmutr_report.Controllers return Ok(); } - + [HttpPost, Route("reports/compensation_head_department/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetComReport([FromRoute] string type, [FromBody] compensation_head three) + { + if (three.data!=null) + { + var s = three.data.Sum(f => f.budget_amount); + + three.total_amount = s; + } + + var threes = new List() { three }; + + Report report = new Report(); + report.Load(_setting.report_path + "compensation_head_department.frx"); + report.RegisterData(threes, "compensation_head"); + 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"); + string date = DateTime.Now.ToString("yyyyMMddHHmmss"); + return File( + stream, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + date + ".xlsx"); + break; + case "doc": + case "docx": + Word2007Export word = new Word2007Export(); + report.Export(word, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "appllication/vnd.ms-word"); + break; + } + + return Ok(); + } + [HttpPost, Route("reports/compensation_head_major/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetCom2Report([FromRoute] string type, [FromBody] compensation_head three) + { + if (three.data!=null) + { + var s = three.data.Sum(f => f.budget_amount); + + three.total_amount = s; + } + + var threes = new List() { three }; + + Report report = new Report(); + report.Load(_setting.report_path + "compensation_head_major.frx"); + report.RegisterData(threes, "compensation_head"); + 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"); + string date = DateTime.Now.ToString("yyyyMMddHHmmss"); + return File( + stream, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + date + ".xlsx"); + break; + case "doc": + case "docx": + Word2007Export word = new Word2007Export(); + report.Export(word, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "appllication/vnd.ms-word"); + break; + } + + return Ok(); + } + } } \ No newline at end of file diff --git a/Models/RoThree/compensation_head.cs b/Models/RoThree/compensation_head.cs new file mode 100644 index 0000000..17a3efe --- /dev/null +++ b/Models/RoThree/compensation_head.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models.RoThree +{ + public class compensation_head + { + public string budget_year { get; set; } + public string date_range { get; set; } + public string product { get; set; } + public string agency_name_th { get; set; } + public string sector { get; set; } + public decimal? total_amount { get; set; } + public List data { get; set; } + + } + + public class compensation_head_detail + { + public string department { get; set; } + public string display_name { get; set; } + public decimal? rate { get; set; } + public decimal? budget_amount { get; set; } + public string remark { get; set; } + } +} \ No newline at end of file diff --git a/bin/Debug/netcoreapp3.1/rmutr_report.dll b/bin/Debug/netcoreapp3.1/rmutr_report.dll index 6a91f62..a6ba908 100644 Binary files a/bin/Debug/netcoreapp3.1/rmutr_report.dll and b/bin/Debug/netcoreapp3.1/rmutr_report.dll differ diff --git a/bin/Debug/netcoreapp3.1/rmutr_report.pdb b/bin/Debug/netcoreapp3.1/rmutr_report.pdb index 433263b..4806351 100644 Binary files a/bin/Debug/netcoreapp3.1/rmutr_report.pdb and b/bin/Debug/netcoreapp3.1/rmutr_report.pdb differ diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache index 7a6206c..d36903f 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -ee5763df9ddeaf2d8acc3f4615148657d930de4e +a715b8fa13ce9533250fc942904a6547d616a090 diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.dll b/obj/Debug/netcoreapp3.1/rmutr_report.dll index 6a91f62..a6ba908 100644 Binary files a/obj/Debug/netcoreapp3.1/rmutr_report.dll and b/obj/Debug/netcoreapp3.1/rmutr_report.dll differ diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.pdb b/obj/Debug/netcoreapp3.1/rmutr_report.pdb index 433263b..4806351 100644 Binary files a/obj/Debug/netcoreapp3.1/rmutr_report.pdb and b/obj/Debug/netcoreapp3.1/rmutr_report.pdb differ diff --git a/wwwroot/reports/compensation_head_department.frx b/wwwroot/reports/compensation_head_department.frx new file mode 100644 index 0000000..b5567d2 --- /dev/null +++ b/wwwroot/reports/compensation_head_department.frx @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/reports/compensation_head_major.frx b/wwwroot/reports/compensation_head_major.frx new file mode 100644 index 0000000..596c42c --- /dev/null +++ b/wwwroot/reports/compensation_head_major.frx @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +