| | |
| | | {//修正换热器 |
| | | result = false; |
| | | } |
| | | if (!CorrectCompressor(rhs, ref msgList)) |
| | | {//修正空压机 |
| | | result = false; |
| | | } |
| | | if (!CorrectCode(rhs, ref msgList)) |
| | | {//修正编码 |
| | | result = false; |
| | |
| | | {//四通 |
| | | rhs.Fourlinks = new List<Model.RevitFourlink>(); |
| | | } |
| | | if (rhs.Nozzles == null) |
| | | {//喷头 |
| | | rhs.Nozzles = new List<Model.RevitNozzle>(); |
| | | } |
| | | if (rhs.Hydrants == null) |
| | | {//消火栓 |
| | | rhs.Hydrants = new List<Model.RevitHydrant>(); |
| | | } |
| | | if (rhs.Meters == null) |
| | | {//水表 |
| | | rhs.Meters = new List<RevitMeter>(); |
| | |
| | | {//压力表 |
| | | rhs.Pressmeters = new List<Model.RevitPressmeter>(); |
| | | } |
| | | if (rhs.Nozzles == null) |
| | | {//喷头 |
| | | rhs.Nozzles = new List<Model.RevitNozzle>(); |
| | | } |
| | | if (rhs.Hydrants == null) |
| | | {//消火栓 |
| | | rhs.Hydrants = new List<Model.RevitHydrant>(); |
| | | } |
| | | |
| | | if (rhs.Pipes == null) |
| | | {//管道 |
| | |
| | | {//过渡件 |
| | | rhs.Translations = new List<Model.RevitTranslation>(); |
| | | } |
| | | if (rhs.Exchangers == null) |
| | | {//换热器 |
| | | rhs.Exchangers = new List<RevitExchanger>(); |
| | | } |
| | | if (rhs.Pumps == null) |
| | | {//水泵 |
| | | rhs.Pumps = new List<Model.RevitPump>(); |
| | |
| | | if (rhs.Valves == null) |
| | | {//阀门 |
| | | rhs.Valves = new List<Model.RevitValve>(); |
| | | } |
| | | if (rhs.Exchangers == null) |
| | | {//换热器 |
| | | rhs.Exchangers = new List<RevitExchanger>(); |
| | | } |
| | | if (rhs.Compressors == null) |
| | | {//空压机 |
| | | rhs.Compressors = new List<RevitCompressor>(); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | if (rhs.Exchangers != null && rhs.Exchangers.Count > 0) |
| | | {//换热器 |
| | | var exchangerNameList = rhs.Exchangers.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).Distinct().ToList(); |
| | | foreach (var exchanger in rhs.Exchangers) |
| | | { |
| | | if (string.IsNullOrEmpty(exchanger.Name)) |
| | | { |
| | | var exchangerName = Yw.Untity.UniqueHelper.CreateFromFirst("换热器", exchangerNameList); |
| | | exchanger.Name = exchangerName; |
| | | exchangerNameList.Add(exchangerName); |
| | | } |
| | | } |
| | | } |
| | | if (rhs.Pumps != null && rhs.Pumps.Count > 0) |
| | | {//水泵 |
| | | var pumpNameList = rhs.Pumps.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).Distinct().ToList(); |
| | |
| | | var valveName = Yw.Untity.UniqueHelper.CreateFromFirst("阀门", valveNameList); |
| | | valve.Name = valveName; |
| | | valveNameList.Add(valveName); |
| | | } |
| | | } |
| | | } |
| | | if (rhs.Exchangers != null && rhs.Exchangers.Count > 0) |
| | | {//换热器 |
| | | var exchangerNameList = rhs.Exchangers.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).Distinct().ToList(); |
| | | foreach (var exchanger in rhs.Exchangers) |
| | | { |
| | | if (string.IsNullOrEmpty(exchanger.Name)) |
| | | { |
| | | var exchangerName = Yw.Untity.UniqueHelper.CreateFromFirst("换热器", exchangerNameList); |
| | | exchanger.Name = exchangerName; |
| | | exchangerNameList.Add(exchangerName); |
| | | } |
| | | } |
| | | } |
| | | if (rhs.Compressors != null && rhs.Compressors.Count > 0) |
| | | {//空压机 |
| | | var compressorNameList = rhs.Compressors.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).Distinct().ToList(); |
| | | foreach (var compressor in rhs.Compressors) |
| | | { |
| | | if (string.IsNullOrEmpty(compressor.Name)) |
| | | { |
| | | var compressorName = Yw.Untity.UniqueHelper.CreateFromFirst("空压机", compressorNameList); |
| | | compressor.Name = compressorName; |
| | | compressorNameList.Add(compressorName); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | var decorator = new Model.RevitDecorator(); |
| | | decorator.Id = blunthead.Id; |
| | | decorator.Code = blunthead.Code; |
| | | decorator.Name = blunthead.Name; |
| | | decorator.Category = RevitJsonCatalog.Blunthead; |
| | | decorator.Decoration = null; |
| | |
| | | } |
| | | if (startConnectList.Count < 1) |
| | | { |
| | | msgList.Add($"换热器[{exchanger.Code}]上游连接组件不存在"); |
| | | msgList.Add($"换热器[{exchanger.Id}]上游连接组件不存在"); |
| | | result = false; |
| | | continue; |
| | | } |
| | | var startJunction = new Model.RevitJunction(); |
| | | startJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); |
| | | startJunction.Code = startJunction.Id; |
| | | startJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); |
| | | startJunction.Name = UniqueHelper.CreateFromFirst("连接节点", allParterList.Select(x => x.Name).Distinct().ToList()); |
| | | startJunction.Flags = null; |
| | | startJunction.ModelType = null; |
| | | startJunction.Description = "换热器修正时,自动添加"; |
| | | startJunction.Quality = exchanger.StartQuality; |
| | | startJunction.Position = startConnectList.GetCenterPosition(); |
| | | startJunction.Elev = exchanger.StartElev; |
| | | startJunction.Elev = exchanger.Elev; |
| | | startJunction.Demand = null; |
| | | startJunction.DemandPattern = null; |
| | | rhs.Junctions.Add(startJunction); |
| | | exchanger.StartCode = startJunction.Code; |
| | | exchanger.StartCode = startJunction.Id; |
| | | foreach (var startConnect in startConnectList) |
| | | { |
| | | var startConnectParter = allParterList.Find(x => x.Id == startConnect.Id); |
| | |
| | | } |
| | | if (endConnectList.Count < 1) |
| | | { |
| | | msgList.Add($"换热器[{exchanger.Code}]下游连接组件不存在"); |
| | | msgList.Add($"换热器[{exchanger.Id}]下游连接组件不存在"); |
| | | result = false; |
| | | continue; |
| | | } |
| | | var endJunction = new Model.RevitJunction(); |
| | | endJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); |
| | | endJunction.Code = endJunction.Id; |
| | | endJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); |
| | | endJunction.Name = UniqueHelper.CreateFromFirst("连接节点", allParterList.Select(x => x.Name).Distinct().ToList()); |
| | | endJunction.Flags = null; |
| | | endJunction.ModelType = null; |
| | | endJunction.Description = "换热器修正时,自动添加"; |
| | | endJunction.Quality = exchanger.EndQuality; |
| | | endJunction.Position = endConnectList.GetCenterPosition(); |
| | | endJunction.Elev = exchanger.EndElev; |
| | | endJunction.Elev = exchanger.Elev; |
| | | endJunction.Demand = null; |
| | | endJunction.DemandPattern = null; |
| | | rhs.Junctions.Add(endJunction); |
| | | exchanger.EndCode = endJunction.Code; |
| | | exchanger.EndCode = endJunction.Id; |
| | | foreach (var endConnect in endConnectList) |
| | | { |
| | | var endConnectParter = allParterList.Find(x => x.Id == endConnect.Id); |
| | |
| | | } |
| | | else |
| | | { |
| | | msgList.Add($"换热器[{exchanger.Code}]连接列表为空"); |
| | | msgList.Add($"换热器[{exchanger.Id}]连接列表为空"); |
| | | result = false; |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | //修复空压机 |
| | | private static bool CorrectCompressor(Model.RevitModel rhs, ref List<string> msgList) |
| | | { |
| | | if (rhs == null) |
| | | { |
| | | return false; |
| | | } |
| | | if (msgList == null) |
| | | { |
| | | msgList = new List<string>(); |
| | | } |
| | | var result = true; |
| | | if (rhs.Compressors != null && rhs.Compressors.Count > 0) |
| | | { |
| | | var allParterList = rhs.GetAllParters(); |
| | | foreach (var compressor in rhs.Compressors) |
| | | { |
| | | if (compressor.ConnectList != null && compressor.ConnectList.Count > 0) |
| | | { |
| | | #region 去除无效连接和闷头 |
| | | |
| | | foreach (var connect in compressor.ConnectList.ToList()) |
| | | { |
| | | var connectParter = allParterList.Find(x => x.Id == connect.Id); |
| | | if (connectParter == null) |
| | | { |
| | | compressor.ConnectList.Remove(connect); |
| | | } |
| | | else |
| | | { |
| | | if (connectParter is RevitBlunthead blunthead) |
| | | { |
| | | var decorator = new Model.RevitDecorator(); |
| | | decorator.Id = blunthead.Id; |
| | | decorator.Name = blunthead.Name; |
| | | decorator.Category = RevitJsonCatalog.Blunthead; |
| | | decorator.Decoration = null; |
| | | decorator.Description = blunthead.Description; |
| | | rhs.Decorators.Add(decorator); |
| | | rhs.Bluntheads.Remove(blunthead); |
| | | allParterList.Remove(connectParter); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 开始连接 |
| | | |
| | | var startConnectList = compressor.ConnectList.GetStartConnects(); |
| | | if (startConnectList.Count < 1) |
| | | { |
| | | var startConnect = compressor.ConnectList.GetStartConnect(); |
| | | if (startConnect != null) |
| | | { |
| | | startConnectList.Add(startConnect); |
| | | } |
| | | } |
| | | if (startConnectList.Count < 1) |
| | | { |
| | | msgList.Add($"空压机[{compressor.Id}]上游连接组件不存在"); |
| | | result = false; |
| | | continue; |
| | | } |
| | | var startJunction = new Model.RevitJunction(); |
| | | startJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); |
| | | startJunction.Name = UniqueHelper.CreateFromFirst("连接节点", allParterList.Select(x => x.Name).Distinct().ToList()); |
| | | startJunction.Flags = null; |
| | | startJunction.ModelType = null; |
| | | startJunction.Description = "空压机修正时,自动添加"; |
| | | startJunction.Position = startConnectList.GetCenterPosition(); |
| | | startJunction.Elev = compressor.Elev; |
| | | startJunction.Demand = null; |
| | | startJunction.DemandPattern = null; |
| | | rhs.Junctions.Add(startJunction); |
| | | compressor.StartCode = startJunction.Id; |
| | | foreach (var startConnect in startConnectList) |
| | | { |
| | | var startConnectParter = allParterList.Find(x => x.Id == startConnect.Id); |
| | | if (startConnectParter is RevitLink revitLink) |
| | | { |
| | | if (revitLink.StartCode == compressor.Id) |
| | | { |
| | | revitLink.StartCode = startJunction.Id; |
| | | } |
| | | else if (revitLink.EndCode == compressor.Id) |
| | | { |
| | | revitLink.EndCode = startJunction.Id; |
| | | } |
| | | } |
| | | } |
| | | allParterList.Add(startJunction); |
| | | |
| | | #endregion |
| | | |
| | | #region 结束连接 |
| | | |
| | | var endConnectList = compressor.ConnectList.GetEndConnects(); |
| | | if (endConnectList.Count < 1) |
| | | { |
| | | var endConnect = compressor.ConnectList.GetEndConnect(); |
| | | if (endConnect != null) |
| | | { |
| | | endConnectList.Add(endConnect); |
| | | } |
| | | } |
| | | if (endConnectList.Count < 1) |
| | | { |
| | | msgList.Add($"空压机[{compressor.Id}]下游连接组件不存在"); |
| | | result = false; |
| | | continue; |
| | | } |
| | | var endJunction = new Model.RevitJunction(); |
| | | endJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); |
| | | endJunction.Name = UniqueHelper.CreateFromFirst("连接节点", allParterList.Select(x => x.Name).Distinct().ToList()); |
| | | endJunction.Flags = null; |
| | | endJunction.ModelType = null; |
| | | endJunction.Description = "空压机修正时,自动添加"; |
| | | endJunction.Position = endConnectList.GetCenterPosition(); |
| | | endJunction.Elev = compressor.Elev; |
| | | endJunction.Demand = null; |
| | | endJunction.DemandPattern = null; |
| | | rhs.Junctions.Add(endJunction); |
| | | compressor.EndCode = endJunction.Id; |
| | | foreach (var endConnect in endConnectList) |
| | | { |
| | | var endConnectParter = allParterList.Find(x => x.Id == endConnect.Id); |
| | | if (endConnectParter is RevitLink revitLink) |
| | | { |
| | | if (revitLink.StartCode == compressor.Id) |
| | | { |
| | | revitLink.StartCode = endJunction.Id; |
| | | } |
| | | else if (revitLink.EndCode == compressor.Id) |
| | | { |
| | | revitLink.EndCode = endJunction.Id; |
| | | } |
| | | } |
| | | } |
| | | allParterList.Add(endJunction); |
| | | |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | msgList.Add($"空压机[{compressor.Id}]连接列表为空"); |
| | | result = false; |
| | | } |
| | | } |
| | |
| | | var startLinkParter = allParterList.Find(x => x.Id == link.StartCode); |
| | | if (startLinkParter == null) |
| | | { |
| | | msgList.Add($"管段:[{link.Code}]上游节点错误"); |
| | | msgList.Add($"管段:[{link.Id}]上游节点[{link.StartCode}]错误"); |
| | | result = false; |
| | | } |
| | | else |
| | | { |
| | | link.StartCode = startLinkParter.Code; |
| | | link.StartCode = startLinkParter.Id; |
| | | } |
| | | |
| | | var endLinkParter = allParterList.Find(x => x.Id == link.EndCode); |
| | | if (endLinkParter == null) |
| | | { |
| | | msgList.Add($"管段:[{link.Code}]下游节点错误"); |
| | | msgList.Add($"管段:[{link.Id}]下游节点[{link.EndCode}]错误"); |
| | | result = false; |
| | | } |
| | | else |
| | | { |
| | | link.EndCode = endLinkParter.Code; |
| | | link.EndCode = endLinkParter.Id; |
| | | } |
| | | |
| | | } |
| | |
| | | var allLinks = rhs.GetAllLinks(); |
| | | foreach (var link in allLinks) |
| | | { |
| | | var startLinkParter = allParterList.Find(x => x.Code == link.StartCode); |
| | | var startLinkParter = allParterList.Find(x => x.Id == link.StartCode); |
| | | if (startLinkParter is RevitLink startLink) |
| | | { |
| | | var junction = new Model.RevitJunction(); |
| | | junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); |
| | | junction.Code = junction.Id; |
| | | junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); |
| | | junction.Name = UniqueHelper.CreateFromFirst("连接节点", allParterList.Select(x => x.Name).Distinct().ToList()); |
| | | junction.Flags = null; |
| | | junction.ModelType = null; |
| | | junction.Description = "水力修正时,自动添加"; |
| | | junction.Quality = link.StartQuality; |
| | | junction.Position = link.StartPosition; |
| | | junction.Elev = link.StartElev; |
| | | junction.Elev = link.StartPosition.Z; |
| | | junction.Demand = null; |
| | | junction.DemandPattern = null; |
| | | rhs.Junctions.Add(junction); |
| | | link.StartCode = junction.Code; |
| | | link.StartCode = junction.Id; |
| | | |
| | | if (startLink.StartCode == link.Code) |
| | | if (startLink.StartCode == link.Id) |
| | | { |
| | | startLink.StartCode = junction.Code; |
| | | startLink.StartCode = junction.Id; |
| | | } |
| | | else if (startLink.EndCode == link.Code) |
| | | else if (startLink.EndCode == link.Id) |
| | | { |
| | | startLink.EndCode = junction.Code; |
| | | startLink.EndCode = junction.Id; |
| | | } |
| | | allParterList.Add(junction); |
| | | } |
| | | |
| | | var endLinkParter = allParterList.Find(x => x.Code == link.EndCode); |
| | | var endLinkParter = allParterList.Find(x => x.Id == link.EndCode); |
| | | if (endLinkParter is RevitLink endLink) |
| | | { |
| | | var junction = new Model.RevitJunction(); |
| | | junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); |
| | | junction.Code = junction.Id; |
| | | junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); |
| | | junction.Name = UniqueHelper.CreateFromFirst("连接节点", allParterList.Select(x => x.Name).Distinct().ToList()); |
| | | junction.Flags = null; |
| | | junction.ModelType = null; |
| | | junction.Description = "水力修正时,自动添加"; |
| | | junction.Quality = link.EndQuality; |
| | | junction.Position = link.EndPosition; |
| | | junction.Elev = link.EndElev; |
| | | junction.Elev = link.EndPosition.Z; |
| | | junction.Demand = null; |
| | | junction.DemandPattern = null; |
| | | rhs.Junctions.Add(junction); |
| | | link.EndCode = junction.Code; |
| | | if (endLink.StartCode == link.Code) |
| | | link.EndCode = junction.Id; |
| | | if (endLink.StartCode == link.Id) |
| | | { |
| | | endLink.StartCode = junction.Code; |
| | | endLink.StartCode = junction.Id; |
| | | } |
| | | else if (endLink.EndCode == link.Code) |
| | | else if (endLink.EndCode == link.Id) |
| | | { |
| | | endLink.EndCode = junction.Code; |
| | | endLink.EndCode = junction.Id; |
| | | } |
| | | allParterList.Add(junction); |
| | | } |