From 4a27caa5a0d8f4eef667cc9ed0d1c01ea7329298 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期五, 20 十二月 2024 21:47:27 +0800 Subject: [PATCH] 增加冷却塔匹配 --- Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs | 318 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 314 insertions(+), 4 deletions(-) diff --git a/Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs b/Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs index 63c625d..f589942 100644 --- a/Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs +++ b/Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs @@ -150,6 +150,15 @@ } } break; + case RevitJsonCatalog.Cooling: + { + var cooling = ParseCooling(jobject); + if (cooling != null) + { + model.Coolings.Add(cooling); + } + } + break; case RevitJsonCatalog.Pipe: { var pipe = ParsePipe(jobject); @@ -2804,6 +2813,289 @@ return hydrant; } + //瑙f瀽鍐峰嵈濉� + private static HStation.Model.RevitCooling ParseCooling(JToken jobject) + { + if (jobject == null) + { + return default; + } + + var cooling = new Model.RevitCooling(); + cooling.Catalog = RevitJsonCatalog.Cooling; + + #region Id + + if (jobject.ParseString(RevitJsonProp.Id, out string id)) + { + cooling.Id = id; + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Id), ePropStatus.Error, "缂哄皯[鏋勪欢缂栫爜]"); + } + + #endregion + + #region Name + + if (jobject.ParseString(RevitJsonProp.Name, out string name)) + { + cooling.Name = name; + cooling.UpdatePropStatus(nameof(cooling.Name), ePropStatus.Lack, "[鏋勪欢鍚嶇О]缂虹渷"); + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Name), ePropStatus.Error, "缂哄皯 [鏋勪欢鍚嶇О]"); + } + + #endregion + + #region ModelType + + if (jobject.ParseString(RevitJsonProp.ModelType, out string modelType)) + { + cooling.ModelType = modelType; + if (string.IsNullOrEmpty(cooling.ModelType)) + { + cooling.UpdatePropStatus(nameof(cooling.ModelType), ePropStatus.Lack, "[鍨嬪彿淇℃伅]缂虹渷"); + } + } + else + { + cooling.UpdatePropStatus(nameof(cooling.ModelType), ePropStatus.Error, "缂哄皯[鍨嬪彿淇℃伅]"); + } + + #endregion + + #region Flags + + if (jobject.ParseString(RevitJsonProp.Flags, out string flags)) + { + cooling.Flags = Yw.Untity.FlagsHelper.ToList(flags); + if (!string.IsNullOrEmpty(flags)) + { + if (cooling.Flags == null || cooling.Flags.Count < 1) + { + cooling.UpdatePropStatus(nameof(cooling.Flags), ePropStatus.Abnormal, "[鏍囩淇℃伅]鏍煎紡閿欒"); + } + } + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Flags), ePropStatus.Error, "缂哄皯[鏍囩淇℃伅]"); + } + + #endregion + + #region Description + + if (jobject.ParseString(RevitJsonProp.Description, out string description)) + { + cooling.Description = description; + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Description), ePropStatus.Error, "缂哄皯[璇存槑淇℃伅]"); + } + + #endregion + + #region ConnectList + + if (jobject.ParseString(RevitJsonProp.Connects, out string connectString)) + { + var connectList = JsonHelper.Json2Object<List<RevitJsonConnectModel>>(connectString); + cooling.ConnectList = connectList?.Select(x => new Model.RevitConnect() + { + Id = x.ConnectId, + Direction = x.Dirction, + Position = new Model.RevitPosition() + { + X = x.Point.X / 1000f, + Y = x.Point.Y / 1000f, + Z = x.Point.Z / 1000f + } + }).ToList(); + if (cooling.ConnectList == null || cooling.ConnectList.Count < 1) + { + cooling.UpdatePropStatus(nameof(cooling.ConnectList), ePropStatus.Error, "[杩炴帴鍒楄〃]瑙f瀽澶辫触"); + } + } + else + { + cooling.UpdatePropStatus(nameof(cooling.ConnectList), ePropStatus.Error, "缂哄皯[杩炴帴鍒楄〃]"); + } + + #endregion + + #region Position + + cooling.Position = cooling.ConnectList?.GetCenterPosition(); + if (cooling.Position == null) + { + cooling.UpdatePropStatus(nameof(cooling.Position), ePropStatus.Lack, "[浣嶇疆淇℃伅]缂虹渷锛屽彲鑳芥槸鍙梉杩炴帴鍒楄〃]瑙f瀽澶辫触褰卞搷"); + } + + #endregion + + #region Elev + + if (jobject[RevitJsonProp.Elev].MatchNumeric(out double elev)) + { + cooling.Elev = elev; + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Elev), ePropStatus.Abnormal, "[鏍囬珮淇℃伅]缂哄皯鎴栬�呮牸寮忛敊璇�"); + } + + if (cooling.Elev <= 0) + { + if (jobject[RevitJsonProp.ElevOfElevation].MatchNumeric(out double elevOfElevation)) + { + cooling.Elev = elevOfElevation / 1000f; + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Elev), ePropStatus.Abnormal, "[鏍囬珮涓殑楂樼▼]缂哄皯鎴栬�呮牸寮忛敊璇�"); + } + } + + if (cooling.Elev <= 0) + { + //閫氳繃z杞磋嚜鍔ㄨ绠� + if (cooling.Position == null) + { + cooling.UpdatePropStatus(nameof(cooling.Elev), ePropStatus.Lack, "[鏍囬珮淇℃伅]缂虹渷锛屽彈[浣嶇疆]褰卞搷锛屾棤娉曢�氳繃Z杞磋嚜鍔ㄨ绠�"); + } + else + { + cooling.Elev = cooling.Position.Z; + cooling.UpdatePropStatus(nameof(cooling.Elev), ePropStatus.Lack, "[鏍囬珮淇℃伅]缂虹渷锛岄�氳繃Z杞磋嚜鍔ㄨ绠�"); + } + } + + #endregion + + #region Material + + if (jobject.ParseString(RevitJsonProp.Material, out string material)) + { + cooling.Material = material; + if (string.IsNullOrEmpty(cooling.Material)) + { + cooling.UpdatePropStatus(nameof(cooling.Material), ePropStatus.Lack, "[鏉愯川淇℃伅]缂虹渷"); + } + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Material), ePropStatus.Abnormal, "缂哄皯[鏉愯川淇℃伅]"); + } + + #endregion + + #region Caliber + + if (jobject[RevitJsonProp.Caliber].MatchNumeric(out double caliber)) + { + cooling.Caliber = caliber; + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Caliber), ePropStatus.Abnormal, "[鍙e緞淇℃伅]缂哄皯鎴栬�呮暟鎹牸寮忛敊璇�"); + } + + #endregion + + #region Demand + + if (jobject[RevitJsonProp.Demand].MatchNumeric(out double demand)) + { + cooling.Demand = demand; + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Demand), ePropStatus.Abnormal, "[闇�姘撮噺]缂哄皯鎴栬�呮暟鎹牸寮忛敊璇�"); + } + + #endregion + + #region DemandPattern + + if (jobject.ParseString(RevitJsonProp.DemandPattern, out string demandPattern)) + { + cooling.DemandPattern = demandPattern; + if (string.IsNullOrEmpty(cooling.DemandPattern)) + { + cooling.UpdatePropStatus(nameof(cooling.DemandPattern), ePropStatus.Lack, "[闇�姘存ā寮廬缂虹渷"); + } + } + else + { + cooling.UpdatePropStatus(nameof(cooling.DemandPattern), ePropStatus.Abnormal, "缂哄皯[闇�姘存ā寮廬"); + } + + #endregion + + #region MinorLoss + + if (jobject[RevitJsonProp.MinorLoss].MatchNumeric(out double minorLoss)) + { + cooling.MinorLoss = minorLoss; + } + else + { + cooling.UpdatePropStatus(nameof(cooling.MinorLoss), ePropStatus.Abnormal, "[灞�闃荤郴鏁癩缂哄皯鎴栬�呮暟鎹牸寮忛敊璇�"); + } + + #endregion + + #region Coefficient + + if (jobject[RevitJsonProp.CoefficientP].MatchNumeric(out double coeffientp)) + { + cooling.Coefficient = coeffientp; + if (cooling.Coefficient <= 0) + { + cooling.UpdatePropStatus(nameof(cooling.Coefficient), ePropStatus.Lack, "[鍠峰皠绯绘暟]缂虹渷"); + } + } + else + { + cooling.UpdatePropStatus(nameof(cooling.Coefficient), ePropStatus.Abnormal, "[鍠峰皠绯绘暟]缂哄皯鎴栬�呮牸寮忛敊璇�"); + if (jobject[RevitJsonProp.CoefficientF].MatchNumeric(out double coeffientf)) + { + cooling.Coefficient = coeffientf; + if (cooling.Coefficient <= 0) + { + cooling.UpdatePropStatus(nameof(cooling.Coefficient), ePropStatus.Lack, "[娴侀噺绯绘暟]缂虹渷"); + } + } + } + + #endregion + + #region LowerLimit + + if (jobject[RevitJsonProp.LowerLimit].MatchNumeric(out double lowerLimit)) + { + cooling.LowerLimit = lowerLimit; + if (cooling.LowerLimit <= 0) + { + cooling.UpdatePropStatus(nameof(cooling.LowerLimit), ePropStatus.Lack, "[鏈�灏忓帇鍔沒缂虹渷"); + } + } + else + { + cooling.UpdatePropStatus(nameof(cooling.LowerLimit), ePropStatus.Abnormal, "[鏈�灏忓帇鍔沒缂哄皯鎴栬�呮牸寮忛敊璇�"); + } + + #endregion + + return cooling; + } + //瑙f瀽姘磋〃 private static HStation.Model.RevitMeter ParseMeter(JToken jobject) { @@ -4040,6 +4332,24 @@ #endregion + #region StartDiameter + + if (jobject[RevitJsonProp.MaxSize].MatchNumeric(out double maxSize)) + { + translation.StartDiameter = maxSize; + } + + #endregion + + #region EndDiameter + + if (jobject[RevitJsonProp.MinSize].MatchNumeric(out double minSize)) + { + translation.EndDiameter = minSize; + } + + #endregion + #region Length if (jobject[RevitJsonProp.Length].MatchNumeric(out double length)) @@ -4817,21 +5127,21 @@ if (string.IsNullOrEmpty(valve.ValveType)) { valve.ValveType = ValveType.GPV; - valve.UpdatePropStatus(nameof(valve.ValveType), ePropStatus.Lack, "[闃�闂ㄧ被鍨媇缂虹渷锛屼娇鐢ㄩ粯璁ゅ��(GPV)杩涜淇"); + valve.UpdatePropStatus(nameof(valve.ValveType), ePropStatus.Lack, "[闃�闂ㄧ被鍨媇缂虹渷锛屼娇鐢ㄩ粯璁ゅ��(TCV)杩涜淇"); } else { if (!ValveType.Contains(valve.ValveType)) { valve.ValveType = ValveType.GPV; - valve.UpdatePropStatus(nameof(valve.ValveType), ePropStatus.Abnormal, "[闃�闂ㄧ被鍨媇璁剧疆閿欒锛屼娇鐢ㄩ粯璁ゅ��(GPV)杩涜淇"); + valve.UpdatePropStatus(nameof(valve.ValveType), ePropStatus.Abnormal, "[闃�闂ㄧ被鍨媇璁剧疆閿欒锛屼娇鐢ㄩ粯璁ゅ��(TCV)杩涜淇"); } } } else { valve.ValveType = ValveType.GPV; - valve.UpdatePropStatus(nameof(valve.ValveType), ePropStatus.Abnormal, "[闃�闂ㄧ被鍨媇缂哄皯鎴栨牸寮忛敊璇紝浣跨敤榛樿鍊�(GPV)杩涜淇"); + valve.UpdatePropStatus(nameof(valve.ValveType), ePropStatus.Abnormal, "[闃�闂ㄧ被鍨媇缂哄皯鎴栨牸寮忛敊璇紝浣跨敤榛樿鍊�(TCV)杩涜淇"); } #endregion @@ -4845,7 +5155,7 @@ else { valve.OpeningDegree = 100; - valve.UpdatePropStatus(nameof(valve.MinorLoss), ePropStatus.Abnormal, "[闃�闂ㄥ紑搴缂哄皯鎴栬�呮暟鎹牸寮忛敊璇紝浣跨敤榛樿鍊�(100)杩涜淇"); + valve.UpdatePropStatus(nameof(valve.OpeningDegree), ePropStatus.Abnormal, "[闃�闂ㄥ紑搴缂哄皯鎴栬�呮暟鎹牸寮忛敊璇紝浣跨敤榛樿鍊�(100)杩涜淇"); } #endregion -- Gitblit v1.9.3