lixiaojun
2024-10-17 4cb1f00f84d160f97afd0fb86cf600e1be667dd5
WinFrmUI/Yw.WinFrmUI.Hydro.Core/03-property/03-link/00-core/HydroLinkPropertyViewModel.cs
@@ -5,12 +5,12 @@
    /// <summary>
    /// 管段属性视图
    /// </summary>
    public class HydroLinkPropertyViewModel : HydroParterPropertyViewModel, IHydroCalcuLinkProperty
    public class HydroLinkPropertyViewModel : HydroParterPropertyViewModel, IHydroCalcuLinkResult
    {
        /// <summary>
        /// 
        /// </summary>
        public HydroLinkPropertyViewModel() { }
        public HydroLinkPropertyViewModel() : base() { }
        /// <summary>
        /// 
@@ -18,33 +18,38 @@
        public HydroLinkPropertyViewModel(Yw.Model.HydroLinkInfo rhs) : base(rhs)
        {
            this.StartCode = rhs.StartCode;
            this.UpdatePropStatus(nameof(this.StartCode), rhs, nameof(rhs.StartCode));
            this.EndCode = rhs.EndCode;
            this.LinkStatus = rhs.LinkStatus;
            this.UpdatePropStatus(nameof(this.EndCode), rhs, nameof(rhs.EndCode));
            this.LinkStatus = HydroLinkStatusHelper.GetStatusName(rhs.LinkStatus);
            this.UpdatePropStatus(nameof(this.LinkStatus), rhs, nameof(rhs.LinkStatus));
        }
        /// <summary>
        /// 上游节点编码
        /// 上游节点
        /// </summary>
        [Category("基础信息")]
        [DisplayName("上游节点编码")]
        [DisplayName("上游节点")]
        [PropertyOrder(11)]
        [Browsable(true)]
        [ShowEditor(false)]
        public string StartCode { get; set; }
        /// <summary>
        /// 下游节点编码
        /// 下游节点
        /// </summary>
        [Category("基础信息")]
        [DisplayName("下游节点编码")]
        [DisplayName("下游节点")]
        [PropertyOrder(12)]
        [Browsable(true)]
        [ShowEditor(false)]
        public string EndCode { get; set; }
        /// <summary>
        /// 管道状态
        /// 管段状态
        /// </summary>
        [Category("数据")]
        [DisplayName("管道状态")]
        [DisplayName("管段状态")]
        [PropertyOrder(13)]
        [Browsable(true)]
        public virtual string LinkStatus { get; set; }
@@ -56,6 +61,9 @@
        [DisplayName("流量")]
        [PropertyOrder(10001)]
        [Browsable(true)]
        [DisplayUnit("m³/h")]
        [IsHydroCalcuPro(true)]
        [ShowEditor(false)]
        public double? CalcuFlow { get; set; }
        /// <summary>
@@ -65,6 +73,9 @@
        [DisplayName("流速")]
        [PropertyOrder(10002)]
        [Browsable(true)]
        [DisplayUnit("m/s")]
        [IsHydroCalcuPro(true)]
        [ShowEditor(false)]
        public double? CalcuVelocity { get; set; }
        /// <summary>
@@ -74,6 +85,9 @@
        [DisplayName("水头损失")]
        [PropertyOrder(10003)]
        [Browsable(true)]
        [DisplayUnit("m")]
        [IsHydroCalcuPro(true)]
        [ShowEditor(false)]
        public double? CalcuHeadLoss { get; set; }
        /// <summary>
@@ -87,8 +101,11 @@
            if (rhs is Yw.Model.HydroLinkInfo hydroLinkInfo)
            {
                this.StartCode = hydroLinkInfo.StartCode;
                this.UpdatePropStatus(nameof(this.StartCode), hydroLinkInfo, nameof(hydroLinkInfo.StartCode));
                this.EndCode = hydroLinkInfo.EndCode;
                this.LinkStatus = hydroLinkInfo.LinkStatus;
                this.UpdatePropStatus(nameof(this.EndCode), hydroLinkInfo, nameof(hydroLinkInfo.EndCode));
                this.LinkStatus = HydroLinkStatusHelper.GetStatusName(hydroLinkInfo.LinkStatus);
                this.UpdatePropStatus(nameof(this.LinkStatus), hydroLinkInfo, nameof(hydroLinkInfo.LinkStatus));
            }
        }
@@ -96,14 +113,14 @@
        /// 更新计算属性
        /// </summary>
        /// <param name="rhs"></param>
        public override void UpdateCalcuProperty(IHydroCalcuProperty rhs)
        public override void UpdateCalcuProperty(IHydroCalcuResult rhs)
        {
            base.UpdateCalcuProperty(rhs);
            if (rhs is IHydroCalcuLinkProperty calcuLinkProperty)
            if (rhs is IHydroCalcuLinkResult calcuLinkProperty)
            {
                this.CalcuFlow = calcuLinkProperty.CalcuFlow;
                this.CalcuVelocity = calcuLinkProperty.CalcuVelocity;
                this.CalcuHeadLoss = calcuLinkProperty.CalcuHeadLoss;
                this.CalcuFlow = calcuLinkProperty.CalcuFlow ?? Math.Round(calcuLinkProperty.CalcuFlow.Value, 1);
                this.CalcuVelocity = calcuLinkProperty.CalcuVelocity ?? Math.Round(calcuLinkProperty.CalcuVelocity.Value, 2);
                this.CalcuHeadLoss = calcuLinkProperty.CalcuHeadLoss ?? Math.Round(calcuLinkProperty.CalcuHeadLoss.Value, 2);
            }
        }