This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using FastReport;
|
||||
using FastReport.Export.OoXML;
|
||||
@@ -143,6 +144,11 @@ foreach (var summaryInvestYear in summaryInvest.years)
|
||||
{
|
||||
plan.total_budget = plan.unit_price;
|
||||
}
|
||||
|
||||
if (!plan.asset_lists?.Any() ?? true)
|
||||
{
|
||||
plan.asset_lists = plan.construct_lists?.ToList() ?? new List<summary_invest_list_v2>();
|
||||
}
|
||||
foreach (var assetList in plan.asset_lists)
|
||||
{
|
||||
string formattedSeller = assetList.seller.Replace("<br>", " ");
|
||||
@@ -214,72 +220,109 @@ foreach (var summaryInvestYear in summaryInvest.years)
|
||||
[SwaggerOperation("จัดสรรค่าครุภัณฑ์")]
|
||||
[HttpPost, Route("reports/summary_invest_approve/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetSummaryInvestApproveReport([FromRoute] string type,
|
||||
[FromBody] summary_invest_v2 summaryInvest)
|
||||
public IActionResult GetSummaryInvestApproveReport([FromRoute] string type,
|
||||
[FromBody] summary_invest_v2 summaryInvest)
|
||||
{
|
||||
var summaryInvests = new List<summary_invest_v2>() { summaryInvest };
|
||||
|
||||
if (summaryInvest != null)
|
||||
{
|
||||
foreach (var summaryInvestYear in summaryInvest.years)
|
||||
{
|
||||
foreach (var plan in summaryInvestYear.plans!)
|
||||
{
|
||||
var summaryInvests = new List<summary_invest_v2>() { summaryInvest };
|
||||
if (summaryInvest != null)
|
||||
if (!plan.asset_lists?.Any() ?? true)
|
||||
{
|
||||
foreach (var summaryInvestYear in summaryInvest.years)
|
||||
plan.asset_lists = plan.construct_lists?.ToList() ?? new List<summary_invest_list_v2>();
|
||||
}
|
||||
|
||||
var validAssets = plan.asset_lists.Where(x => x.unit_price.HasValue && x.unit_price > 0);
|
||||
|
||||
if (validAssets.Any())
|
||||
{
|
||||
plan.unit_price = validAssets.Sum(x => x.unit_price) ?? 0;
|
||||
plan.total_budget = validAssets.Sum(x => x.total_budget) ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
plan.unit_price = 0;
|
||||
plan.total_budget = 0;
|
||||
}
|
||||
|
||||
if (summaryInvestYear.plans != null && summaryInvestYear.plans.Any())
|
||||
{
|
||||
var validPlanAssets = summaryInvestYear.plans.SelectMany(p => p.asset_lists)
|
||||
.Where(x => x.unit_price.HasValue && x.unit_price > 0);
|
||||
|
||||
if (validPlanAssets.Any())
|
||||
{
|
||||
foreach (var plan in summaryInvestYear.plans)
|
||||
{
|
||||
foreach (var assetList in plan.asset_lists)
|
||||
{
|
||||
string formattedSeller = assetList.seller.Replace("<br>", " ");
|
||||
string pattern = @"<a href=.*?>(.*?)<\/a>";
|
||||
MatchCollection matches = Regex.Matches(assetList.file, pattern);
|
||||
|
||||
string formattedFile = "";
|
||||
if (assetList.is_approve == true)
|
||||
{
|
||||
assetList.approve_name = "อนุมัติแล้ว";
|
||||
}
|
||||
|
||||
|
||||
assetList.seller2 = formattedSeller;
|
||||
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
formattedFile += match.Groups[1].Value + " ";
|
||||
}
|
||||
|
||||
formattedFile = formattedFile.Trim();
|
||||
assetList.file2 = formattedFile;
|
||||
|
||||
//Console.WriteLine("seller output: " + formattedSeller);
|
||||
//Console.WriteLine("file output: " + formattedFile);
|
||||
}
|
||||
}
|
||||
summaryInvest.unit_price = validPlanAssets.Sum(x => x.unit_price) ?? 0;
|
||||
summaryInvest.total_budget = validPlanAssets.Sum(x => x.total_budget) ?? 0;
|
||||
summaryInvestYear.unit_price = validPlanAssets.Sum(x => x.unit_price) ?? 0;
|
||||
summaryInvestYear.total_budget = validPlanAssets.Sum(x => x.total_budget) ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
summaryInvest.unit_price = 0;
|
||||
summaryInvest.total_budget = 0;
|
||||
summaryInvestYear.unit_price = 0;
|
||||
summaryInvestYear.total_budget = 0;
|
||||
}
|
||||
}
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "summary_invest_approve.frx");
|
||||
report.RegisterData(summaryInvests, "summary_invest");
|
||||
report.Prepare();
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
switch (type)
|
||||
foreach (var assetList in plan.asset_lists)
|
||||
{
|
||||
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.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"summary_invest_approve" + ".xlsx");
|
||||
break;
|
||||
}
|
||||
string formattedSeller = assetList.seller.Replace("<br>", " ");
|
||||
string pattern = @"<a href=.*?>(.*?)<\/a>";
|
||||
MatchCollection matches = Regex.Matches(assetList.file, pattern);
|
||||
|
||||
return Ok();
|
||||
string formattedFile = "";
|
||||
if (assetList.is_approve == true)
|
||||
{
|
||||
assetList.approve_name = "อนุมัติแล้ว";
|
||||
}
|
||||
|
||||
assetList.seller2 = formattedSeller;
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
formattedFile += match.Groups[1].Value + " ";
|
||||
}
|
||||
|
||||
assetList.file2 = formattedFile.Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "summary_invest_approve.frx");
|
||||
report.RegisterData(summaryInvests, "summary_invest");
|
||||
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.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"summary_invest_approve.xlsx");
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a4b9c896dd6684ef18b94d0e0c44fdf79a3468a6")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c5e56063e2ef2d254a6fbb2035095a181b7103c3")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
371c200e98a2676e758da94f74c0bc6363cbbc35d65b4f08b471b97250d1118e
|
||||
a6497678f9a2aa9e7e5abc4d22eb7e42715ef7b2ca97041d4bf70762dfbe0fd9
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a4b9c896dd6684ef18b94d0e0c44fdf79a3468a6")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c5e56063e2ef2d254a6fbb2035095a181b7103c3")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
371c200e98a2676e758da94f74c0bc6363cbbc35d65b4f08b471b97250d1118e
|
||||
a6497678f9a2aa9e7e5abc4d22eb7e42715ef7b2ca97041d4bf70762dfbe0fd9
|
||||
|
||||
@@ -1 +1 @@
|
||||
d38f7f6bbd27710e139b96d62b84aa76d97b6926b9acb21af98f13c47c32ed09
|
||||
7b9ea42177d03ced8fb55213fec1b4d1c2989a406793ce7eea8fa8ff8087eae0
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
17403867488254078
|
||||
17404853499076394
|
||||
@@ -1 +1 @@
|
||||
17404853499076394
|
||||
17408131531650790
|
||||
Reference in New Issue
Block a user