This commit is contained in:
kamonwan taengsuk
2023-06-13 13:17:16 +07:00
parent 7d5a2fdfc3
commit 3756864fca
13 changed files with 2073 additions and 12 deletions

View File

@@ -14,8 +14,7 @@ using Swashbuckle.AspNetCore.Annotations;
namespace rmutr_report.Controllers
{
[SwaggerTag("สำหรับรายงาน ร.3 คำชี้แจงงบดำเนินงาน")]
public class RoThree : Controller
public class RoThree : Controller
{
readonly Setting _setting;
@@ -28,7 +27,6 @@ namespace rmutr_report.Controllers
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetRoThreeReport([FromRoute] string type, [FromBody] operating_budget_ro_three three)
{
var threes = new List<operating_budget_ro_three>() { three };
Report report = new Report();
@@ -72,13 +70,13 @@ namespace rmutr_report.Controllers
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetComReport([FromRoute] string type, [FromBody] compensation_head three)
{
if (three.data!=null)
if (three.data != null)
{
var s = three.data.Sum(f => f.budget_amount);
three.total_amount = s;
}
var threes = new List<compensation_head>() { three };
Report report = new Report();
@@ -117,17 +115,18 @@ namespace rmutr_report.Controllers
return Ok();
}
[HttpPost, Route("reports/compensation_head_major/{type}")]
[HttpPost, Route("reports/compensation_head_major/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetCom2Report([FromRoute] string type, [FromBody] compensation_head three)
{
if (three.data!=null)
if (three.data != null)
{
var s = three.data.Sum(f => f.budget_amount);
three.total_amount = s;
}
var threes = new List<compensation_head>() { three };
Report report = new Report();
@@ -166,7 +165,235 @@ namespace rmutr_report.Controllers
return Ok();
}
[HttpPost, Route("reports/teaching_fee_extra_ro_three/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetTeachExReport([FromRoute] string type, [FromBody] teaching_fee_ro_three three)
{
var threes = new List<teaching_fee_ro_three>() { three };
Report report = new Report();
report.Load(_setting.report_path + "teaching_fee_extra.frx");
report.RegisterData(threes, "teaching_fee_ro_three");
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",
date + ".xlsx");
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();
}
[HttpPost, Route("reports/teaching_fee_ro_three/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetTeachReport([FromRoute] string type, [FromBody] teaching_fee_ro_three three)
{
var threes = new List<teaching_fee_ro_three>() { three };
Report report = new Report();
report.Load(_setting.report_path + "teaching_fee.frx");
report.RegisterData(threes, "teaching_fee_ro_three");
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",
date + ".xlsx");
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();
}
[HttpPost, Route("reports/teaching_fee_workload/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetTeachWorkloadReport([FromRoute] string type, [FromBody] teaching_fee_ro_three three)
{
var threes = new List<teaching_fee_ro_three>() { three };
Report report = new Report();
report.Load(_setting.report_path + "teaching_fee_workload.frx");
report.RegisterData(threes, "teaching_fee_ro_three");
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",
date + ".xlsx");
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();
}
[HttpPost, Route("reports/material_office/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetMaterial1Report([FromRoute] string type, [FromBody] material_ro_three three)
{
if (three.data != null)
{
var s = three.data.Sum(f => f.material_amount);
three.total_amount = s;
}
var threes = new List<material_ro_three>() { three };
Report report = new Report();
report.Load(_setting.report_path + "material_office.frx");
report.RegisterData(threes, "material_ro_three");
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",
date + ".xlsx");
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();
}
[HttpPost, Route("reports/material_computer/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetMaterial2Report([FromRoute] string type, [FromBody] material_ro_three three)
{
if (three.data != null)
{
var s = three.data.Sum(f => f.material_amount);
three.total_amount = s;
}
var threes = new List<material_ro_three>() { three };
Report report = new Report();
report.Load(_setting.report_path + "material_computer.frx");
report.RegisterData(threes, "material_ro_three");
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",
date + ".xlsx");
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();
}
}
}