From f1efcbcf48fa6fc7dede2c5c7e91cc953b367fe0 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期四, 05 十二月 2024 09:58:02 +0800
Subject: [PATCH] 增加匹配应用方法,用于视图

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs |  930 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 497 insertions(+), 433 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs
index b62dcb2..045a8db 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs
@@ -1,4 +1,6 @@
-锘縩amespace HStation.WinFrmUI
+锘縰sing SqlSugar;
+
+namespace HStation.WinFrmUI
 {
     /// <summary>
     /// 璧勪骇鍖归厤鍙傛暟杈呭姪绫�
@@ -11,7 +13,7 @@
         /// <summary>
         /// 鍒涘缓璧勪骇鑷姩鍖归厤ViewModel
         /// </summary>
-        public static AssetsMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo)
+        public static AssetsMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultList)
         {
             if (hydroInfo == null)
             {
@@ -20,22 +22,22 @@
             var input = new AssetsMatchingViewModel();
 
             //姘存车
-            input.PumpMatchingList = hydroInfo.Pumps?.Select(x => Create(hydroInfo, x)).ToList();
+            input.PumpMatchingList = hydroInfo.Pumps?.Select(x => Create(hydroInfo, x, allCalcuResultList)).ToList();
 
             //闃�闂�
-            input.ValveMatchingList = hydroInfo.Valves?.Select(x => Create(hydroInfo, x)).ToList();
+            input.ValveMatchingList = hydroInfo.Valves?.Select(x => Create(hydroInfo, x, allCalcuResultList)).ToList();
 
             //绠¢亾
-            input.PipeMatchingList = hydroInfo.Pipes?.Select(x => Create(hydroInfo, x)).ToList();
+            input.PipeMatchingList = hydroInfo.Pipes?.Select(x => Create(hydroInfo, x, allCalcuResultList)).ToList();
 
             //寮ご
-            input.ElbowMatchingList = hydroInfo.Elbows?.Select(x => Create(hydroInfo, x)).ToList();
+            input.ElbowMatchingList = hydroInfo.Elbows?.Select(x => Create(hydroInfo, x, allCalcuResultList)).ToList();
 
             //涓夐��
-            input.ThreelinkMatchingList = hydroInfo.Threelinks?.Select(x => Create(hydroInfo, x)).ToList();
+            input.ThreelinkMatchingList = hydroInfo.Threelinks?.Select(x => Create(hydroInfo, x, allCalcuResultList)).ToList();
 
             //鍥涢��
-            input.FourlinkMatchingList = hydroInfo.Fourlinks?.Select(x => Create(hydroInfo, x)).ToList();
+            input.FourlinkMatchingList = hydroInfo.Fourlinks?.Select(x => Create(hydroInfo, x, allCalcuResultList)).ToList();
 
             return input;
         }
@@ -43,7 +45,7 @@
         /// <summary>
         /// 鍒涘缓娉佃嚜鍔ㄥ尮閰峍iewModel
         /// </summary>
-        public static PumpMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPumpInfo pumpInfo)
+        public static PumpMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPumpInfo pumpInfo, List<HydroCalcuVisualResult> allCalcuResultList)
         {
             if (hydroInfo == null)
             {
@@ -53,26 +55,13 @@
             {
                 return default;
             }
-            return new PumpMatchingViewModel()
-            {
-                ID = pumpInfo.ID,
-                Code = pumpInfo.Code,
-                Name = pumpInfo.Name,
-                DbLocked = pumpInfo.DbLocked,
-                ModelType = pumpInfo.ModelType,
-                DbId = pumpInfo.DbId,
-                CurveDbId = hydroInfo.Curves?.Find(t => t.Code == pumpInfo.CurveQH)?.DbId,
-                RatedP = pumpInfo.RatedP,
-                RatedH = pumpInfo.RatedH,
-                RatedN = pumpInfo.RatedN,
-                RatedQ = pumpInfo.RatedQ,
-            };
+            return new PumpMatchingViewModel(pumpInfo, hydroInfo, allCalcuResultList);
         }
 
         /// <summary>
         /// 鍒涘缓闃�闂ㄨ嚜鍔ㄥ尮閰峍iewModel
         /// </summary>
-        public static ValveMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroValveInfo valveInfo)
+        public static ValveMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroValveInfo valveInfo, List<HydroCalcuVisualResult> allCalcuResultList)
         {
             if (hydroInfo == null)
             {
@@ -82,25 +71,13 @@
             {
                 return default;
             }
-            return new ValveMatchingViewModel()
-            {
-                ID = valveInfo.ID,
-                Code = valveInfo.Code,
-                Name = valveInfo.Name,
-                DbLocked = valveInfo.DbLocked,
-                ModelType = valveInfo.ModelType,
-                DbId = valveInfo.DbId,
-                Diameter = valveInfo.Diameter,
-                Material = valveInfo.Material,
-                MinorLoss = valveInfo.MinorLoss,
-                ValveType = valveInfo.ValveType
-            };
+            return new ValveMatchingViewModel(valveInfo, hydroInfo, allCalcuResultList);
         }
 
         /// <summary>
         /// 鍒涘缓绠¢亾鑷姩鍖归厤ViewModel
         /// </summary>
-        public static PipeMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPipeInfo pipeInfo)
+        public static PipeMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPipeInfo pipeInfo, List<HydroCalcuVisualResult> allCalcuResultList)
         {
             if (hydroInfo == null)
             {
@@ -129,7 +106,7 @@
         /// <summary>
         /// 鍒涘缓寮ご鑷姩鍖归厤ViewModel
         /// </summary>
-        public static ElbowMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroElbowInfo elbowInfo)
+        public static ElbowMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroElbowInfo elbowInfo, List<HydroCalcuVisualResult> allCalcuResultList)
         {
             if (hydroInfo == null)
             {
@@ -156,7 +133,7 @@
         /// <summary>
         /// 鍒涘缓涓夐�氳嚜鍔ㄥ尮閰峍iewModel
         /// </summary>
-        public static ThreelinkMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroThreelinkInfo threelinkInfo)
+        public static ThreelinkMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroThreelinkInfo threelinkInfo, List<HydroCalcuVisualResult> allCalcuResultList)
         {
             if (hydroInfo == null)
             {
@@ -183,7 +160,7 @@
         /// <summary>
         /// 鍒涘缓鍥涢�氳嚜鍔ㄥ尮閰峍iewModel
         /// </summary>
-        public static FourlinkMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroFourlinkInfo fourlinkInfo)
+        public static FourlinkMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroFourlinkInfo fourlinkInfo, List<HydroCalcuVisualResult> allCalcuResultList)
         {
             if (hydroInfo == null)
             {
@@ -209,6 +186,8 @@
 
         #endregion
 
+        #region 搴旂敤
+
         /// <summary>
         /// 搴旂敤璧勪骇鑷姩鍖归厤ViewModel
         /// </summary>
@@ -226,389 +205,58 @@
             bool result = false;
 
             //姘存车
-            if (output.PumpMatchingList != null && output.PumpMatchingList.Count > 0)
+            output.PumpMatchingList?.ForEach(x =>
             {
-                if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
+                if (Apply(hydroInfo, x))
                 {
-                    foreach (var pumpMatching in output.PumpMatchingList)
-                    {
-                        var pump = hydroInfo.Pumps.Find(x => x.Code == pumpMatching.Code);
-                        if (pump != null)
-                        {
-                            pump.DbLocked = pumpMatching.DbLocked;
-                            pump.ModelType = pumpMatching.ModelType;
-                            pump.RatedP = pumpMatching.RatedP;
-                            pump.RatedQ = pumpMatching.RatedQ;
-                            pump.RatedH = pumpMatching.RatedH;
-                            pump.RatedN = pumpMatching.RatedN;
-
-                            if (!pump.DbLocked)
-                            {
-                                if (!string.IsNullOrEmpty(pumpMatching.MatchingModelType))
-                                {
-                                    pump.ModelType = pumpMatching.MatchingModelType;
-                                }
-                                if (!string.IsNullOrEmpty(pumpMatching.MatchingDbId))
-                                {
-                                    pump.DbId = pumpMatching.MatchingDbId;
-                                }
-                                if (pumpMatching.MatchingRatedP.HasValue)
-                                {
-                                    pump.RatedP = pumpMatching.MatchingRatedP.Value;
-                                }
-                                if (pumpMatching.MatchingRatedQ.HasValue)
-                                {
-                                    pump.RatedQ = pumpMatching.MatchingRatedQ.Value;
-                                }
-                                if (pumpMatching.MatchingRatedH.HasValue)
-                                {
-                                    pump.RatedH = pumpMatching.MatchingRatedH.Value;
-                                }
-                                if (pumpMatching.MatchingRatedN.HasValue)
-                                {
-                                    pump.RatedN = pumpMatching.MatchingRatedN.Value;
-                                }
-
-                                if (!string.IsNullOrEmpty(pumpMatching.MatchingCurveDbId))
-                                {
-                                    //娴侀噺鎵▼鏇茬嚎
-                                    var curveqh = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQH);
-                                    if (curveqh == null)
-                                    {
-                                        curveqh = new Yw.Model.HydroCurveInfo();
-                                        curveqh.Catalog = Yw.Hydro.ParterCatalog.Curve;
-                                        curveqh.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", GetAllCodeList(hydroInfo));
-                                        curveqh.Name = "鍖归厤";
-                                        curveqh.ModelType = string.Empty;
-                                        curveqh.DbLocked = false;
-                                        curveqh.DbId = pumpMatching.MatchingCurveDbId;
-                                        curveqh.CurveType = Yw.WinFrmUI.HydroCurve.PumpQH;
-                                        curveqh.CurveData = pumpMatching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
-                                        if (hydroInfo.Curves == null)
-                                        {
-                                            hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
-                                        }
-                                        hydroInfo.Curves.Add(curveqh);
-                                        pump.CurveQH = curveqh.Code;
-                                    }
-                                    else
-                                    {
-                                        if (!curveqh.DbLocked)
-                                        {
-                                            curveqh.DbId = pumpMatching.MatchingDbId;
-                                            curveqh.CurveData = pumpMatching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
-                                        }
-                                    }
-
-                                    //娴侀噺鍔熺巼鏇茬嚎
-                                    var curveqp = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQP);
-                                    if (curveqp == null)
-                                    {
-                                        curveqp = new Yw.Model.HydroCurveInfo();
-                                        curveqp.Catalog = Yw.Hydro.ParterCatalog.Curve;
-                                        curveqp.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", GetAllCodeList(hydroInfo));
-                                        curveqp.Name = "鍖归厤";
-                                        curveqp.ModelType = string.Empty;
-                                        curveqp.DbLocked = false;
-                                        curveqp.DbId = pumpMatching.MatchingCurveDbId;
-                                        curveqp.CurveType = Yw.WinFrmUI.HydroCurve.PumpQP;
-                                        curveqp.CurveData = pumpMatching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
-                                        if (hydroInfo.Curves == null)
-                                        {
-                                            hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
-                                        }
-                                        hydroInfo.Curves.Add(curveqp);
-                                        pump.CurveQP = curveqp.Code;
-                                    }
-                                    else
-                                    {
-                                        if (!curveqp.DbLocked)
-                                        {
-                                            curveqp.DbId = pumpMatching.MatchingDbId;
-                                            curveqp.CurveData = pumpMatching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
-                                        }
-                                    }
-
-                                    //娴侀噺鏁堢巼鏇茬嚎
-                                    var curveqe = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQE);
-                                    if (curveqe == null)
-                                    {
-                                        curveqe = new Yw.Model.HydroCurveInfo();
-                                        curveqe.Catalog = Yw.Hydro.ParterCatalog.Curve;
-                                        curveqe.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", GetAllCodeList(hydroInfo));
-                                        curveqe.Name = "鍖归厤";
-                                        curveqe.ModelType = string.Empty;
-                                        curveqe.DbLocked = false;
-                                        curveqe.DbId = pumpMatching.MatchingCurveDbId;
-                                        curveqe.CurveType = Yw.WinFrmUI.HydroCurve.PumpQE;
-                                        curveqe.CurveData = pumpMatching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
-                                        if (hydroInfo.Curves == null)
-                                        {
-                                            hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
-                                        }
-                                        hydroInfo.Curves.Add(curveqe);
-                                        pump.CurveQE = curveqe.Code;
-                                    }
-                                    else
-                                    {
-                                        if (!curveqe.DbLocked)
-                                        {
-                                            curveqe.DbId = pumpMatching.MatchingDbId;
-                                            curveqe.CurveData = pumpMatching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
-                                        }
-                                    }
-
-                                }
-                                result = true;
-                            }
-                        }
-                    }
+                    result = true;
                 }
-            }
+            });
 
             //闃�闂�
-            if (output.ValveMatchingList != null && output.PumpMatchingList.Count > 0)
+            output.ValveMatchingList?.ForEach(x =>
             {
-                if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0)
+                if (Apply(hydroInfo, x))
                 {
-                    foreach (var valveMatching in output.ValveMatchingList)
-                    {
-                        var valve = hydroInfo.Valves.Find(x => x.Code == valveMatching.Code);
-                        if (valve != null)
-                        {
-                            valve.DbLocked = valveMatching.DbLocked;
-                            valve.ModelType = valveMatching.ModelType;
-                            valve.Diameter = valveMatching.Diameter;
-                            valve.Material = valveMatching.Material;
-                            valve.MinorLoss = valveMatching.MinorLoss;
-                            valve.ValveType = valveMatching.ValveType;
-                            valve.ValveSetting = valveMatching.ValveSetting;
-
-                            if (!valve.DbLocked)
-                            {
-                                if (!string.IsNullOrEmpty(valveMatching.MatchingModelType))
-                                {
-                                    valve.ModelType = valveMatching.MatchingModelType;
-                                }
-                                if (!string.IsNullOrEmpty(valveMatching.MatchingDbId))
-                                {
-                                    valve.DbId = valveMatching.MatchingDbId;
-                                }
-                                if (valveMatching.MatchingDiameter.HasValue)
-                                {
-                                    valve.Diameter = valveMatching.MatchingDiameter.Value;
-                                }
-                                if (!string.IsNullOrEmpty(valveMatching.MatchingMaterial))
-                                {
-                                    valve.Material = valveMatching.MatchingMaterial;
-                                }
-                                if (valveMatching.MatchingMinorLoss.HasValue)
-                                {
-                                    valve.MinorLoss = valveMatching.MatchingMinorLoss.Value;
-                                }
-                                if (!string.IsNullOrEmpty(valveMatching.MatchingValveType))
-                                {
-                                    valve.ValveType = valveMatching.MatchingValveType;
-                                }
-                                if (!string.IsNullOrEmpty(valveMatching.MatchingValveSetting))
-                                {
-                                    valve.ValveSetting = valveMatching.MatchingValveSetting;
-                                }
-                                result = true;
-                            }
-                        }
-                    }
+                    result = true;
                 }
-            }
+            });
 
             //绠¢亾
-            if (output.PipeMatchingList != null && output.PipeMatchingList.Count > 0)
+            output.PipeMatchingList?.ForEach(x =>
             {
-                if (hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0)
+                if (Apply(hydroInfo, x))
                 {
-                    foreach (var pipeMatching in output.PipeMatchingList)
-                    {
-                        var pipe = hydroInfo.Pipes.Find(x => x.Code == pipeMatching.Code);
-                        if (pipe != null)
-                        {
-                            pipe.DbLocked = pipeMatching.DbLocked;
-                            pipe.ModelType = pipeMatching.ModelType;
-                            pipe.Diameter = pipeMatching.Diameter;
-                            pipe.Material = pipeMatching.Material;
-                            pipe.Roughness = pipeMatching.Roughness;
-                            pipe.MinorLoss = pipeMatching.MinorLoss;
-
-                            if (!pipe.DbLocked)
-                            {
-                                if (!string.IsNullOrEmpty(pipeMatching.MatchingModelType))
-                                {
-                                    pipe.ModelType = pipeMatching.MatchingModelType;
-                                }
-                                if (!string.IsNullOrEmpty(pipeMatching.MatchingDbId))
-                                {
-                                    pipe.DbId = pipeMatching.MatchingDbId;
-                                }
-                                if (pipeMatching.MatchingDiameter.HasValue)
-                                {
-                                    pipe.Diameter = pipeMatching.MatchingDiameter.Value;
-                                }
-                                if (!string.IsNullOrEmpty(pipeMatching.MatchingMaterial))
-                                {
-                                    pipe.Material = pipeMatching.MatchingMaterial;
-                                }
-                                if (pipeMatching.MatchingRoughness.HasValue)
-                                {
-                                    pipe.Roughness = pipeMatching.MatchingRoughness.Value;
-                                }
-                                if (pipeMatching.MatchingMinorLoss.HasValue)
-                                {
-                                    pipe.MinorLoss = pipeMatching.MatchingMinorLoss.Value;
-                                }
-
-                                result = true;
-                            }
-                        }
-                    }
+                    result = true;
                 }
-            }
+            });
 
             //寮ご
-            if (output.ElbowMatchingList != null && output.ElbowMatchingList.Count > 0)
+            output.ElbowMatchingList?.ForEach(x =>
             {
-                if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0)
+                if (Apply(hydroInfo, x))
                 {
-                    foreach (var elbowsMatching in output.ElbowMatchingList)
-                    {
-                        var elbows = hydroInfo.Elbows.Find(x => x.Code == elbowsMatching.Code);
-                        if (elbows != null)
-                        {
-                            elbows.DbLocked = elbowsMatching.DbLocked;
-                            elbows.ModelType = elbowsMatching.ModelType;
-                            elbows.Caliber = elbowsMatching.Caliber;
-                            elbows.Material = elbowsMatching.Material;
-                            elbows.MinorLoss = elbowsMatching.MinorLoss;
-
-                            if (!elbows.DbLocked)
-                            {
-                                if (!string.IsNullOrEmpty(elbowsMatching.MatchingModelType))
-                                {
-                                    elbows.ModelType = elbowsMatching.MatchingModelType;
-                                }
-                                if (!string.IsNullOrEmpty(elbowsMatching.MatchingDbId))
-                                {
-                                    elbows.DbId = elbowsMatching.MatchingDbId;
-                                }
-                                if (elbowsMatching.MatchingCaliber.HasValue)
-                                {
-                                    elbows.Caliber = elbowsMatching.MatchingCaliber.Value;
-                                }
-                                if (!string.IsNullOrEmpty(elbowsMatching.MatchingMaterial))
-                                {
-                                    elbows.Material = elbowsMatching.MatchingMaterial;
-                                }
-                                if (elbowsMatching.MatchingMinorLoss.HasValue)
-                                {
-                                    elbows.MinorLoss = elbowsMatching.MatchingMinorLoss.Value;
-                                }
-
-                                result = true;
-                            }
-                        }
-                    }
+                    result = true;
                 }
-            }
+            });
 
             //涓夐��
-            if (output.ThreelinkMatchingList != null && output.ThreelinkMatchingList.Count > 0)
+            output.ThreelinkMatchingList?.ForEach(x =>
             {
-                if (hydroInfo.Threelinks != null && hydroInfo.Threelinks.Count > 0)
+                if (Apply(hydroInfo, x))
                 {
-                    foreach (var threelinkMatching in output.ThreelinkMatchingList)
-                    {
-                        var threelink = hydroInfo.Threelinks.Find(x => x.Code == threelinkMatching.Code);
-                        if (threelink != null)
-                        {
-                            threelink.DbLocked = threelinkMatching.DbLocked;
-                            threelink.ModelType = threelinkMatching.ModelType;
-                            threelink.Caliber = threelinkMatching.Caliber;
-                            threelink.Material = threelinkMatching.Material;
-                            threelink.MinorLoss = threelinkMatching.MinorLoss;
-
-                            if (!threelink.DbLocked)
-                            {
-                                if (!string.IsNullOrEmpty(threelinkMatching.MatchingModelType))
-                                {
-                                    threelink.ModelType = threelinkMatching.MatchingModelType;
-                                }
-                                if (!string.IsNullOrEmpty(threelinkMatching.MatchingDbId))
-                                {
-                                    threelink.DbId = threelinkMatching.MatchingDbId;
-                                }
-                                if (threelinkMatching.MatchingCaliber.HasValue)
-                                {
-                                    threelink.Caliber = threelinkMatching.MatchingCaliber.Value;
-                                }
-                                if (!string.IsNullOrEmpty(threelinkMatching.MatchingMaterial))
-                                {
-                                    threelink.Material = threelinkMatching.MatchingMaterial;
-                                }
-                                if (threelinkMatching.MatchingMinorLoss.HasValue)
-                                {
-                                    threelink.MinorLoss = threelinkMatching.MatchingMinorLoss.Value;
-                                }
-
-                                result = true;
-                            }
-                        }
-                    }
+                    result = true;
                 }
-            }
+            });
 
             //鍥涢��
-            if (output.FourlinkMatchingList != null && output.FourlinkMatchingList.Count > 0)
+            output.FourlinkMatchingList?.ForEach(x =>
             {
-                if (hydroInfo.Fourlinks != null && hydroInfo.Fourlinks.Count > 0)
+                if (Apply(hydroInfo, x))
                 {
-                    foreach (var fourlinkMatching in output.FourlinkMatchingList)
-                    {
-                        var fourlink = hydroInfo.Fourlinks.Find(x => x.Code == fourlinkMatching.Code);
-                        if (fourlink != null)
-                        {
-                            fourlink.DbLocked = fourlinkMatching.DbLocked;
-                            fourlink.ModelType = fourlinkMatching.ModelType;
-                            fourlink.Caliber = fourlinkMatching.Caliber;
-                            fourlink.Material = fourlinkMatching.Material;
-                            fourlink.MinorLoss = fourlinkMatching.MinorLoss;
-
-                            if (!fourlink.DbLocked)
-                            {
-                                if (!string.IsNullOrEmpty(fourlinkMatching.MatchingModelType))
-                                {
-                                    fourlink.ModelType = fourlinkMatching.MatchingModelType;
-                                }
-                                if (!string.IsNullOrEmpty(fourlinkMatching.MatchingDbId))
-                                {
-                                    fourlink.DbId = fourlinkMatching.MatchingDbId;
-                                }
-                                if (fourlinkMatching.MatchingCaliber.HasValue)
-                                {
-                                    fourlink.Caliber = fourlinkMatching.MatchingCaliber.Value;
-                                }
-                                if (!string.IsNullOrEmpty(fourlinkMatching.MatchingMaterial))
-                                {
-                                    fourlink.Material = fourlinkMatching.MatchingMaterial;
-                                }
-                                if (fourlinkMatching.MatchingMinorLoss.HasValue)
-                                {
-                                    fourlink.MinorLoss = fourlinkMatching.MatchingMinorLoss.Value;
-                                }
-
-                                result = true;
-                            }
-                        }
-                    }
+                    result = true;
                 }
-            }
+            });
 
             return result;
         }
@@ -616,57 +264,59 @@
         /// <summary>
         /// 搴旂敤娉佃嚜鍔ㄥ尮閰峍iewModel
         /// </summary>
-        public static bool ApplyPump(Yw.Model.HydroModelInfo hydroInfo, PumpMatchingViewModel pumpMatching)
+        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, PumpMatchingViewModel matching)
         {
             if (hydroInfo == null)
             {
                 return false;
             }
-            if (pumpMatching == null)
+            if (matching == null)
             {
                 return false;
             }
 
             bool result = false;
 
-            var pump = hydroInfo.Pumps?.Find(x => x.Code == pumpMatching.Code);
+            var pump = hydroInfo.Pumps?.Find(x => x.Code == matching.Code);
             if (pump != null)
             {
-                pump.DbLocked = pumpMatching.DbLocked;
-                pump.ModelType = pumpMatching.ModelType;
-                pump.RatedP = pumpMatching.RatedP;
-                pump.RatedQ = pumpMatching.RatedQ;
-                pump.RatedH = pumpMatching.RatedH;
-                pump.RatedN = pumpMatching.RatedN;
+                pump.DbLocked = matching.DbLocked;
+                pump.ModelType = matching.ModelType;
+                pump.RatedP = matching.RatedP;
+                pump.RatedQ = matching.RatedQ;
+                pump.RatedH = matching.RatedH;
+                pump.RatedN = matching.RatedN;
+                pump.RatedHz = matching.RatedHz;
+                pump.SpeedRatio = Math.Round(matching.CurrentHz / matching.RatedHz, 1);
 
                 if (!pump.DbLocked)
                 {
-                    if (!string.IsNullOrEmpty(pumpMatching.MatchingModelType))
+                    if (!string.IsNullOrEmpty(matching.MatchingModelType))
                     {
-                        pump.ModelType = pumpMatching.MatchingModelType;
+                        pump.ModelType = matching.MatchingModelType;
                     }
-                    if (!string.IsNullOrEmpty(pumpMatching.MatchingDbId))
+                    if (!string.IsNullOrEmpty(matching.MatchingDbId))
                     {
-                        pump.DbId = pumpMatching.MatchingDbId;
+                        pump.DbId = matching.MatchingDbId;
                     }
-                    if (pumpMatching.MatchingRatedP.HasValue)
+                    if (matching.MatchingRatedP.HasValue)
                     {
-                        pump.RatedP = pumpMatching.MatchingRatedP.Value;
+                        pump.RatedP = matching.MatchingRatedP.Value;
                     }
-                    if (pumpMatching.MatchingRatedQ.HasValue)
+                    if (matching.MatchingRatedQ.HasValue)
                     {
-                        pump.RatedQ = pumpMatching.MatchingRatedQ.Value;
+                        pump.RatedQ = matching.MatchingRatedQ.Value;
                     }
-                    if (pumpMatching.MatchingRatedH.HasValue)
+                    if (matching.MatchingRatedH.HasValue)
                     {
-                        pump.RatedH = pumpMatching.MatchingRatedH.Value;
+                        pump.RatedH = matching.MatchingRatedH.Value;
                     }
-                    if (pumpMatching.MatchingRatedN.HasValue)
+                    if (matching.MatchingRatedN.HasValue)
                     {
-                        pump.RatedN = pumpMatching.MatchingRatedN.Value;
+                        pump.RatedN = matching.MatchingRatedN.Value;
                     }
 
-                    if (!string.IsNullOrEmpty(pumpMatching.MatchingCurveDbId))
+                    if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
                     {
                         //娴侀噺鎵▼鏇茬嚎
                         var curveqh = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQH);
@@ -674,13 +324,13 @@
                         {
                             curveqh = new Yw.Model.HydroCurveInfo();
                             curveqh.Catalog = Yw.Hydro.ParterCatalog.Curve;
-                            curveqh.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", GetAllCodeList(hydroInfo));
+                            curveqh.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
                             curveqh.Name = "鍖归厤";
                             curveqh.ModelType = string.Empty;
                             curveqh.DbLocked = false;
-                            curveqh.DbId = pumpMatching.MatchingCurveDbId;
+                            curveqh.DbId = matching.MatchingCurveDbId;
                             curveqh.CurveType = Yw.WinFrmUI.HydroCurve.PumpQH;
-                            curveqh.CurveData = pumpMatching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                            curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
                             if (hydroInfo.Curves == null)
                             {
                                 hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
@@ -692,8 +342,8 @@
                         {
                             if (!curveqh.DbLocked)
                             {
-                                curveqh.DbId = pumpMatching.MatchingDbId;
-                                curveqh.CurveData = pumpMatching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                                curveqh.DbId = matching.MatchingCurveDbId;
+                                curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
                             }
                         }
 
@@ -703,13 +353,13 @@
                         {
                             curveqp = new Yw.Model.HydroCurveInfo();
                             curveqp.Catalog = Yw.Hydro.ParterCatalog.Curve;
-                            curveqp.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", GetAllCodeList(hydroInfo));
+                            curveqp.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
                             curveqp.Name = "鍖归厤";
                             curveqp.ModelType = string.Empty;
                             curveqp.DbLocked = false;
-                            curveqp.DbId = pumpMatching.MatchingCurveDbId;
+                            curveqp.DbId = matching.MatchingCurveDbId;
                             curveqp.CurveType = Yw.WinFrmUI.HydroCurve.PumpQP;
-                            curveqp.CurveData = pumpMatching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                            curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
                             if (hydroInfo.Curves == null)
                             {
                                 hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
@@ -721,8 +371,8 @@
                         {
                             if (!curveqp.DbLocked)
                             {
-                                curveqp.DbId = pumpMatching.MatchingDbId;
-                                curveqp.CurveData = pumpMatching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                                curveqp.DbId = matching.MatchingCurveDbId;
+                                curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
                             }
                         }
 
@@ -732,13 +382,13 @@
                         {
                             curveqe = new Yw.Model.HydroCurveInfo();
                             curveqe.Catalog = Yw.Hydro.ParterCatalog.Curve;
-                            curveqe.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", GetAllCodeList(hydroInfo));
+                            curveqe.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
                             curveqe.Name = "鍖归厤";
                             curveqe.ModelType = string.Empty;
                             curveqe.DbLocked = false;
-                            curveqe.DbId = pumpMatching.MatchingCurveDbId;
+                            curveqe.DbId = matching.MatchingCurveDbId;
                             curveqe.CurveType = Yw.WinFrmUI.HydroCurve.PumpQE;
-                            curveqe.CurveData = pumpMatching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                            curveqe.CurveData = matching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
                             if (hydroInfo.Curves == null)
                             {
                                 hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
@@ -750,12 +400,13 @@
                         {
                             if (!curveqe.DbLocked)
                             {
-                                curveqe.DbId = pumpMatching.MatchingDbId;
-                                curveqe.CurveData = pumpMatching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                                curveqe.DbId = matching.MatchingCurveDbId;
+                                curveqe.CurveData = matching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
                             }
                         }
 
                     }
+
                     result = true;
                 }
             }
@@ -763,6 +414,419 @@
             return result;
         }
 
+        /// <summary>
+        /// 搴旂敤闃�闂ㄨ嚜鍔ㄥ尮閰峍iewModel
+        /// </summary>
+        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, ValveMatchingViewModel matching)
+        {
+            if (hydroInfo == null)
+            {
+                return false;
+            }
+            if (matching == null)
+            {
+                return false;
+            }
+
+            bool result = false;
+
+            var valve = hydroInfo.Valves?.Find(x => x.Code == matching.Code);
+            if (valve != null)
+            {
+                valve.DbLocked = matching.DbLocked;
+                valve.ModelType = matching.ModelType;
+                valve.Material = matching.Material;
+                valve.Diameter = matching.Diameter;
+                valve.MinorLoss = matching.MinorLoss;
+                switch (matching.ValveType)
+                {
+                    case HStation.Assets.eValveType.PBV: valve.ValveType = Yw.Hydro.ValveType.PBV; break;
+                    case HStation.Assets.eValveType.PRV: valve.ValveType = Yw.Hydro.ValveType.PRV; break;
+                    case HStation.Assets.eValveType.PSV: valve.ValveType = Yw.Hydro.ValveType.PSV; break;
+                    case HStation.Assets.eValveType.TCV: valve.ValveType = Yw.Hydro.ValveType.TCV; break;
+                    case HStation.Assets.eValveType.FCV: valve.ValveType = Yw.Hydro.ValveType.FCV; break;
+                    case HStation.Assets.eValveType.GPV: valve.ValveType = Yw.Hydro.ValveType.GPV; break;
+                    case HStation.Assets.eValveType.CV: valve.ValveType = Yw.Hydro.ValveType.CV; break;
+                    default: break;
+                }
+                valve.ValveSetting = matching.ValveSetting;
+
+                if (!valve.DbLocked)
+                {
+                    if (!string.IsNullOrEmpty(matching.MatchingDbId))
+                    {
+                        valve.DbId = matching.MatchingDbId;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingModelType))
+                    {
+                        valve.ModelType = matching.MatchingModelType;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingMaterial))
+                    {
+                        valve.Material = matching.MatchingMaterial;
+                    }
+                    if (matching.MatchingDiameter.HasValue)
+                    {
+                        valve.Diameter = matching.MatchingDiameter.Value;
+                    }
+                    if (matching.MatchingMinorLoss.HasValue)
+                    {
+                        valve.MinorLoss = matching.MatchingMinorLoss.Value;
+                    }
+                    if (matching.MatchingValveType.HasValue)
+                    {
+                        switch (matching.MatchingValveType.Value)
+                        {
+                            case HStation.Assets.eValveType.PBV: valve.ValveType = Yw.Hydro.ValveType.PBV; break;
+                            case HStation.Assets.eValveType.PRV: valve.ValveType = Yw.Hydro.ValveType.PRV; break;
+                            case HStation.Assets.eValveType.PSV: valve.ValveType = Yw.Hydro.ValveType.PSV; break;
+                            case HStation.Assets.eValveType.TCV: valve.ValveType = Yw.Hydro.ValveType.TCV; break;
+                            case HStation.Assets.eValveType.FCV: valve.ValveType = Yw.Hydro.ValveType.FCV; break;
+                            case HStation.Assets.eValveType.GPV: valve.ValveType = Yw.Hydro.ValveType.GPV; break;
+                            case HStation.Assets.eValveType.CV: valve.ValveType = Yw.Hydro.ValveType.CV; break;
+                            default: break;
+                        }
+                    }
+                    switch (valve.ValveType)
+                    {
+                        case Yw.Hydro.ValveType.PSV:
+                            {
+                                if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
+                                {
+                                    valve.ValveSetting = matching.MatchingValveSetting;
+                                }
+                            }
+                            break;
+                        case Yw.Hydro.ValveType.PBV:
+                            {
+                                if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
+                                {
+                                    valve.ValveSetting = matching.MatchingValveSetting;
+                                }
+                            }
+                            break;
+                        case Yw.Hydro.ValveType.PRV:
+                            {
+                                if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
+                                {
+                                    valve.ValveSetting = matching.MatchingValveSetting;
+                                }
+                            }
+                            break;
+                        case Yw.Hydro.ValveType.FCV:
+                            {
+                                if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
+                                {
+                                    valve.ValveSetting = matching.MatchingValveSetting;
+                                }
+                            }
+                            break;
+                        case Yw.Hydro.ValveType.TCV:
+                            {
+                                if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
+                                {
+                                    //闃�闂ㄥ紑搴︽崯澶辩郴鏁版洸绾�
+                                    var curveol = hydroInfo.Curves?.Find(x => x.Code == valve.ValveSetting);
+                                    if (curveol == null)
+                                    {
+                                        curveol = new Yw.Model.HydroCurveInfo();
+                                        curveol.Catalog = Yw.Hydro.ParterCatalog.Curve;
+                                        curveol.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
+                                        curveol.Name = "鍖归厤";
+                                        curveol.ModelType = valve.ModelType;
+                                        curveol.DbLocked = false;
+                                        curveol.DbId = matching.MatchingCurveDbId;
+                                        curveol.CurveType = Yw.WinFrmUI.HydroCurve.ValveOL;
+                                        curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                                        if (hydroInfo.Curves == null)
+                                        {
+                                            hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
+                                        }
+                                        hydroInfo.Curves.Add(curveol);
+                                        valve.ValveSetting = curveol.Code;
+                                    }
+                                    else
+                                    {
+                                        if (!curveol.DbLocked)
+                                        {
+                                            curveol.DbId = matching.MatchingCurveDbId;
+                                            curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                                        }
+                                    }
+                                }
+                            }
+                            break;
+                        case Yw.Hydro.ValveType.GPV:
+                            {
+                                if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
+                                {
+                                    //闃�闂ㄥ紑搴︽崯澶辩郴鏁版洸绾�
+                                    var curveql = hydroInfo.Curves?.Find(x => x.Code == valve.ValveSetting);
+                                    if (curveql == null)
+                                    {
+                                        curveql = new Yw.Model.HydroCurveInfo();
+                                        curveql.Catalog = Yw.Hydro.ParterCatalog.Curve;
+                                        curveql.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
+                                        curveql.Name = "鍖归厤";
+                                        curveql.ModelType = valve.ModelType;
+                                        curveql.DbLocked = false;
+                                        curveql.DbId = matching.MatchingCurveDbId;
+                                        curveql.CurveType = Yw.WinFrmUI.HydroCurve.ValveOL;
+                                        curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                                        if (hydroInfo.Curves == null)
+                                        {
+                                            hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
+                                        }
+                                        hydroInfo.Curves.Add(curveql);
+                                        valve.ValveSetting = curveql.Code;
+                                    }
+                                    else
+                                    {
+                                        if (!curveql.DbLocked)
+                                        {
+                                            curveql.DbId = matching.MatchingCurveDbId;
+                                            curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
+                                        }
+                                    }
+                                }
+                            }
+                            break;
+                        case Yw.Hydro.ValveType.CV:
+                            {
+
+                            }
+                            break;
+                    }
+
+                    result = true;
+                }
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 搴旂敤绠¢亾鑷姩鍖归厤ViewModel
+        /// </summary>
+        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, PipeMatchingViewModel matching)
+        {
+            if (hydroInfo == null)
+            {
+                return false;
+            }
+            if (matching == null)
+            {
+                return false;
+            }
+
+            bool result = false;
+
+            var pipe = hydroInfo.Pipes?.Find(x => x.Code == matching.Code);
+            if (pipe != null)
+            {
+                pipe.DbLocked = matching.DbLocked;
+                pipe.ModelType = matching.ModelType;
+                pipe.Diameter = matching.Diameter;
+                pipe.Material = matching.Material;
+                pipe.Roughness = matching.Roughness;
+                pipe.MinorLoss = matching.MinorLoss;
+
+                if (!pipe.DbLocked)
+                {
+                    if (!string.IsNullOrEmpty(matching.MatchingModelType))
+                    {
+                        pipe.ModelType = matching.MatchingModelType;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingDbId))
+                    {
+                        pipe.DbId = matching.MatchingDbId;
+                    }
+                    if (matching.MatchingDiameter.HasValue)
+                    {
+                        pipe.Diameter = matching.MatchingDiameter.Value;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingMaterial))
+                    {
+                        pipe.Material = matching.MatchingMaterial;
+                    }
+                    if (matching.MatchingRoughness.HasValue)
+                    {
+                        pipe.Roughness = matching.MatchingRoughness.Value;
+                    }
+                    if (matching.MatchingMinorLoss.HasValue)
+                    {
+                        pipe.MinorLoss = matching.MatchingMinorLoss.Value;
+                    }
+
+                    result = true;
+                }
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 搴旂敤寮ご鑷姩鍖归厤ViewModel
+        /// </summary>
+        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, ElbowMatchingViewModel matching)
+        {
+            if (hydroInfo == null)
+            {
+                return false;
+            }
+            if (matching == null)
+            {
+                return false;
+            }
+
+            bool result = false;
+
+            var elbow = hydroInfo.Elbows?.Find(x => x.Code == matching.Code);
+            if (elbow != null)
+            {
+                elbow.DbLocked = matching.DbLocked;
+                elbow.ModelType = matching.ModelType;
+                elbow.Caliber = matching.Caliber;
+                elbow.Material = matching.Material;
+                elbow.MinorLoss = matching.MinorLoss;
+
+                if (!elbow.DbLocked)
+                {
+                    if (!string.IsNullOrEmpty(matching.MatchingModelType))
+                    {
+                        elbow.ModelType = matching.MatchingModelType;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingDbId))
+                    {
+                        elbow.DbId = matching.MatchingDbId;
+                    }
+                    if (matching.MatchingCaliber.HasValue)
+                    {
+                        elbow.Caliber = matching.MatchingCaliber.Value;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingMaterial))
+                    {
+                        elbow.Material = matching.MatchingMaterial;
+                    }
+                    if (matching.MatchingMinorLoss.HasValue)
+                    {
+                        elbow.MinorLoss = matching.MatchingMinorLoss.Value;
+                    }
+
+                    result = true;
+                }
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 搴旂敤涓夐�氳嚜鍔ㄥ尮閰峍iewModel
+        /// </summary>
+        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, ThreelinkMatchingViewModel matching)
+        {
+            if (hydroInfo == null)
+            {
+                return false;
+            }
+            if (matching == null)
+            {
+                return false;
+            }
+
+            bool result = false;
+
+            var threelink = hydroInfo.Threelinks?.Find(x => x.Code == matching.Code);
+            if (threelink != null)
+            {
+                threelink.DbLocked = matching.DbLocked;
+                threelink.ModelType = matching.ModelType;
+                threelink.Caliber = matching.Caliber;
+                threelink.Material = matching.Material;
+                threelink.MinorLoss = matching.MinorLoss;
+
+                if (!threelink.DbLocked)
+                {
+                    if (!string.IsNullOrEmpty(matching.MatchingModelType))
+                    {
+                        threelink.ModelType = matching.MatchingModelType;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingDbId))
+                    {
+                        threelink.DbId = matching.MatchingDbId;
+                    }
+                    if (matching.MatchingCaliber.HasValue)
+                    {
+                        threelink.Caliber = matching.MatchingCaliber.Value;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingMaterial))
+                    {
+                        threelink.Material = matching.MatchingMaterial;
+                    }
+                    if (matching.MatchingMinorLoss.HasValue)
+                    {
+                        threelink.MinorLoss = matching.MatchingMinorLoss.Value;
+                    }
+
+                    result = true;
+                }
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 搴旂敤鍥涢�氳嚜鍔ㄥ尮閰峍iewModel
+        /// </summary>
+        public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, FourlinkMatchingViewModel matching)
+        {
+            if (hydroInfo == null)
+            {
+                return false;
+            }
+            if (matching == null)
+            {
+                return false;
+            }
+
+            bool result = false;
+
+            var fourlink = hydroInfo.Fourlinks?.Find(x => x.Code == matching.Code);
+            if (fourlink != null)
+            {
+                fourlink.DbLocked = matching.DbLocked;
+                fourlink.ModelType = matching.ModelType;
+                fourlink.Caliber = matching.Caliber;
+                fourlink.Material = matching.Material;
+                fourlink.MinorLoss = matching.MinorLoss;
+
+                if (!fourlink.DbLocked)
+                {
+                    if (!string.IsNullOrEmpty(matching.MatchingModelType))
+                    {
+                        fourlink.ModelType = matching.MatchingModelType;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingDbId))
+                    {
+                        fourlink.DbId = matching.MatchingDbId;
+                    }
+                    if (matching.MatchingCaliber.HasValue)
+                    {
+                        fourlink.Caliber = matching.MatchingCaliber.Value;
+                    }
+                    if (!string.IsNullOrEmpty(matching.MatchingMaterial))
+                    {
+                        fourlink.Material = matching.MatchingMaterial;
+                    }
+                    if (matching.MatchingMinorLoss.HasValue)
+                    {
+                        fourlink.MinorLoss = matching.MatchingMinorLoss.Value;
+                    }
+
+                    result = true;
+                }
+            }
+            return result;
+        }
+
+        #endregion
+
         //鑾峰彇鎵�鏈夌紪鐮佸垪琛�
         private static List<string> GetAllCodeList(Yw.Model.HydroModelInfo hydroInfo)
         {

--
Gitblit v1.9.3