diff --git a/Controllers/project_principle_rationale.Controller.cs b/Controllers/project_principle_rationale.Controller.cs new file mode 100644 index 0000000..59c9ed1 --- /dev/null +++ b/Controllers/project_principle_rationale.Controller.cs @@ -0,0 +1,137 @@ +using System.Collections.Generic; +using System.IO; +using ClosedXML.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 Swashbuckle.AspNetCore.Annotations; + +namespace rmutr_report.Controllers +{ + [SwaggerTag("สำหรับรายงาน ง.5")] + public class ProjectPrincipleRationale: Controller + { + readonly Setting _setting; + + public ProjectPrincipleRationale(Setting setting) + { + this._setting = setting; + } + [HttpPost, Route("reports/project_principle_rationale/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetProjectReport([FromRoute] string type, [FromBody] project_principle_rationale project) + { + var total = project.activity.Count; + var total2 = project.sixteenth.Count; + foreach (var v in project.activity) + { + if (v.activity != null) + { + //var total = project.activity.Select(r => r.count).Sum(t => t.Value); + project.together_with = "ประกอบด้วยกิจกรรมหรือโครงการย่อย " + total +" โครงการดังนี้คือ"; + } + else + { + project.together_with = null; + } + } + foreach (var v in project.eighth) + { + string na = "ประเด็นยุทธศาสตร์ที่ " ; + v.strategic_issues = na + v.strategic_issues; + string na2 = "มาตรการที่ " ; + v.measure = na2 + v.measure; + } + foreach (var v in project.fourteenth) + { + string na = "องค์ประกอบที่ " ; + v.component = na + v.component; + string na2 = "ตัวบ่งชี้ที่ " ; + v.indicator = na2 + v.indicator; + } + project.count_activity = total2; + foreach (var v in project.eighteenth) + { + foreach (var vv in v.eighteenths) + { + + string na = "ครั้งที่ "; + vv.the_time = na + vv.the_time; + string na2 = " จำนวน "; + vv.count_day = na2 + vv.count_day + " วัน"; + } + } + // foreach (var a in project.seventeenth) + // { + // foreach (var aa in a.seventeenths) + // { + // foreach (var a2 in aa.seventeenths2) + // { + // if (aa.type == "1") + // { + // a2.internal_external = "ภายในมหาวิทยาลัย"; + // a2.area_province = "พื้นที่" + a2.area_province; + // a2.location = "ระบุสถานที่" + a2.location; + // } + // if (aa.type == "2") + // { + // a2.internal_external = "ภายนอกมหาวิทยาลัย"; + // a2.area_province = "จังหวัด" + a2.area_province; + // a2.location = "ระบุสถานที่" + a2.location; + // } + // if (aa.type == "3") + // { + // a2.internal_external = "ภายนอกมหาวิทยาลัย"; + // a2.area_province = "จังหวัด" + a2.area_province; + // a2.location = "ระบุสถานที่" + a2.location; + // } + // } + // } + + // } + var _project = new List() {project}; + + Report report = new Report(); + report.Load(_setting.report_path + "project_principle_rationale.frx"); + report.RegisterData(_project, "project_principle_rationale"); + 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(); + } + + } +} \ No newline at end of file diff --git a/Models/budget/project_principle_rationale.cs b/Models/budget/project_principle_rationale.cs new file mode 100644 index 0000000..4bb95d7 --- /dev/null +++ b/Models/budget/project_principle_rationale.cs @@ -0,0 +1,287 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models +{ + public class project_principle_rationale + { + public string faculty { get; set; } + public string product { get; set; } + public string side { get; set; } + public string project { get; set; } + //public int? count_project { get; set; } + public List activity { get; set; } + public string together_with { get; set; } + public string strategic_plan { get; set; } //ข้อ 2 + public string target_second { get; set; } + public string subject_second { get; set; } + public string country_reform_plan { get; set; } //ข้อ 3 + public string target_third { get; set; } + public string subject_third { get; set; } + public string pin { get; set; } //ข้อ 4 + public string target_fourth { get; set; } + public string pin_fourth { get; set; } + public string principles_reasons { get; set; } //ข้อ 5 + public string objective { get; set; } //ข้อ 6 + public List seventh { get; set; } //ข้อ 7 + public List eighth { get; set; } //ข้อ 8 + public List ninth { get; set; } //ข้อ 9 + public string explain_consistency1 { get; set; } //อธิบายความสอดคล้อง + public string explain_consistency2 { get; set; } //อธิบายความสอดคล้อง + public List tenth { get; set; } //ข้อ 10 + public string subject_eleventh { get; set; } //ข้อ 11 + public string subject_twelfth { get; set; } //ข้อ 12 + public string strategic_issues_thirteenth { get; set; } //ข้อ 13 + public string subject_thirteenth { get; set; } //ข้อ 13 + public string strategy_thirteenth { get; set; } //ข้อ 13 + public string level { get; set; } //ข้อ 14 + public List fourteenth { get; set; } //ข้อ 14 + public List fifteenth { get; set; } //ข้อ 15 + public int? count_activity { get; set; } //ข้อ 16 + public List sixteenth { get; set; } //ข้อ 16 + public List sixteenths { get; set; } //ข้อ 16 detail ตาราง + public List seventeenth { get; set; } //ข้อ 17 + public List eighteenth { get; set; } //ข้อ 18 + public List nineteenth { get; set; } //ข้อ 19 + + } + + public class activity_data + { + public string activity { get; set; } + } + public class seventh_data + { + public string identity { get; set; } + public string description { get; set; } + } + + public class eighth_data + { + public string strategic_issues { get; set; } + public string measure { get; set; } + } + + public class ninth_data + { + public string clause { get; set; } + public List ninths { get; set; } + } + + public class ninth_data_detail + { + public string detail { get; set; } + } + + public class tenth_data + { + public string target { get; set; } + } + + public class fourteenth_data + { + public string component { get; set; } + public string indicator { get; set; } + } + + public class fifteenth_data + { + public string activity { get; set; } + public string activity_table { get; set; } + public List fifteenths { get; set; } + } + + public class fifteenth_data_detail + { + public string detail { get; set; } + } + + public class sixteenth_data + { + public string activity { get; set; } + } + + public class sixteenth_data_detail + { + public string activity_table { get; set; } + public List sixteenths2 { get; set; } + + } + + public class sixteenth_data_details + { + + public decimal? salaya_executive { get; set; } + public decimal? bophitphimuk_executive { get; set; } + public decimal? pohchang_executive { get; set; } + public decimal? klai_kangwon_executive { get; set; } + public decimal? salaya_teacher { get; set; } + public decimal? bophitphimuk_teacher { get; set; } + public decimal? pohchang_teacher { get; set; } + public decimal? klai_kangwon_teacher { get; set; } + public decimal? salaya_officer { get; set; } + public decimal? bophitphimuk_officer { get; set; } + public decimal? pohchang_officer { get; set; } + public decimal? klai_kangwon_officer { get; set; } + public decimal? salaya_internal_student { get; set; } + public decimal? bophitphimuk_internal_student { get; set; } + public decimal? pohchang_internal_student { get; set; } + public decimal? klai_kangwon_internal_student { get; set; } + public decimal? salaya_external_student{ get; set; } + public decimal? bophitphimuk_external_student { get; set; } + public decimal? pohchang_external_student { get; set; } + public decimal? klai_kangwon_external_student { get; set; } + public decimal? salaya_person { get; set; } + public decimal? bophitphimuk_person { get; set; } + public decimal? pohchang_person{ get; set; } + public decimal? klai_kangwon_person { get; set; } + public decimal? salaya_lecturer { get; set; } + public decimal? bophitphimuk_lecturer { get; set; } + public decimal? pohchang_lecturer { get; set; } + public decimal? klai_kangwon_lecturer{ get; set; } + + public decimal? salaya_board { get; set; } + public decimal? bophitphimuk_board { get; set; } + public decimal? pohchang_board { get; set; } + public decimal? klai_kangwon_board { get; set; } + + public decimal? salaya_driver { get; set; } + public decimal? bophitphimuk_driver { get; set; } + public decimal? pohchang_driver { get; set; } + public decimal? klai_kangwon_driver{ get; set; } + + public decimal? salaya_other { get; set; } + public decimal? bophitphimuk_other { get; set; } + public decimal? pohchang_other { get; set; } + public decimal? klai_kangwon_other { get; set; } + + public decimal? salaya_total { get; set; } + public decimal? bophitphimuk_total { get; set; } + public decimal? pohchang_total { get; set; } + public decimal? klai_kangwon_total { get; set; } + } + + public class seventeenth_data + { + public string activity { get; set; } + public List seventeenths { get; set; } + } + + public class seventeenth_data_detail + { + public string the_time { get; set; } + public List seventeenths2 { get; set; } + + } + + public class seventeenth_data_details // 1 in 2 out + { + public string internal_external1 { get; set; } + public string area_province1 { get; set; } + public string location1 { get; set; } + public string internal_external2 { get; set; } + public string area_province2 { get; set; } + public string location2 { get; set; } + // public string external_university { get; set; } + // public string province { get; set; } + // public string province_location { get; set; } + + } + + public class eighteenth_data + { + public string activity { get; set; } + public List eighteenths { get; set; } + } + + public class eighteenth_data_detail + { + public string the_time { get; set; } + public string count_day { get; set; } + public string start_date { get; set; } + public string end_date { get; set; } + } + + public class nineteenth_data + { + public string activity { get; set; } + public decimal? budget_total_amount { get; set; } + public decimal? budget_amount { get; set; } + public decimal? compensation { get; set; } + public decimal? expenses { get; set; } + public decimal? material { get; set; } + public List nineteenths_compensation { get; set; } + public List nineteenths_expenses { get; set; } + public List nineteenths_material { get; set; } + } + + public class nineteenth_data_detail + { + public string header_name { get; set; } + public List nineteenths2_compensation { get; set; } + } + + public class nineteenth_data_details + { + public string name { get; set; } + public decimal? hour { get; set; } + public decimal? amount { get; set; } + public decimal? count_person { get; set; } + public decimal? total_amount { get; set; } + } + + public class nineteenth_data_detail2 + { + public string header_name1 { get; set; } + public string header_name2 { get; set; } + //public string header_name3 { get; set; } + public List nineteenths_expenses1 { get; set; } + public List nineteenths_expenses2 { get; set; } + public List nineteenths_expenses3 { get; set; } + } + + public class nineteenth2_data_details + { + public string name { get; set; } + public decimal? amount { get; set; } + public decimal? count_person { get; set; } + public decimal? total_amount { get; set; } + } + + public class nineteenth2_data_details2 + { + public string name { get; set; } + public decimal? amount { get; set; } + public decimal? day { get; set; } + public decimal? count_person { get; set; } + public decimal? total_amount { get; set; } + } + + public class nineteenth2_data_details3 + { + + public string header_name3 { get; set; } + public List nineteenths_expenses3_details { get; set; } + + + } + + public class nineteenths_expenses3_detail + { + public string name { get; set; } + public decimal? amount { get; set; } + public decimal? potion { get; set; } + public decimal? count_person { get; set; } + public decimal? total_amount { get; set; } + } + + public class nineteenth_data_detail3 + { + public string name { get; set; } + public string unit { get; set; } + public decimal? amount { get; set; } + public decimal? unit_price { get; set; } + public decimal? total_amount { get; set; } + } + + +} \ No newline at end of file diff --git a/wwwroot/reports/project_principle_rationale.frx b/wwwroot/reports/project_principle_rationale.frx new file mode 100644 index 0000000..d2da9f2 --- /dev/null +++ b/wwwroot/reports/project_principle_rationale.frx @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +