更新
This commit is contained in:
@@ -119,10 +119,10 @@ public sealed class NpoiReportExportService : IReportExportService
|
||||
SetValueBesideLabel(sheet, "大气压力", input.AtmosphericPressure);
|
||||
SetValueBesideLabel(sheet, "大气湿度", input.AtmosphericHumidity);
|
||||
SetValueBesideLabel(sheet, "时间记录", input.TimeRecord);
|
||||
SetValueBesideLabel(sheet, "点燃时间", FirstNonEmpty(input.IgnitionTime, summary.IgnitionTime));
|
||||
SetValueBesideLabel(sheet, "点燃时间", summary.IgnitionTime);
|
||||
SetValueBesideLabel(sheet, "熄灭时间", input.FlameoutTime);
|
||||
SetValueBesideLabel(sheet, "结束标准", input.EndCriteria);
|
||||
SetValueBesideLabel(sheet, "结束时间", FirstNonEmpty(input.EndTime, summary.EndTime));
|
||||
SetValueBesideLabel(sheet, "结束时间", summary.EndTime);
|
||||
SetValueBesideLabel(sheet, "E等价热值", input.EquivalentHeatValue);
|
||||
SetRequiredValueBesideLabel(sheet, "C-系数", FirstNonEmpty(input.CFactor, summary.CFactor));
|
||||
SetValueBesideLabel(sheet, "光程", input.LightPath);
|
||||
@@ -325,6 +325,7 @@ public sealed class NpoiReportExportService : IReportExportService
|
||||
|
||||
private static bool SetValueBesideLabel(ISheet sheet, string label, string value)
|
||||
{
|
||||
var updated = false;
|
||||
for (var rowIndex = sheet.FirstRowNum; rowIndex <= sheet.LastRowNum; rowIndex++)
|
||||
{
|
||||
var row = sheet.GetRow(rowIndex);
|
||||
@@ -349,11 +350,11 @@ public sealed class NpoiReportExportService : IReportExportService
|
||||
var targetColumn = FindTargetColumn(sheet, rowIndex, columnIndex);
|
||||
var target = row.GetCell(targetColumn) ?? row.CreateCell(targetColumn);
|
||||
SetTextOrBlank(target, value);
|
||||
return true;
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return updated;
|
||||
}
|
||||
|
||||
private static void SetGraphValuesBesideLabel(ISheet sheet, string label, string value)
|
||||
@@ -561,8 +562,6 @@ public sealed class NpoiReportExportService : IReportExportService
|
||||
}
|
||||
|
||||
var last = records[^1];
|
||||
var ignition = records.FirstOrDefault(record => record.FlameDetected)?.TestSeconds;
|
||||
|
||||
return new ReportSummary(
|
||||
PeakHeatReleaseRate: FormatWithUnit(LastFinite(records, record => record.PeakHeatReleaseRate), "kW/㎡"),
|
||||
PeakSmokeProduction: FormatWithUnit(MaxFinite(records, record => record.SmokeProduction), "m²/s"),
|
||||
@@ -571,7 +570,7 @@ public sealed class NpoiReportExportService : IReportExportService
|
||||
MassLoss: FormatWithUnit(LastFinite(records, record => record.MassLoss), "g"),
|
||||
InitialMass: FormatWithUnit(LastFinite(records, record => record.InitialMass), "g"),
|
||||
CFactor: FormatValue(LastFinite(records, record => record.CFactor)),
|
||||
IgnitionTime: FormatSeconds(ignition),
|
||||
IgnitionTime: FormatSeconds(LastNonNegative(records, record => record.IgnitionSeconds)),
|
||||
EndTime: FormatSeconds(last.TestSeconds));
|
||||
}
|
||||
|
||||
@@ -646,6 +645,20 @@ public sealed class NpoiReportExportService : IReportExportService
|
||||
return max;
|
||||
}
|
||||
|
||||
private static int? LastNonNegative(IReadOnlyList<RealtimeDataRecord> records, Func<RealtimeDataRecord, int> selector)
|
||||
{
|
||||
for (var i = records.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var value = selector(records[i]);
|
||||
if (value >= 0)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string FirstNonEmpty(params string[] values)
|
||||
{
|
||||
return values.FirstOrDefault(value => !string.IsNullOrWhiteSpace(value)) ?? string.Empty;
|
||||
|
||||
@@ -251,6 +251,8 @@ public sealed class ReportPageViewModel : PageViewModel
|
||||
{
|
||||
FindField("InitialMass")?.SetAutoValue(FormatWithUnit(LastFinite(records, record => record.InitialMass), "g"));
|
||||
FindField("CFactor")?.SetAutoValue(FormatValue(LastFinite(records, record => record.CFactor)));
|
||||
FindField("IgnitionTime")?.SetAutoValue(FormatSeconds(LastNonNegative(records, record => record.IgnitionSeconds)));
|
||||
FindField("EndTime")?.SetAutoValue(FormatSeconds(LastNonNegative(records, record => record.TestSeconds)));
|
||||
}
|
||||
|
||||
private ReportFieldViewModel? FindField(string key)
|
||||
@@ -273,6 +275,25 @@ public sealed class ReportPageViewModel : PageViewModel
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
private static int? LastNonNegative(IReadOnlyList<RealtimeDataRecord> records, Func<RealtimeDataRecord, int> selector)
|
||||
{
|
||||
for (var i = records.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var value = selector(records[i]);
|
||||
if (value >= 0)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string FormatSeconds(int? value)
|
||||
{
|
||||
return value.HasValue ? $"{value.Value} s" : string.Empty;
|
||||
}
|
||||
|
||||
private static string FormatValue(double value)
|
||||
{
|
||||
return double.IsFinite(value) ? $"{value:0.00}" : string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user