From 95e7fe3b1dc1c1bc6bb8e48425f0bac2080e3568 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期二, 07 一月 2025 17:44:26 +0800
Subject: [PATCH] 匹配增加状态判断

---
 WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs              |  318 ++++++++++++++++++++++++++++++++++++++++++++--------
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/SimulationPropertyCtrl.cs |   32 ++--
 2 files changed, 281 insertions(+), 69 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/SimulationPropertyCtrl.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/SimulationPropertyCtrl.cs
index d2d7e22..6994bee 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/SimulationPropertyCtrl.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/01-property/SimulationPropertyCtrl.cs
@@ -149,7 +149,7 @@
                         var dlg = new AssetsTankSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(tankViewModel, output);
+                            HydroMatchingHelper.Apply(tankViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -167,7 +167,7 @@
                         var dlg = new AssetsTankSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(tankViewModel, output);
+                            HydroMatchingHelper.Apply(tankViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -185,7 +185,7 @@
                         var dlg = new AssetsBluntheadSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(bluntheadViewModel, output);
+                            HydroMatchingHelper.Apply(bluntheadViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -203,7 +203,7 @@
                         var dlg = new AssetsElbowSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(elbowViewModel, output);
+                            HydroMatchingHelper.Apply(elbowViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -239,7 +239,7 @@
                         var dlg = new AssetsFourlinkSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(fourlinkViewModel, output);
+                            HydroMatchingHelper.Apply(fourlinkViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -257,7 +257,7 @@
                         var dlg = new AssetsMeterSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(meterViewModel, output);
+                            HydroMatchingHelper.Apply(meterViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -275,7 +275,7 @@
                         var dlg = new AssetsFlowmeterSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(flowmeterViewModel, output);
+                            HydroMatchingHelper.Apply(flowmeterViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -293,7 +293,7 @@
                         var dlg = new AssetsPressmeterSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(pressmeterViewModel, output);
+                            HydroMatchingHelper.Apply(pressmeterViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -311,7 +311,7 @@
                         var dlg = new AssetsSprinklerSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(nozzleViewModel, output);
+                            HydroMatchingHelper.Apply(nozzleViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -329,7 +329,7 @@
                         var dlg = new AssetsHydrantSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(hydrantViewModel, output);
+                            HydroMatchingHelper.Apply(hydrantViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -347,7 +347,7 @@
                         var dlg = new AssetsCoolingSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(coolingViewModel, output);
+                            HydroMatchingHelper.Apply(coolingViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -365,7 +365,7 @@
                         var dlg = new AssetsPipeSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(pipeViewModel, output);
+                            HydroMatchingHelper.Apply(pipeViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -382,7 +382,7 @@
                         var dlg = new SimulationPumpSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(pumpViewModel, output);
+                            HydroMatchingHelper.Apply(pumpViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -400,7 +400,7 @@
                         var dlg = new AssetsValveSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(valveViewModel, output);
+                            HydroMatchingHelper.Apply(valveViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -418,7 +418,7 @@
                         var dlg = new AssetsExchangerSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(exchangerViewModel, output);
+                            HydroMatchingHelper.Apply(exchangerViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
@@ -436,7 +436,7 @@
                         var dlg = new AssetsCompressorSingleMatchingDlg();
                         dlg.ReloadDataEvent += (output) =>
                         {
-                            HydroMatchingHelper.Apply(compressorViewModel, output);
+                            HydroMatchingHelper.Apply(compressorViewModel, output, _changeHelper, _propStatusHelper);
                             this.hydroVisualPropertyCtrl1.UpdateRows();
                             this.PropertyValueChangedEvent?.Invoke(vm.Vmo);
                             this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo);
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 7b90309..9e48ccf 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
@@ -1,5 +1,6 @@
 锘縰sing DevExpress.XtraSpreadsheet.Model.CopyOperation;
 using System.Windows.Media.Imaging;
+using Yw.Ahart;
 using Yw.DAL.Basic;
 using Yw.EPAnet;
 using Yw.Hydro;
@@ -684,7 +685,13 @@
         /// <summary>
         /// 搴旂敤鑷姩鍖归厤ViewModel
         /// </summary>
-        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, HydroMatchingViewModel matchingInfo)
+        public static bool Apply
+            (
+                Yw.Model.HydroModelInfo hydroInfo,
+                HydroMatchingViewModel matchingInfo,
+                HydroChangeHelper changeHelper = null,
+                HydroPropStatusHelper propStatusHelper = null
+            )
         {
             if (hydroInfo == null)
             {
@@ -707,7 +714,7 @@
                     allTanks.ForEach(x =>
                     {
                         var matching = matchingInfo.Tanks.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -727,7 +734,7 @@
                     hydroInfo.Bluntheads.ForEach(x =>
                     {
                         var matching = matchingInfo.Bluntheads.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -746,7 +753,7 @@
                     hydroInfo.Elbows.ForEach(x =>
                     {
                         var matching = matchingInfo.Elbows.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -765,7 +772,7 @@
                     hydroInfo.Threelinks.ForEach(x =>
                     {
                         var matching = matchingInfo.Threelinks.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -784,7 +791,7 @@
                     hydroInfo.Fourlinks.ForEach(x =>
                     {
                         var matching = matchingInfo.Fourlinks.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -803,7 +810,7 @@
                     hydroInfo.Nozzles.ForEach(x =>
                     {
                         var matching = matchingInfo.Nozzles.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -822,7 +829,7 @@
                     hydroInfo.Hydrants.ForEach(x =>
                     {
                         var matching = matchingInfo.Hydrants.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -841,7 +848,7 @@
                     hydroInfo.Coolings.ForEach(x =>
                     {
                         var matching = matchingInfo.Coolings.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -860,7 +867,7 @@
                     hydroInfo.Meters.ForEach(x =>
                     {
                         var matching = matchingInfo.Meters.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -879,7 +886,7 @@
                     hydroInfo.Flowmeters.ForEach(x =>
                     {
                         var matching = matchingInfo.Flowmeters.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -898,7 +905,7 @@
                     hydroInfo.Pressmeters.ForEach(x =>
                     {
                         var matching = matchingInfo.Pressmeters.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -917,7 +924,7 @@
                     hydroInfo.Pipes.ForEach(x =>
                     {
                         var matching = matchingInfo.Pipes.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -936,7 +943,7 @@
                     hydroInfo.Translations.ForEach(x =>
                     {
                         var matching = matchingInfo.Translations.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -955,7 +962,7 @@
                     hydroInfo.Pumps.ForEach(x =>
                     {
                         var matching = matchingInfo.Pumps.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -974,7 +981,7 @@
                     hydroInfo.Valves.ForEach(x =>
                     {
                         var matching = matchingInfo.Valves.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -993,7 +1000,7 @@
                     hydroInfo.Exchangers.ForEach(x =>
                     {
                         var matching = matchingInfo.Exchangers.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -1012,7 +1019,7 @@
                     hydroInfo.Compressors.ForEach(x =>
                     {
                         var matching = matchingInfo.Compressors.Find(t => t.Code == x.Code);
-                        if (Apply(hydroInfo, x, matching))
+                        if (Apply(hydroInfo, x, matching, changeHelper, propStatusHelper))
                         {
                             result = true;
                         }
@@ -2591,9 +2598,15 @@
         /// <summary>
         /// 搴旂敤
         /// </summary>
-        public static bool Apply(HydroPumpViewModel visualViewModel, HydroPumpMatchingViewModel matching)
+        public static bool Apply
+            (
+                HydroPumpViewModel visualViewModel,
+                HydroPumpMatchingViewModel 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;
         }
@@ -2740,6 +2753,8 @@
                         }
                         hydroInfo.Curves.Add(curveqh);
                         visual.CurveQH = curveqh.Code;
+                        changeHelper?.Append(curveqh, eChangeType.Add);
+                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQH), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                         result = true;
                     }
                     else
@@ -2748,6 +2763,8 @@
                         {
                             curveqh.DbId = matching.MatchingCurveDbId;
                             curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                            changeHelper?.Append(curveqh, eChangeType.Update);
+                            propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQH), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                             result = true;
                         }
                     }
@@ -2771,6 +2788,8 @@
                         }
                         hydroInfo.Curves.Add(curveqp);
                         visual.CurveQP = curveqp.Code;
+                        changeHelper?.Append(curveqp, eChangeType.Add);
+                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQP), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                         result = true;
                     }
                     else
@@ -2779,6 +2798,8 @@
                         {
                             curveqp.DbId = matching.MatchingCurveDbId;
                             curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                            changeHelper?.Append(curveqp, eChangeType.Update);
+                            propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQP), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                             result = true;
                         }
                     }
@@ -2802,6 +2823,8 @@
                         }
                         hydroInfo.Curves.Add(curveqe);
                         visual.CurveQE = curveqe.Code;
+                        changeHelper?.Append(curveqe, eChangeType.Add);
+                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQE), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                         result = true;
                     }
                     else
@@ -2810,7 +2833,42 @@
                         {
                             curveqe.DbId = matching.MatchingCurveDbId;
                             curveqe.CurveData = matching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                            changeHelper?.Append(curveqe, eChangeType.Update);
+                            propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQE), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                             result = true;
+                        }
+                    }
+                }
+                else
+                {
+                    if (!string.IsNullOrEmpty(visual.CurveQH))
+                    {
+                        var curveQH = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQH);
+                        if (curveQH != null)
+                        {
+                            hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQH);
+                            visual.CurveQH = string.Empty;
+                            changeHelper?.Append(curveQH, eChangeType.Remove);
+                        }
+                    }
+                    if (!string.IsNullOrEmpty(visual.CurveQP))
+                    {
+                        var curveQP = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQP);
+                        if (curveQP != null)
+                        {
+                            hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQP);
+                            visual.CurveQP = string.Empty;
+                            changeHelper?.Append(curveQP, eChangeType.Remove);
+                        }
+                    }
+                    if (!string.IsNullOrEmpty(visual.CurveQE))
+                    {
+                        var curveQE = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQE);
+                        if (curveQE != null)
+                        {
+                            hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQE);
+                            visual.CurveQE = string.Empty;
+                            changeHelper?.Append(curveQE, eChangeType.Remove);
                         }
                     }
                 }
@@ -2826,9 +2884,15 @@
         /// <summary>
         /// 搴旂敤
         /// </summary>
-        public static bool Apply(HydroValveViewModel visualViewModel, HydroValveMatchingViewModel matching)
+        public static bool Apply
+            (
+                HydroValveViewModel visualViewModel,
+                HydroValveMatchingViewModel 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;
         }
@@ -2836,7 +2900,14 @@
         /// <summary>
         /// 搴旂敤
         /// </summary>
-        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroValveInfo visual, HydroValveMatchingViewModel matching)
+        public static bool Apply
+            (
+                Yw.Model.HydroModelInfo hydroInfo,
+                Yw.Model.HydroValveInfo visual,
+                HydroValveMatchingViewModel matching,
+                HydroChangeHelper changeHelper = null,
+                HydroPropStatusHelper propStatusHelper = null
+            )
         {
             if (hydroInfo == null)
             {
@@ -2851,15 +2922,15 @@
                 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.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.ValveType);
-            visual.ValveSetting = matching.ValveSetting;
+            // 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.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.ValveType);
+            //visual.ValveSetting = matching.ValveSetting;
 
             bool result = false;
 
@@ -2867,32 +2938,63 @@
             {
                 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;
                 }
                 if (matching.MatchingValveType.HasValue)
                 {
-                    visual.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.MatchingValveType.Value);
+                    var valveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.MatchingValveType.Value);
+                    if (visual.ValveType != valveType)
+                    {
+                        changeHelper?.Append(visual, eChangeType.Update);
+                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ValveType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
+                    }
+                    visual.ValveType = valveType;
                     result = true;
                 }
                 switch (visual.ValveType)
@@ -3026,9 +3128,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;
         }
@@ -3036,7 +3144,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)
             {
@@ -3050,39 +3165,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;
                 }
@@ -3107,6 +3247,8 @@
                         }
                         hydroInfo.Curves.Add(curvevql);
                         visual.CurveQL = curvevql.Code;
+                        changeHelper?.Append(curvevql, eChangeType.Add);
+                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                         result = true;
                     }
                     else
@@ -3115,7 +3257,22 @@
                         {
                             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);
+                            propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                             result = true;
+                        }
+                    }
+                }
+                else
+                {
+                    if (!string.IsNullOrEmpty(visual.CurveQL))
+                    {
+                        var curveql = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQL);
+                        if (curveql != null)
+                        {
+                            hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQL);
+                            visual.CurveQL = string.Empty;
+                            changeHelper?.Append(curveql, eChangeType.Remove);
                         }
                     }
                 }
@@ -3130,9 +3287,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;
         }
@@ -3140,7 +3303,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)
             {
@@ -3154,39 +3324,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;
                 }
@@ -3211,6 +3406,8 @@
                         }
                         hydroInfo.Curves.Add(curvevql);
                         visual.CurveQL = curvevql.Code;
+                        changeHelper?.Append(curvevql, eChangeType.Add);
+                        propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                         result = true;
                     }
                     else
@@ -3219,10 +3416,25 @@
                         {
                             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);
+                            propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveQL), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}閫氳繃浜у搧閰嶇疆鍖归厤淇敼");
                             result = true;
                         }
                     }
                 }
+                else
+                {
+                    if (!string.IsNullOrEmpty(visual.CurveQL))
+                    {
+                        var curveql = hydroInfo?.Curves?.Find(x => x.Code == visual.CurveQL);
+                        if (curveql != null)
+                        {
+                            hydroInfo.Curves?.RemoveAll(x => x.Code == visual.CurveQL);
+                            visual.CurveQL = string.Empty;
+                            changeHelper?.Append(curveql, eChangeType.Remove);
+                        }
+                    }
+                }
             }
             return result;
         }

--
Gitblit v1.9.3