add hr report

This commit is contained in:
kamonwan taengsuk
2022-12-11 12:26:57 +07:00
parent 31a036e637
commit f56408a9b2
4 changed files with 332 additions and 22 deletions

View File

@@ -28,11 +28,11 @@ namespace rmutr_report.Controllers
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetHrReport([FromRoute] string type, [FromBody] personnel_summary personnel_summarys)
{
foreach (var v in personnel_summarys.personnel_types)
foreach (var v in personnel_summarys.personnel_types)
{
if (v.count != null)
{
var total = personnel_summarys.personnel_types.Select(r => r.count).Sum(t=>t.Value);
var total = personnel_summarys.personnel_types.Select(r => r.count).Sum(t => t.Value);
personnel_summarys.total_pertype = total;
}
else
@@ -40,7 +40,8 @@ namespace rmutr_report.Controllers
return null;
}
}
var personnel_summaryss = new List<personnel_summary>() { personnel_summarys };
var personnel_summaryss = new List<personnel_summary>() {personnel_summarys};
Report report = new Report();
report.Load(_setting.report_path + "personnel_summary.frx");
@@ -57,6 +58,7 @@ namespace rmutr_report.Controllers
return File(stream, "application/pdf");
case "xls":
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
@@ -78,12 +80,12 @@ namespace rmutr_report.Controllers
return Ok();
}
[HttpPost, Route("reports/man_power/{type}")]
[HttpPost, Route("reports/man_power/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetManReport([FromRoute] string type, [FromBody] List<man_power> man_powers)
{
//var personnel_summaryss = new List<personnel_summary>() { personnel_summarys };
//var personnel_summaryss = new List<personnel_summary>() { personnel_summarys };
Report report = new Report();
report.Load(_setting.report_path + "man_power.frx");
@@ -100,6 +102,7 @@ namespace rmutr_report.Controllers
return File(stream, "application/pdf");
case "xls":
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
@@ -121,12 +124,12 @@ namespace rmutr_report.Controllers
return Ok();
}
[HttpPost, Route("reports/data_line_support/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetDataLineReport([FromRoute] string type, [FromBody] data_line_support data_line_supports)
{
var data_line_supportss = new List<data_line_support>() { data_line_supports };
var data_line_supportss = new List<data_line_support>() {data_line_supports};
Report report = new Report();
report.Load(_setting.report_path + "data_line_support.frx");
@@ -143,6 +146,7 @@ namespace rmutr_report.Controllers
return File(stream, "application/pdf");
case "xls":
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
@@ -164,12 +168,13 @@ namespace rmutr_report.Controllers
return Ok();
}
[HttpPost, Route("reports/data_line_academic/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetDataLineAcaReport([FromRoute] string type, [FromBody] data_line_academic data_line_academicss)
public IActionResult GetDataLineAcaReport([FromRoute] string type,
[FromBody] data_line_academic data_line_academicss)
{
var _data_line_academics = new List<data_line_academic>() { data_line_academicss };
var _data_line_academics = new List<data_line_academic>() {data_line_academicss};
Report report = new Report();
report.Load(_setting.report_path + "data_line_academic.frx");
@@ -186,6 +191,7 @@ namespace rmutr_report.Controllers
return File(stream, "application/pdf");
case "xls":
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
@@ -207,12 +213,13 @@ namespace rmutr_report.Controllers
return Ok();
}
[HttpPost, Route("reports/qualifications_teacher/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetQualificationsTeacherReport([FromRoute] string type, [FromBody] qualifications_teacher qualifications_teachers)
public IActionResult GetQualificationsTeacherReport([FromRoute] string type,
[FromBody] qualifications_teacher qualifications_teachers)
{
var qualifications_teacherss = new List<qualifications_teacher>() { qualifications_teachers };
var qualifications_teacherss = new List<qualifications_teacher>() {qualifications_teachers};
Report report = new Report();
report.Load(_setting.report_path + "qualifications_teacher.frx");
@@ -229,6 +236,7 @@ namespace rmutr_report.Controllers
return File(stream, "application/pdf");
case "xls":
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
@@ -250,12 +258,13 @@ namespace rmutr_report.Controllers
return Ok();
}
[HttpPost, Route("reports/academic_position/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetAcademicPositionReport([FromRoute] string type, [FromBody] academic_position _academic_position)
public IActionResult GetAcademicPositionReport([FromRoute] string type,
[FromBody] academic_position _academic_position)
{
var academic_positions = new List<academic_position>() { _academic_position };
var academic_positions = new List<academic_position>() {_academic_position};
Report report = new Report();
report.Load(_setting.report_path + "academic_position.frx");
@@ -272,6 +281,170 @@ namespace rmutr_report.Controllers
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/postponement_compensation/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetPostponementCompensationReport([FromRoute] string type,
[FromBody] postponement_compensation postponement_compensations)
{
string NumberText1 = postponement_compensations.data_date;
var str1 =
NumberText1.Replace('0', '').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
.Replace('9', '๙');
postponement_compensations.data_date = str1;
string NumberText2 = postponement_compensations.start_date;
var str2 =
NumberText2.Replace('0', '').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
.Replace('9', '๙');
postponement_compensations.start_date = str2;
string NumberText3 = postponement_compensations.end_date;
var str3 =
NumberText3.Replace('0', '').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
.Replace('9', '๙');
postponement_compensations.end_date = str3;
string NumberText4 = postponement_compensations.base_calculation_date;
var str4 =
NumberText4.Replace('0', '').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
.Replace('9', '๙');
postponement_compensations.base_calculation_date = str4;
string NumberText5 = postponement_compensations.director_date;
var str5 =
NumberText5.Replace('0', '').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
.Replace('9', '๙');
postponement_compensations.director_date = str5;
foreach (var data in postponement_compensations.data)
{
if (data.base_calculation != null)
{
string NumberText = data.base_calculation.ToString();
var str =
NumberText.Replace('0', '').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
.Replace('9', '๙');
if (str.Length == 4)
{
for (int i = 1; i <= str.Length - 1; i += 4)
{
postponement_compensations.money1 = str.Insert(i, ",");
}
}
else if (str.Length == 5)
{
for (int i = 2; i <= str.Length - 1; i += 5)
{
postponement_compensations.money1 = str.Insert(i, ",");
}
}
else
{
postponement_compensations.money1 = str;
}
}
if (data.compensation_slide != null)
{
string NumberText = data.compensation_slide.ToString();
var str =
NumberText.Replace('0', '').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
.Replace('9', '๙');
if (str.Length == 4)
{
for (int i = 1; i <= str.Length - 1; i += 4)
{
postponement_compensations.money2 = str.Insert(i, ",");
}
}
else if (str.Length == 5)
{
for (int i = 2; i <= str.Length - 1; i += 5)
{
postponement_compensations.money2 = str.Insert(i, ",");
}
}
else
{
postponement_compensations.money2 = str;
}
}
if (data.compensation_receive != null)
{
string NumberText = data.compensation_receive.ToString();
var str =
NumberText.Replace('0', '').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
.Replace('9', '๙');
if (str.Length == 4)
{
for (int i = 1; i <= str.Length - 1; i += 4)
{
postponement_compensations.money3 = str.Insert(i, ",");
}
}
else if (str.Length == 5)
{
for (int i = 2; i <= str.Length - 1; i += 5)
{
postponement_compensations.money3 = str.Insert(i, ",");
}
}
else
{
postponement_compensations.money3 = str;
}
}
string NumberText6 = data.percentage.ToString();
var str6 =
NumberText6.Replace('0', '').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
.Replace('9', '๙');
postponement_compensations.percentage = str6;
}
var _postponement_compensations = new List<postponement_compensation>() {postponement_compensations};
Report report = new Report();
report.Load(_setting.report_path + "postponement_compensation.frx");
report.RegisterData(_postponement_compensations, "postponement_compensation");
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);