diff --git a/Controllers/SummaryInvest.Controller.cs b/Controllers/SummaryInvest.Controller.cs new file mode 100644 index 0000000..0c87d27 --- /dev/null +++ b/Controllers/SummaryInvest.Controller.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.RegularExpressions; +using FastReport; +using FastReport.Export.OoXML; +using FastReport.Export.Pdf; +using Microsoft.AspNetCore.Mvc; +using rmutr_report.Models; +using Swashbuckle.AspNetCore.Annotations; + +namespace rmutr_report.Controllers +{ + [SwaggerTag("สำหรับรายงาน invest")] + public class SummaryInvest : Controller + { + readonly Setting _setting; + + public SummaryInvest(Setting setting) + { + _setting = setting; + } + + [SwaggerOperation("จัดทำค่าครุภัณฑ์ Key e-Budgeting")] + [HttpPost, Route("reports/summary_invest/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetEBudgetingReport([FromRoute] string type, [FromBody] summary_invest summaryInvest) + { + var summaryInvests = new List() { summaryInvest }; + + Report report = new Report(); + report.Load(_setting.report_path + "summary_invest.frx"); + report.RegisterData(summaryInvests, "summary_invest"); + 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.openxmlformats-officedocument.spreadsheetml.sheet", + "summary_invest" + ".xlsx"); + break; + } + + return Ok(); + } + + [SwaggerOperation("จัดทำค่าครุภัณฑ์ (ใบเสนอราคา)")] + [HttpPost, Route("reports/summary_invest_preview/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetSummaryInvestPreviewReport([FromRoute] string type, + [FromBody] summary_invest_v2 summaryInvest) + { + var summaryInvests = new List() { summaryInvest }; + if (summaryInvest != null) + { + foreach (var summaryInvestYear in summaryInvest.years) + { + foreach (var plan in summaryInvestYear.plans) + { + foreach (var assetList in plan.asset_lists) + { + string formattedSeller = assetList.seller.Replace("
", " "); + string pattern = @"(.*?)<\/a>"; + MatchCollection matches = Regex.Matches(assetList.file, pattern); + + string formattedFile = ""; + if (assetList.is_approve == true) + { + assetList.approve_name = "อนุมัติแล้ว"; + } + + + assetList.seller2 = formattedSeller; + + + foreach (Match match in matches) + { + formattedFile += match.Groups[1].Value + " "; + } + + formattedFile = formattedFile.Trim(); + assetList.file2 = formattedFile; + + //Console.WriteLine("seller output: " + formattedSeller); + //Console.WriteLine("file output: " + formattedFile); + } + } + } + } + + Report report = new Report(); + report.Load(_setting.report_path + "summary_invest_preview.frx"); + report.RegisterData(summaryInvests, "summary_invest"); + 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.openxmlformats-officedocument.spreadsheetml.sheet", + "summary_invest_preview" + ".xlsx"); + break; + } + + return Ok(); + } + + [SwaggerOperation("จัดสรรค่าครุภัณฑ์")] + [HttpPost, Route("reports/summary_invest_approve/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetSummaryInvestApproveReport([FromRoute] string type, + [FromBody] summary_invest_v2 summaryInvest) + { + var summaryInvests = new List() { summaryInvest }; + if (summaryInvest != null) + { + foreach (var summaryInvestYear in summaryInvest.years) + { + foreach (var plan in summaryInvestYear.plans) + { + foreach (var assetList in plan.asset_lists) + { + string formattedSeller = assetList.seller.Replace("
", " "); + string pattern = @"
(.*?)<\/a>"; + MatchCollection matches = Regex.Matches(assetList.file, pattern); + + string formattedFile = ""; + if (assetList.is_approve == true) + { + assetList.approve_name = "อนุมัติแล้ว"; + } + + + assetList.seller2 = formattedSeller; + + + foreach (Match match in matches) + { + formattedFile += match.Groups[1].Value + " "; + } + + formattedFile = formattedFile.Trim(); + assetList.file2 = formattedFile; + + //Console.WriteLine("seller output: " + formattedSeller); + //Console.WriteLine("file output: " + formattedFile); + } + } + } + } + Report report = new Report(); + report.Load(_setting.report_path + "summary_invest_approve.frx"); + report.RegisterData(summaryInvests, "summary_invest"); + 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.openxmlformats-officedocument.spreadsheetml.sheet", + "summary_invest_approve" + ".xlsx"); + break; + } + + return Ok(); + } + } +} \ No newline at end of file diff --git a/Models/budget/summary_invest.cs b/Models/budget/summary_invest.cs new file mode 100644 index 0000000..193b4ac --- /dev/null +++ b/Models/budget/summary_invest.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; + +public class summary_invest : summary_invest_initial +{ + public List years { get; set; } +} +public class summary_invest_year : summary_invest_initial +{ + public Guid? budget_year_uid { get; set; } + public string budget_year_name_th { get; set; } + public List plans { get; set; } +} +public class summary_invest_plan : summary_invest_initial +{ + public Guid? budget_plan_uid { get; set; } + public string budget_plan_name_th { get; set; } + public List projects { get; set; } +} +public class summary_invest_project : summary_invest_initial +{ + public Guid? budget_project_uid { get; set; } + public string budget_project_name_th { get; set; } + public List facultys { get; set; } +} +public class summary_invest_faculty : summary_invest_initial +{ + public Guid? faculty_uid { get; set; } + public string faculty_name_th { get; set; } + public List asset_lists { get; set; } + public List construct_lists { get; set; } +} +public class summary_invest_list : summary_invest_initial +{ + public Guid? invest_asset_approve_uid { get; set; } + public Guid? invest_construct_approve_uid { get; set; } + public Guid? key_uid { get; set; } + public Guid? key_request_uid { get; set; } + public string list_name { get; set; } + public string unit_name { get; set; } + public string seller { get; set; } + public string file { get; set; } + public int? row_order { get; set; } + public int? step_order { get; set; } + public int? amount { get; set; } + public bool? is_from_reject { get; set; } + public bool? is_edit { get; set; } + public bool? is_approve { get; set; } + public string approve_name { get; set; } + public string petitioner_full_name { get; set; } + public string phone_number { get; set; } +} +public class summary_invest_search +{ + public Guid? budget_year_uid { get; set; } + public Guid? budget_project_uid { get; set; } + public Guid? budget_plan_uid { get; set; } + public Guid? faculty_uid { get; set; } + public string list_name { get; set; } + public string petitioner_full_name { get; set; } + public bool? is_asset { get; set; } + public bool? is_construct { get; set; } + public bool? is_approve { get; set; } +} +public class summary_invest_data_initial : summary_invest_search +{ + public int? budget_year_number { get; set; } + public string budget_year_name_th { get; set; } + public string budget_project_name_th { get; set; } + public string budget_plan_name_th { get; set; } + public string faculty_name_th { get; set; } +} +public class summary_invest_initial +{ + public decimal? unit_price { get; set; } + public decimal? total { get; set; } + public decimal? total_budget { get; set; } + public decimal? asset_unit_price { get; set; } + public decimal? asset_total_budget { get; set; } + public decimal? construct_unit_price { get; set; } + public decimal? construct_total_budget { get; set; } +} +public class summary_invest_v2 : summary_invest_initial +{ + public List years { get; set; } +} +public class summary_invest_year_v2 : summary_invest_initial +{ + public Guid? budget_year_uid { get; set; } + public string budget_year_name_th { get; set; } + public List plans { get; set; } +} +public class summary_invest_plan_v2 : summary_invest_initial +{ + public Guid? budget_plan_uid { get; set; } + public string budget_plan_name_th { get; set; } + public List asset_lists { get; set; } + public List construct_lists { get; set; } +} +public class summary_invest_list_v2 : summary_invest_initial +{ + public Guid? budget_project_uid { get; set; } + public Guid? faculty_uid { get; set; } + public string budget_project_name_th { get; set; } + public string faculty_name_th { get; set; } + public Guid? invest_asset_approve_uid { get; set; } + public Guid? invest_construct_approve_uid { get; set; } + public Guid? key_uid { get; set; } + public Guid? key_request_uid { get; set; } + public string list_name { get; set; } + public string unit_name { get; set; } + public string seller { get; set; } + public string seller2 { get; set; } + public string file { get; set; } + public string file2 { get; set; } + public int? row_order { get; set; } + public int? step_order { get; set; } + public int? amount { get; set; } + public bool? is_from_reject { get; set; } + public bool? is_edit { get; set; } + public bool? is_approve { get; set; } + public string approve_name { get; set; } + public string petitioner_full_name { get; set; } + public string phone_number { 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 5dbe293..b228572 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 34b30e5..cd614bd 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/net5.0/rmutr_report.AssemblyInfo.cs b/obj/Debug/net5.0/rmutr_report.AssemblyInfo.cs index c7fa1f2..c0afd7c 100644 --- a/obj/Debug/net5.0/rmutr_report.AssemblyInfo.cs +++ b/obj/Debug/net5.0/rmutr_report.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e2a3977734a6c0e63d669a0800cfaf4bca52db1a")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+da8805020d3aac23490c9d2a0b621d651ee44921")] [assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net5.0/rmutr_report.AssemblyInfoInputs.cache b/obj/Debug/net5.0/rmutr_report.AssemblyInfoInputs.cache index 628d4ea..9dab78d 100644 --- a/obj/Debug/net5.0/rmutr_report.AssemblyInfoInputs.cache +++ b/obj/Debug/net5.0/rmutr_report.AssemblyInfoInputs.cache @@ -1 +1 @@ -83b7c8eaf06473c917649059b491b34a25238c6d940329abfd68e57bff3c4984 +fb341293279b66bfac2dcb8964beca0310d8356768610a72c001a0b0c99d163a diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfo.cs b/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfo.cs index dc64e6f..c0afd7c 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfo.cs +++ b/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9c37d45f5cd26f307eeed46e82c6833c27288b33")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+da8805020d3aac23490c9d2a0b621d651ee44921")] [assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfoInputs.cache b/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfoInputs.cache index 2e3a39d..9dab78d 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfoInputs.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfoInputs.cache @@ -1 +1 @@ -ce1e068e9e13ade3aae57571fad3b5eebac258828f5dbf8839f024cafd6dced7 +fb341293279b66bfac2dcb8964beca0310d8356768610a72c001a0b0c99d163a diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.RazorTargetAssemblyInfo.cache b/obj/Debug/netcoreapp3.1/rmutr_report.RazorTargetAssemblyInfo.cache index 8779c83..2c46216 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.RazorTargetAssemblyInfo.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.RazorTargetAssemblyInfo.cache @@ -1 +1 @@ -807162356eee65d68db8165b5fb955d25318de2207b8907923f13b609c16ee01 +486197f055fb5d72cad81ec325faa738048e295edd4b24fa7153c34679c68bad diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache index eb22f13..01052d9 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -2a87f4d099a984a0e9253410e6f4597f90c3d03ecbe20d28d0efc2bffc02a7bc +8d0a705eb05b7d31a5543fad875abccdcc0dec6fa2790db8f635c6c6cfa76d95 diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.dll b/obj/Debug/netcoreapp3.1/rmutr_report.dll index 5dbe293..b228572 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 34b30e5..cd614bd 100644 Binary files a/obj/Debug/netcoreapp3.1/rmutr_report.pdb and b/obj/Debug/netcoreapp3.1/rmutr_report.pdb differ diff --git a/obj/Debug/netcoreapp3.1/staticwebassets/msbuild.rmutr_report.Microsoft.AspNetCore.StaticWebAssets.props b/obj/Debug/netcoreapp3.1/staticwebassets/msbuild.rmutr_report.Microsoft.AspNetCore.StaticWebAssets.props index 5dd9d7b..8506899 100644 --- a/obj/Debug/netcoreapp3.1/staticwebassets/msbuild.rmutr_report.Microsoft.AspNetCore.StaticWebAssets.props +++ b/obj/Debug/netcoreapp3.1/staticwebassets/msbuild.rmutr_report.Microsoft.AspNetCore.StaticWebAssets.props @@ -3024,6 +3024,70 @@ PreserveNewest $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\reports\summary_income_cooperative.frx)) + + Package + rmutr_report + $(MSBuildThisFileDirectory)..\staticwebassets\ + _content/rmutr_report + reports\summary_invest.frx + + + + + + + + PreserveNewest + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\reports\summary_invest.frx)) + + + Package + rmutr_report + $(MSBuildThisFileDirectory)..\staticwebassets\ + _content/rmutr_report + reports\summary_invest_approve.frx + + + + + + + + PreserveNewest + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\reports\summary_invest_approve.frx)) + + + Package + rmutr_report + $(MSBuildThisFileDirectory)..\staticwebassets\ + _content/rmutr_report + reports\summary_invest_preview.frx + + + + + + + + PreserveNewest + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\reports\summary_invest_preview.frx)) + + + Package + rmutr_report + $(MSBuildThisFileDirectory)..\staticwebassets\ + _content/rmutr_report + reports\summary_invest_previewv2.frx + + + + + + + + PreserveNewest + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\reports\summary_invest_previewv2.frx)) + Package rmutr_report diff --git a/obj/Debug/netcoreapp3.1/staticwebassets/rmutr_report.StaticWebAssets.Pack.cache b/obj/Debug/netcoreapp3.1/staticwebassets/rmutr_report.StaticWebAssets.Pack.cache index c12641e..1ae2371 100644 --- a/obj/Debug/netcoreapp3.1/staticwebassets/rmutr_report.StaticWebAssets.Pack.cache +++ b/obj/Debug/netcoreapp3.1/staticwebassets/rmutr_report.StaticWebAssets.Pack.cache @@ -1 +1 @@ -f897b4952cd5268294905ba9623c4e220b69b02b431d5352f3f0a6591fa71fa2 +c50bede8becdc099c2f6e83e533c61274065063dd9f82764a97f4e0ec79d5558 diff --git a/obj/rider.project.model.nuget.info b/obj/rider.project.model.nuget.info index 5e9e084..e0843dd 100644 --- a/obj/rider.project.model.nuget.info +++ b/obj/rider.project.model.nuget.info @@ -1 +1 @@ -17248395490624370 \ No newline at end of file +17249025111686656 \ No newline at end of file diff --git a/obj/rider.project.restore.info b/obj/rider.project.restore.info index 5e9e084..f94e32b 100644 --- a/obj/rider.project.restore.info +++ b/obj/rider.project.restore.info @@ -1 +1 @@ -17248395490624370 \ No newline at end of file +17249123958142058 \ No newline at end of file diff --git a/wwwroot/reports/summary_invest.frx b/wwwroot/reports/summary_invest.frx new file mode 100644 index 0000000..4881285 --- /dev/null +++ b/wwwroot/reports/summary_invest.frx @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/reports/summary_invest_approve.frx b/wwwroot/reports/summary_invest_approve.frx new file mode 100644 index 0000000..45d66af --- /dev/null +++ b/wwwroot/reports/summary_invest_approve.frx @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/reports/summary_invest_preview.frx b/wwwroot/reports/summary_invest_preview.frx new file mode 100644 index 0000000..e88b50c --- /dev/null +++ b/wwwroot/reports/summary_invest_preview.frx @@ -0,0 +1,260 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +