lixiaojun
2025-01-16 63854f704730af6f1f9a3cc08bc9276ac9350edc
WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs
@@ -3040,9 +3040,15 @@
        /// <summary>
        /// 应用
        /// </summary>
        public static bool Apply(HydroExchangerViewModel visualViewModel, HydroExchangerMatchingViewModel matching)
        public static bool Apply
            (
                HydroExchangerViewModel visualViewModel,
                HydroExchangerMatchingViewModel matching,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
            var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper);
            visualViewModel.UpdateProperty();
            return bol;
        }
@@ -3050,7 +3056,14 @@
        /// <summary>
        /// 应用
        /// </summary>
        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroExchangerInfo visual, HydroExchangerMatchingViewModel matching)
        public static bool Apply
            (
                Yw.Model.HydroModelInfo hydroInfo,
                Yw.Model.HydroExchangerInfo visual,
                HydroExchangerMatchingViewModel matching,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            if (hydroInfo == null)
            {
@@ -3064,39 +3077,64 @@
            {
                return false;
            }
            visual.Name = matching.Name;
            visual.DbLocked = matching.DbLocked;
            visual.DbId = matching.DbId;
            visual.ModelType = matching.ModelType;
            visual.Material = matching.Material;
            visual.Diameter = matching.Diameter;
            visual.MinorLoss = matching.MinorLoss;
            //visual.Name = matching.Name;
            //visual.DbLocked = matching.DbLocked;
            //visual.DbId = matching.DbId;
            //visual.ModelType = matching.ModelType;
            //visual.Material = matching.Material;
            //visual.Diameter = matching.Diameter;
            //visual.MinorLoss = matching.MinorLoss;
            bool result = false;
            if (!visual.DbLocked)
            {
                if (!string.IsNullOrEmpty(matching.MatchingModelType))
                {
                    if (visual.ModelType != matching.MatchingModelType)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.ModelType = matching.MatchingModelType;
                    result = true;
                }
                if (!string.IsNullOrEmpty(matching.MatchingDbId))
                {
                    if (visual.DbId != matching.MatchingDbId)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.DbId = matching.MatchingDbId;
                    result = true;
                }
                if (!string.IsNullOrEmpty(matching.MatchingMaterial))
                {
                    if (visual.Material != matching.MatchingMaterial)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.Material = matching.MatchingMaterial;
                    result = true;
                }
                if (matching.MatchingDiameter.HasValue)
                {
                    if (visual.Diameter != matching.MatchingDiameter.Value)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Diameter), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.Diameter = matching.MatchingDiameter.Value;
                    result = true;
                }
                if (matching.MatchingMinorLoss.HasValue)
                {
                    if (visual.MinorLoss != matching.MatchingMinorLoss.Value)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.MinorLoss = matching.MatchingMinorLoss.Value;
                    result = true;
                }
@@ -3121,6 +3159,9 @@
                        }
                        hydroInfo.Curves.Add(curvevql);
                        visual.CurveQL = curvevql.Code;
                        changeHelper?.Append(curvevql, eChangeType.Add);
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                        result = true;
                    }
                    else
@@ -3129,6 +3170,7 @@
                        {
                            curvevql.DbId = matching.MatchingCurveDbId;
                            curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
                            changeHelper?.Append(curvevql, eChangeType.Update);
                            result = true;
                        }
                    }
@@ -3144,9 +3186,15 @@
        /// <summary>
        /// 应用
        /// </summary>
        public static bool Apply(HydroCompressorViewModel visualViewModel, HydroCompressorMatchingViewModel matching)
        public static bool Apply
            (
                HydroCompressorViewModel visualViewModel,
                HydroCompressorMatchingViewModel matching,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
            var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper);
            visualViewModel.UpdateProperty();
            return bol;
        }
@@ -3154,7 +3202,14 @@
        /// <summary>
        /// 应用
        /// </summary>
        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroCompressorInfo visual, HydroCompressorMatchingViewModel matching)
        public static bool Apply
            (
                Yw.Model.HydroModelInfo hydroInfo,
                Yw.Model.HydroCompressorInfo visual,
                HydroCompressorMatchingViewModel matching,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            if (hydroInfo == null)
            {
@@ -3168,39 +3223,64 @@
            {
                return false;
            }
            visual.Name = matching.Name;
            visual.DbLocked = matching.DbLocked;
            visual.DbId = matching.DbId;
            visual.ModelType = matching.ModelType;
            visual.Material = matching.Material;
            visual.Diameter = matching.Diameter;
            visual.MinorLoss = matching.MinorLoss;
            //visual.Name = matching.Name;
            //visual.DbLocked = matching.DbLocked;
            //visual.DbId = matching.DbId;
            //visual.ModelType = matching.ModelType;
            //visual.Material = matching.Material;
            //visual.Diameter = matching.Diameter;
            //visual.MinorLoss = matching.MinorLoss;
            bool result = false;
            if (!visual.DbLocked)
            {
                if (!string.IsNullOrEmpty(matching.MatchingModelType))
                {
                    if (visual.ModelType != matching.MatchingModelType)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.ModelType = matching.MatchingModelType;
                    result = true;
                }
                if (!string.IsNullOrEmpty(matching.MatchingDbId))
                {
                    if (visual.DbId != matching.MatchingDbId)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.DbId = matching.MatchingDbId;
                    result = true;
                }
                if (!string.IsNullOrEmpty(matching.MatchingMaterial))
                {
                    if (visual.Material != matching.MatchingMaterial)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.Material = matching.MatchingMaterial;
                    result = true;
                }
                if (matching.MatchingDiameter.HasValue)
                {
                    if (visual.Diameter != matching.MatchingDiameter.Value)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Diameter), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.Diameter = matching.MatchingDiameter.Value;
                    result = true;
                }
                if (matching.MatchingMinorLoss.HasValue)
                {
                    if (visual.MinorLoss != matching.MatchingMinorLoss.Value)
                    {
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                    }
                    visual.MinorLoss = matching.MatchingMinorLoss.Value;
                    result = true;
                }
@@ -3225,6 +3305,9 @@
                        }
                        hydroInfo.Curves.Add(curvevql);
                        visual.CurveQL = curvevql.Code;
                        changeHelper?.Append(curvevql, eChangeType.Add);
                        changeHelper?.Append(visual, eChangeType.Update);
                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改");
                        result = true;
                    }
                    else
@@ -3233,6 +3316,7 @@
                        {
                            curvevql.DbId = matching.MatchingCurveDbId;
                            curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
                            changeHelper?.Append(curvevql, eChangeType.Update);
                            result = true;
                        }
                    }