using System.Text;
using FootwearTest.Models;

namespace FootwearTest.Services;

public sealed class ReportService
{
    public string CreateTextReport(TestRunRecord record)
    {
        var builder = new StringBuilder();
        builder.AppendLine("GB/T 33393-2023 整鞋热阻和湿阻测定报告");
        builder.AppendLine();
        builder.AppendLine($"记录编号: {record.Id}");
        builder.AppendLine($"文件编号: GB/T 33393-2023");
        builder.AppendLine($"使用的试验方法: {record.Method}");
        builder.AppendLine($"试样描述: {record.SampleDescription}");
        builder.AppendLine($"试验条件: {record.Conditions}");
        builder.AppendLine($"试验结果: {record.ResultSummary}");
        builder.AppendLine($"试验日期: {record.CreatedAt:yyyy-MM-dd HH:mm:ss}");
        builder.AppendLine($"与方法偏差: {(record.IsValid ? "无已知偏差" : "结果被标记为需复核或重测")}");
        builder.AppendLine();
        builder.AppendLine("原始数据摘要:");
        builder.AppendLine(record.DataJson);
        return builder.ToString();
    }
}
