Update
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kamonwan taengsuk
2024-08-28 17:07:57 +07:00
parent 9c37d45f5c
commit e3335ae91e
12 changed files with 237 additions and 158 deletions

View File

@@ -3612,92 +3612,188 @@ namespace rmutr_report.Controllers
return Ok(); return Ok();
} }
[SwaggerOperation("รวมทุกแผน")] [SwaggerOperation("request_summary")]
[HttpPost, Route("reports/request_summary_all_plans/{type}")] [HttpPost, Route("reports/request_summary_all_plans/{type}")]
[ApiExplorerSettings(GroupName = "reports")] [ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetRequestSummaryReport([FromRoute] string type, public IActionResult GetRequestSummaryAllReport([FromRoute] string type, [FromBody] request_summary requestSummary)
[FromBody] request_summary requestSummary)
{ {
int row = 1; var workbook = new XLWorkbook();
foreach (var requestSummaryDetail in requestSummary.data_1) var ws = workbook.Worksheets.Add("Sheet1");
{
requestSummaryDetail.rowno = row.ToString(); ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. "+requestSummary.budget_year+" (คำขอ)";
row++; ws.Cell("A1").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
} ws.Cell("A1").Style.Font.FontSize = 16;
ws.Cell("A2").Value = "มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์";
ws.Cell("A2").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A2").Style.Font.FontSize = 16;
int col = 2;
int rowhead = 4;
int rowt = 5;
int row = 6;
requestSummary.short_budget_year = requestSummary.budget_year.Substring(2, 2); int rowno = 1;
var requestSummaries = new List<request_summary>() { requestSummary };
if (requestSummary != null)
{
var countbudgetplan = requestSummary.budget_plans.Count;
if (countbudgetplan==1)
{
foreach (var i in requestSummary.budget_plans)
{
ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
ws.Cell(3, 2).Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)";
ws.Cell(4, 2).Value = i.budget_plan_name;
ws.Cell(5, 2).Value = i.total_value;
ws.Cell(4, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(4, 2).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Cell(4, 2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(4, 2).Style.Font.FontSize = 16;
ws.Cell(4, 2).Style.Alignment.WrapText = true;
ws.Cell("A3").Style.Alignment.WrapText = true;
ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A3").Style.Font.FontSize = 16;
ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(3, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(3, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(3, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(3, 2).Style.Font.FontSize = 16;
ws.Cell(3, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(4, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(4, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(4, 2).Style.Font.FontSize = 16;
ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(5, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(5, 2).Style.Font.FontSize = 16;
ws.Cell(5, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(rowhead, col).Value = i.budget_plan_name;
// ws.Cell(rowhead, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(rowhead, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(rowhead, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(rowhead, col).Style.Border.RightBorder = XLBorderStyleValues.Thin;
// ws.Cell(rowhead, col).Style.Font.FontName = "TH SarabunPSK";
// ws.Cell(rowhead, col).Style.Font.FontSize = 16;
// ws.Cell(rowhead, col).Style.Alignment.WrapText = true;
// col++;
// ws.Cell(3, 2).Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)";
}
Report report = new Report(); foreach (var detail in requestSummary.data)
report.Load(_setting.report_path + "all_plans.frx"); {
report.RegisterData(requestSummaries, "request_summary"); if (detail.color==1&&detail.is_bold==null)
report.Prepare(); {
ws.Cell(row, 1).Value = rowno+"."+detail.list;
MemoryStream stream = new MemoryStream(); rowno++;
switch (type) foreach (var budgetPlan in detail.budget_plans)
{
ws.Cell(row, 2).Value = budgetPlan.value;
}
ws.Cell(row,1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(5,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 16;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(204, 153, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.color==2&&detail.is_bold==true)
{
ws.Cell(row, 1).Value = detail.list;
foreach (var budgetPlan in detail.budget_plans)
{
ws.Cell(row, 2).Value = budgetPlan.value;
}
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 16;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.color==3&&detail.is_bold==null)
{
ws.Cell(row, 1).Value = detail.list;
foreach (var budgetPlan in detail.budget_plans)
{
ws.Cell(row, 2).Value = budgetPlan.value;
}
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 16;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 153);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
}
}
}
using (var stream = new MemoryStream())
{ {
case "pdf": workbook.SaveAs(stream);
PDFExport pdf = new PDFExport(); var content = stream.ToArray();
report.Export(pdf, stream); string date = DateTime.Now.ToString("yyyyMMddHHmmss");
stream.Seek(0, SeekOrigin.Begin); return File(
return File(stream, "application/pdf"); content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
case "xls": date + ".xlsx");
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(
stream,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"request_summary" + ".xlsx");
} }
return Ok();
}
[SwaggerOperation("แผนบูรณาการแผนยุทธศาสตร์")]
[HttpPost, Route("reports/request_summary_integrated_strategic/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetRequestSummary2Report([FromRoute] string type,
[FromBody] request_summary requestSummary)
{
requestSummary.short_budget_year = requestSummary.budget_year.Substring(2, 2);
int row = 1;
foreach (var requestSummaryDetail in requestSummary.data_1)
{
requestSummaryDetail.rowno = row.ToString();
row++;
}
var requestSummaries = new List<request_summary>() { requestSummary };
Report report = new Report();
report.Load(_setting.report_path + "integrated_strategic.frx");
report.RegisterData(requestSummaries, "request_summary");
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",
"request_summary" + ".xlsx");
}
return Ok();
} }
// [SwaggerOperation("แผนบูรณาการแผนยุทธศาสตร์")]
// [HttpPost, Route("reports/request_summary_integrated_strategic/{type}")]
// [ApiExplorerSettings(GroupName = "reports")]
// public IActionResult GetBudgetRequestSummary2Report([FromRoute] string type,
// [FromBody] request_summary requestSummary)
// {
//
// var requestSummaries = new List<request_summary>() { requestSummary };
//
// Report report = new Report();
// report.Load(_setting.report_path + "integrated_strategic.frx");
// report.RegisterData(requestSummaries, "request_summary");
// 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",
// "request_summary" + ".xlsx");
// }
//
// return Ok();
// }
} }
} }

View File

@@ -5,87 +5,70 @@ namespace rmutr_report.Models.RoThree
public class request_summary public class request_summary
{ {
public string budget_year { get; set; } public string budget_year { get; set; }
public string short_budget_year { get; set; } public List<request_summary_detail> data { get; set; }
public decimal? total_amount_1 { get; set; } public List<budget_plan_data> budget_plans { get; set; }
public decimal? total_amount_2 { get; set; }
public decimal? total_amount_3 { get; set; }
public decimal? total_amount_4 { get; set; }
public decimal? total_amount_5 { get; set; }
public decimal? total_amount_6 { get; set; }
public decimal? total_amount_7 { get; set; }
public decimal? total_amount_8 { get; set; }
public decimal? total_amount_9 { get; set; }
public decimal? total_amount_10 { get; set; }
public decimal? total_amount_11 { get; set; }
public decimal? total_amount_12 { get; set; }
public decimal? total_amount_13 { get; set; }
public decimal? total_amount_14 { get; set; }
public List<request_summary_detail> data_1 { get; set; }
} }
public class request_summary_detail public class request_summary_detail
{ {
public string rowno { get; set; }
public string list { get; set; } public string list { get; set; }
public decimal? amount_1 { get; set; }
public decimal? amount_2 { get; set; }
public decimal? amount_3{ get; set; }
public decimal? amount_4 { get; set; }
public decimal? amount_5 { get; set; }
public decimal? amount_6 { get; set; }
public decimal? amount_7 { get; set; }
public decimal? amount_8 { get; set; }
public decimal? amount_9 { get; set; }
public decimal? amount_10 { get; set; }
public decimal? amount_11 { get; set; }
public decimal? amount_12 { get; set; }
public decimal? amount_13 { get; set; }
public decimal? amount_14 { get; set; }
public List<request_summary_detail2> data_2 { get; set; }
}
public class request_summary_detail2
{
public string rowno { get; set; }
public string list { get; set; }
public decimal? amount_1 { get; set; }
public decimal? amount_2 { get; set; }
public decimal? amount_3{ get; set; }
public decimal? amount_4 { get; set; }
public decimal? amount_5 { get; set; }
public decimal? amount_6 { get; set; }
public decimal? amount_7 { get; set; }
public decimal? amount_8 { get; set; }
public decimal? amount_9 { get; set; }
public decimal? amount_10 { get; set; }
public decimal? amount_11 { get; set; }
public decimal? amount_12 { get; set; }
public decimal? amount_13 { get; set; }
public decimal? amount_14 { get; set; }
public bool? is_bold { get; set; } public bool? is_bold { get; set; }
public string color { get; set; } public int? color { get; set; }
public List<request_summary_detail3> data_3 { get; set; } public List<budget_plan> budget_plans { get; set; }
} }
public class budget_plan
public class request_summary_detail3
{ {
public string rowno { get; set; } public string budget_plan_name { get; set; }
public string list { get; set; } public decimal? value { get; set; }
public decimal? amount_1 { get; set; }
public decimal? amount_2 { get; set; }
public decimal? amount_3{ get; set; }
public decimal? amount_4 { get; set; }
public decimal? amount_5 { get; set; }
public decimal? amount_6 { get; set; }
public decimal? amount_7 { get; set; }
public decimal? amount_8 { get; set; }
public decimal? amount_9 { get; set; }
public decimal? amount_10 { get; set; }
public decimal? amount_11 { get; set; }
public decimal? amount_12 { get; set; }
public decimal? amount_13 { get; set; }
public decimal? amount_14 { get; set; }
public bool? is_bold { get; set; }
} }
public class budget_plan_data
{
public string budget_plan_name { get; set; }
public decimal? total_value { get; set; }
}
// public class request_summary_detail2
// {
// public string rowno { get; set; }
// public string list { get; set; }
// public decimal? amount_1 { get; set; }
// public decimal? amount_2 { get; set; }
// public decimal? amount_3{ get; set; }
// public decimal? amount_4 { get; set; }
// public decimal? amount_5 { get; set; }
// public decimal? amount_6 { get; set; }
// public decimal? amount_7 { get; set; }
// public decimal? amount_8 { get; set; }
// public decimal? amount_9 { get; set; }
// public decimal? amount_10 { get; set; }
// public decimal? amount_11 { get; set; }
// public decimal? amount_12 { get; set; }
// public decimal? amount_13 { get; set; }
// public decimal? amount_14 { get; set; }
// public bool? is_bold { get; set; }
// public string color { get; set; }
// public List<request_summary_detail3> data_3 { get; set; }
// }
//
// public class request_summary_detail3
// {
// public string rowno { get; set; }
// public string list { get; set; }
// public decimal? amount_1 { get; set; }
// public decimal? amount_2 { get; set; }
// public decimal? amount_3{ get; set; }
// public decimal? amount_4 { get; set; }
// public decimal? amount_5 { get; set; }
// public decimal? amount_6 { get; set; }
// public decimal? amount_7 { get; set; }
// public decimal? amount_8 { get; set; }
// public decimal? amount_9 { get; set; }
// public decimal? amount_10 { get; set; }
// public decimal? amount_11 { get; set; }
// public decimal? amount_12 { get; set; }
// public decimal? amount_13 { get; set; }
// public decimal? amount_14 { get; set; }
// public bool? is_bold { get; set; }
// }
} }

View File

@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7e05f00fd365c536d3ee467c1f9eb3399596a61b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9c37d45f5cd26f307eeed46e82c6833c27288b33")]
[assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")]
[assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@@ -1 +1 @@
7ac3f37958a71820e8df5f45b5e179cc281750374662722aed13a4edc0d38b47 ce1e068e9e13ade3aae57571fad3b5eebac258828f5dbf8839f024cafd6dced7

View File

@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7e05f00fd365c536d3ee467c1f9eb3399596a61b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9c37d45f5cd26f307eeed46e82c6833c27288b33")]
[assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")]
[assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@@ -1 +1 @@
7ac3f37958a71820e8df5f45b5e179cc281750374662722aed13a4edc0d38b47 ce1e068e9e13ade3aae57571fad3b5eebac258828f5dbf8839f024cafd6dced7

View File

@@ -1 +1 @@
1cc1e30a55c8da36681abf907e9ced005ba9121991e772a39f582d11acbda306 807162356eee65d68db8165b5fb955d25318de2207b8907923f13b609c16ee01

View File

@@ -1 +1 @@
17248180168527223 17248395490624370