add report
This commit is contained in:
202
Controllers/MultiplierDetails.Controller.cs
Normal file
202
Controllers/MultiplierDetails.Controller.cs
Normal file
@@ -0,0 +1,202 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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("สำหรับรายงานรายละเอียดแยกตัวคูณ")]
|
||||
public class MultiplierDetails: Controller
|
||||
{
|
||||
readonly Setting _setting;
|
||||
|
||||
public MultiplierDetails(Setting setting)
|
||||
{
|
||||
this._setting = setting;
|
||||
}
|
||||
[HttpPost, Route("reports/expenditure_budget_proposal/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetExpendReport([FromRoute] string type, [FromBody] expenditure_budget_proposal budget_summary_reports)
|
||||
{
|
||||
var _budget_summary_report = new List<expenditure_budget_proposal>() { budget_summary_reports };
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "expenditure_budget_proposal.frx");
|
||||
report.RegisterData(_budget_summary_report, "expenditure_budget_proposal");
|
||||
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 "mht":
|
||||
MHTExport mht = new MHTExport();
|
||||
report.Export(mht, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "multipart/related");
|
||||
break;
|
||||
case "csv":
|
||||
CSVExport csv = new CSVExport();
|
||||
report.Export(csv, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "text/csv");
|
||||
break;
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
[HttpPost, Route("reports/summary_excess_tuitionfee_science/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetExpendReport([FromRoute] string type, [FromBody] summary_excess_tuitionfee budget_summary_reports)
|
||||
{
|
||||
var _budget_summary_report = new List<summary_excess_tuitionfee>() { budget_summary_reports };
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "summary_excess_tuition.frx");
|
||||
report.RegisterData(_budget_summary_report, "summary_excess_tuitionfee");
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
[HttpPost, Route("reports/summary_excess_tuitionfee_social/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetExpend2Report([FromRoute] string type, [FromBody] summary_excess_tuitionfee budget_summary_reports)
|
||||
{
|
||||
var _budget_summary_report = new List<summary_excess_tuitionfee>() { budget_summary_reports };
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "summary_excess_tuition2.frx");
|
||||
report.RegisterData(_budget_summary_report, "summary_excess_tuitionfee");
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
[HttpPost, Route("reports/service_fee/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetExpend3Report([FromRoute] string type, [FromBody] service_fee budget_summary_reports)
|
||||
{
|
||||
var s1 = budget_summary_reports.data.Sum(d => d.wage_rate_science);
|
||||
var s2 = budget_summary_reports.data.Sum(d => d.wage_rate_social);
|
||||
budget_summary_reports.total_amount_1 = s1;
|
||||
budget_summary_reports.total_amount_2 = s2;
|
||||
budget_summary_reports.total_amount_all = budget_summary_reports.total_amount_1 + budget_summary_reports.total_amount_2;
|
||||
|
||||
var _budget_summary_report = new List<service_fee>() { budget_summary_reports };
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "service_fee.frx");
|
||||
report.RegisterData(_budget_summary_report, "service_fee");
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost, Route("reports/car_insurance/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetExpend4Report([FromRoute] string type, [FromBody] car_insurance budget_summary_reports)
|
||||
{
|
||||
var ss = budget_summary_reports.group_header.Sum(f => f.data.Sum(g => g.data_detail.Sum(h => h.amount)));
|
||||
budget_summary_reports.total_amount_all = ss;
|
||||
var _budget_summary_report = new List<car_insurance>() { budget_summary_reports };
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "car_insurance.frx");
|
||||
report.RegisterData(_budget_summary_report, "car_insurance");
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user