add report hr
This commit is contained in:
189
Controllers/HrRegister.Controller.cs
Normal file
189
Controllers/HrRegister.Controller.cs
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
|
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 rmutr_report.Models.Hrregister;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace rmutr_report.Controllers
|
||||||
|
{
|
||||||
|
[SwaggerTag("สำหรับรายงาน งานทะเบียนประวัติและค่าตอบแทน")]
|
||||||
|
public class HRRegis : Controller
|
||||||
|
{
|
||||||
|
readonly Setting _setting;
|
||||||
|
|
||||||
|
public HRRegis(Setting setting)
|
||||||
|
{
|
||||||
|
this._setting = setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, Route("reports/hr_position_manage/{type}")]
|
||||||
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
|
public IActionResult GetHr1Report([FromRoute] string type, [FromBody] hr_position_manage _hr)
|
||||||
|
{
|
||||||
|
foreach (var hr in _hr.data)
|
||||||
|
{
|
||||||
|
if (hr.position_manage_salary != null)
|
||||||
|
{
|
||||||
|
string NumberText = hr.position_manage_salary.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)
|
||||||
|
{
|
||||||
|
hr.money1 = str.Insert(i, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (str.Length == 5)
|
||||||
|
{
|
||||||
|
for (int i = 2; i <= str.Length - 1; i += 5)
|
||||||
|
{
|
||||||
|
hr.money1 = str.Insert(i, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr.money1 = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
var total1 = _hr.data.Select(t => t.position_manage_salary).Sum(h => h.Value);
|
||||||
|
var str3 =
|
||||||
|
total1.ToString().Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
|
||||||
|
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
|
||||||
|
.Replace('9', '๙');
|
||||||
|
if (str3.Length == 4)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= str3.Length - 1; i += 4)
|
||||||
|
{
|
||||||
|
_hr.total1 = str3.Insert(i, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (str3.Length == 5)
|
||||||
|
{
|
||||||
|
for (int i = 2; i <= str3.Length - 1; i += 5)
|
||||||
|
{
|
||||||
|
_hr.total1 = str3.Insert(i, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_hr.total1 = str3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hr.position_manage_salary == null)
|
||||||
|
{
|
||||||
|
_hr.total1 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hr.compensation != null)
|
||||||
|
{
|
||||||
|
string NumberText2 = hr.compensation.ToString();
|
||||||
|
var str2 =
|
||||||
|
NumberText2.Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
|
||||||
|
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
|
||||||
|
.Replace('9', '๙');
|
||||||
|
if (str2.Length == 4)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= str2.Length - 1; i += 4)
|
||||||
|
{
|
||||||
|
hr.money2 = str2.Insert(i, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (str2.Length == 5)
|
||||||
|
{
|
||||||
|
for (int i = 2; i <= str2.Length - 1; i += 5)
|
||||||
|
{
|
||||||
|
hr.money2 = str2.Insert(i, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr.money2 = str2;
|
||||||
|
}
|
||||||
|
|
||||||
|
var total2 = _hr.data.Select(t => t.compensation).Sum(h => h.Value);
|
||||||
|
var str4 =
|
||||||
|
total2.ToString().Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓')
|
||||||
|
.Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘')
|
||||||
|
.Replace('9', '๙');
|
||||||
|
if (str4.Length == 4)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= str4.Length - 1; i += 4)
|
||||||
|
{
|
||||||
|
_hr.total2 = str4.Insert(i, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (str4.Length == 5)
|
||||||
|
{
|
||||||
|
for (int i = 2; i <= str4.Length - 1; i += 5)
|
||||||
|
{
|
||||||
|
_hr.total2 = str4.Insert(i, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_hr.total2 = str4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hr.compensation == null)
|
||||||
|
{
|
||||||
|
_hr.total2 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var hr1 = new List<hr_position_manage>() {_hr};
|
||||||
|
|
||||||
|
Report report = new Report();
|
||||||
|
report.Load(_setting.report_path + "hr_position_manage.frx");
|
||||||
|
report.RegisterData(hr1, "hr_position_manage");
|
||||||
|
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");
|
||||||
|
break;
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
Models/Hrregister/hr_position_manage.cs
Normal file
30
Models/Hrregister/hr_position_manage.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace rmutr_report.Models.Hrregister
|
||||||
|
{
|
||||||
|
public class hr_position_manage
|
||||||
|
{
|
||||||
|
public string academic_year_name_th { get; set; }
|
||||||
|
public string position_manage_type { get; set; }
|
||||||
|
public string status { get; set; }
|
||||||
|
public List<hr_position_manage_detail> data { get; set; }
|
||||||
|
public string total1 { get; set; }
|
||||||
|
public string total2 { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class hr_position_manage_detail
|
||||||
|
{
|
||||||
|
public string position_manage_name { get; set; }
|
||||||
|
public decimal? position_manage_salary { get; set; }
|
||||||
|
public decimal? compensation { get; set; }
|
||||||
|
public string position_id { get; set; }
|
||||||
|
public string display_name_th { get; set; }
|
||||||
|
public string agency_name_th { get; set; }
|
||||||
|
public string date_office { get; set; }
|
||||||
|
public string date_term_of_ffice { get; set; }
|
||||||
|
public string directive { get; set; }
|
||||||
|
public string money1 { get; set; }
|
||||||
|
public string money2 { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
97
wwwroot/reports/hr_position_manage.frx
Normal file
97
wwwroot/reports/hr_position_manage.frx
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Report ScriptLanguage="CSharp" ReportInfo.Created="09/14/2021 15:20:39" ReportInfo.Modified="11/06/2022 18:29:17" ReportInfo.CreatorVersion="2022.1.0.0">
|
||||||
|
<Dictionary>
|
||||||
|
<BusinessObjectDataSource Name="hr_position_manage" ReferenceName="hr_position_manage" DataType="null" Enabled="true">
|
||||||
|
<Column Name="academic_year_name_th" DataType="System.String"/>
|
||||||
|
<Column Name="position_manage_type" DataType="System.String"/>
|
||||||
|
<Column Name="status" DataType="System.String"/>
|
||||||
|
<Column Name="total1" DataType="System.String"/>
|
||||||
|
<Column Name="total2" DataType="System.String"/>
|
||||||
|
<BusinessObjectDataSource Name="data" DataType="null" Enabled="true">
|
||||||
|
<Column Name="position_manage_name" DataType="System.String"/>
|
||||||
|
<Column Name="position_manage_salary" DataType="System.Decimal"/>
|
||||||
|
<Column Name="compensation" DataType="System.Decimal"/>
|
||||||
|
<Column Name="position_id" DataType="System.String"/>
|
||||||
|
<Column Name="display_name_th" DataType="System.String"/>
|
||||||
|
<Column Name="agency_name_th" DataType="System.String"/>
|
||||||
|
<Column Name="date_office" DataType="System.String"/>
|
||||||
|
<Column Name="date_term_of_ffice" DataType="System.String"/>
|
||||||
|
<Column Name="directive" DataType="System.String"/>
|
||||||
|
<Column Name="money1" DataType="System.String"/>
|
||||||
|
<Column Name="money2" DataType="System.String"/>
|
||||||
|
</BusinessObjectDataSource>
|
||||||
|
</BusinessObjectDataSource>
|
||||||
|
</Dictionary>
|
||||||
|
<ReportPage Name="Page1" Landscape="true" PaperWidth="500" PaperHeight="210" Watermark.Font="Arial, 60pt">
|
||||||
|
<PageHeaderBand Name="PageHeader1" Width="1814.4" Height="170.1">
|
||||||
|
<TextObject Name="Text1" Top="37.8" Width="1814.4" Height="28.35" Text="มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 18pt, style=Bold"/>
|
||||||
|
<TextObject Name="Text29" Top="75.6" Width="94.5" Height="28.35" Text="ปีงบประมาณ " VertAlign="Center" Font="TH Sarabun New, 16pt, style=Bold"/>
|
||||||
|
<TextObject Name="Text40" Top="9.45" Width="1814.4" Height="28.35" Text="ทะเบียนตำแหน่งประเภทบริหาร" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 18pt, style=Bold"/>
|
||||||
|
<TextObject Name="Text41" Left="94.5" Top="75.6" Width="198.45" Height="28.35" Text="[hr_position_manage.academic_year_name_th]" VertAlign="Center" Font="TH Sarabun New, 16pt"/>
|
||||||
|
<TextObject Name="Text42" Left="746.55" Top="75.6" Width="226.8" Height="28.35" Text=" ประเภทตำแหน่งบริหาร/หน่วยงาน" VertAlign="Center" Font="TH Sarabun New, 16pt, style=Bold"/>
|
||||||
|
<TextObject Name="Text43" Left="973.35" Top="75.6" Width="481.95" Height="28.35" Text="[hr_position_manage.position_manage_type]" VertAlign="Center" Font="TH Sarabun New, 16pt"/>
|
||||||
|
<TextObject Name="Text44" Left="1483.65" Top="75.6" Width="56.7" Height="28.35" Text="สถานะ" VertAlign="Center" Font="TH Sarabun New, 16pt, style=Bold"/>
|
||||||
|
<TextObject Name="Text45" Left="1540.35" Top="75.6" Width="274.05" Height="28.35" Text="[hr_position_manage.status]" VertAlign="Center" Font="TH Sarabun New, 16pt"/>
|
||||||
|
<TableObject Name="Table14" Top="122.85" Width="1814.4" Height="47.25" Border.Lines="All">
|
||||||
|
<TableColumn Name="Column70" Width="245.7"/>
|
||||||
|
<TableColumn Name="Column71" Width="132.3"/>
|
||||||
|
<TableColumn Name="Column72" Width="141.75"/>
|
||||||
|
<TableColumn Name="Column73" Width="160.65"/>
|
||||||
|
<TableColumn Name="Column74" Width="274.05"/>
|
||||||
|
<TableColumn Name="Column75" Width="274.05"/>
|
||||||
|
<TableColumn Name="Column76" Width="122.85"/>
|
||||||
|
<TableColumn Name="Column77" Width="132.3"/>
|
||||||
|
<TableColumn Name="Column78" Width="330.75"/>
|
||||||
|
<TableRow Name="Row14" Height="47.25">
|
||||||
|
<TableCell Name="Cell110" Text="ชื่อตำแหน่งบริหาร" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell111" Border.Lines="All" Text="เงินประจำตำแหน่ง" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell112" Border.Lines="All" Text="ค่าตอบแทนตำแหน่ง" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell113" Border.Lines="All" Text="เลขที่ตำแหน่ง" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell114" Border.Lines="All" Text="ชื่อ - สกุล" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell135" Border.Lines="All" Text="สังกัด" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell136" Border.Lines="All" Text="วันที่ดำรงตำแหน่ง" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell137" Border.Lines="All" Text="วันครบวาระ" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell138" Border.Lines="All" Text="คำสั่งมทร.รัตนโกสินทร์" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
</TableRow>
|
||||||
|
</TableObject>
|
||||||
|
</PageHeaderBand>
|
||||||
|
<DataBand Name="Data1" Top="175.73" Width="1814.4">
|
||||||
|
<DataBand Name="Data2" Top="181.37" Width="1814.4" Height="47.25" DataSource="data">
|
||||||
|
<TableObject Name="Table15" Width="1814.4" Height="47.25" Border.Lines="All">
|
||||||
|
<TableColumn Name="Column79" Width="245.7"/>
|
||||||
|
<TableColumn Name="Column80" Width="132.3"/>
|
||||||
|
<TableColumn Name="Column81" Width="141.75"/>
|
||||||
|
<TableColumn Name="Column82" Width="160.65"/>
|
||||||
|
<TableColumn Name="Column83" Width="274.05"/>
|
||||||
|
<TableColumn Name="Column84" Width="274.05"/>
|
||||||
|
<TableColumn Name="Column85" Width="122.85"/>
|
||||||
|
<TableColumn Name="Column86" Width="132.3"/>
|
||||||
|
<TableColumn Name="Column87" Width="330.75"/>
|
||||||
|
<TableRow Name="Row15" Height="47.25">
|
||||||
|
<TableCell Name="Cell139" Text="[hr_position_manage.data.position_manage_name]" VertAlign="Center" Font="TH Sarabun New, 12pt"/>
|
||||||
|
<TableCell Name="Cell140" Border.Lines="All" Text="[hr_position_manage.data.money1]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Right" VertAlign="Center" Font="TH Sarabun New, 12pt"/>
|
||||||
|
<TableCell Name="Cell141" Border.Lines="All" Text="[hr_position_manage.data.money2]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Right" VertAlign="Center" Font="TH Sarabun New, 12pt"/>
|
||||||
|
<TableCell Name="Cell142" Border.Lines="All" Text="[hr_position_manage.data.position_id]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 12pt"/>
|
||||||
|
<TableCell Name="Cell143" Border.Lines="All" Text="[hr_position_manage.data.display_name_th]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" VertAlign="Center" Font="TH Sarabun New, 12pt"/>
|
||||||
|
<TableCell Name="Cell144" Border.Lines="All" Text="[hr_position_manage.data.agency_name_th]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" VertAlign="Center" Font="TH Sarabun New, 12pt"/>
|
||||||
|
<TableCell Name="Cell145" Border.Lines="All" Text="[hr_position_manage.data.date_office]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 12pt"/>
|
||||||
|
<TableCell Name="Cell146" Border.Lines="All" Text="[hr_position_manage.data.date_term_of_ffice]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 12pt"/>
|
||||||
|
<TableCell Name="Cell147" Border.Lines="All" Text="[hr_position_manage.data.directive]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" VertAlign="Center" Font="TH Sarabun New, 12pt"/>
|
||||||
|
</TableRow>
|
||||||
|
</TableObject>
|
||||||
|
</DataBand>
|
||||||
|
</DataBand>
|
||||||
|
<ReportSummaryBand Name="ReportSummary1" Top="234.25" Width="1814.4" Height="47.25">
|
||||||
|
<TableObject Name="Table16" Width="519.75" Height="47.25" Border.Lines="All">
|
||||||
|
<TableColumn Name="Column88" Width="245.7"/>
|
||||||
|
<TableColumn Name="Column89" Width="132.3"/>
|
||||||
|
<TableColumn Name="Column90" Width="141.75"/>
|
||||||
|
<TableRow Name="Row16" Height="47.25">
|
||||||
|
<TableCell Name="Cell148" Text="สรุปจำนวนเงิน" HorzAlign="Center" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell149" Border.Lines="All" Text="[hr_position_manage.total1]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Right" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
<TableCell Name="Cell150" Border.Lines="All" Text="[hr_position_manage.total2]" Format="Number" Format.UseLocale="true" Format.DecimalDigits="0" HorzAlign="Right" VertAlign="Center" Font="TH Sarabun New, 14pt, style=Bold"/>
|
||||||
|
</TableRow>
|
||||||
|
</TableObject>
|
||||||
|
</ReportSummaryBand>
|
||||||
|
</ReportPage>
|
||||||
|
</Report>
|
||||||
Reference in New Issue
Block a user