diff --git a/Controllers/Budget.Controller.cs b/Controllers/Budget.Controller.cs index 6bab2db..7e8b2e0 100644 --- a/Controllers/Budget.Controller.cs +++ b/Controllers/Budget.Controller.cs @@ -2482,141 +2482,323 @@ namespace rmutr_report.Controllers return Ok(); } - [SwaggerOperation("แผนงานบุคลากรภาครัฐ")] - [HttpPost, Route("reports/budget_expenditure_report_from_revenue/{type}")] + // [SwaggerOperation("แผนงานบุคลากรภาครัฐ")] + // [HttpPost, Route("reports/budget_expenditure_report_from_revenue/{type}")] + // [ApiExplorerSettings(GroupName = "reports")] + // public IActionResult GetBudgetExpenditureRevenueReport([FromRoute] string type, + // [FromBody] budget_expenditure_report_from_revenue budget) + // { + // int no = 1; + // + // var b = budget.budgets.ToArray(); + // foreach (var bb in b) + // { + // bb.personnel_list_s = new List { bb.personnel_lists }; + // foreach (var detail in bb.personnel_list_s) + // { + // foreach (var detail2 in detail.budget_personnel_lists) + // { + // if (detail2.rate != null) + // { + // detail2.text1 = "อัตรา"; + // } + // + // var cperson = detail.budget_personnel_lists.Count(); + // + // if (cperson == 1) + // { + // detail.budget_personnel_lists[0].topic = "งบบุคลากร"; + // } + // + // foreach (var detail3 in detail2.budget_personnel_lists_2) + // { + // if (detail3.rate != null) + // { + // detail3.text1 = "อัตรา"; + // } + // + // int no2 = 1; + // + // if (detail3.topic != null) + // { + // detail3.row_no = no; + // no++; + // } + // + // foreach (var detail4 in detail3.budget_rates) + // { + // if (detail4.rate != null) + // { + // detail4.text1 = "อัตรา"; + // } + // + // int no3 = 1; + // if (detail4.topic != null) + // { + // detail4.row_no = no2; + // no2++; + // } + // + // foreach (var detail5 in detail4.details) + // { + // int no4 = 1; + // if (detail5.rate != null) + // { + // detail5.text1 = "อัตรา"; + // } + // + // if (detail5.position_level != null) + // { + // detail5.row_no = no3; + // no3++; + // } + // + // if (detail5.details2 != null) + // { + // foreach (var detail6 in detail5.details2) + // { + // if (detail6.topic != null) + // { + // detail6.row_no = no4; + // no4++; + // detail6.text1 = "บาท"; + // } + // } + // } + // + // if (detail5.details2.Any()) + // { + // if (detail5.details2==null) + // { + // foreach (var detail6 in detail5.details2) + // { + // detail6.topic = null; + // detail6.total = null; + // detail6.row_no = null; + // detail6.text1 = null; + // } + // } + // } + // else + // { + // detail5.details2.Add(new details2() + // { + // topic = "", total = 999999999 + // }); + // } + // } + // } + // } + // + // + // if (cperson == 2) + // { + // detail.budget_personnel_lists[0].topic = "งบบุคลากร"; + // detail.budget_personnel_lists[1].topic = "งบดําเนินงาน"; + // detail.budget_personnel_lists[1].text1 = null; + // detail.budget_personnel_lists[1].budget_personnel_lists_2[0].text1 = null; + // detail.budget_personnel_lists[1].budget_personnel_lists_2[0].row_no = null; + // detail.budget_personnel_lists[1].budget_personnel_lists_2[0].budget_rates[0] + // .row_no = null; + // detail.budget_personnel_lists[1].budget_personnel_lists_2[0].budget_rates[0] + // .text1 = null; + // detail.budget_personnel_lists[1].budget_personnel_lists_2[0].budget_rates[0] + // .details[0].text1 = null; + // } + // } + // } + // } + // + // + // var budgetExpenditure = new List() { budget }; + // + // Report report = new Report(); + // report.Load(_setting.report_path + "budget_expenditure_report_from_revenue.frx"); + // report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue"); + // 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", + // "budgetExpenditure_" + date + ".xlsx"); + // } + // + // return Ok(); + // } + [SwaggerOperation("แบบฟอร์มสรุปรายจ่าย")] + [HttpPost, Route("reports/budget_expenditure_report_from_revenue_v2/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetBudgetExpenditureRevenueReport([FromRoute] string type, - [FromBody] budget_expenditure_report_from_revenue budget) + [FromBody] budget_expenditure_report_from_revenue_v2 budget) { - int no = 1; - - var b = budget.budgets.ToArray(); - foreach (var bb in b) + int no1 = 1; + int no2 = 1; + int no3 = 1; + int no4 = 1; + int no5 = 1; + int no6 = 1; + + var detail = budget.details.ToArray(); + foreach (var indetail in detail) { - bb.personnel_list_s = new List { bb.personnel_lists }; - foreach (var detail in bb.personnel_list_s) + if (indetail.topic_type==1) { - foreach (var detail2 in detail.budget_personnel_lists) - { - if (detail2.rate != null) - { - detail2.text1 = "อัตรา"; - } - - var cperson = detail.budget_personnel_lists.Count(); - - if (cperson == 1) - { - detail.budget_personnel_lists[0].topic = "งบบุคลากร"; - } - - foreach (var detail3 in detail2.budget_personnel_lists_2) - { - if (detail3.rate != null) - { - detail3.text1 = "อัตรา"; - } - - int no2 = 1; - - if (detail3.topic != null) - { - detail3.row_no = no; - no++; - } - - foreach (var detail4 in detail3.budget_rates) - { - if (detail4.rate != null) - { - detail4.text1 = "อัตรา"; - } - - int no3 = 1; - if (detail4.topic != null) - { - detail4.row_no = no2; - no2++; - } - - foreach (var detail5 in detail4.details) - { - int no4 = 1; - if (detail5.rate != null) - { - detail5.text1 = "อัตรา"; - } - - if (detail5.position_level != null) - { - detail5.row_no = no3; - no3++; - } - - if (detail5.details2 != null) - { - foreach (var detail6 in detail5.details2) - { - if (detail6.topic != null) - { - detail6.row_no = no4; - no4++; - detail6.text1 = "บาท"; - } - } - } - - if (detail5.details2.Any()) - { - if (detail5.details2==null) - { - foreach (var detail6 in detail5.details2) - { - detail6.topic = null; - detail6.total = null; - detail6.row_no = null; - detail6.text1 = null; - } - } - - } - else - { - detail5.details2.Add(new details2() - { - topic = "",total = 999999999 - }); - - } - } - } - } - - - if (cperson == 2) - { - detail.budget_personnel_lists[0].topic = "งบบุคลากร"; - detail.budget_personnel_lists[1].topic = "งบดําเนินงาน"; - detail.budget_personnel_lists[1].text1 = null; - detail.budget_personnel_lists[1].budget_personnel_lists_2[0].text1 = null; - detail.budget_personnel_lists[1].budget_personnel_lists_2[0].row_no = null; - detail.budget_personnel_lists[1].budget_personnel_lists_2[0].budget_rates[0] - .row_no = null; - detail.budget_personnel_lists[1].budget_personnel_lists_2[0].budget_rates[0] - .text1 = null; - detail.budget_personnel_lists[1].budget_personnel_lists_2[0].budget_rates[0] - .details[0].text1 = null; - } + indetail.topic1 = indetail.topic; + indetail.amount1 = indetail.value1; + indetail.text1 = "บาท"; + indetail.topic2 = null; + indetail.amount2 = null; + indetail.text2 = null; + } + if (indetail.topic_type==2) + { + indetail.topic2 = indetail.topic; + indetail.amount2 = indetail.value1; + indetail.text2 = "บาท"; + indetail.topic1 = null; + indetail.amount1 = null; + indetail.text1 = null; + } + if (indetail.topic_type==3) + { + indetail.topic3 = indetail.topic; + indetail.amount3 = indetail.value1; + indetail.amount4 = indetail.value2; + indetail.text3 = "อัตรา"; + indetail.text4 = "บาท"; + indetail.topic1 = null; + indetail.amount1 = null; + indetail.text1 = null; + indetail.topic2 = null; + indetail.amount2 = null; + indetail.text2 = null; + } + if (indetail.topic_type==3 && indetail.topic=="งบดําเนินงาน") + { + indetail.topic3 = indetail.topic; + //indetail.amount3 = indetail.value1; + indetail.amount4 = indetail.value1; + indetail.text3 = null; + indetail.text4 = "บาท"; + indetail.topic1 = null; + indetail.amount1 = null; + indetail.text1 = null; + indetail.topic2 = null; + indetail.amount2 = null; + indetail.amount3 = null; + indetail.text2 = null; + } + if (indetail.topic_type==4) + { + indetail.topic4 = indetail.topic; + indetail.amount5 = indetail.value1; + indetail.amount6 = indetail.value2; + indetail.text5 = "อัตรา"; + indetail.text6 = "บาท"; + indetail.row_no1 = no1; + no1++; + } + if (indetail.topic_type==4&& indetail.topic=="ค่าตอบแทน ค่าใช้สอยและค่าวัสดุ") + { + + indetail.row_no1 = null; + indetail.amount6 = indetail.value1; + indetail.text5 = null; + indetail.amount5 =null; + indetail.text6 = "บาท"; } + if (indetail.topic_type==5) + { + indetail.topic5 = indetail.topic; + indetail.amount7 = indetail.value1; + indetail.amount8 = indetail.value2; + indetail.text7 = "อัตรา"; + indetail.text8 = "บาท"; + indetail.row_no2 = no2; + no2++; + } + if (indetail.topic_type==5&& indetail.topic=="ค่าตอบแทน") + { + + indetail.topic5 = indetail.topic; + indetail.amount7 = null; + indetail.amount8 = indetail.value1; + indetail.text7 = null; + indetail.text8 = "บาท"; + indetail.row_no2 = null; + } + if (indetail.topic_type==6) + { + indetail.topic9 = indetail.topic; + indetail.topic10 = indetail.qualification; + indetail.amount9 = indetail.value1; + indetail.amount10 = indetail.value2; + indetail.text9 = "อัตรา"; + indetail.text10 = "บาท"; + indetail.row_no3 = no3; + no3++; + } + if (indetail.topic_type==7) + { + indetail.topic11 = indetail.topic; + indetail.amount11 = indetail.value1; + indetail.text11 = "บาท"; + indetail.row_no4 = no4; + no4++; + } + if (indetail.topic_type==8) + { + indetail.topic12 = indetail.topic; + indetail.amount12 = indetail.value1; + indetail.text12 = "บาท"; + indetail.row_no5 = no5; + no5++; + } + if (indetail.topic_type==9) + { + + indetail.text13 = "รายการ"; + indetail.text14 = "จำนวน"; + indetail.text15 = "หน่วยนับ"; + indetail.text16 = "ราคาต่อหน่วย"; + indetail.text17 = "รวมเงิน"; + + } + if (indetail.topic_type==10) + { + indetail.topic13 = indetail.topic; + indetail.amount13 = indetail.value1; + indetail.amount14 = indetail.value2; + indetail.amount15 = indetail.value3; + //indetail.amount16 = indetail.value4; + indetail.text18 = "บาท"; + indetail.text19 = "."; + indetail.row_no6 = no6; + no6++; + } } - - - var budgetExpenditure = new List() { budget }; + var budgetExpenditure = new List() { budget }; Report report = new Report(); - report.Load(_setting.report_path + "budget_expenditure_report_from_revenue.frx"); - report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue"); + report.Load(_setting.report_path + "budget_expenditure_report_from_revenue_v2.frx"); + report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue_v2"); report.Prepare(); MemoryStream stream = new MemoryStream(); @@ -2638,11 +2820,12 @@ namespace rmutr_report.Controllers return File( stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - "budgetExpenditure_" + date + ".xlsx"); + "budgetExpenditureV2_" + date + ".xlsx"); } return Ok(); } + [SwaggerOperation("สรุปงบประมาณแผนปฏิบัติราชการประจำปี")] [HttpPost, Route("reports/summary_government_budget_plan/{type}")] diff --git a/Models/budget/budget_expenditure_report_from_revenue_v2.cs b/Models/budget/budget_expenditure_report_from_revenue_v2.cs new file mode 100644 index 0000000..90c4abd --- /dev/null +++ b/Models/budget/budget_expenditure_report_from_revenue_v2.cs @@ -0,0 +1,87 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models +{ + public class budget_expenditure_report_from_revenue_v2 + { + public string academic_year_name_th { get; set; } + public string sector { get; set; } //ภาค + public string parent_agency_name { get; set; } //หน่วยงาน + public string agency_name_th { get; set; } //พื้นที่ + public decimal? total { get; set; } + public List details { get; set; } + } + + public class budget_expenditure_report_from_revenue_v2_detail + { + public int? topic_type { get; set; } + public int? row_no1 { get; set; } + public int? row_no2 { get; set; } + public int? row_no3 { get; set; } + public int? row_no4 { get; set; } + public int? row_no5 { get; set; } + public int? row_no6 { get; set; } + public string topic { get; set; } + public string qualification { get; set; } + public string unit { get; set; } + public decimal? value1 { get; set; } + public decimal? value2 { get; set; } + public decimal? value3 { get; set; } + public decimal? value4 { get; set; } + public string topic1 { get; set; } + public string topic2 { get; set; } + public string topic3 { get; set; } + public string topic4 { get; set; } + public string topic5 { get; set; } + public string topic6 { get; set; } + public string topic7 { get; set; } + public string topic8 { get; set; } + public string topic9 { get; set; } + public string topic10 { get; set; } + public string topic11 { get; set; } + public string topic12 { get; set; } + public string topic13 { get; set; } + public string topic14 { get; set; } + public string topic15 { get; set; } + public decimal? amount1 { get; set; } + public decimal? amount2 { get; set; } + public decimal? amount3 { get; set; } + public decimal? amount4 { get; set; } + public decimal? amount5 { get; set; } + public decimal? amount6 { get; set; } + public decimal? amount7 { get; set; } + public decimal? amount8 { get; set; } + public decimal? amount9 { get; set; } + public decimal? amount10 { get; set; } + public decimal? amount11 { get; set; } + public decimal? amount12 { get; set; } + public decimal? amount13 { get; set; } + public decimal? amount14 { get; set; } + public decimal? amount15 { get; set; } + public decimal? amount16 { get; set; } + public decimal? amount17 { 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 text6 { get; set; } + public string text7 { get; set; } + public string text8 { get; set; } + public string text9 { get; set; } + public string text10 { get; set; } + public string text11 { get; set; } + public string text12 { get; set; } + public string text13 { get; set; } + public string text14 { get; set; } + public string text15 { get; set; } + public string text16 { get; set; } + public string text17 { get; set; } + public string text18 { get; set; } + public string text19 { get; set; } + public string text20 { get; set; } + public string text21 { get; set; } + public string text22 { get; set; } + //public string line { 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 70460a3..a00eeed 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 7fb2fc9..688c404 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 5a222f6..97d58cb 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -15c434a94e38d0b88f3ec6c7fee5cdb9307882c2 +08426863366ac1cc0305f074194bd81e401f7c35 diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.dll b/obj/Debug/netcoreapp3.1/rmutr_report.dll index 70460a3..a00eeed 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 7fb2fc9..688c404 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/rider.project.restore.info b/obj/rider.project.restore.info index 09ca182..2ab0b68 100644 --- a/obj/rider.project.restore.info +++ b/obj/rider.project.restore.info @@ -1 +1 @@ -16926820101922101 \ No newline at end of file +16926988309592902 \ No newline at end of file diff --git a/wwwroot/reports/budget_expenditure_report_from_revenue_v2.frx b/wwwroot/reports/budget_expenditure_report_from_revenue_v2.frx new file mode 100644 index 0000000..8e21b09 --- /dev/null +++ b/wwwroot/reports/budget_expenditure_report_from_revenue_v2.frx @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +