| | |
| | | } |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Cooling: |
| | | { |
| | | var cooling = ParseCooling(jobject); |
| | | if (cooling != null) |
| | | { |
| | | model.Coolings.Add(cooling); |
| | | } |
| | | } |
| | | break; |
| | | case RevitJsonCatalog.Pipe: |
| | | { |
| | | var pipe = ParsePipe(jobject); |
| | |
| | | return hydrant; |
| | | } |
| | | |
| | | //解析冷却塔 |
| | | 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, "[连接列表]解析失败"); |
| | | } |
| | | } |
| | | 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, "[位置信息]缺省,可能是受[连接列表]解析失败影响"); |
| | | } |
| | | |
| | | #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, "[口径信息]缺少或者数据格式错误"); |
| | | } |
| | | |
| | | #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; |
| | | } |
| | | |
| | | //解析水表 |
| | | private static HStation.Model.RevitMeter ParseMeter(JToken jobject) |
| | | { |