diff --git a/Controllers/Budget.Controller.cs b/Controllers/Budget.Controller.cs index 5795524..c27df88 100644 --- a/Controllers/Budget.Controller.cs +++ b/Controllers/Budget.Controller.cs @@ -242,90 +242,7 @@ namespace rmutr_report.Controllers return Ok(); } -[HttpPost, Route("reports/external_research/{type}")] - [ApiExplorerSettings(GroupName = "reports")] - public IActionResult GetExReport([FromRoute] string type, [FromBody] external_research external) - { - var s1 = external.data.Sum(g => g.budget_1); - var s2 = external.data.Sum(g => g.budget_2); - var s3 = external.data.Sum(g => g.budget_3); - var s4 = external.data.Sum(g => g.budget_4); - var s5 = external.data.Sum(g => g.budget_5); - var s6 = external.data.Sum(g => g.budget_received); - var s7 = external.data.Sum(g => g.total_budget); - var s8 = external.data.Sum(g => g.expenses); - if (s1!=null&&s2!=null&&s3!=null&&s4!=null&&s5!=null) - { - external.project_amount = s6; - external.total_1 = s6; - //external.total_8 = s7; - external.total_2 = s8; - external.total_3 = s1; - external.total_4 = s2; - external.total_5 = s3; - external.total_6 = s4; - external.total_7 = s5; - } - - CultureInfo culture = new CultureInfo("th-TH"); - - if (external.data_date != null) - { - external.data_day = external.data_date.Value.ToString("dd", culture); - external.data_month = external.data_date.Value.ToString("MMMM", culture); - external.data_year = external.data_date.Value.ToString("yyyy", culture); - } - if (external.data_date == null) - { - external.data_day = ""; - external.data_month = ""; - external.data_year = ""; - } - foreach (var data in external.data) - { - data.total_budget = data.budget_1+data.budget_2+data.budget_3+data.budget_4+data.budget_5; - var ss = external.data.Sum(y => y.total_budget); - external.institutional_subsidy_fee = ss; - external.total_8 = external.institutional_subsidy_fee; - - - } - - - - var _budget_summary_report = new List() { external }; - - Report report = new Report(); - report.Load(_setting.report_path + "external_research.frx"); - report.RegisterData(_budget_summary_report, "external_research"); - 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"); - break; - 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; - - } - - return Ok(); - } } } \ No newline at end of file diff --git a/Controllers/RoFive.Controller.cs b/Controllers/RoFive.Controller.cs index d564bed..af78bb7 100644 --- a/Controllers/RoFive.Controller.cs +++ b/Controllers/RoFive.Controller.cs @@ -14,12 +14,12 @@ using Swashbuckle.AspNetCore.Annotations; namespace rmutr_report.Controllers { - [SwaggerTag("สำหรับรายงาน ร.5")] - public class RoFive : Controller + [SwaggerTag("สำหรับรายงาน ร.(คำของบประมาณรายจ่ายจากเงินรายได้)")] + public class Ro : Controller { readonly Setting _setting; - public RoFive(Setting setting) + public Ro(Setting setting) { this._setting = setting; } @@ -113,55 +113,55 @@ namespace rmutr_report.Controllers } } - foreach (var boqPrice in building_fours.basic_information) - { - if (boqPrice.list != null) - { - string str = boqPrice.list; - string num = String.Concat(str.Where(c => c >= '0' && c <= '9')); - - if (num.Length == 4) - { - for (int i = 1; i <= num.Length - 1; i += 4) - { - boqPrice.list = num.Insert(i, ","); - } - } - else if (num.Length == 5) - { - for (int i = 2; i <= num.Length - 1; i += 5) - { - boqPrice.list = num.Insert(i, ","); - } - } - else if (num.Length == 6) - { - for (int i = 3; i <= num.Length - 1; i += 6) - { - boqPrice.list = num.Insert(i, ","); - } - } - else if (num.Length == 7) - { - for (int i = 1,j=5; i <= num.Length -1 ;i +=7,j+=7) - { - boqPrice.list = num.Insert(i, ",").Insert(j,","); - } - - } - else if (num.Length == 8) - { for (int i = 2,j=6; i <= num.Length -1 ;i +=8,j+=8) - { - boqPrice.list = num.Insert(i, ",").Insert(j,","); - } - } - - if (boqPrice.list=="20000000.0000") - { - boqPrice.list = "20,000,000"; - } - } - } + foreach (var boqPrice in building_fours.basic_information) + { + if (boqPrice.list != null) + { + string str = boqPrice.list; + string num = String.Concat(str.Where(c => c >= '0' && c <= '9')); + + if (num.Length == 4) + { + for (int i = 1; i <= num.Length - 1; i += 4) + { + boqPrice.list = num.Insert(i, ","); + } + } + else if (num.Length == 5) + { + for (int i = 2; i <= num.Length - 1; i += 5) + { + boqPrice.list = num.Insert(i, ","); + } + } + else if (num.Length == 6) + { + for (int i = 3; i <= num.Length - 1; i += 6) + { + boqPrice.list = num.Insert(i, ","); + } + } + else if (num.Length == 7) + { + for (int i = 1, j = 5; i <= num.Length - 1; i += 7, j += 7) + { + boqPrice.list = num.Insert(i, ",").Insert(j, ","); + } + } + else if (num.Length == 8) + { + for (int i = 2, j = 6; i <= num.Length - 1; i += 8, j += 8) + { + boqPrice.list = num.Insert(i, ",").Insert(j, ","); + } + } + + if (boqPrice.list == "20000000.0000") + { + boqPrice.list = "20,000,000"; + } + } + } foreach (var boqPrice in building_fours.boq) { @@ -195,7 +195,6 @@ namespace rmutr_report.Controllers { boqPrice.have = str.Insert(i, ",").Insert(j, ","); } - } else if (str.Length == 8) { @@ -241,13 +240,17 @@ namespace rmutr_report.Controllers 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"); + //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": @@ -256,7 +259,277 @@ namespace rmutr_report.Controllers stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); break; + } + return Ok(); + } + + [HttpPost, Route("reports/external_research/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetExReport([FromRoute] string type, [FromBody] external_research external) + { + var s1 = external.data.Sum(g => g.budget_1); + var s2 = external.data.Sum(g => g.budget_2); + var s3 = external.data.Sum(g => g.budget_3); + var s4 = external.data.Sum(g => g.budget_4); + var s5 = external.data.Sum(g => g.budget_5); + var s6 = external.data.Sum(g => g.budget_received); + var s7 = external.data.Sum(g => g.total_budget); + var s8 = external.data.Sum(g => g.expenses); + if (s1 != null && s2 != null && s3 != null && s4 != null && s5 != null) + { + external.project_amount = s6; + external.total_1 = s6; + //external.total_8 = s7; + external.total_2 = s8; + external.total_3 = s1; + external.total_4 = s2; + external.total_5 = s3; + external.total_6 = s4; + external.total_7 = s5; + } + + CultureInfo culture = new CultureInfo("th-TH"); + + if (external.data_date != null) + { + external.data_day = external.data_date.Value.ToString("dd", culture); + external.data_month = external.data_date.Value.ToString("MMMM", culture); + external.data_year = external.data_date.Value.ToString("yyyy", culture); + } + + if (external.data_date == null) + { + external.data_day = ""; + external.data_month = ""; + external.data_year = ""; + } + + if (external.data != null) + { + foreach (var data in external.data) + { + data.total_budget = data.budget_1 + data.budget_2 + data.budget_3 + data.budget_4 + + data.budget_5; + var ss = external.data.Sum(y => y.total_budget); + external.institutional_subsidy_fee = ss; + external.total_8 = external.institutional_subsidy_fee; + } + } + + + var _budget_summary_report = new List() { external }; + + Report report = new Report(); + report.Load(_setting.report_path + "external_research.frx"); + report.RegisterData(_budget_summary_report, "external_research"); + 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"); + break; + 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; + } + + return Ok(); + } + + [HttpPost, Route("reports/ro_nine/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetNineReport([FromRoute] string type, [FromBody] ro_nine external) + { + var s1 = external.data.Sum(g => g.budget_1); + var s2 = external.data.Sum(g => g.budget_2); + var s3 = external.data.Sum(g => g.budget_3); + var s4 = external.data.Sum(g => g.budget_4); + var s5 = external.data.Sum(g => g.budget_5); + var s6 = external.data.Sum(g => g.budget_received); + var s7 = external.data.Sum(g => g.total_budget); + var s8 = external.data.Sum(g => g.expenses); + if (s1 != null && s2 != null && s3 != null && s4 != null && s5 != null) + { + external.total_1 = s6; + //external.total_8 = s7; + external.total_2 = s8; + external.total_3 = s1; + external.total_4 = s2; + external.total_5 = s3; + external.total_6 = s4; + external.total_7 = s5; + } + + CultureInfo culture = new CultureInfo("th-TH"); + + if (external.data_date != null) + { + external.data_day = external.data_date.Value.ToString("dd", culture); + external.data_month = external.data_date.Value.ToString("MMMM", culture); + external.data_year = external.data_date.Value.ToString("yyyy", culture); + } + + if (external.data_date == null) + { + external.data_day = ""; + external.data_month = ""; + external.data_year = ""; + } + + if (external.data != null) + { + foreach (var data in external.data) + { + data.total_budget = data.budget_1 + data.budget_2 + data.budget_3 + data.budget_4 + data.budget_5; + var ss = external.data.Sum(y => y.total_budget); + external.total_8 = ss; + } + } + + var _budget_summary_report = new List() { external }; + + Report report = new Report(); + report.Load(_setting.report_path + "ro_nine.frx"); + report.RegisterData(_budget_summary_report, "ro_nine"); + 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"); + break; + 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; + } + + return Ok(); + } + [HttpPost, Route("reports/ro_ten/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetTenReport([FromRoute] string type, [FromBody] ro_ten ten) + { + var t_ten = ten.data.ToArray(); + if (t_ten != null) + { + // var t1 = ten.data.Sum(g => g.amount_1); + // var t2 = ten.data.Sum(g => g.amount_2); + // var t3 = ten.data.Sum(g => g.amount_3); + // var t2 = t_ten.Sum(g => g.amount_2); + // var t3 = t_ten.Sum(g => g.amount_3); + + + foreach (var detail in t_ten) + { + var s1 = detail.data_detail.Sum(g => g.amount_1); + var s2 = detail.data_detail.Sum(g => g.amount_2); + var s3 = detail.data_detail.Sum(g => g.amount_3); + // var s4 = t_ten.Sum(g => g.amount_1); + // var s5 = t_ten.Sum(g => g.amount_2); + // var s6 = t_ten.Sum(g => g.amount_3); + detail.amount_1 = s1; + detail.amount_2 = s2; + detail.amount_3 = s3; + + } + + } + + var _budget_summary_report = new List() { ten }; + + Report report = new Report(); + report.Load(_setting.report_path + "ro_ten.frx"); + report.RegisterData(_budget_summary_report, "ro_ten"); + 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; + + } + + return Ok(); + } + [HttpPost, Route("reports/ro_eleven/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetEleReport([FromRoute] string type, [FromBody] ro_eleven eleven) + { + var t_eleven = eleven.data.ToArray(); + if (t_eleven != null) + { + var t1 = eleven.data.Sum(g => g.amount_1); + var t2 = eleven.data.Sum(g => g.amount_2); + var t3 = eleven.data.Sum(g => g.amount_3); + eleven.total_amount_1 = t1; + eleven.total_amount_2 = t2; + eleven.total_amount_3 = t3; + + + } + + var ele = new List() { eleven }; + + Report report = new Report(); + report.Load(_setting.report_path + "ro_eleven.frx"); + report.RegisterData(ele, "ro_eleven"); + 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; + } return Ok(); diff --git a/Models/budget/ro_eleven.cs b/Models/budget/ro_eleven.cs new file mode 100644 index 0000000..0fc7cc4 --- /dev/null +++ b/Models/budget/ro_eleven.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models +{ + public class ro_eleven + { + public string budget_year { get; set; } + public string date_range { get; set; } + public string agency_name_th { get; set; } + public string setrevenue_year { get; set; } + public string prepare_revenue_year { get; set; } + public string revenue_year { get; set; } + public List data { get; set; } + public decimal? total_amount_1 { get; set; } + public decimal? total_amount_2 { get; set; } + public decimal? total_amount_3 { get; set; } + public string save_data_name { get; set; } + public string save_data_display_name { get; set; } + public string position { get; set; } + public string data_date { get; set; } + public string phone_no { get; set; } + } + + public class ro_eleven_detail + { + public string list { get; set; } + public decimal? amount_1 { get; set; } + public decimal? amount_2 { get; set; } + public decimal? amount_3 { get; set; } + } +} \ No newline at end of file diff --git a/Models/budget/ro_nine.cs b/Models/budget/ro_nine.cs new file mode 100644 index 0000000..4fb7b96 --- /dev/null +++ b/Models/budget/ro_nine.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; + +namespace rmutr_report.Models +{ + public class ro_nine + { + public string budget_year { get; set; } + public string date_range { get; set; } + public string agency_name_th { get; set; } + public decimal? budget_amount { get; set; } + public decimal? budget_1 { get; set; } + public decimal? budget_2 { get; set; } + public decimal? budget_3 { get; set; } + public decimal? budget_4 { get; set; } + public decimal? budget_5 { get; set; } + public List data { get; set; } + public decimal? total_1 { get; set; } + public decimal? total_2 { get; set; } + public decimal? total_3 { get; set; } + public decimal? total_4 { get; set; } + public decimal? total_5 { get; set; } + public decimal? total_6 { get; set; } + public decimal? total_7 { get; set; } + public decimal? total_8 { get; set; } + public string save_data_name { get; set; } + public string position { get; set; } + public DateTime? data_date { get; set; } + public string data_day { get; set; } + public string data_month { get; set; } + public string data_year { get; set; } + public string phone_no { get; set; } + } + + public class ro_nine_detail + { + public string agency_name_th { get; set; } + public string project_name_th { get; set; } + public string contract_period { get; set; } + public decimal? budget_received { get; set; } + public decimal? expenses { get; set; } + public decimal? budget_1 { get; set; } + public decimal? budget_2 { get; set; } + public decimal? budget_3 { get; set; } + public decimal? budget_4 { get; set; } + public decimal? budget_5 { get; set; } + public decimal? total_budget { get; set; } + } +} \ No newline at end of file diff --git a/Models/budget/ro_ten.cs b/Models/budget/ro_ten.cs new file mode 100644 index 0000000..8b0b648 --- /dev/null +++ b/Models/budget/ro_ten.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models +{ + public class ro_ten + { + public string budget_year { get; set; } + public string date_range { get; set; } + public string agency_name_th { get; set; } + public string setrevenue_year { get; set; } + public string prepare_revenue_year { get; set; } + public string revenue_year { get; set; } + public List data { get; set; } + + // public decimal? total_amount_1 { get; set; } + // public decimal? total_amount_2 { get; set; } + // public decimal? total_amount_3 { get; set; } + public string save_data_name { get; set; } + public string save_data_display_name { get; set; } + public string position { get; set; } + public string data_date { get; set; } + public string phone_no { get; set; } + + } + + public class ro_ten_detail + { + public string header_name { get; set; } + public decimal? amount_1 { get; set; } + public decimal? amount_2 { get; set; } + public decimal? amount_3 { get; set; } + public List data_detail { get; set; } + + } + + public class ro_ten_detail2 + { + public string list { get; set; } + public decimal? amount_1 { get; set; } + public decimal? amount_2 { get; set; } + public decimal? amount_3 { get; set; } + } +} \ No newline at end of file diff --git a/bin/Debug/net5.0/rmutr-report.dll b/bin/Debug/net5.0/rmutr-report.dll index 23f1fa2..ecda2ef 100644 Binary files a/bin/Debug/net5.0/rmutr-report.dll and b/bin/Debug/net5.0/rmutr-report.dll differ diff --git a/bin/Debug/net5.0/rmutr-report.pdb b/bin/Debug/net5.0/rmutr-report.pdb index ff09c2e..1ee0592 100644 Binary files a/bin/Debug/net5.0/rmutr-report.pdb and b/bin/Debug/net5.0/rmutr-report.pdb differ diff --git a/obj/Debug/net5.0/ref/rmutr-report.dll b/obj/Debug/net5.0/ref/rmutr-report.dll index 16f0a53..7bfb3b5 100644 Binary files a/obj/Debug/net5.0/ref/rmutr-report.dll and b/obj/Debug/net5.0/ref/rmutr-report.dll differ diff --git a/obj/Debug/net5.0/refint/rmutr-report.dll b/obj/Debug/net5.0/refint/rmutr-report.dll index 16f0a53..7bfb3b5 100644 Binary files a/obj/Debug/net5.0/refint/rmutr-report.dll and b/obj/Debug/net5.0/refint/rmutr-report.dll differ diff --git a/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache b/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache index 0e6a99a..dc57dee 100644 --- a/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache +++ b/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -57cd4f89f195b698c7cc6d74d63f49bb6d30374d +fbfff5b43174e027b575f40fbfe1e939e8a759e3 diff --git a/obj/Debug/net5.0/rmutr-report.dll b/obj/Debug/net5.0/rmutr-report.dll index 23f1fa2..ecda2ef 100644 Binary files a/obj/Debug/net5.0/rmutr-report.dll and b/obj/Debug/net5.0/rmutr-report.dll differ diff --git a/obj/Debug/net5.0/rmutr-report.pdb b/obj/Debug/net5.0/rmutr-report.pdb index ff09c2e..1ee0592 100644 Binary files a/obj/Debug/net5.0/rmutr-report.pdb and b/obj/Debug/net5.0/rmutr-report.pdb differ diff --git a/wwwroot/reports/external_research.frx b/wwwroot/reports/external_research.frx index ab3e3e1..f71d706 100644 --- a/wwwroot/reports/external_research.frx +++ b/wwwroot/reports/external_research.frx @@ -1,5 +1,5 @@  - + @@ -63,10 +63,10 @@ - - - - + + + + diff --git a/wwwroot/reports/ro_eleven.frx b/wwwroot/reports/ro_eleven.frx new file mode 100644 index 0000000..ec443f5 --- /dev/null +++ b/wwwroot/reports/ro_eleven.frx @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/reports/ro_nine.frx b/wwwroot/reports/ro_nine.frx new file mode 100644 index 0000000..30fd506 --- /dev/null +++ b/wwwroot/reports/ro_nine.frx @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/reports/ro_ten.frx b/wwwroot/reports/ro_ten.frx new file mode 100644 index 0000000..191a88f --- /dev/null +++ b/wwwroot/reports/ro_ten.frx @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +