lixiaojun
2024-09-26 2bff362885fd70b806cd031f5923bdf420b3ab9a
名称修改
已修改6个文件
369 ■■■■ 文件已修改
WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingHelper.cs 359 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/03-valve/XhsProjectSimulationValveMatchingListCtrl.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/04-pipe/XhsProjectSimulationPipeMatchingListCtrl.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/05-elbows/XhsProjectSimulationElbowsMatchingListCtrl.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/06-threelink/XhsProjectSimulationThreelinkMatchingListCtrl.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/07-fourlink/XhsProjectSimulationFourlinkMatchingListCtrl.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingHelper.cs
@@ -35,27 +35,27 @@
            //三通匹配
            foreach (var item in assetsAutoMatchingView.ThreelinkMatchingList)
            {
                threeLinkMatchingList.Add(MatchingThreeLink(item, allAdapting));
                threeLinkMatchingList.Add(MatchingThreelink(item, allAdapting));
            }
            //四通匹配
            foreach (var item in assetsAutoMatchingView.FourlinkMatchingList)
            {
                fourLinkMatchingList.Add(MatchingFourLink(item, allAdapting));
                fourLinkMatchingList.Add(MatchingFourlink(item, allAdapting));
            }
            //管道匹配
            foreach (var item in assetsAutoMatchingView.PipeMatchingList)
            {
                pipeLineMatchingList.Add(MatchingPipes(item, allPipeLine));
                pipeLineMatchingList.Add(MatchingPipe(item, allPipeLine));
            }
            //阀门匹配
            foreach (var item in assetsAutoMatchingView.ValveMatchingList)
            {
                valveMatchingList.Add(MatchingValves(item, allValve));
                valveMatchingList.Add(MatchingValve(item, allValve));
            }
            //弯头匹配
            foreach (var item in assetsAutoMatchingView.ElbowsMatchingList)
            {
                elbowsMatchingList.Add(MatchingElbows(item, allAdapting));
                elbowsMatchingList.Add(MatchingElbow(item, allAdapting));
            }
            assetsAutoMatching.PumpMatchingList = pumpMatchingList;
            assetsAutoMatching.ThreelinkMatchingList = threeLinkMatchingList;
@@ -66,15 +66,88 @@
            return assetsAutoMatching;
        }
        //弯头匹配
        public static ElbowsMatchingViewModel MatchingElbows(ElbowsMatchingViewModel input, List<Vmo.AdaptingManageVmo> adaptingManageVmos)
        //泵匹配
        public static async Task<PumpMatchingViewModel> MatchingPumps(PumpMatchingViewModel viewModel, List<Vmo.PumpMainVmo> pumpMainVmos)
        {
            Vmo.AdaptingManageVmo vmo = null;
            Vmo.PumpMainVmo vmo = null;
            int startCount = 0;
            // 尝试绝对匹配
            var absoluteMatch = pumpMainVmos.Where(item =>
            (viewModel.RatedN == null || viewModel.RatedN == item.RatedSpeed) &&
            (viewModel.RatedQ == null || viewModel.RatedQ == item.RatedFlow) &&
            (viewModel.RatedH == null || viewModel.RatedH == item.RatedHead) &&
            (viewModel.RatedP == item.RatedPower)).ToList();
            if (absoluteMatch != null && absoluteMatch.Count != 0)
            {
                foreach (var item in absoluteMatch)
                {
                    int commonCount = CountCommonCharacters(viewModel.ModelType, item.Name);
                    if (commonCount > startCount)
                    {
                        vmo = item;
                        startCount = commonCount;
                    }
                }
            }
            else
            {
                // 尝试区间匹配
                var rangeMatch = pumpMainVmos.Where(item =>
                   (viewModel.RatedN.HasValue ? Math.Abs(viewModel.RatedN.Value - item.RatedSpeed) <= _speedTolerance : true) &&
                   (viewModel.RatedQ.HasValue ? Math.Abs(viewModel.RatedQ.Value - item.RatedFlow) <= _flowTolerance : true) &&
                   (viewModel.RatedH.HasValue ? Math.Abs(viewModel.RatedH.Value - item.RatedHead) <= _headTolerance : true) &&
                   (Math.Abs(viewModel.RatedP - item.RatedPower) <= _powerTolerance)).ToList();
                if (rangeMatch != null && rangeMatch.Count != 0)
                {
                    foreach (var item in rangeMatch)
                    {
                        int commonCount = CountCommonCharacters(viewModel.ModelType, item.Name);
                        if (commonCount > startCount)
                        {
                            vmo = item;
                            startCount = commonCount;
                        }
                    }
                }
            }
            //
            if (vmo == null)
            {
                foreach (var item in pumpMainVmos)
                {
                    int commonCount = CountCommonCharacters(viewModel.ModelType, item.Name);
                    if (commonCount > startCount)
                    {
                        vmo = item;
                        startCount = commonCount;
                    }
                }
            }
            if (vmo != null)
            {
                viewModel.MatchingRatedH = vmo.RatedHead;
                viewModel.MatchingRatedN = vmo.RatedSpeed;
                viewModel.MatchingRatedQ = vmo.RatedFlow;
                viewModel.MatchingRatedP = vmo.RatedPower;
                viewModel.MatchingDbId = vmo.ID.ToString();
                var list = await new BLL.XhsPumpMainPhartMappingExtensions().GetByPumpMainID(vmo.ID);
                if (list != null && list.Count > 0)
                {
                    viewModel.MatchingCurveDbId = list.First().ID;
                }
            }
            return null;
        }
        //阀门匹配
        public static ValveMatchingViewModel MatchingValve(ValveMatchingViewModel input, List<Vmo.ValveMainVmo> adaptingManageVmos)
        {
            HStation.Vmo.ValveMainVmo vmo = null;
            int firstCount = 0;
            //口径最小差值
            // 绝对匹配
            var absoluteMatch = adaptingManageVmos.Where(i =>
              ((input.Caliber == null && i.Caliber == null) || i.Caliber == input.Caliber) &&
              ((input.Diameter == null && i.Caliber == null) || i.Caliber == input.Diameter) &&
               ((input.Material == null && i.Material == "默认") || i.Material == input.Material)).ToList();
            if (absoluteMatch.Any())
            {
@@ -93,9 +166,9 @@
                //区间匹配
                var rangeMatch = adaptingManageVmos.Where(item =>
                {
                    if (item.Caliber != null && input.Caliber != null)
                    if (item.Caliber != null && input.Diameter != null)
                    {
                        return Math.Abs(Convert.ToInt64(item.Caliber - input.Caliber)) <= _caliberTolerance;
                        return Math.Abs(Convert.ToInt64(item.Caliber - input.Diameter)) <= _caliberTolerance;
                    }
                    else
                    {
@@ -109,7 +182,7 @@
             .ToList();
                if (rangeMatch != null && rangeMatch.Count > 0)
                {
                    var materialList = new List<Vmo.AdaptingManageVmo>();
                    var materialList = new List<Vmo.ValveMainVmo>();
                    foreach (var range in rangeMatch)
                    {
                        //以材料为条件开始匹配
@@ -162,8 +235,93 @@
            return input;
        }
        //四通匹配
        public static FourlinkMatchingViewModel MatchingFourLink(FourlinkMatchingViewModel input, List<Vmo.AdaptingManageVmo> adaptingManageVmos)
        //管道匹配
        public static PipeMatchingViewModel MatchingPipe(PipeMatchingViewModel input, List<Vmo.PipeLineManageVmo> pipeLineManageVmos)
        {
            Vmo.PipeLineManageVmo vmo = null;
            int StartCount = 0;
            //口径最小差值
            // 绝对匹配
            var absoluteMatch = pipeLineManageVmos.Where(i =>
              ((input.Caliber == null && i.Caliber == null) || i.Caliber == input.Caliber) &&
               ((input.Material == null && i.Material == "默认") || i.Material == input.Material)).ToList();
            if (absoluteMatch.Any())
            {
                foreach (var range in absoluteMatch)
                {
                    int commonCount = CountCommonCharacters(input.ModelType, range.Name);
                    if (commonCount > StartCount)
                    {
                        vmo = range;
                        StartCount = commonCount;
                    }
                }
            }
            else
            {
                //区间匹配
                var rangeMatch = pipeLineManageVmos.Where(item =>
                {
                    if (item.Caliber != null && input.Caliber != null)
                    {
                        return Math.Abs(Convert.ToInt64(item.Caliber - input.Caliber)) <= _caliberTolerance;
                    }
                    return false;
                })
             .ToList();
                if (rangeMatch != null)
                {
                    foreach (var range in rangeMatch)
                    {
                        //以材料为条件开始匹配
                        int commonCount = CountCommonCharacters(input.Material, range.Material);
                        if (commonCount > StartCount)
                        {
                            vmo = range;
                            StartCount = commonCount;
                        }
                    }
                }
            }
            //口径和材料都没有匹配上,就用型号名匹配
            if (vmo == null)
            {
                foreach (var item in pipeLineManageVmos)
                {
                    int commonCount = CountCommonCharacters(input.ModelType, item.Name);
                    if (commonCount > StartCount)
                    {
                        vmo = item;
                        StartCount = commonCount;
                    }
                }
            }
            if (vmo != null)
            {
                switch (input.eAlgorithmType)
                {
                    case HStation.Assets.eAlgorithmType.Hazen:
                        input.MatchingMinorLoss = vmo.Hazen;
                        return input;
                    case HStation.Assets.eAlgorithmType.Manning:
                        input.MatchingMinorLoss = vmo.Manning;
                        return input;
                    case HStation.Assets.eAlgorithmType.Darcy:
                        input.MatchingMinorLoss = vmo.Darcy;
                        return input;
                    default:
                        input.MatchingMinorLoss = vmo.Hazen;
                        return input;
                }
            }
            return input;
        }
        //弯头匹配
        public static ElbowsMatchingViewModel MatchingElbow(ElbowsMatchingViewModel input, List<Vmo.AdaptingManageVmo> adaptingManageVmos)
        {
            Vmo.AdaptingManageVmo vmo = null;
            int firstCount = 0;
@@ -259,7 +417,7 @@
        }
        //三通匹配
        public static ThreelinkMatchingViewModel MatchingThreeLink(ThreelinkMatchingViewModel input, List<Vmo.AdaptingManageVmo> adaptingManageVmos)
        public static ThreelinkMatchingViewModel MatchingThreelink(ThreelinkMatchingViewModel input, List<Vmo.AdaptingManageVmo> adaptingManageVmos)
        {
            Vmo.AdaptingManageVmo vmo = null;
            int firstCount = 0;
@@ -354,15 +512,15 @@
            return input;
        }
        //阀门匹配
        public static ValveMatchingViewModel MatchingValves(ValveMatchingViewModel input, List<Vmo.ValveMainVmo> adaptingManageVmos)
        //四通匹配
        public static FourlinkMatchingViewModel MatchingFourlink(FourlinkMatchingViewModel input, List<Vmo.AdaptingManageVmo> adaptingManageVmos)
        {
            HStation.Vmo.ValveMainVmo vmo = null;
            Vmo.AdaptingManageVmo vmo = null;
            int firstCount = 0;
            //口径最小差值
            // 绝对匹配
            var absoluteMatch = adaptingManageVmos.Where(i =>
              ((input.Diameter == null && i.Caliber == null) || i.Caliber == input.Diameter) &&
              ((input.Caliber == null && i.Caliber == null) || i.Caliber == input.Caliber) &&
               ((input.Material == null && i.Material == "默认") || i.Material == input.Material)).ToList();
            if (absoluteMatch.Any())
            {
@@ -381,9 +539,9 @@
                //区间匹配
                var rangeMatch = adaptingManageVmos.Where(item =>
                {
                    if (item.Caliber != null && input.Diameter != null)
                    if (item.Caliber != null && input.Caliber != null)
                    {
                        return Math.Abs(Convert.ToInt64(item.Caliber - input.Diameter)) <= _caliberTolerance;
                        return Math.Abs(Convert.ToInt64(item.Caliber - input.Caliber)) <= _caliberTolerance;
                    }
                    else
                    {
@@ -397,7 +555,7 @@
             .ToList();
                if (rangeMatch != null && rangeMatch.Count > 0)
                {
                    var materialList = new List<Vmo.ValveMainVmo>();
                    var materialList = new List<Vmo.AdaptingManageVmo>();
                    foreach (var range in rangeMatch)
                    {
                        //以材料为条件开始匹配
@@ -450,163 +608,6 @@
            return input;
        }
        //泵匹配
        public static async Task<PumpMatchingViewModel> MatchingPumps(PumpMatchingViewModel viewModel, List<Vmo.PumpMainVmo> pumpMainVmos)
        {
            Vmo.PumpMainVmo vmo = null;
            int startCount = 0;
            // 尝试绝对匹配
            var absoluteMatch = pumpMainVmos.Where(item =>
            (viewModel.RatedN == null || viewModel.RatedN == item.RatedSpeed) &&
            (viewModel.RatedQ == null || viewModel.RatedQ == item.RatedFlow) &&
            (viewModel.RatedH == null || viewModel.RatedH == item.RatedHead) &&
            (viewModel.RatedP == item.RatedPower)).ToList();
            if (absoluteMatch != null && absoluteMatch.Count != 0)
            {
                foreach (var item in absoluteMatch)
                {
                    int commonCount = CountCommonCharacters(viewModel.ModelType, item.Name);
                    if (commonCount > startCount)
                    {
                        vmo = item;
                        startCount = commonCount;
                    }
                }
            }
            else
            {
                // 尝试区间匹配
                var rangeMatch = pumpMainVmos.Where(item =>
                   (viewModel.RatedN.HasValue ? Math.Abs(viewModel.RatedN.Value - item.RatedSpeed) <= _speedTolerance : true) &&
                   (viewModel.RatedQ.HasValue ? Math.Abs(viewModel.RatedQ.Value - item.RatedFlow) <= _flowTolerance : true) &&
                   (viewModel.RatedH.HasValue ? Math.Abs(viewModel.RatedH.Value - item.RatedHead) <= _headTolerance : true) &&
                   (Math.Abs(viewModel.RatedP - item.RatedPower) <= _powerTolerance)).ToList();
                if (rangeMatch != null && rangeMatch.Count != 0)
                {
                    foreach (var item in rangeMatch)
                    {
                        int commonCount = CountCommonCharacters(viewModel.ModelType, item.Name);
                        if (commonCount > startCount)
                        {
                            vmo = item;
                            startCount = commonCount;
                        }
                    }
                }
            }
            //
            if (vmo == null)
            {
                foreach (var item in pumpMainVmos)
                {
                    int commonCount = CountCommonCharacters(viewModel.ModelType, item.Name);
                    if (commonCount > startCount)
                    {
                        vmo = item;
                        startCount = commonCount;
                    }
                }
            }
            if (vmo != null)
            {
                viewModel.MatchingRatedH = vmo.RatedHead;
                viewModel.MatchingRatedN = vmo.RatedSpeed;
                viewModel.MatchingRatedQ = vmo.RatedFlow;
                viewModel.MatchingRatedP = vmo.RatedPower;
                viewModel.MatchingDbId = vmo.ID.ToString();
                var list = await new BLL.XhsPumpMainPhartMappingExtensions().GetByPumpMainID(vmo.ID);
                if (list != null && list.Count > 0)
                {
                    viewModel.MatchingCurveDbId = list.First().ID;
                }
            }
            return null;
        }
        //管道匹配
        public static PipeMatchingViewModel MatchingPipes(PipeMatchingViewModel input, List<Vmo.PipeLineManageVmo> pipeLineManageVmos)
        {
            Vmo.PipeLineManageVmo vmo = null;
            int StartCount = 0;
            //口径最小差值
            // 绝对匹配
            var absoluteMatch = pipeLineManageVmos.Where(i =>
              ((input.Caliber == null && i.Caliber == null) || i.Caliber == input.Caliber) &&
               ((input.Material == null && i.Material == "默认") || i.Material == input.Material)).ToList();
            if (absoluteMatch.Any())
            {
                foreach (var range in absoluteMatch)
                {
                    int commonCount = CountCommonCharacters(input.ModelType, range.Name);
                    if (commonCount > StartCount)
                    {
                        vmo = range;
                        StartCount = commonCount;
                    }
                }
            }
            else
            {
                //区间匹配
                var rangeMatch = pipeLineManageVmos.Where(item =>
                {
                    if (item.Caliber != null && input.Caliber != null)
                    {
                        return Math.Abs(Convert.ToInt64(item.Caliber - input.Caliber)) <= _caliberTolerance;
                    }
                    return false;
                })
             .ToList();
                if (rangeMatch != null)
                {
                    foreach (var range in rangeMatch)
                    {
                        //以材料为条件开始匹配
                        int commonCount = CountCommonCharacters(input.Material, range.Material);
                        if (commonCount > StartCount)
                        {
                            vmo = range;
                            StartCount = commonCount;
                        }
                    }
                }
            }
            //口径和材料都没有匹配上,就用型号名匹配
            if (vmo == null)
            {
                foreach (var item in pipeLineManageVmos)
                {
                    int commonCount = CountCommonCharacters(input.ModelType, item.Name);
                    if (commonCount > StartCount)
                    {
                        vmo = item;
                        StartCount = commonCount;
                    }
                }
            }
            if (vmo != null)
            {
                switch (input.eAlgorithmType)
                {
                    case HStation.Assets.eAlgorithmType.Hazen:
                        input.MatchingMinorLoss = vmo.Hazen;
                        return input;
                    case HStation.Assets.eAlgorithmType.Manning:
                        input.MatchingMinorLoss = vmo.Manning;
                        return input;
                    case HStation.Assets.eAlgorithmType.Darcy:
                        input.MatchingMinorLoss = vmo.Darcy;
                        return input;
                    default:
                        input.MatchingMinorLoss = vmo.Hazen;
                        return input;
                }
            }
            return input;
        }
        //返回两个字符串之间相同的字符个数
        private static int CountCommonCharacters(string baseString, string compareString)
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/03-valve/XhsProjectSimulationValveMatchingListCtrl.cs
@@ -36,7 +36,7 @@
            var finishList = new List<ValveMatchingViewModel>();
            foreach (var item in inputs)
            {
                var result = AssetsMatchingHelper.MatchingValves(item, alllist);
                var result = AssetsMatchingHelper.MatchingValve(item, alllist);
                if (result != null)
                {
                    finishList.Add(result);
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/04-pipe/XhsProjectSimulationPipeMatchingListCtrl.cs
@@ -38,7 +38,7 @@
            var finishList = new List<PipeMatchingViewModel>();
            foreach (var item in inputs)
            {
                var result = AssetsMatchingHelper.MatchingPipes(item, alllist);
                var result = AssetsMatchingHelper.MatchingPipe(item, alllist);
                if (result != null)
                {
                    finishList.Add(result);
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/05-elbows/XhsProjectSimulationElbowsMatchingListCtrl.cs
@@ -36,7 +36,7 @@
            var resultList = new List<ElbowsMatchingViewModel>();
            foreach (var item in inputs)
            {
                var result = AssetsMatchingHelper.MatchingElbows(item, alllist);
                var result = AssetsMatchingHelper.MatchingElbow(item, alllist);
                if (result != null)
                {
                    resultList.Add(result);
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/06-threelink/XhsProjectSimulationThreelinkMatchingListCtrl.cs
@@ -38,7 +38,7 @@
            var resultList = new List<ThreelinkMatchingViewModel>();
            foreach (var item in inputs)
            {
                var result = AssetsMatchingHelper.MatchingThreeLink(item, alllist);
                var result = AssetsMatchingHelper.MatchingThreelink(item, alllist);
                if (result != null)
                {
                    resultList.Add(result);
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-matching/07-fourlink/XhsProjectSimulationFourlinkMatchingListCtrl.cs
@@ -36,7 +36,7 @@
            var resultList = new List<FourlinkMatchingViewModel>();
            foreach (var item in inputs)
            {
                var result = AssetsMatchingHelper.MatchingFourLink(item, alllist);
                var result = AssetsMatchingHelper.MatchingFourlink(item, alllist);
                if (result != null)
                {
                    resultList.Add(result);