using System; using System.Collections.Generic; using System.Linq; using System.Text; using CustomOpenItemAddins; namespace CustomOpenAddins.Models { public class Measurement { /// /// 备注说明 /// public string Description { get; set; } = string.Empty; public Measurement(MeasurementUnit measurementUnit, DetailItem detail) { Detail = detail; Unit = measurementUnit; //根据围岩类型设置支护类型 switch (Detail.SubItem.Primary.Table.TypeOfSurrounding) { case TypeOfSurrounding.LevelTwo: Proofs = new HashSet(1) { new Proof("Ⅱ级限排型") }; break; case TypeOfSurrounding.LevelThree: Proofs = new HashSet(9) { new Proof("Ⅲ级限排型"), new Proof("Ⅲ级防水型"), new Proof("Ⅲ级抗水压Ⅰ型"), new Proof("Ⅲ级抗水压Ⅱ型"), new Proof("Ⅲ级抗水压Ⅲ型"), new Proof("Ⅲ级导洞1"), new Proof("Ⅲ级导洞2"), new Proof("Ⅲ级盾构拆解段"), new Proof("Ⅲ级"), }; break; case TypeOfSurrounding.LevelFour: Proofs = new HashSet(6) { new Proof("Ⅳ a级限排型"), new Proof("Ⅳ b级限排型"), new Proof("Ⅳ a级防水型"), new Proof("Ⅳ级平移横通道防水型"), new Proof("Ⅳ级盾构拆解段"), new Proof("Ⅳ级"), }; break; case TypeOfSurrounding.LevelFive: Proofs = new HashSet(7) { new Proof("Ⅴ a级限排型"), new Proof("Ⅴ b级限排型"), new Proof("Ⅴ a级防水型"), new Proof("Ⅴ a级防水型"), new Proof("Ⅴ级导洞1"), new Proof("Ⅴ级导洞2"), new Proof("Ⅴ级"), }; break; case TypeOfSurrounding.LevelSix: Proofs = new HashSet(4) { new Proof("Ⅵ级防水型"), new Proof("Ⅵ级导洞1"), new Proof("Ⅵ级导洞2"), new Proof("Ⅵ级"), }; break; } } public override string ToString() { StringBuilder sb = new StringBuilder($"计量方式:{Mode.GetDescription()};计量单位{Unit.GetDescription()};"); foreach (var item in Proofs) { sb.AppendLine($"{item}"); } return sb.ToString(); } /// /// 父级细类 /// public DetailItem Detail { get; } /// /// 计量方式 /// public MeasurementMode Mode { get { switch (Unit) { case MeasurementUnit.Count: case MeasurementUnit.Set: case MeasurementUnit.Stick: case MeasurementUnit.Hole: return MeasurementMode.Count; case MeasurementUnit.Meter: case MeasurementUnit.Millimeter: case MeasurementUnit.Centimeter: return MeasurementMode.Length; case MeasurementUnit.SquareMeter: return MeasurementMode.Area; case MeasurementUnit.CubicMeter: return MeasurementMode.Volume; default: return MeasurementMode.Unknow; } } } /// /// 计算规则 /// public string CalculationRule { get; set; } = string.Empty; /// /// 计量单位 /// public MeasurementUnit Unit { get; } /// /// 合计计算结果 /// public object Total { get { return Proofs.Sum(x => x.Amount); } } /// /// 防水类型 /// public HashSet Proofs { get; set; } /// /// 设置值 /// /// /// /// public Measurement SetProof(int index, double value) { var proof = Proofs.ElementAt(index); proof.Measurement = this; proof.Amount = value; return this; } } }