lixiaojun
2024-12-17 39b6a686ab59135e63a44ab206fd8ca361878f91
WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingHelper.cs
@@ -4,7 +4,7 @@
{
    public class AssetsMatchingHelper
    {
        private readonly Lazy<BLL.XhsPumpMainPhartMappingExtensions> _bll_ex = new();
        private readonly Lazy<BLL.PhartDiagramRelation> _bll_ex = new();
        private const double _caliberTolerance = 10.0;
        private const double _speedTolerance = 100;
        private const double _flowTolerance = 10;
@@ -261,14 +261,14 @@
                InputModel.MatchingRatedP = vmo.RatedPower;
                InputModel.MatchingDbId = vmo.ID.ToString();
                InputModel.MatchingModelType = vmo.Name;
                var list = Task.Run(async () => await new BLL.XhsPumpMainPhartMappingExtensions().GetByPumpMainID(vmo.ID)).Result;
                var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.PumpMain, vmo.ID)).Result;
                if (list != null && list.Count > 0)
                {
                    var maxImportanceItem = list.OrderByDescending(x => x.Importance).First();
                    InputModel.MatchingCurveDbId = maxImportanceItem.ID.ToString();
                    var graph_qh = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH);
                    var graph_qe = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQE);
                    var graph_qp = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQP);
                    var graph_qh = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QH);
                    var graph_qe = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QE);
                    var graph_qp = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QP);
                    if (graph_qh != null)
                    {
                        var points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 100, null);
@@ -305,6 +305,7 @@
        //阀门匹配
        public static bool MatchingValve(HydroValveMatchingViewModel input, List<Vmo.AssetsValveMainVmo> valveMainVmos)
        {
            bool isNotarize = false; //是否确定
            if (valveMainVmos == null)
            {
                return true;
@@ -344,6 +345,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -351,6 +354,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -374,6 +379,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -381,31 +388,72 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingDiameter = vmo.Caliber;
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                input.MatchingValveSetting = vmo.ValveSetting;
                input.MatchingValveType = (eValveType?)(int)vmo.ValveType;
                if (vmo.ValveType == HStation.Assets.eValveType.GPV)
                if (!isNotarize)
                {
                    var curveList = Task.Run(async () => await new BLL.AssetsValveCoefficient().GetByMainID(vmo.ID)).Result;
                    if (curveList != null && curveList.Count > 0)
                    if (input.CurveDbId == null)
                    {
                        input.MatchingCurveDbId = curveList.First().ID.ToString();
                        var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                        input.MatchingCurveQL = pt_list;
                        if ((int)input.ValveType == (int)HStation.Assets.eValveType.GPV)
                        {
                            var curveList = Task.Run(async () => await new BLL.AssetsValveCoefficient().GetByMainID(vmo.ID)).Result;
                            if (curveList != null && curveList.Count > 0)
                            {
                                input.MatchingCurveDbId = curveList.First().ID.ToString();
                                var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                                input.MatchingCurveQL = pt_list;
                            }
                        }
                        else if ((int)vmo.ValveType == (int)HStation.Assets.eValveType.TCV)
                        {
                            var curveList = Task.Run(async () => await new BLL.AssetsValveCoefficient().GetByMainID(vmo.ID)).Result;
                            if (curveList != null && curveList.Count > 0)
                            {
                                input.MatchingCurveDbId = curveList.First().ID.ToString();
                                var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().OpenLossCurve);
                                input.MatchingCurveOL = pt_list;
                            }
                        }
                    }
                    if (input.MinorLoss < 0)
                    {
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    }
                    if (!input.MatchingDiameter.HasValue)
                        input.MatchingDiameter = vmo.Caliber;
                    if (input.ValveSetting == null)
                        input.MatchingValveSetting = vmo.ValveSetting;
                    if (input.DbId == null)
                    {
                        input.MatchingDbId = vmo.ID.ToString();
                    }
                }
                else if (vmo.ValveType == HStation.Assets.eValveType.TCV)
                else
                {
                    var curveList = Task.Run(async () => await new BLL.AssetsValveCoefficient().GetByMainID(vmo.ID)).Result;
                    if (curveList != null && curveList.Count > 0)
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingDiameter = vmo.Caliber;
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                    input.MatchingValveSetting = vmo.ValveSetting;
                    input.MatchingValveType = (eValveType?)(int)vmo.ValveType;
                    if (vmo.ValveType == HStation.Assets.eValveType.GPV)
                    {
                        input.MatchingCurveDbId = curveList.First().ID.ToString();
                        var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().OpenLossCurve);
                        input.MatchingCurveOL = pt_list;
                        var curveList = Task.Run(async () => await new BLL.AssetsValveCoefficient().GetByMainID(vmo.ID)).Result;
                        if (curveList != null && curveList.Count > 0)
                        {
                            input.MatchingCurveDbId = curveList.First().ID.ToString();
                            var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                            input.MatchingCurveQL = pt_list;
                        }
                    }
                    else if (vmo.ValveType == HStation.Assets.eValveType.TCV)
                    {
                        var curveList = Task.Run(async () => await new BLL.AssetsValveCoefficient().GetByMainID(vmo.ID)).Result;
                        if (curveList != null && curveList.Count > 0)
                        {
                            input.MatchingCurveDbId = curveList.First().ID.ToString();
                            var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().OpenLossCurve);
                            input.MatchingCurveOL = pt_list;
                        }
                    }
                }
                return true;
@@ -416,6 +464,7 @@
        //管道匹配
        public static bool MatchingPipe(HydroPipeMatchingViewModel input, List<Vmo.AssetsPipeMainVmo> pipeLineMainVmos)
        {
            bool isNotarize = false; //是否确定
            if (pipeLineMainVmos == null)
            {
                return true;
@@ -451,6 +500,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -458,6 +509,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -481,6 +534,7 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -488,28 +542,58 @@
            }
            if (vmo != null)
            {
                switch (input.eAlgorithmType)
                if (!isNotarize)
                {
                    case eAlgorithmType.Hazen:
                        input.MatchingRoughness = vmo.Hazen;
                        break;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.Material == null)
                        input.MatchingMaterial = vmo.Material;
                    if (input.MinorLoss < 0)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    switch (input.eAlgorithmType)
                    {
                        case eAlgorithmType.Hazen:
                            input.MatchingRoughness = vmo.Hazen;
                            break;
                    case eAlgorithmType.Manning:
                        input.MatchingRoughness = vmo.Manning;
                        break;
                        case eAlgorithmType.Manning:
                            input.MatchingRoughness = vmo.Manning;
                            break;
                    case eAlgorithmType.Darcy:
                        input.MatchingRoughness = vmo.Darcy;
                        break;
                        case eAlgorithmType.Darcy:
                            input.MatchingRoughness = vmo.Darcy;
                            break;
                    default:
                        input.MatchingRoughness = vmo.Hazen;
                        break;
                        default:
                            input.MatchingRoughness = vmo.Hazen;
                            break;
                    }
                }
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                input.MatchingMinorLoss = vmo.MinorLoss;
                else
                {
                    switch (input.eAlgorithmType)
                    {
                        case eAlgorithmType.Hazen:
                            input.MatchingRoughness = vmo.Hazen;
                            break;
                        case eAlgorithmType.Manning:
                            input.MatchingRoughness = vmo.Manning;
                            break;
                        case eAlgorithmType.Darcy:
                            input.MatchingRoughness = vmo.Darcy;
                            break;
                        default:
                            input.MatchingRoughness = vmo.Hazen;
                            break;
                    }
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                    input.MatchingMinorLoss = vmo.MinorLoss;
                }
                return true;
            }
            return false;
@@ -518,6 +602,7 @@
        //弯头匹配
        public static bool MatchingElbow(HydroElbowMatchingViewModel input, List<Vmo.AssetsElbowMainVmo> elbowMainVmos)
        {
            bool isNotarize = false; //是否确定
            if (elbowMainVmos == null || input == null || elbowMainVmos.Count == 0)
            {
                return true;
@@ -552,6 +637,7 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -559,6 +645,7 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -582,6 +669,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -589,12 +678,42 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                input.MatchingElbowType = (eElbowType?)(int)vmo.ElbowType;
                input.MatchingBendingAngle = vmo.Angle;
                if (!isNotarize)
                {
                    if (!input.MinorLoss.HasValue)
                    {
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    }
                    if (input.DbId == null)
                    {
                        input.MatchingDbId = vmo.ID.ToString();
                    }
                    if (input.Material == null)
                    {
                        input.MatchingMaterial = vmo.Material;
                    }
                    if (input.ModelType == null)
                    {
                        input.MatchingModelType = vmo.Material;
                    }
                    if (!input.ElbowType.HasValue)
                    {
                        input.MatchingElbowType = (eElbowType?)(int)vmo.ElbowType;
                    }
                    if (!input.BendingAngle.HasValue)
                    {
                        input.MatchingBendingAngle = vmo.Angle;
                    }
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                    input.MatchingElbowType = (eElbowType?)(int)vmo.ElbowType;
                    input.MatchingBendingAngle = vmo.Angle;
                }
                return true;
            }
            return false;
@@ -603,6 +722,7 @@
        //三通匹配
        public static bool MatchingThreelink(HydroThreelinkMatchingViewModel input, List<Vmo.AssetsThreelinkMainVmo> threelinkVmos)
        {
            bool isNotarize = false; //是否确定
            Vmo.AssetsThreelinkMainVmo vmo = null;
            if (threelinkVmos == null || input == null || threelinkVmos.Count == 0)
            {
@@ -637,6 +757,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -644,6 +766,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -667,6 +791,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -674,12 +800,26 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                input.MatchingRunningThroughLoss = vmo.RunThroughMinorLoss;
                input.MatchingBranchThroughLoss = vmo.BranchThroughMinorLoss;
                if (!isNotarize)
                {
                    if (!input.MinorLoss.HasValue)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (!input.RunningThroughLoss.HasValue)
                        input.MatchingRunningThroughLoss = vmo.RunThroughMinorLoss;
                    if (!input.MatchingBranchThroughLoss.HasValue)
                        input.MatchingRunningThroughLoss = vmo.BranchThroughMinorLoss;
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                    input.MatchingRunningThroughLoss = vmo.RunThroughMinorLoss;
                    input.MatchingBranchThroughLoss = vmo.BranchThroughMinorLoss;
                }
                return true;
            }
            return false;
@@ -688,6 +828,7 @@
        //四通匹配
        public static bool MatchingFourlink(HydroFourlinkMatchingViewModel input, List<Vmo.AssetsFourlinkMainVmo> fourLinkVmos)
        {
            bool isNotarize = false; //是否确定
            if (fourLinkVmos == null || input == null || fourLinkVmos.Count == 0)
            {
                return true;
@@ -722,6 +863,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -729,6 +872,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -752,6 +897,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -759,10 +906,24 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                if (!isNotarize)
                {
                    if (!input.MinorLoss.HasValue)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.Material == null)
                        input.MatchingMaterial = vmo.Material;
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                }
                return true;
            }
            return false;
@@ -771,6 +932,7 @@
        //喷头匹配
        public static bool MatchingSprinkler(HydroNozzleMatchingViewModel input, List<Vmo.AssetsSprinklerMainVmo> sprinklerVmos)
        {
            bool isNotarize = false; //是否确定
            if (sprinklerVmos == null || input == null || sprinklerVmos.Count == 0)
            {
                return true;
@@ -805,6 +967,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -812,6 +976,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -835,6 +1001,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -842,10 +1010,24 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                if (!isNotarize)
                {
                    if (!input.MinorLoss.HasValue)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.Material == null)
                        input.MatchingMaterial = vmo.Material;
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                }
                return true;
            }
            return false;
@@ -854,6 +1036,8 @@
        //换热器匹配
        public static bool MatchingExchanger(HydroExchangerMatchingViewModel input, List<Vmo.AssetsExchangerMainVmo> exchangerVmos)
        {
            bool isNotarize = false; //是否确定
            if (exchangerVmos == null || input == null || exchangerVmos.Count == 0)
            {
                return true;
@@ -887,6 +1071,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -894,6 +1080,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -916,6 +1104,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -923,16 +1113,40 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                var curveList = Task.Run(async () => await new BLL.AssetsCompressorCoefficient().GetByMainID(vmo.ID)).Result;
                if (curveList != null && curveList.Count > 0)
                if (!isNotarize)
                {
                    input.MatchingCurveDbId = curveList.First().ID.ToString();
                    var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                    input.MatchingCurveQL = pt_list;
                    if (input.MinorLoss < 0)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.Material == null)
                        input.MatchingMaterial = vmo.Material;
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                    if (input.CurveDbId == null)
                    {
                        var curveList = Task.Run(async () => await new BLL.AssetsExchangerCoefficient().GetByMainID(vmo.ID)).Result;
                        if (curveList != null && curveList.Count > 0)
                        {
                            input.MatchingCurveDbId = curveList.First().ID.ToString();
                            var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                            input.MatchingCurveQL = pt_list;
                        }
                    }
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                    var curveList = Task.Run(async () => await new BLL.AssetsExchangerCoefficient().GetByMainID(vmo.ID)).Result;
                    if (curveList != null && curveList.Count > 0)
                    {
                        input.MatchingCurveDbId = curveList.First().ID.ToString();
                        var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                        input.MatchingCurveQL = pt_list;
                    }
                }
                return true;
            }
@@ -942,6 +1156,7 @@
        //空压机匹配
        public static bool MatchingCompressor(HydroCompressorMatchingViewModel input, List<Vmo.AssetsCompressorMainVmo> compressorVmos)
        {
            bool isNotarize = false; //是否确定
            if (compressorVmos == null || input == null || compressorVmos.Count == 0)
            {
                return true;
@@ -975,6 +1190,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -982,6 +1199,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -1004,6 +1223,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -1011,16 +1232,40 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                var curveList = Task.Run(async () => await new BLL.AssetsCompressorCoefficient().GetByMainID(vmo.ID)).Result;
                if (curveList != null && curveList.Count > 0)
                if (!isNotarize)
                {
                    input.MatchingCurveDbId = curveList.First().ID.ToString();
                    var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                    input.MatchingCurveQL = pt_list;
                    if (input.MinorLoss < 0)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.Material == null)
                        input.MatchingMaterial = vmo.Material;
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                    if (input.CurveDbId == null)
                    {
                        var curveList = Task.Run(async () => await new BLL.AssetsCompressorCoefficient().GetByMainID(vmo.ID)).Result;
                        if (curveList != null && curveList.Count > 0)
                        {
                            input.MatchingCurveDbId = curveList.First().ID.ToString();
                            var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                            input.MatchingCurveQL = pt_list;
                        }
                    }
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                    var curveList = Task.Run(async () => await new BLL.AssetsCompressorCoefficient().GetByMainID(vmo.ID)).Result;
                    if (curveList != null && curveList.Count > 0)
                    {
                        input.MatchingCurveDbId = curveList.First().ID.ToString();
                        var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                        input.MatchingCurveQL = pt_list;
                    }
                }
                return true;
            }
@@ -1030,6 +1275,7 @@
        //闷头匹配
        public static bool MatchingBlunthead(HydroBluntheadMatchingViewModel input, List<Vmo.AssetsBluntheadMainVmo> bluntheadVmos)
        {
            bool isNotarize = false; //是否确定
            if (bluntheadVmos == null || input == null || bluntheadVmos.Count == 0)
            {
                return true;
@@ -1064,6 +1310,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -1071,6 +1319,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -1094,6 +1344,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -1101,10 +1353,24 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                if (!isNotarize)
                {
                    if (input.MinorLoss < 0)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.Material == null)
                        input.MatchingMaterial = vmo.Material;
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                }
                return true;
            }
            return false;
@@ -1113,6 +1379,7 @@
        //水池匹配
        public static bool MatchingTank(HydroTankMatchingViewModel input, List<Vmo.AssetsTankMainVmo> tankVmos)
        {
            bool isNotarize = false; //是否确定
            if (tankVmos == null || input == null || tankVmos.Count == 0)
            {
                return true;
@@ -1141,23 +1408,49 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
                vmo = tankVmos.First();
            if (vmo != null)
            {
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingModelType = vmo.Name;
                input.MatchingDN = vmo.DN;
                input.MatchingMinLevel = vmo.MinLevel;
                input.MatchingOverFlow = vmo.OverFlow;
                var curveList = Task.Run(async () => await new BLL.AssetsTankCoefficient().GetByMainID(vmo.ID)).Result;
                if (curveList != null && curveList.Count > 0)
                if (!isNotarize)
                {
                    input.MatchingCurveDbId = curveList.First().ID.ToString();
                    var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().VolCurve);
                    input.MatchingVolCurve = pt_list;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                    if (input.DN < 0)
                        input.MatchingDN = vmo.DN;
                    if (input.MinLevel < 0)
                        input.MatchingMinLevel = vmo.MinLevel;
                    if (input.CurveDbId == null)
                    {
                        var curveList = Task.Run(async () => await new BLL.AssetsTankCoefficient().GetByMainID(vmo.ID)).Result;
                        if (curveList != null && curveList.Count > 0)
                        {
                            input.MatchingCurveDbId = curveList.First().ID.ToString();
                            var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().VolCurve);
                            input.MatchingVolCurve = pt_list;
                        }
                    }
                }
                else
                {
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingModelType = vmo.Name;
                    input.MatchingDN = vmo.DN;
                    input.MatchingMinLevel = vmo.MinLevel;
                    input.MatchingOverFlow = vmo.OverFlow;
                    var curveList = Task.Run(async () => await new BLL.AssetsTankCoefficient().GetByMainID(vmo.ID)).Result;
                    if (curveList != null && curveList.Count > 0)
                    {
                        input.MatchingCurveDbId = curveList.First().ID.ToString();
                        var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().VolCurve);
                        input.MatchingVolCurve = pt_list;
                    }
                }
                return true;
            }
@@ -1167,6 +1460,7 @@
        //水表匹配
        public static bool MatchingMeter(HydroMeterMatchingViewModel input, List<Vmo.AssetsMeterMainVmo> MeterMainVmos)
        {
            bool isNotarize = false; //是否确定
            Vmo.AssetsMeterMainVmo vmo = null;
            if (MeterMainVmos == null || input == null || MeterMainVmos.Count == 0)
            {
@@ -1194,6 +1488,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -1201,9 +1497,21 @@
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingModelType = vmo.Name;
                if (!isNotarize)
                {
                    if (input.MinorLoss < 0)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingModelType = vmo.Name;
                }
                return true;
            }
            return false;
@@ -1212,6 +1520,7 @@
        //流量计匹配
        public static bool MatchingFlowmeter(HydroFlowmeterMatchingViewModel input, List<Vmo.AssetsFlowmeterMainVmo> FlowmeterMainVmos)
        {
            bool isNotarize = false; //是否确定
            if (FlowmeterMainVmos == null || input == null || FlowmeterMainVmos.Count == 0)
            {
                return true;
@@ -1240,6 +1549,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -1248,9 +1559,21 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingModelType = vmo.Name;
                if (!isNotarize)
                {
                    if (input.MinorLoss < 0)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingModelType = vmo.Name;
                }
                return true;
            }
            return false;
@@ -1259,6 +1582,7 @@
        //消火栓匹配
        public static bool MatchingHydrant(HydroHydrantMatchingViewModel input, List<Vmo.AssetsHydrantMainVmo> hydrantVmos)
        {
            bool isNotarize = false; //是否确定
            if (hydrantVmos == null || input == null || hydrantVmos.Count == 0)
            {
                return true;
@@ -1293,6 +1617,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -1323,6 +1649,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -1330,10 +1658,22 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                if (!isNotarize)
                {
                    if (input.MinorLoss < 0)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                }
                return true;
            }
            return false;
@@ -1342,6 +1682,7 @@
        //压力表匹配
        public static bool MatchingPressmeter(HydroPressmeterMatchingViewModel input, List<Vmo.AssetsPressmeterMainVmo> pressmeterVmos)
        {
            bool isNotarize = false; //是否确定
            if (pressmeterVmos == null || input == null || pressmeterVmos.Count == 0)
            {
                return true;
@@ -1370,6 +1711,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -1378,9 +1721,21 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingModelType = vmo.Name;
                if (!isNotarize)
                {
                    if (input.MinorLoss < 0)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingModelType = vmo.Name;
                }
                return true;
            }
            return false;
@@ -1389,6 +1744,8 @@
        //过渡件匹配
        public static bool MatchingTranslation(HydroTranslationMatchingViewModel input, List<Vmo.AssetsTranslationMainVmo> translationVmos)
        {
            bool isNotarize = false; //是否确定
            if (translationVmos == null || input == null || translationVmos.Count == 0)
            {
                return true;
@@ -1422,6 +1779,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -1429,6 +1788,8 @@
            }
            else if (nameMatching.Count == 1)
            {
                isNotarize = true;
                vmo = nameMatching.First();
            }
            else
@@ -1451,6 +1812,8 @@
                }
                else if (absoluteMatching.Count == 1)
                {
                    isNotarize = true;
                    vmo = absoluteMatching.First();
                }
                else
@@ -1458,14 +1821,34 @@
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                input.MatchingDiameter = vmo.Diameter;
                input.MatchingEndDiameter = vmo.EndDiameter;
                input.MatchingStartDiameter = vmo.StartDiameter;
                input.MatchingRoughness = vmo.Roughness;
                if (!isNotarize)
                {
                    if (input.MinorLoss < 0)
                        input.MatchingMinorLoss = vmo.MinorLoss;
                    if (input.DbId == null)
                        input.MatchingDbId = vmo.ID.ToString();
                    if (input.ModelType == null)
                        input.MatchingModelType = vmo.Name;
                    if (input.Roughness < 0)
                        input.MatchingRoughness = vmo.Roughness;
                    if (input.EndDiameter < 0)
                        input.MatchingEndDiameter = vmo.EndDiameter;
                    if (input.StartDiameter < 0)
                        input.MatchingStartDiameter = vmo.StartDiameter;
                    if (input.Diameter < 0)
                        input.MatchingDiameter = vmo.Diameter;
                }
                else
                {
                    input.MatchingMinorLoss = vmo.MinorLoss;
                    input.MatchingDbId = vmo.ID.ToString();
                    input.MatchingMaterial = vmo.Material;
                    input.MatchingModelType = vmo.Name;
                    input.MatchingDiameter = vmo.Diameter;
                    input.MatchingEndDiameter = vmo.EndDiameter;
                    input.MatchingStartDiameter = vmo.StartDiameter;
                    input.MatchingRoughness = vmo.Roughness;
                }
                return true;
            }
            return false;