From 30e078df2eae453b8ea39680816d5abbf5c51b25 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期四, 26 九月 2024 14:01:07 +0800 Subject: [PATCH] Xhs匹配改造,有错误 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs | 405 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 368 insertions(+), 37 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs index cedf261..684cb31 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingParasHelper.cs @@ -1,4 +1,5 @@ -锘縰sing System; +锘縰sing StackExchange.Profiling.Internal; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -13,35 +14,73 @@ { //鍒涘缓璧勪骇鑷姩鍖归厤ViewModel - public static AssetsAutoMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo) + public static AssetsMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo) { - var input = new AssetsAutoMatchingViewModel(); - input.PumpMatchingModels = hydroInfo.Pumps?.Select(x => new PumpMatchingViewModel() + var input = new AssetsMatchingViewModel(); + + //姘存车 + input.PumpMatchingList = hydroInfo.Pumps?.Select(x => new PumpMatchingViewModel() { ID = x.ID, Code = x.Code, Name = x.Name, - DbId = x.DbId, DbLocked = x.DbLocked, - ChartDbID = hydroInfo.Curves?.Find(t => t.Code == x.CurveQH)?.DbId, ModelType = x.ModelType, + DbId = x.DbId, + CurveDbId = hydroInfo.Curves?.Find(t => t.Code == x.CurveQH)?.DbId, RatedP = x.RatedP, RatedH = x.RatedH, RatedN = x.RatedN, RatedQ = x.RatedQ, }).ToList(); - input.ElbowsMatchingModels = hydroInfo.Elbows?.Select(x => new ElbowsMatchingViewModel() + + //闃�闂� + input.ValveMatchingList = hydroInfo.Valves?.Select(x => new ValveMatchingViewModel() { ID = x.ID, - Name = x.Name, Code = x.Code, - Dbid = x.DbId, + Name = x.Name, DbLocked = x.DbLocked, ModelType = x.ModelType, - Caliber = x.Caliber, - Material = x.Material + DbId = x.DbId, + Diameter = x.Diameter, + Material = x.Material, + MinorLoss = x.MinorLoss, + ValveType = x.ValveType }).ToList(); - input.ThreeLinkMatchingModels = hydroInfo.Threelinks?.Select(x => new ThreeLinkMatchingViewModel() + + //绠¢亾 + input.PipeMatchingList = hydroInfo.Pipes?.Select(x => new PipeMatchingViewModel() + { + ID = x.ID, + Code = x.Code, + Name = x.Name, + DbLocked = x.DbLocked, + ModelType = x.ModelType, + DbId = x.DbId, + Diameter = x.Diameter, + Material = x.Material, + Roughness = x.Roughness, + MinorLoss = x.MinorLoss, + eAlgorithmType = HStation.Assets.eAlgorithmType.Hazen + }).ToList(); + + //寮ご + input.ElbowsMatchingList = hydroInfo.Elbows?.Select(x => new ElbowsMatchingViewModel() + { + ID = x.ID, + Code = x.Code, + Name = x.Name, + DbLocked = x.DbLocked, + ModelType = x.ModelType, + DbId = x.DbId, + Caliber = x.Caliber, + Material = x.Material, + MinorLoss = x.MinorLoss + }).ToList(); + + //涓夐�� + input.ThreelinkMatchingList = hydroInfo.Threelinks?.Select(x => new ThreelinkMatchingViewModel() { ID = x.ID, Name = x.Name, @@ -52,46 +91,338 @@ Caliber = x.Caliber, Material = x.Material }).ToList(); - input.FourLinkMatchingModels = hydroInfo.Fourlinks?.Select(x => new FourLinkMatchingViewModel() + + //鍥涢�� + input.FourlinkMatchingList = hydroInfo.Fourlinks?.Select(x => new FourlinkMatchingViewModel() { ID = x.ID, Name = x.Name, Code = x.Code, - Dbid = x.DbId, + DbId = x.DbId, DbLocked = x.DbLocked, ModelType = x.ModelType, Caliber = x.Caliber, Material = x.Material }).ToList(); - input.PipeLineMatchingModels = hydroInfo.Pipes?.Select(x => new PipeLineMatchingViewModel() - { - ID = x.ID, - Name = x.Name, - Code = x.Code, - DbId = x.DbId, - DbLocked = x.DbLocked, - ModelType = x.ModelType, - Caliber = x.Diameter,//杩欓噷鏄暟鍊� - Material = x.Material - }).ToList(); - input.ValveMatchingModels = hydroInfo.Pipes?.Select(x => new ValveMatchingViewModel() - { - ID = x.ID, - Name = x.Name, - Code = x.Code, - DbId = x.DbId, - DbLocked = x.DbLocked, - ModelType = x.ModelType, - Caliber = x.Diameter,//杩欓噷鏄暟鍊� - Material = x.Material//鎬庝箞娌℃湁闃�闂ㄧ被鍨� - }).ToList(); + return input; } //搴旂敤璧勪骇鑷姩鍖归厤ViewModel - public static void Apply(Yw.Model.HydroModelInfo hydroInfo, AssetsAutoMatchingViewModel output) + public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, AssetsMatchingViewModel output) { + if (hydroInfo == null) + { + return false; + } + if (output == null) + { + return false; + } + bool result = false; + + //姘存车 + if (output.PumpMatchingList != null && output.PumpMatchingList.Count > 0) + { + if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0) + { + 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)) + { + + } + } + } + } + } + } + + //闃�闂� + if (output.ValveMatchingList != null && output.PumpMatchingList.Count > 0) + { + if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0) + { + 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; + } + } + } + } + } + + //绠¢亾 + if (output.PipeMatchingList != null && output.PipeMatchingList.Count > 0) + { + if (hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0) + { + 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; + } + } + } + } + } + + //寮ご + if (output.ElbowsMatchingList != null && output.ElbowsMatchingList.Count > 0) + { + if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0) + { + foreach (var elbowsMatching in output.ElbowsMatchingList) + { + 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; + } + } + } + } + } + + //涓夐�� + if (output.ThreelinkMatchingList != null && output.ThreelinkMatchingList.Count > 0) + { + if (hydroInfo.Threelinks != null && hydroInfo.Threelinks.Count > 0) + { + 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; + } + } + } + } + } + + //鍥涢�� + if (output.FourlinkMatchingList != null && output.FourlinkMatchingList.Count > 0) + { + if (hydroInfo.Fourlinks != null && hydroInfo.Fourlinks.Count > 0) + { + 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; + } + } + } + } + } + + return result; } + + } } -- Gitblit v1.9.3