duheng
2025-01-19 f10f00cf1739b49fe51abfbb96093a2a2f66a65c
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs
@@ -528,7 +528,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in pipeLineMainVmos)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -643,7 +643,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in threelinkVmos)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -766,7 +766,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in fourLinkVmos)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -884,7 +884,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in sprinklerVmos)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1002,7 +1002,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in allExchangerList)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1141,7 +1141,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in allCompressorList)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1280,7 +1280,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in bluntheadVmos)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1365,7 +1365,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in tankVmos)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1471,7 +1471,7 @@
            }
            //标签
            int flagWeight = 10;
            int flagWeight = 1000;
            foreach (var item in allMeterList)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1548,7 +1548,7 @@
            }
            //标签
            int flagWeight = 10;
            int flagWeight = 1000;
            foreach (var item in allFlowmeterList)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1658,7 +1658,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in hydrantVmos)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1706,7 +1706,7 @@
            {
                return false;
            }
            allElbowList = allElbowList.Where(x => x.Angle == 90).ToList();
            //权重字典
            var dict = new Dictionary<AssetsElbowMainVmo, double>();
            foreach (var item in allElbowList)
@@ -1727,7 +1727,40 @@
                    }
                }
            }
            //口径
            int caliberWeight = 1;
            if (input.Caliber > 0)
            {
                foreach (var item in allElbowList)
                {
                    if (item.Caliber.HasValue)
                    {
                        var diff = Math.Abs(item.Caliber.Value - input.Caliber);
                        dict[item] += diff / input.Caliber * 100 * caliberWeight;
                    }
                }
            }
            // 角度
            int angleWeight = 1000;
            if (input.BendingAngle > 0)
            {
                foreach (var item in allElbowList)
                {
                    if (item.Angle > 0)
                    {
                        var count = Math.Abs(item.Angle.Value - input.BendingAngle);
                        if (count != 0)
                        {
                            dict[item] += (1.0 / count) * angleWeight;
                        }
                        else
                        {
                            // 如果 count 为 0,表示完全匹配,给予最大权重
                            dict[item] += angleWeight * 100;
                        }
                    }
                }
            }
            // 关键字
            int keywordWeight = 1;
            foreach (var item in allElbowList)
@@ -1743,7 +1776,7 @@
            }
            //标签
            int flagWeight = 10;
            int flagWeight = 1000;
            foreach (var item in allElbowList)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1835,7 +1868,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in pressmeterVmos)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -1897,6 +1930,37 @@
                }
            }
            // 上游和下游直径
            int diameterWeight = 100;
            if (input.StartDiameter > 0 && input.EndDiameter > 0)
            {
                foreach (var item in translationVmos)
                {
                    if (item.StartDiameter > 0 && item.EndDiameter > 0)
                    {
                        var startCount = Math.Abs(item.StartDiameter - input.StartDiameter);
                        var endCount = Math.Abs(item.EndDiameter - input.EndDiameter);
                        if (startCount == 0 && endCount == 0)
                        {
                            // 如果 startCount 和 endCount 都为 0,表示完全匹配,给予最大权重
                            dict[item] += diameterWeight * 100;
                        }
                        else
                        {
                            // 否则,分别计算权重
                            if (startCount != 0)
                            {
                                dict[item] += (1.0 / startCount) * diameterWeight;
                            }
                            if (endCount != 0)
                            {
                                dict[item] += (1.0 / endCount) * diameterWeight;
                            }
                        }
                    }
                }
            }
            //材质
            int materialWeight = 5;
            if (!string.IsNullOrEmpty(input.Material))
@@ -1931,7 +1995,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in translationVmos)
            {
                if (item.Flags != null && item.Flags.Count > 0)
@@ -2057,7 +2121,7 @@
            }
            //标签
            int flagWeight = 1;
            int flagWeight = 1000;
            foreach (var item in allCoolingList)
            {
                if (item.Flags != null && item.Flags.Count > 0)