diff --git a/Controllers/RoFive.Controller.cs b/Controllers/RoFive.Controller.cs new file mode 100644 index 0000000..84aa002 --- /dev/null +++ b/Controllers/RoFive.Controller.cs @@ -0,0 +1,269 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +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 Swashbuckle.AspNetCore.Annotations; + +namespace rmutr_report.Controllers +{ + [SwaggerTag("สำหรับรายงาน ร.5")] + public class RoFive : Controller + { + readonly Setting _setting; + + public RoFive(Setting setting) + { + this._setting = setting; + } + + [HttpPost, Route("reports/ro_five/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetRoFiveReport([FromRoute] string type, [FromBody] ro_five building_fours) + { + foreach (var a in building_fours.building_type) + { + if (a.usage_per_target != null) + { + var a1 = a.usage_per_target.Where(d => d.used_year == d.used_year) + .Sum(o => o.used_year); + building_fours.sum_year1 = a1; + var a2 = a.usage_per_target.Where(d => d.year1 == d.year1) + .Sum(o => o.year1); + building_fours.sum_year2 = a2; + var a3 = a.usage_per_target.Where(d => d.year2 == d.year2) + .Sum(o => o.year2); + building_fours.sum_year3 = a3; + var a4 = a.usage_per_target.Where(d => d.year3 == d.year3) + .Sum(o => o.year3); + building_fours.sum_year4 = a4; + var a5 = a.usage_per_target.Where(d => d.year4 == d.year4) + .Sum(o => o.year4); + building_fours.sum_year5 = a5; + var a6 = a.usage_per_target.Where(d => d.year5 == d.year5) + .Sum(o => o.year5); + building_fours.sum_year6 = a6; + } + } + + // foreach (var bb in building_fours.material_construction_labor1) + // { + // if (bb != null) + // { + // bb.total_amount = bb.material_cost + bb.labor_unit; + // var f = building_fours.material_construction_labor1.Where(d => d.total_amount == d.total_amount) + // .Sum(o => o.total_amount); + // building_fours.material_total_amount1 = f; + // } + // } + // foreach (var bb in building_fours.material_construction_labor2) + // { + // if (bb != null) + // { + // bb.total_amount = bb.material_cost + bb.labor_unit; + // var f = building_fours.material_construction_labor2.Where(d => d.total_amount == d.total_amount) + // .Sum(o => o.total_amount); + // building_fours.material_total_amount2 = f; + // } + // } + // foreach (var bb in building_fours.material_construction_labor3) + // { + // if (bb != null) + // { + // bb.total_amount = bb.material_cost + bb.labor_unit; + // var f = building_fours.material_construction_labor3.Where(d => d.total_amount == d.total_amount) + // .Sum(o => o.total_amount); + // building_fours.material_total_amount3 = f; + // } + // } + foreach (var cc in building_fours.budget_limit) + { + if (cc != null) + { + var a = building_fours.budget_limit.Where(d => d.amount == d.amount) + .Sum(o => o.amount); + building_fours.amount = a; + if (cc.outside_amount != null) + { + var b = building_fours.budget_limit.Where(d => d.outside_amount == d.outside_amount) + .Sum(o => o.outside_amount); + building_fours.outside_amount = b; + } + + if (cc.outside_amount == null) + { + building_fours.outside_amount = null; + } + + if (cc.amount != null && cc.outside_amount != null) + { + cc.total_amount = cc.amount + cc.outside_amount; + } + + var c = building_fours.budget_limit.Where(d => d.total_amount == d.total_amount) + .Sum(o => o.total_amount); + building_fours.total_amount = c; + } + } + + foreach (var boqPrice in building_fours.basic_information) + { + // string str = boqPrice.list; + if (boqPrice.list != null) + { + boqPrice.list.Split("."); + } + + if (boqPrice.list == "20000000.0000") + { + boqPrice.list = "20,000,000"; + } + // if (str.Length == 4) + // { + // for (int i = 1; i <= str.Length - 1; i += 4) + // { + // boqPrice.list = str.Insert(i, ","); + // } + // } + // if (str.Length == 5) + // { + // for (int i = 2; i <= str.Length - 1; i += 5) + // { + // boqPrice.list = str.Insert(i, ","); + // } + // } + // else if (str.Length == 6) + // { + // for (int i = 3; i <= str.Length - 1; i += 6) + // { + // boqPrice.list = str.Insert(i, ","); + // } + // } + // else if (str.Length == 7) + // { + // for (int i = 1,j=5; i <= str.Length -1 ;i +=7,j+=7) + // { + // boqPrice.list = str.Insert(i, ",").Insert(j,","); + // } + // + // } + // if (str.Length == 8) + // { for (int i = 2,j=6; i <= str.Length -1 ;i +=8,j+=8) + // { + // boqPrice.list = str.Insert(i, ",").Insert(j,","); + // } + // } + + if (boqPrice.list == "10000000") + { + boqPrice.list = "10,000,000"; + } + } + + foreach (var boqPrice in building_fours.boq) + { + if (boqPrice.is_data == "1") + { + string str = boqPrice.have; + if (str.Length == 4) + { + for (int i = 1; i <= str.Length - 1; i += 4) + { + boqPrice.have = str.Insert(i, ","); + } + } + else if (str.Length == 5) + { + for (int i = 2; i <= str.Length - 1; i += 5) + { + boqPrice.have = str.Insert(i, ","); + } + } + else if (str.Length == 6) + { + for (int i = 3; i <= str.Length - 1; i += 6) + { + boqPrice.have = str.Insert(i, ","); + } + } + else if (str.Length == 7) + { + for (int i = 1, j = 5; i <= str.Length - 1; i += 7, j += 7) + { + boqPrice.have = str.Insert(i, ",").Insert(j, ","); + } + + } + else if (str.Length == 8) + { + for (int i = 2, j = 6; i <= str.Length - 1; i += 8, j += 8) + { + boqPrice.have = str.Insert(i, ",").Insert(j, ","); + } + } + + // if (boqPrice.have == "10000000") + // { + // boqPrice.have = "10,000,000"; + // } + boqPrice.text1 = "- มี วงเงิน " + boqPrice.have + " บาท"; + boqPrice.text2 = "- ดำเนินการจัดทำ BOQ เดือน " + boqPrice.pending_boq_month; + boqPrice.text3 = "- BOQ แล้วเสร็จเดือน " + boqPrice.done_boq_month; + boqPrice.text4 = "- ขออนุมัติ BOQ เดือน " + boqPrice.approval_month; + boqPrice.text5 = "- ทำสัญญาก่อสร้าง เดือน " + boqPrice.construction_contract_month; + } + + if (boqPrice.is_data == "2") + { + boqPrice.text1 = "- ไม่มี"; + boqPrice.text2 = "- กรณีไม่มีคาดว่าจะแล้วเสร็จ เดือน " + boqPrice.months + " ปี " + + boqPrice.years; + boqPrice.text3 = "- ขณะนี้อยูในขั้นตอน " + boqPrice.step; + } + } + + + var _budget_summary_report = new List() { building_fours }; + + Report report = new Report(); + report.Load(_setting.report_path + "ro_five.frx"); + report.RegisterData(_budget_summary_report, "ro_five"); + 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 "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/budget/ro_five.cs b/Models/budget/ro_five.cs new file mode 100644 index 0000000..0766ebe --- /dev/null +++ b/Models/budget/ro_five.cs @@ -0,0 +1,203 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models +{ + public class ro_five + { + public string year { get; set; } + public string agency_faculty { get; set; } + public string major { get; set; } + public string area { get; set; } + public string responsible_person { get; set; } + public string phone_no { get; set; } + public string email { get; set; } + public string product { get; set; } + public string budget_year { get; set; } + public string year_range { get; set; } + public List data { get; set; } + public string list { get; set; } + public List building_type { get; set; } + public string year1 { get; set; } + public string year2 { get; set; } + public string year3 { get; set; } + public string year4 { get; set; } + public string year5 { get; set; } + public string year6 { get; set; } + public List readiness_action { get; set; } + public string necessity_reason { get; set; } + + public List objective { get; set; } + + //public string objective { get; set; } + public string utility { get; set; } + public string processing_time { get; set; } + public string start_date { get; set; } + public string end_date { get; set; } + public string total_day { get; set; } + public List basic_information { get; set; } + public List budget_limit { get; set; } + public decimal? amount { get; set; } + public decimal? outside_amount { get; set; } + public decimal? total_amount { get; set; } + public List list_format { get; set; } + public List boq { get; set; } + public List spending_plan { get; set; } + + public string budget_spending_plan_year { get; set; } + + //public decimal? spending_plan_amount { get; set; } + public List material_construction_labor { get; set; } + + // public List material_construction_labor2 { get; set; } + // public List material_construction_labor3 { get; set; } + //public string url_file { get; set; } + public decimal? material_total_amount { get; set; } + + // public decimal? material_total_amount2 { get; set; } + // public decimal? material_total_amount3 { get; set; } + // public decimal? full_limit { get; set; } + // public decimal? national_budget { get; set; } + public decimal? income_budget { get; set; } + public List detail_division_work { get; set; } + public List detail_division_work_table { get; set; } + public string result { get; set; } + public string cause_damage { get; set; } + public string other_clarifications_consideration { get; set; } + public decimal? sum_year1 { get; set; } + public decimal? sum_year2 { get; set; } + public decimal? sum_year3 { get; set; } + public decimal? sum_year4 { get; set; } + public decimal? sum_year5 { get; set; } + + public decimal? sum_year6 { get; set; } + //public string bath { get; set; } + } + + public class building_four_details + { + public string list { get; set; } + public decimal? amount { get; set; } + } + + public class building_types + { + public string type_name { get; set; } + public string text { get; set; } + + public List building_style { get; set; } + public List usage_per_target { get; set; } + public string text_footer { get; set; } + public string remark { get; set; } + } + + public class buildings_styles + { + public string list { get; set; } + public string location { get; set; } + public string build_year { get; set; } + public string used_year { get; set; } + public string quantity_floors { get; set; } + public string note { get; set; } + } + + public class usage_per_targets + { + public string list { get; set; } + public decimal? used_year { get; set; } + public decimal? year1 { get; set; } + public decimal? year2 { get; set; } + public decimal? year3 { get; set; } + public decimal? year4 { get; set; } + public decimal? year5 { get; set; } + } + + public class readiness_actions + { + public string list { get; set; } + } + + public class budget_limits + { + public string budget_year { get; set; } + public decimal? amount { get; set; } + public decimal? outside_amount { get; set; } + public decimal? total_amount { get; set; } + } + + public class list_formats + { + public string pending { get; set; } + public string done { get; set; } + public string pending_design_month { get; set; } + public string done_design_month { get; set; } + public string approval_month { get; set; } + public string construction_contract_month { get; set; } + } + + public class boq_prices + { + public string is_data { get; set; } + public string text1 { get; set; } + public string text2 { get; set; } + public string text3 { get; set; } + public string text4 { get; set; } + public string text5 { get; set; } + public string have { get; set; } + public string pending_boq_month { get; set; } + public string done_boq_month { get; set; } + public string approval_month { get; set; } + + public string construction_contract_month { get; set; } + + //public string no_have { get; set; } + public string months { get; set; } + public string years { get; set; } + public string step { get; set; } + } + + public class spending_plans + { + public string list { get; set; } + public string month_1 { get; set; } + public string month_2 { get; set; } + public string month_3 { get; set; } + public string month_4 { get; set; } + public string month_5 { get; set; } + public string month_6 { get; set; } + public string month_7 { get; set; } + public string month_8 { get; set; } + public string month_9 { get; set; } + public string month_10 { get; set; } + public string month_11 { get; set; } + public string month_12 { get; set; } + } + + public class materials_construction_labors + { + public string operational_activities { get; set; } + public decimal? amount { get; set; } + public string unit { get; set; } + public decimal? material_unit { get; set; } + public decimal? material_cost { get; set; } + public decimal? labor_unit { get; set; } + public decimal? labor_cost { get; set; } + public decimal? total_amount { get; set; } + public string note { get; set; } + } + + public class details_division_works + { + public string budget_year { get; set; } + public decimal? amount { get; set; } + } + + public class details_division_work_tables + { + public string installment { get; set; } + public string percentage { get; set; } + public string contracted_date { get; set; } + public string inspection_date { get; set; } + public decimal? amount { get; set; } + public decimal? cumulative_payment { 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 b08fc0f..23f1fa2 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 b3007b0..ff09c2e 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 fe6a101..16f0a53 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 fe6a101..16f0a53 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 e21add1..0e6a99a 100644 --- a/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache +++ b/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -4016abde0a942687404c1b0022dc5b31762b26b5 +57cd4f89f195b698c7cc6d74d63f49bb6d30374d diff --git a/obj/Debug/net5.0/rmutr-report.dll b/obj/Debug/net5.0/rmutr-report.dll index b08fc0f..23f1fa2 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 b3007b0..ff09c2e 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/ro_five.frx b/wwwroot/reports/ro_five.frx new file mode 100644 index 0000000..04118a0 --- /dev/null +++ b/wwwroot/reports/ro_five.frx @@ -0,0 +1,645 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +