From c3b9a9a473957b0b30e462b54ed26d1d7eba86d5 Mon Sep 17 00:00:00 2001 From: kamonwan taengsuk Date: Sat, 25 Mar 2023 22:14:21 +0700 Subject: [PATCH] update --- Controllers/Expenses.Controller.cs | 1 + Controllers/Personnel.Controller.cs | 173 ++++++++++++++++++ .../Personnel/personnel_salary_permanent.cs | 67 +++++++ .../reports/personnel_salary_permanent.frx | 143 +++++++++++++++ 4 files changed, 384 insertions(+) create mode 100644 Models/Personnel/personnel_salary_permanent.cs create mode 100644 wwwroot/reports/personnel_salary_permanent.frx diff --git a/Controllers/Expenses.Controller.cs b/Controllers/Expenses.Controller.cs index 2e633b8..e38a1d9 100644 --- a/Controllers/Expenses.Controller.cs +++ b/Controllers/Expenses.Controller.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Net; using ClosedXML.Excel; using Microsoft.AspNetCore.Mvc; using rmutr_report.Models; diff --git a/Controllers/Personnel.Controller.cs b/Controllers/Personnel.Controller.cs index 18f5593..84f9418 100644 --- a/Controllers/Personnel.Controller.cs +++ b/Controllers/Personnel.Controller.cs @@ -1,7 +1,9 @@ +using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using ClosedXML.Excel; using FastReport; using FastReport.Export.Csv; using FastReport.Export.Mht; @@ -10,6 +12,7 @@ using FastReport.Export.Pdf; using Microsoft.AspNetCore.Mvc; using rmutr_report.Models; using rmutr_report.Models.Hr; +using rmutr_report.Models.Personnel; using Swashbuckle.AspNetCore.Annotations; namespace rmutr_report.Controllers @@ -491,5 +494,175 @@ namespace rmutr_report.Controllers return Ok(); } + [HttpPost, Route("reports/personnel_salary_permanent/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetPersonSalaryReport([FromRoute] string type, + [FromBody] personnel_salary_permanent_root _personnel) + { + var workbook = new XLWorkbook(); + var ws = workbook.Worksheets.Add("พนักงานราชการ"); + + ws.Range("A4:A6").Merge().Value = "ลำดับความสำคัญ(1)"; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:A6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:A6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("A4:A6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("A4").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("A4").Style.Font.FontSize = 14; + ws.Range("B4:B6").Merge().Value = "รายการ"; + ws.Cell("B4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("B4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("B4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("B4").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("B4").Style.Font.FontSize = 14; + ws.Range("C5:E5").Merge().Value = "ประเภทของครุภัณฑ์"; + ws.Range("C5:E5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("C5:E5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("C5:E5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("C5").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("C5").Style.Font.FontSize = 11; + ws.Range("C6").Value = "ทดแทนของเดิม"; + ws.Cell("C6").Style.Alignment.WrapText = true; + ws.Cell("C6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("C6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("C6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("C6").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("C6").Style.Font.FontSize = 11; + ws.Range("D6").Value = "เพิ่มประสิทธิภาพ"; + ws.Cell("D6").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("D6").Style.Font.FontSize = 11; + ws.Cell("D6").Style.Alignment.WrapText = true; + ws.Cell("D6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("D6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("D6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Range("E6").Value = "ครุภัณฑ์ใหม่"; + ws.Cell("E6").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("E6").Style.Font.FontSize = 11; + ws.Cell("E6").Style.Alignment.WrapText = true; + ws.Cell("E6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("E6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("E6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Range("F5:F6").Merge().Value = "หน่วยนับ"; + ws.Cell("F5").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("F5").Style.Font.FontSize = 12; + //ws.Range("F3").Style.Font.Bold = true; + ws.Range("F5:F6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("F5:F6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("F5:F6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Range("G5:G6").Merge().Value = "จำนวน"; + ws.Cell("G5").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("G5").Style.Font.FontSize = 12; + //ws.Range("G3").Style.Font.Bold = true; + ws.Range("G5:G6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("G5:G6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("G5:G6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Range("G5").Style.Alignment.SetTextRotation(90); + ws.Range("H5:H6").Merge().Value = "ราคาต่อหน่วย"; + ws.Cell("H5").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H5").Style.Font.FontSize = 12; + //ws.Range("H3").Style.Font.Bold = true; + ws.Range("H5:H6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("H5:H6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("H5:H6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Range("I4:M4").Merge().Value = "แผนความต้องการครุภัณฑ์"; + ws.Cell("I4").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("I4").Style.Font.FontSize = 14; + //ws.Range("I2").Style.Font.Bold = true; + ws.Range("I4:M4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("I4:M4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("I4:M4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Range("I5:M5").Merge().Value = "วงเงิน"; + ws.Cell("I5").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("I5").Style.Font.FontSize = 14; + ws.Range("I5:M5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("I5:M5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("I5:M5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Range("N4:N6").Merge().Value = "คำอธิบายความพร้อม/ประโยชน์ที่จะได้รับ"; + ws.Cell("N4").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("N4").Style.Font.FontSize = 14; + ws.Cell("N4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("N4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("N4:N6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Row(4).Height = 30; + ws.Row(5).Height = 30; + ws.Row(6).Height = 30; + ws.Column(1).Width = 9; + ws.Column(2).Width = 40; + ws.Column(3).Width = 5; + ws.Column(4).Width = 5; + ws.Column(5).Width = 5; + ws.Column(6).Width = 10; + ws.Column(7).Width = 10; + ws.Column(8).Width = 10; + ws.Column(9).Width = 10; + ws.Column(10).Width = 10; + ws.Column(11).Width = 10; + ws.Column(12).Width = 10; + ws.Column(13).Width = 10; + ws.Column(14).Width = 40; + int row = 7; + int no = 1; + + if (_personnel != null) + { + + foreach (var detail in _personnel.personnel_salary_permanent) + { + + ws.Cell(row, 1).Value = no; + no++; + //ws.Cell(row, 2).Value = detail.manpower; + + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + + ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Font.FontName = + "TH Sarabun New"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Font.FontSize = 11; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Alignment.WrapText = true; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + 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.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; + ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; + ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; + ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; + ws.Cell(row, 12).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; + ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; + ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + + row++; + } + } + + using (var stream1 = new MemoryStream()) + { + workbook.SaveAs(stream1); + var content = stream1.ToArray(); + string date = DateTime.Now.ToString("yyyyMMddHHmmss"); + return File( + content, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "personnel_" + date + ".xlsx"); + } + } } } \ No newline at end of file diff --git a/Models/Personnel/personnel_salary_permanent.cs b/Models/Personnel/personnel_salary_permanent.cs new file mode 100644 index 0000000..3ca4915 --- /dev/null +++ b/Models/Personnel/personnel_salary_permanent.cs @@ -0,0 +1,67 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models.Personnel +{ + public class personnel_salary_permanent_root + { + public int? total_salary { get; set; } + public int? total_estimate_salary { get; set; } + public int? total_promote { get; set; } + public int? total { get; set; } + public int? total_salary_12 { get; set; } + public int? total_social_security { get; set; } + public int? total_social_security_12 { get; set; } + public int? total_social_compensation { get; set; } + public int? total_social_compensation_12 { get; set; } + public int? total_another2 { get; set; } + public int? total_quantity_money { get; set; } + public int? total2 { get; set; } + public int? including_salary_and_fittings { get; set; } + public int? including_salary_and_fittings_12 { get; set; } + public List personnel_salary_permanent { get; set; } + } + public class personnel_salary_permanent + { + public string agency_category_name { get; set; } + public int? total_estimate_salary { get; set; } + public int? total_promote { get; set; } + public int? total { get; set; } + public int? total_salary_12 { get; set; } + public int? total_social_security { get; set; } + public int? total_social_security_12 { get; set; } + public int? total_social_compensation { get; set; } + public int? total_social_compensation_12 { get; set; } + public int? total_another2 { get; set; } + public int? total_quantity_money { get; set; } + public int? total2 { get; set; } + public int? including_salary_and_fittings { get; set; } + public int? including_salary_and_fittings_12 { get; set; } + public List personnel_salary_deltails { get; set; } + } + + public class personnel_salary_deltail + { + public bool? is_color { get; set; } + public string manpower { get; set; } + public string full_name { get; set; } + public string first_name_th { get; set; } + public string last_name_th { get; set; } + public string position { get; set; } + public string parent_agency_name { get; set; } + public string area { get; set; } + public int? salary { get; set; } + public int? estimate_salary { get; set; } + public int? promote { get; set; } + public int? total { get; set; } + public int? salary_12 { get; set; } + public int? social_security { get; set; } + public int? social_security_12 { get; set; } + public int? social_compensation { get; set; } + public int? social_compensation_12 { get; set; } + public int? another2 { get; set; } + public int? quantity_money { get; set; } + public int? total2 { get; set; } + public int? including_salary_and_fittings { get; set; } + public int? including_salary_and_fittings_12 { get; set; } + } +} \ No newline at end of file diff --git a/wwwroot/reports/personnel_salary_permanent.frx b/wwwroot/reports/personnel_salary_permanent.frx new file mode 100644 index 0000000..f887dd9 --- /dev/null +++ b/wwwroot/reports/personnel_salary_permanent.frx @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +