From 63854f704730af6f1f9a3cc08bc9276ac9350edc Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期四, 16 一月 2025 12:01:45 +0800
Subject: [PATCH] 基准标高判断验证

---
 WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs |  124 ++++++++++++++++++++----
 Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs  |  138 +++++++++++++++++++++------
 2 files changed, 212 insertions(+), 50 deletions(-)

diff --git a/Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs b/Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs
index 2d96426..d4ed13e 100644
--- a/Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs
+++ b/Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs
@@ -446,6 +446,17 @@
                 if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation))
                 {
                     reservoir.PoolElev = elevOfElevation / 1000f;
+                    var jre = jobject[RevitJsonProp.Elev];
+                    if (jre != null)
+                    {
+                        if (jre.HasValues)
+                        {
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                reservoir.PoolElev += facade / 1000f;
+                            }
+                        }
+                    }
                 }
                 else
                 {
@@ -649,6 +660,17 @@
                 if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation))
                 {
                     tank.PoolElev = elevOfElevation / 1000f;
+                    var jre = jobject[RevitJsonProp.Elev];
+                    if (jre != null)
+                    {
+                        if (jre.HasValues)
+                        {
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                tank.PoolElev += facade / 1000f;
+                            }
+                        }
+                    }
                 }
                 else
                 {
@@ -927,6 +949,17 @@
                 if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation))
                 {
                     waterbox.PoolElev = elevOfElevation / 1000f;
+                    var jre = jobject[RevitJsonProp.Elev];
+                    if (jre != null)
+                    {
+                        if (jre.HasValues)
+                        {
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                waterbox.PoolElev += facade / 1000f;
+                            }
+                        }
+                    }
                 }
                 else
                 {
@@ -1208,9 +1241,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            junction.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                junction.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -1433,9 +1469,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            blunthead.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                blunthead.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -1695,9 +1734,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            elbow.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                elbow.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -1986,9 +2028,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            threelink.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                threelink.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -2273,9 +2318,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            fourlink.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                fourlink.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -2534,9 +2582,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            nozzle.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                nozzle.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -2818,9 +2869,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            hydrant.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                hydrant.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -3097,9 +3151,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            cooling.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                cooling.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -3393,9 +3450,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            meter.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                meter.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -3854,9 +3914,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            pressmeter.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                pressmeter.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -4461,9 +4524,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            translation.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                translation.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -4831,9 +4897,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            pump.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                pump.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -5215,9 +5284,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            valve.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                valve.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -5658,9 +5730,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            exchanger.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                exchanger.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
@@ -5989,9 +6064,12 @@
                     var jre = jobject[RevitJsonProp.Elev];
                     if (jre != null)
                     {
-                        if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                        if (jre.HasValues)
                         {
-                            compressor.Elev += facade / 1000f;
+                            if (jre[RevitJsonProp.ElevFacade].MatchNumeric(out double facade))
+                            {
+                                compressor.Elev += facade / 1000f;
+                            }
                         }
                     }
                 }
diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs
index 4158f0a..3f953ac 100644
--- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs
+++ b/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;
                         }
                     }

--
Gitblit v1.9.3