add report
This commit is contained in:
@@ -39,7 +39,7 @@ namespace rmutr_report.Controllers
|
||||
ws.Cell("A2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("A2").Style.Font.FontSize = 16;
|
||||
ws.Range("A2:F2").Style.Font.Bold = true;
|
||||
ws.Range("A3:F3").Merge().Value = "แผน" + _house_for_rent.budget_year+" ผลผลิต "+_house_for_rent.product;
|
||||
ws.Range("A3:F3").Merge().Value = "แผน" + _house_for_rent.plan+" ผลผลิต "+_house_for_rent.product;
|
||||
ws.Range("A3:F3").Style.Alignment.WrapText = true;
|
||||
ws.Range("A3:F3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Range("A3:F3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
|
||||
177
Controllers/RepairCost.Controller.cs
Normal file
177
Controllers/RepairCost.Controller.cs
Normal file
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using ClosedXML.Excel;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using rmutr_report.Models;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
|
||||
namespace rmutr_report.Controllers
|
||||
{
|
||||
[SwaggerTag("สำหรับรายงานค่าซ่อมพาหนะ ง.2")]
|
||||
public class repaircost : Controller
|
||||
{
|
||||
readonly Setting _setting;
|
||||
|
||||
public repaircost(Setting setting)
|
||||
{
|
||||
this._setting = setting;
|
||||
}
|
||||
[HttpPost, Route("reports/repair_cost/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetRepairReport([FromRoute] string type,
|
||||
[FromBody] repair_cost _repair_cost)
|
||||
{
|
||||
//var t = _teaching_fee_extra.ToArray();
|
||||
{
|
||||
var workbook = new XLWorkbook();
|
||||
var ws = workbook.Worksheets.Add("ค่าซ่อม");
|
||||
ws.Cell("E1").Value = "แบบ ง.2";
|
||||
ws.Cell("E1").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("E1").Style.Font.FontSize = 16;
|
||||
ws.Cell("E1").Style.Font.Bold = true;
|
||||
ws.Cell("E1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("E1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Range("A2:E2").Merge().Value = "รายละเอียดค่าซ่อมแซมยานพาหนะและขนส่ง ปีงบประมาณ " + _repair_cost.budget_year;
|
||||
ws.Range("A2:E2").Style.Alignment.WrapText = true;
|
||||
ws.Range("A2:E2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Range("A2:E2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("A2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("A2").Style.Font.FontSize = 16;
|
||||
ws.Range("A2:E2").Style.Font.Bold = true;
|
||||
ws.Range("A3:E3").Merge().Value = "แผน " + _repair_cost.plan+" ผลผลิต "+_repair_cost.product;
|
||||
ws.Range("A3:E3").Style.Alignment.WrapText = true;
|
||||
ws.Range("A3:E3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Range("A3:E3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("A3").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("A3").Style.Font.FontSize = 16;
|
||||
ws.Range("A3:E3").Style.Font.Bold = true;
|
||||
ws.Range("A4:E4").Merge().Value = "หน่วยงาน " + _repair_cost.agency+" พื้นที่ "+_repair_cost.area;
|
||||
ws.Range("A4:E4").Style.Alignment.WrapText = true;
|
||||
ws.Range("A4:E4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Range("A4:E4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("A4").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("A4").Style.Font.FontSize = 16;
|
||||
ws.Range("A4:E4").Style.Font.Bold = true;
|
||||
|
||||
ws.Range("A5:A6").Merge().Value = "ที่";
|
||||
ws.Range("A5:A6").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Range("A5:A6").Style.Font.FontSize = 16;
|
||||
ws.Range("A5:A6").Style.Font.Bold = true;
|
||||
ws.Range("A5:A6").Style.Alignment.WrapText = true;
|
||||
ws.Range("B5:B6").Merge().Value = "ประเภทยานพาหนะและขนส่ง";
|
||||
ws.Cell("B5").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("B5").Style.Font.FontSize = 16;
|
||||
ws.Cell("B5").Style.Font.Bold = true;
|
||||
ws.Cell("B5").Style.Alignment.WrapText = true;
|
||||
ws.Cell("C5").Value = "จำนวน";
|
||||
ws.Cell("C5").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("C5").Style.Font.FontSize = 16;
|
||||
ws.Cell("C5").Style.Font.Bold = true;
|
||||
ws.Cell("C5").Style.Alignment.WrapText = true;
|
||||
ws.Cell("C6").Value = "(คัน)";
|
||||
ws.Cell("C6").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("C6").Style.Font.FontSize = 16;
|
||||
ws.Cell("C6").Style.Font.Bold = true;
|
||||
ws.Cell("C6").Style.Alignment.WrapText = true;
|
||||
ws.Cell("D5").Value = "อัตราค่าซ่อมแซม";
|
||||
ws.Cell("D5").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("D5").Style.Font.FontSize = 16;
|
||||
ws.Cell("D5").Style.Font.Bold = true;
|
||||
ws.Cell("D5").Style.Alignment.WrapText = true;
|
||||
ws.Cell("D6").Value = "บาท/คัน/ปี";
|
||||
ws.Cell("D6").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("D6").Style.Font.FontSize = 16;
|
||||
ws.Cell("D6").Style.Font.Bold = true;
|
||||
ws.Cell("D6").Style.Alignment.WrapText = true;
|
||||
ws.Cell("E5").Value = "ค่าซ่อมแซม";
|
||||
ws.Cell("E5").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("E5").Style.Font.FontSize = 16;
|
||||
ws.Cell("E5").Style.Font.Bold = true;
|
||||
ws.Cell("E5").Style.Alignment.WrapText = true;
|
||||
ws.Cell("E6").Value = "บาท/ปี";
|
||||
ws.Cell("E6").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("E6").Style.Font.FontSize = 16;
|
||||
ws.Cell("E6").Style.Font.Bold = true;
|
||||
ws.Cell("E6").Style.Alignment.WrapText = true;
|
||||
|
||||
ws.Range("A5:E6").Style.Fill.BackgroundColor = XLColor.Gainsboro;
|
||||
ws.Range("A5:E6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Range("A5:E6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Range("A5:E6").Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range("A5:A6").Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range("B5:B6").Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range("C5:C6").Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range("D5:D6").Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
|
||||
ws.Column(1).Width = 10;
|
||||
ws.Column(2).Width = 40;
|
||||
ws.Column(3).Width = 10;
|
||||
ws.Column(4).Width = 15;
|
||||
ws.Column(5).Width = 15;
|
||||
|
||||
int row = 7;
|
||||
//int row2 = 9;
|
||||
//ws.Cell(row, 3).SetDataType(XLDataType.Number);
|
||||
if (_repair_cost != null)
|
||||
{
|
||||
foreach (var house in _repair_cost.data)
|
||||
{
|
||||
|
||||
ws.Cell(row, 1).Value = house.no;
|
||||
ws.Cell(row, 2).Value = house.type_vehicle_transport;
|
||||
ws.Cell(row, 3).Value = house.quantity;
|
||||
ws.Cell(row, 4).Value = house.repair_rate;
|
||||
ws.Cell(row, 5).Value = house.amount;
|
||||
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 5)).Style.Font.FontName =
|
||||
"TH SarabunPSK";
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 5)).Style.Font.FontSize = 16;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 5)).Style.Alignment.WrapText = true;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 5)).Style.Alignment.Vertical =
|
||||
XLAlignmentVerticalValues.Center;
|
||||
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 5)).Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 5)).Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
|
||||
ws.Range(ws.Cell(row, 4), ws.Cell(row, 5)).SetDataType(XLDataType.Number);
|
||||
ws.Range(ws.Cell(row, 4), ws.Cell(row, 5)).Style.NumberFormat.SetFormat("#,#");
|
||||
row++;
|
||||
|
||||
|
||||
if (house.type_vehicle_transport == "รวม")
|
||||
{
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.LeftBorder =
|
||||
XLBorderStyleValues.None;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.RightBorder =
|
||||
XLBorderStyleValues.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
workbook.SaveAs(stream);
|
||||
var content = stream.ToArray();
|
||||
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
return File(
|
||||
content,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"repair_cost_" + date + ".xlsx");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
233
Controllers/StudentNews.Controller.cs
Normal file
233
Controllers/StudentNews.Controller.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
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 rmutr_report.Models.Hr;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
|
||||
namespace rmutr_report.Controllers
|
||||
{
|
||||
[SwaggerTag("สำหรับรายงานนักศึกษาเข้าใหม่")]
|
||||
public class StudentNews : Controller
|
||||
{
|
||||
readonly Setting _setting;
|
||||
|
||||
public StudentNews(Setting setting)
|
||||
{
|
||||
this._setting = setting;
|
||||
}
|
||||
|
||||
[HttpPost, Route("reports/student_news_faculty/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetStd1Report([FromRoute] string type,
|
||||
[FromBody] student_news_faculty _student_news_faculty)
|
||||
{
|
||||
var std = _student_news_faculty.data;
|
||||
var a1 = _student_news_faculty.data.Where(d => d.bachelors_degree == d.bachelors_degree)
|
||||
.Sum(o => o.bachelors_degree);
|
||||
|
||||
foreach (var data in std)
|
||||
{
|
||||
data.total1 = a1;
|
||||
if (data.bachelors_degree != 0 )
|
||||
{
|
||||
data.sum_percentage = (data.bachelors_degree*100)/a1;
|
||||
}
|
||||
var a2 = _student_news_faculty.data.Where(d => d.sum_percentage == d.sum_percentage)
|
||||
.Sum(o => o.sum_percentage);
|
||||
data.total2 = a2;
|
||||
}
|
||||
var student_news_facultys = new List<student_news_faculty>() {_student_news_faculty};
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "student_news_faculty.frx");
|
||||
report.RegisterData(student_news_facultys, "student_news_faculty");
|
||||
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/student_news_area/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetStd2Report([FromRoute] string type,
|
||||
[FromBody] student_news_area _student_news_faculty)
|
||||
{
|
||||
var std = _student_news_faculty.data;
|
||||
var a1 = _student_news_faculty.data.Where(d => d.bachelors_degree_science == d.bachelors_degree_science)
|
||||
.Sum(o => o.bachelors_degree_science);
|
||||
var a2 = _student_news_faculty.data.Where(d => d.bachelors_degree_social == d.bachelors_degree_social)
|
||||
.Sum(o => o.bachelors_degree_social);
|
||||
|
||||
foreach (var data in std)
|
||||
{
|
||||
data.bachelors_degree_total = data.bachelors_degree_science + data.bachelors_degree_social;
|
||||
data.total1 = a1;
|
||||
if ( data.bachelors_degree_total != 0)
|
||||
{
|
||||
data.sum_percentage_science = (data.bachelors_degree_science*100)/data.bachelors_degree_total;
|
||||
}
|
||||
if ( data.bachelors_degree_total != 0)
|
||||
{
|
||||
data.sum_percentage_social = (data.bachelors_degree_social*100)/data.bachelors_degree_total;
|
||||
}
|
||||
var a3 = _student_news_faculty.data.Where(d => d.bachelors_degree_total == d.bachelors_degree_total)
|
||||
.Sum(o => o.bachelors_degree_total);
|
||||
var a4 = _student_news_faculty.data.Where(d => d.sum_percentage_science == d.sum_percentage_science)
|
||||
.Sum(o => o.sum_percentage_science);
|
||||
var a5 = _student_news_faculty.data.Where(d => d.sum_percentage_social == d.sum_percentage_social)
|
||||
.Sum(o => o.sum_percentage_social);
|
||||
data.total2 = a2;
|
||||
data.total3 = a3;
|
||||
data.total4 = (data.total1*100)/data.total3;
|
||||
data.total5 = (data.total2*100)/data.total3;
|
||||
}
|
||||
var student_news_facultys = new List<student_news_area>() {_student_news_faculty};
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "student_news_area.frx");
|
||||
report.RegisterData(student_news_facultys, "student_news_area");
|
||||
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/student_news_area_major/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetStd3Report([FromRoute] string type,
|
||||
[FromBody] student_news_area _student_news_faculty)
|
||||
{
|
||||
var std = _student_news_faculty.data;
|
||||
var a1 = _student_news_faculty.data.Where(d => d.bachelors_degree_science == d.bachelors_degree_science)
|
||||
.Sum(o => o.bachelors_degree_science);
|
||||
var a2 = _student_news_faculty.data.Where(d => d.bachelors_degree_social == d.bachelors_degree_social)
|
||||
.Sum(o => o.bachelors_degree_social);
|
||||
|
||||
foreach (var data in std)
|
||||
{
|
||||
data.bachelors_degree_total = data.bachelors_degree_science + data.bachelors_degree_social;
|
||||
data.total1 = a1;
|
||||
if ( data.bachelors_degree_total != 0)
|
||||
{
|
||||
data.sum_percentage_science = (data.bachelors_degree_science*100)/data.bachelors_degree_total;
|
||||
}
|
||||
if ( data.bachelors_degree_total != 0)
|
||||
{
|
||||
data.sum_percentage_social = (data.bachelors_degree_social*100)/data.bachelors_degree_total;
|
||||
}
|
||||
var a3 = _student_news_faculty.data.Where(d => d.bachelors_degree_total == d.bachelors_degree_total)
|
||||
.Sum(o => o.bachelors_degree_total);
|
||||
var a4 = _student_news_faculty.data.Where(d => d.sum_percentage_science == d.sum_percentage_science)
|
||||
.Sum(o => o.sum_percentage_science);
|
||||
var a5 = _student_news_faculty.data.Where(d => d.sum_percentage_social == d.sum_percentage_social)
|
||||
.Sum(o => o.sum_percentage_social);
|
||||
data.total2 = a2;
|
||||
data.total3 = a3;
|
||||
data.total4 = (data.total1*100)/data.total3;
|
||||
data.total5 = (data.total2*100)/data.total3;
|
||||
}
|
||||
var student_news_facultys = new List<student_news_area>() {_student_news_faculty};
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "student_news_area_major.frx");
|
||||
report.RegisterData(student_news_facultys, "student_news_area");
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user