Shuxia Ning
2024-12-17 907a1579fecf2c160852cf99b3ea77c08eb481cc
WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs
@@ -70,6 +70,12 @@
            #endregion
            #region 冷却塔
            vm.Coolings = hydroInfo.Coolings?.Select(x => Create(x, hydroInfo)).ToList();
            #endregion
            #region 水表
            vm.Meters = hydroInfo.Meters?.Select(x => Create(x, hydroInfo)).ToList();
@@ -347,6 +353,38 @@
                return default;
            }
            return new HydroHydrantMatchingViewModel(visualViewModel);
        }
        #endregion
        #region 冷却塔
        /// <summary>
        /// 创建冷却塔自动匹配ViewModel
        /// </summary>
        public static HydroCoolingMatchingViewModel Create(HydroCoolingInfo visualInfo, HydroModelInfo hydroInfo)
        {
            if (visualInfo == null)
            {
                return default;
            }
            if (hydroInfo == null)
            {
                return default;
            }
            return new HydroCoolingMatchingViewModel(visualInfo, hydroInfo);
        }
        /// <summary>
        /// 创建冷却塔自动匹配ViewModel
        /// </summary>
        public static HydroCoolingMatchingViewModel Create(HydroCoolingViewModel visualViewModel)
        {
            if (visualViewModel == null)
            {
                return default;
            }
            return new HydroCoolingMatchingViewModel(visualViewModel);
        }
        #endregion
@@ -784,6 +822,25 @@
                    hydroInfo.Hydrants.ForEach(x =>
                    {
                        var matching = matchingInfo.Hydrants.Find(t => t.Code == x.Code);
                        if (Apply(hydroInfo, x, matching))
                        {
                            result = true;
                        }
                    });
                }
            }
            #endregion
            #region 消火栓
            if (hydroInfo.Coolings != null && hydroInfo.Coolings.Count > 0)
            {
                if (matchingInfo.Coolings != null && matchingInfo.Coolings.Count > 0)
                {
                    hydroInfo.Coolings.ForEach(x =>
                    {
                        var matching = matchingInfo.Coolings.Find(t => t.Code == x.Code);
                        if (Apply(hydroInfo, x, matching))
                        {
                            result = true;
@@ -1555,6 +1612,96 @@
        #endregion
        #region 冷却塔
        /// <summary>
        /// 应用
        /// </summary>
        public static bool Apply(HydroCoolingViewModel visualViewModel, HydroCoolingMatchingViewModel matching)
        {
            var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
            visualViewModel.UpdateProperty();
            return bol;
        }
        /// <summary>
        /// 应用
        /// </summary>
        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroCoolingInfo visual, HydroCoolingMatchingViewModel matching)
        {
            if (hydroInfo == null)
            {
                return false;
            }
            if (visual == null)
            {
                return false;
            }
            if (matching == null)
            {
                return false;
            }
            visual.Name = matching.Name;
            visual.DbLocked = matching.DbLocked;
            visual.DbId = matching.DbId;
            visual.ModelType = matching.ModelType;
            visual.Material = matching.Material;
            visual.Caliber = matching.Caliber;
            visual.MinorLoss = matching.MinorLoss;
            visual.Coefficient = matching.Coefficient;
            visual.LowerLimit = matching.LowerLimit;
            bool result = false;
            if (!visual.DbLocked)
            {
                if (!string.IsNullOrEmpty(matching.MatchingModelType))
                {
                    visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.ModelType}");
                    visual.ModelType = matching.MatchingModelType;
                    result = true;
                }
                if (!string.IsNullOrEmpty(matching.MatchingDbId))
                {
                    visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.DbId}");
                    visual.DbId = matching.MatchingDbId;
                    result = true;
                }
                if (matching.MatchingCaliber.HasValue)
                {
                    visual.UpdatePropStatus(nameof(visual.Caliber), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.Caliber}");
                    visual.Caliber = matching.MatchingCaliber.Value;
                    result = true;
                }
                if (!string.IsNullOrEmpty(matching.MatchingMaterial))
                {
                    visual.UpdatePropStatus(nameof(visual.Material), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.Material}");
                    visual.Material = matching.MatchingMaterial;
                    result = true;
                }
                if (matching.MatchingMinorLoss.HasValue)
                {
                    visual.UpdatePropStatus(nameof(visual.MinorLoss), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.MinorLoss}");
                    visual.MinorLoss = matching.MatchingMinorLoss.Value;
                    result = true;
                }
                if (matching.MatchingCoefficient.HasValue)
                {
                    visual.UpdatePropStatus(nameof(visual.Coefficient), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.Coefficient}");
                    visual.Coefficient = matching.MatchingCoefficient.Value;
                    result = true;
                }
                if (matching.MatchingLowerLimit.HasValue)
                {
                    visual.UpdatePropStatus(nameof(visual.LowerLimit), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.LowerLimit}");
                    visual.LowerLimit = matching.MatchingLowerLimit.Value;
                    result = true;
                }
            }
            return result;
        }
        #endregion
        #region 水表
        /// <summary>