using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; namespace TabletTester2025.Models { public class TestBatch { public int Id { get; set; } public DateTime TestTime { get; set; } public int StationId { get; set; } public string SampleName { get; set; } // 硬度 public double HardnessAvg { get; set; } public double HardnessRSD { get; set; } public double HardnessMax { get; set; } public double HardnessMin { get; set; } public int HardnessTestCount { get; set; } public double HardnessInternalMin { get; set; } public double HardnessInternalMax { get; set; } // 脆碎度 public double FriabilityLoss { get; set; } public double FriabilityTargetRpm { get; set; } public int FriabilityTargetTimeSec { get; set; } public int FriabilityTargetRounds { get; set; } public bool FriabilityClockwise { get; set; } public int FriabilityRemainingRounds { get; set; } public double WeightBefore { get; set; } public double WeightAfter { get; set; } [NotMapped] public double FriabilityTargetTimeMin => FriabilityTargetTimeSec / 60.0; // 崩解 public double DisintegrationTimeSec { get; set; } public int RemainingTubesAtEnd { get; set; } public double DisintegrationTargetFreq { get; set; } public double DisintegrationTemp { get; set; } public string DisintegrationDosageForm { get; set; } = ""; public int DisintegrationLimitSeconds { get; set; } // 溶出 public string DissolutionChannel { get; set; } = ""; public double DissolutionRate30Min { get; set; } public double DissolutionTargetRpm { get; set; } public double DissolutionRSquared { get; set; } public int DissolutionSampleInterval { get; set; } public double Dissolution1SampleInterval { get; set; } public double Dissolution2SampleInterval { get; set; } public double DissolutionUpDownFreq { get; set; } public List DissolutionSamples { get; set; } = new(); [NotMapped] public string DissolutionSampleSummary => DissolutionSamples == null || DissolutionSamples.Count == 0 ? "" : string.Join(";", DissolutionSamples .OrderBy(s => s.Channel) .ThenBy(s => s.ScheduledTimeMin) .Select(s => $"{s.ChannelName} {s.ScheduledTimeMin:0.#}min={s.Percent:0.##}%")); // 综合 public bool IsQualified { get; set; } public bool HardnessPass { get; set; } public bool FriabilityPass { get; set; } public bool DisintegrationPass { get; set; } public bool DissolutionPass { get; set; } [NotMapped] public string HardnessPassText => ToPassText(HardnessPass); [NotMapped] public string FriabilityPassText => ToPassText(FriabilityPass); [NotMapped] public string DisintegrationPassText => ToPassText(DisintegrationPass); [NotMapped] public string DissolutionPassText => ToPassText(DissolutionPass); public string TestType { get; set; } // "硬度", "脆碎度", "崩解", "溶出" private static string ToPassText(bool value) => value ? "合格" : "不合格"; } }