From 1062dfc5f3d522a880e54d94eb87478c08013c96 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期四, 19 九月 2024 15:33:50 +0800
Subject: [PATCH] 部分bug修复

---
 Service/HStation.Service.Revit.Core/04-service/01-json/RevitJsonHelper.cs |  127 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 122 insertions(+), 5 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 5d7d7d5..a09b241 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
@@ -10,8 +10,6 @@
         /// <summary>
         /// 浠巎son瀛楃涓蹭腑瑙f瀽
         /// </summary>
-        /// <param name="revitJsonString">json瀛楃涓�</param>
-        /// <returns>鏍煎紡閿欒锛屼細鎶涘嚭寮傚父</returns>
         public static HStation.Model.RevitModel FromJsonString(string revitJsonString, out string msg)
         {
             msg = string.Empty;
@@ -71,6 +69,10 @@
                                     reservoir.Head = head;
                                 }
                                 reservoir.HeadPattern = jobject[RevitJsonProp.HeadPattern].ToString();
+                                if (!string.IsNullOrEmpty(reservoir.HeadPattern))
+                                {
+                                    reservoir.HeadPattern = string.Empty;
+                                }
                                 model.Reservoirs.Add(reservoir);
                             }
                             break;
@@ -129,6 +131,10 @@
                                     tank.MinVol = minVol;
                                 }
                                 tank.VolCurve = jobject[RevitJsonProp.VolCurve].ToString();
+                                if (!string.IsNullOrEmpty(tank.VolCurve))
+                                {
+                                    tank.VolCurve = string.Empty;
+                                }
                                 model.Tanks.Add(tank);
                             }
                             break;
@@ -187,6 +193,10 @@
                                     waterbox.MinVol = minVol;
                                 }
                                 waterbox.VolCurve = jobject[RevitJsonProp.VolCurve].ToString();
+                                if (!string.IsNullOrEmpty(waterbox.VolCurve))
+                                {
+                                    waterbox.VolCurve = string.Empty;
+                                }
                                 model.Waterboxs.Add(waterbox);
                             }
                             break;
@@ -229,6 +239,10 @@
                                     junction.Demand = demand;
                                 }
                                 junction.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(junction.DemandPattern))
+                                {
+                                    junction.DemandPattern = string.Empty;
+                                }
                                 model.Junctions.Add(junction);
                             }
                             break;
@@ -271,6 +285,10 @@
                                     elbow.Demand = demand;
                                 }
                                 elbow.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(elbow.DemandPattern))
+                                {
+                                    elbow.DemandPattern = string.Empty;
+                                }
                                 model.Elbows.Add(elbow);
                             }
                             break;
@@ -313,6 +331,10 @@
                                     threelink.Demand = demand;
                                 }
                                 threelink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(threelink.DemandPattern))
+                                {
+                                    threelink.DemandPattern = string.Empty;
+                                }
                                 model.Threelinks.Add(threelink);
                             }
                             break;
@@ -355,6 +377,10 @@
                                     fourlink.Demand = demand;
                                 }
                                 fourlink.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(fourlink.DemandPattern))
+                                {
+                                    fourlink.DemandPattern = string.Empty;
+                                }
                                 model.Fourlinks.Add(fourlink);
                             }
                             break;
@@ -397,6 +423,10 @@
                                     meter.Demand = demand;
                                 }
                                 meter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(meter.DemandPattern))
+                                {
+                                    meter.DemandPattern = string.Empty;
+                                }
                                 model.Meters.Add(meter);
                             }
                             break;
@@ -439,6 +469,10 @@
                                     flowmeter.Demand = demand;
                                 }
                                 flowmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(flowmeter.DemandPattern))
+                                {
+                                    flowmeter.DemandPattern = string.Empty;
+                                }
                                 model.Flowmeters.Add(flowmeter);
                             }
                             break;
@@ -481,6 +515,10 @@
                                     pressmeter.Demand = demand;
                                 }
                                 pressmeter.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(pressmeter.DemandPattern))
+                                {
+                                    pressmeter.DemandPattern = string.Empty;
+                                }
                                 model.Pressmeters.Add(pressmeter);
                             }
                             break;
@@ -523,6 +561,10 @@
                                     blunthead.Demand = demand;
                                 }
                                 blunthead.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(blunthead.DemandPattern))
+                                {
+                                    blunthead.DemandPattern = string.Empty;
+                                }
                                 model.Bluntheads.Add(blunthead);
                             }
                             break;
@@ -565,6 +607,10 @@
                                     nozzle.Demand = demand;
                                 }
                                 nozzle.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(nozzle.DemandPattern))
+                                {
+                                    nozzle.DemandPattern = string.Empty;
+                                }
                                 if (jobject[RevitJsonProp.CoefficientP].MatchNumeric(out double coeffient))
                                 {
                                     nozzle.Coefficient = coeffient;
@@ -611,6 +657,10 @@
                                     hydrant.Demand = demand;
                                 }
                                 hydrant.DemandPattern = jobject[RevitJsonProp.DemandPattern].ToString();
+                                if (!string.IsNullOrEmpty(hydrant.DemandPattern))
+                                {
+                                    hydrant.DemandPattern = string.Empty;
+                                }
                                 if (jobject[RevitJsonProp.CoefficientF].MatchNumeric(out double coeffient))
                                 {
                                     hydrant.Coefficient = coeffient;
@@ -687,6 +737,18 @@
                                 {
                                     exchanger.Roughness = roughness;
                                 }
+                                if (exchanger.Length <= 0)
+                                {
+                                    exchanger.Length = exchanger.StartPosition.Distance(exchanger.EndPosition);
+                                }
+                                if (exchanger.Diameter < 0.1)
+                                {
+                                    exchanger.Diameter = 500;
+                                }
+                                if (exchanger.Roughness < 0.1)
+                                {
+                                    exchanger.Roughness = 110;
+                                }
                                 model.Exchangers.Add(exchanger);
                             }
                             break;
@@ -758,6 +820,18 @@
                                 if (jobject[RevitJsonProp.Roughness].MatchNumeric(out double roughness))
                                 {
                                     pipe.Roughness = roughness;
+                                }
+                                if (pipe.Length <= 0)
+                                {
+                                    pipe.Length = pipe.StartPosition.Distance(pipe.EndPosition);
+                                }
+                                if (pipe.Diameter < 0.1)
+                                {
+                                    pipe.Diameter = 500;
+                                }
+                                if (pipe.Roughness < 0.1)
+                                {
+                                    pipe.Roughness = 110;
                                 }
                                 model.Pipes.Add(pipe);
                             }
@@ -831,6 +905,18 @@
                                 {
                                     translation.Roughness = roughness;
                                 }
+                                if (translation.Length <= 0)
+                                {
+                                    translation.Length = translation.StartPosition.Distance(translation.EndPosition);
+                                }
+                                if (translation.Diameter < 0.1)
+                                {
+                                    translation.Diameter = 500;
+                                }
+                                if (translation.Roughness < 0.1)
+                                {
+                                    translation.Roughness = 110;
+                                }
                                 model.Translations.Add(translation);
                             }
                             break;
@@ -887,17 +973,30 @@
                                     pump.RatedPower = ratedPower;
                                 }
                                 pump.CurveQH = jobject[RevitJsonProp.CurveQH].ToString();
+                                pump.CurveQH = "PumpDefault";
                                 if (jobject[RevitJsonProp.SpeedRatio].MatchNumeric(out double speedRatio))
                                 {
                                     pump.SpeedRatio = speedRatio;
                                 }
                                 pump.SpeedRatioPattern = jobject[RevitJsonProp.SpeedRatioPattern].ToString();
+                                if (!string.IsNullOrEmpty(pump.SpeedRatioPattern))
+                                {
+                                    pump.SpeedRatioPattern = string.Empty;
+                                }
                                 if (jobject[RevitJsonProp.Price].MatchNumeric(out double price))
                                 {
                                     pump.Price = price;
                                 }
                                 pump.PricePattern = jobject[RevitJsonProp.PricePattern].ToString();
+                                if (!string.IsNullOrEmpty(pump.PricePattern))
+                                {
+                                    pump.PricePattern = string.Empty;
+                                }
                                 pump.CurveQE = jobject[RevitJsonProp.CurveQE].ToString();
+                                if (!string.IsNullOrEmpty(pump.CurveQE))
+                                {
+                                    pump.CurveQE = string.Empty;
+                                }
                                 model.Pumps.Add(pump);
                             }
                             break;
@@ -958,12 +1057,32 @@
                                     valve.MinorLoss = minorLoss;
                                 }
 
+                                if (valve.Diameter < 0.1)
+                                {
+                                    valve.Diameter = 500;
+                                }
+
                                 valve.ValveType = jobject[RevitJsonProp.ValveType].ToString();
                                 valve.ValveSetting = jobject[RevitJsonProp.ValveSetting].ToString();
                                 model.Valves.Add(valve);
                             }
                             break;
-
+                        case RevitJsonCatalog.Other:
+                            {
+                                var decorator = new Model.RevitDecorator();
+                                decorator.Id = jobject[RevitJsonProp.Id].ToString();
+                                decorator.Code = jobject[RevitJsonProp.Code].ToString();
+                                if (string.IsNullOrEmpty(decorator.Code))
+                                {
+                                    decorator.Code = decorator.Id;
+                                }
+                                decorator.Name = string.Empty;
+                                decorator.Category = jobject[RevitJsonProp.ClanAndType][RevitJsonProp.ClanName].ToString();
+                                decorator.Decoration = string.Empty;
+                                decorator.Decoration = string.Empty;
+                                model.Decorators.Add(decorator);
+                            }
+                            break;
                         default: break;
                     }
                 }
@@ -981,8 +1100,6 @@
         /// <summary>
         /// 浠巎son鏂囦欢涓В鏋�
         /// </summary>
-        /// <param name="revitJsonFile">json鏂囦欢璺緞</param>
-        /// <returns></returns>
         public static Model.RevitModel FromJsonFile(string revitJsonFile, out string msg)
         {
             if (!File.Exists(revitJsonFile))

--
Gitblit v1.9.3