Files
MsAddIns/ExportExcelTest/Models/Measurement.cs
2026-02-28 21:01:57 +08:00

155 lines
5.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CustomOpenItemAddins;
namespace CustomOpenAddins.Models
{
public class Measurement
{
/// <summary>
/// 备注说明
/// </summary>
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<Proof>(1) { new Proof("Ⅱ级限排型") };
break;
case TypeOfSurrounding.LevelThree:
Proofs = new HashSet<Proof>(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<Proof>(6)
{
new Proof("Ⅳ a级限排型"),
new Proof("Ⅳ b级限排型"),
new Proof("Ⅳ a级防水型"),
new Proof("Ⅳ级平移横通道防水型"),
new Proof("Ⅳ级盾构拆解段"),
new Proof("Ⅳ级"),
};
break;
case TypeOfSurrounding.LevelFive:
Proofs = new HashSet<Proof>(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<Proof>(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();
}
/// <summary>
/// 父级细类
/// </summary>
public DetailItem Detail { get; }
/// <summary>
/// 计量方式
/// </summary>
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;
}
}
}
/// <summary>
/// 计算规则
/// </summary>
public string CalculationRule { get; set; } = string.Empty;
/// <summary>
/// 计量单位
/// </summary>
public MeasurementUnit Unit { get; }
/// <summary>
/// 合计计算结果
/// </summary>
public object Total { get { return Proofs.Sum(x => x.Amount); } }
/// <summary>
/// 防水类型
/// </summary>
public HashSet<Proof> Proofs { get; set; }
/// <summary>
/// 设置值
/// </summary>
/// <param name="index"></param>
/// <param name="value"></param>
/// <returns></returns>
public Measurement SetProof(int index, double value)
{
var proof = Proofs.ElementAt(index);
proof.Measurement = this;
proof.Amount = value;
return this;
}
}
}