duheng
2024-12-22 7baac1dbfc0b1c677ef263ff037ac81c6d91f5fb
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs
@@ -1,6 +1,7 @@
using HStation.WinFrmUI.PhartRelation;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Linq;
using System.Windows.Input;
using Yw.WinFrmUI.Q3d;
namespace HStation.WinFrmUI
@@ -39,6 +40,7 @@
            var AssetsHydrantMain = new BLL.AssetsHydrantMain();
            var AssetsPressmeterMain = new BLL.AssetsPressmeterMain();
            var AssetsTranslationMain = new BLL.AssetsTranslationMain();
            var AssetsCoolingMain = new BLL.AssetsCoolingMain();
            try
            {
                var allPump = Task.Run(async () => await AssetsPumpMain.GetAll()).Result;
@@ -58,6 +60,7 @@
                var allHydrantMain = Task.Run(async () => await AssetsHydrantMain.GetAll()).Result;
                var allPressmeterMain = Task.Run(async () => await AssetsPressmeterMain.GetAll()).Result;
                var allTranslationMain = Task.Run(async () => await AssetsTranslationMain.GetAll()).Result;
                var allCoolingMain = Task.Run(async () => await AssetsCoolingMain.GetAll()).Result;
                //泵匹配
                foreach (var item in assetsAutoMatchingView.Pumps)
                {
@@ -110,6 +113,15 @@
                foreach (var item in assetsAutoMatchingView.Nozzles)
                {
                    if (MatchingSprinkler(item, allSprinkler))
                    {
                        IsMaching = true;
                    }
                }
                //喷头匹配
                foreach (var item in assetsAutoMatchingView.Coolings)
                {
                    if (Matching(item, allCoolingMain))
                    {
                        IsMaching = true;
                    }
@@ -265,41 +277,31 @@
                InputModel.MatchingDbId = vmo.ID.ToString();
                InputModel.MatchingModelType = vmo.Name;
                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.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);
                             InputModel.MatchingCurveQH = new List<HydroCurvePointViewModel>();
                             foreach (var item in points_qh)
                             {
                                 InputModel.MatchingCurveQH.Add(new HydroCurvePointViewModel(item.X, item.Y));
                             }
                         }
                         if (graph_qe != null)
                         {
                             var points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 100, null);
                             InputModel.MatchingCurveQE = new List<HydroCurvePointViewModel>();
                             foreach (var item in points_qe)
                             {
                                 InputModel.MatchingCurveQE.Add(new HydroCurvePointViewModel(item.X, item.Y));
                             }
                         }
                         if (graph_qp != null)
                         {
                             var points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 100, null);
                             InputModel.MatchingCurveQP = new List<HydroCurvePointViewModel>();
                             foreach (var item in points_qp)
                             {
                                 InputModel.MatchingCurveQP.Add(new HydroCurvePointViewModel(item.X, item.Y));
                             }
                         }
                     }*/
                if (list != null && list.Count > 0)
                {
                    var def = list.OrderByDescending(x => x.Importance).First();
                    InputModel.MatchingCurveDbId = def.ID.ToString();
                    var diagram = def.Diagram.GetDefaultVmo();
                    var qh = diagram.QH.GetFeatPointList();
                    var qp = diagram.QP.GetFeatPointList();
                    var qe = diagram.QE.GetFeatPointList();
                    InputModel.MatchingCurveQH = new List<HydroCurvePointViewModel>();
                    InputModel.MatchingCurveQP = new List<HydroCurvePointViewModel>();
                    InputModel.MatchingCurveQE = new List<HydroCurvePointViewModel>();
                    foreach (var item in qh)
                    {
                        InputModel.MatchingCurveQH.Add(new HydroCurvePointViewModel(item.X, item.Y));
                    }
                    foreach (var item in qp)
                    {
                        InputModel.MatchingCurveQP.Add(new HydroCurvePointViewModel(item.X, item.Y));
                    }
                    foreach (var item in qe)
                    {
                        InputModel.MatchingCurveQE.Add(new HydroCurvePointViewModel(item.X, item.Y));
                    }
                }
                return true;
            }
            return false;
@@ -395,24 +397,27 @@
                {
                    if (input.CurveDbId == null)
                    {
                        if ((int)input.ValveType == (int)HStation.Assets.eValveType.GPV)
                        var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result;
                        if (list != null && list.Count > 0)
                        {
                            var curveList = Task.Run(async () => await new BLL.AssetsValveFactor().GetByMainID(vmo.ID)).Result;
                            if (curveList != null && curveList.Count > 0)
                            var def = list.OrderByDescending(x => x.Importance).First();
                            input.MatchingCurveDbId = def.ID.ToString();
                            var curve = def.Diagram.GraphList[0].GetFeatPointList();
                            if (vmo.ValveType == HStation.Assets.eValveType.GPV)
                            {
                                input.MatchingCurveDbId = curveList.First().ID.ToString();
                                var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                                input.MatchingCurveQL = pt_list;
                                input.MatchingCurveQL = new List<HydroCurvePointViewModel>();
                                foreach (var item in curve)
                                {
                                    input.MatchingCurveQL.Add(new HydroCurvePointViewModel(item.X, item.Y));
                                }
                            }
                        }
                        else if ((int)vmo.ValveType == (int)HStation.Assets.eValveType.TCV)
                        {
                            var curveList = Task.Run(async () => await new BLL.AssetsValveFactor().GetByMainID(vmo.ID)).Result;
                            if (curveList != null && curveList.Count > 0)
                            else if (vmo.ValveType == HStation.Assets.eValveType.TCV)
                            {
                                input.MatchingCurveDbId = curveList.First().ID.ToString();
                                var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().OpenLossCurve);
                                input.MatchingCurveOL = pt_list;
                                input.MatchingCurveOL = new List<HydroCurvePointViewModel>();
                                foreach (var item in curve)
                                {
                                    input.MatchingCurveOL.Add(new HydroCurvePointViewModel(item.X, item.Y));
                                }
                            }
                        }
                    }
@@ -438,24 +443,27 @@
                    input.MatchingModelType = vmo.Name;
                    input.MatchingValveSetting = vmo.ValveSetting;
                    input.MatchingValveType = (eValveType?)(int)vmo.ValveType;
                    if (vmo.ValveType == HStation.Assets.eValveType.GPV)
                    var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result;
                    if (list != null && list.Count > 0)
                    {
                        var curveList = Task.Run(async () => await new BLL.AssetsValveFactor().GetByMainID(vmo.ID)).Result;
                        if (curveList != null && curveList.Count > 0)
                        var def = list.OrderByDescending(x => x.Importance).First();
                        input.MatchingCurveDbId = def.ID.ToString();
                        var curve = def.Diagram.GraphList[0].GetFeatPointList();
                        if (vmo.ValveType == HStation.Assets.eValveType.GPV)
                        {
                            input.MatchingCurveDbId = curveList.First().ID.ToString();
                            var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().MinorLossCurve);
                            input.MatchingCurveQL = pt_list;
                            input.MatchingCurveQL = new List<HydroCurvePointViewModel>();
                            foreach (var item in curve)
                            {
                                input.MatchingCurveQL.Add(new HydroCurvePointViewModel(item.X, item.Y));
                            }
                        }
                    }
                    else if (vmo.ValveType == HStation.Assets.eValveType.TCV)
                    {
                        var curveList = Task.Run(async () => await new BLL.AssetsValveFactor().GetByMainID(vmo.ID)).Result;
                        if (curveList != null && curveList.Count > 0)
                        else if (vmo.ValveType == HStation.Assets.eValveType.TCV)
                        {
                            input.MatchingCurveDbId = curveList.First().ID.ToString();
                            var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().OpenLossCurve);
                            input.MatchingCurveOL = pt_list;
                            input.MatchingCurveOL = new List<HydroCurvePointViewModel>();
                            foreach (var item in curve)
                            {
                                input.MatchingCurveOL.Add(new HydroCurvePointViewModel(item.X, item.Y));
                            }
                        }
                    }
                }
@@ -1428,12 +1436,12 @@
            }
            Vmo.AssetsTankMainVmo vmo = null;
            var nameMatching = tankVmos.Where(x =>
    (x.KeyWord != null && x.KeyWord.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
    (x.KeyWord == null || !x.KeyWord.Any()) && GetIntersect(x.Name, input.ModelType) >= 1
    (x.KeyWords != null && x.KeyWords.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
    (x.KeyWords == null || !x.KeyWords.Any()) && GetIntersect(x.Name, input.ModelType) >= 1
    ) //先进行筛选,后进行从大到小排序
    .OrderByDescending(x =>
     (x.KeyWord != null && x.KeyWord.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
     (x.KeyWord == null || !x.KeyWord.Any()) && GetIntersect(x.Name, input.ModelType) >= 1).ToList();
     (x.KeyWords != null && x.KeyWords.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
     (x.KeyWords == null || !x.KeyWords.Any()) && GetIntersect(x.Name, input.ModelType) >= 1).ToList();
            if (nameMatching.Count > 1)
            {
@@ -1470,12 +1478,17 @@
                        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)
                        var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result;
                        if (list != null && list.Count > 0)
                        {
                            input.MatchingCurveDbId = curveList.First().ID.ToString();
                            var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().VolCurve);
                            input.MatchingVolCurve = pt_list;
                            var def = list.OrderByDescending(x => x.Importance).First();
                            input.MatchingCurveDbId = def.ID.ToString();
                            var curve = def.Diagram.GraphList[0].GetFeatPointList();
                            input.MatchingVolCurve = new List<HydroCurvePointViewModel>();
                            foreach (var item in curve)
                            {
                                input.MatchingVolCurve.Add(new HydroCurvePointViewModel(item.X, item.Y));
                            }
                        }
                    }
                }
@@ -1486,12 +1499,17 @@
                    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)
                    var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result;
                    if (list != null && list.Count > 0)
                    {
                        input.MatchingCurveDbId = curveList.First().ID.ToString();
                        var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(curveList.First().VolCurve);
                        input.MatchingVolCurve = pt_list;
                        var def = list.OrderByDescending(x => x.Importance).First();
                        input.MatchingCurveDbId = def.ID.ToString();
                        var curve = def.Diagram.GraphList[0].GetFeatPointList();
                        input.MatchingVolCurve = new List<HydroCurvePointViewModel>();
                        foreach (var item in curve)
                        {
                            input.MatchingVolCurve.Add(new HydroCurvePointViewModel(item.X, item.Y));
                        }
                    }
                }
                return true;