From 91c87afb0418628d23962014dc7cdca4778642c5 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期一, 30 九月 2024 16:09:04 +0800
Subject: [PATCH] Revit解析修正

---
 Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs |   76 +++++++++++++++++++++++++++++--------
 1 files changed, 59 insertions(+), 17 deletions(-)

diff --git a/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs b/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs
index 61eb6f5..b023219 100644
--- a/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs
+++ b/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs
@@ -1,6 +1,4 @@
 锘縰sing HStation.Model;
-using Microsoft.VisualBasic;
-using System;
 
 namespace HStation.Service
 {
@@ -10,9 +8,8 @@
     public static class RevitCorrectHelper
     {
         /// <summary>
-        /// 淇(鏃犳硶淇浼氭姏鍑哄紓甯�)
+        /// 淇
         /// </summary>
-        /// <param name="rhs">RevitModel</param>
         public static bool Correct(this Model.RevitModel rhs, out string msg)
         {
             if (rhs == null)
@@ -152,13 +149,29 @@
                 {
                     if (exchanger.ConnectList != null && exchanger.ConnectList.Count > 0)
                     {
-                        foreach (var connect in exchanger.ConnectList)
+                        foreach (var connect in exchanger.ConnectList.ToList())
                         {
                             var connectParter = allParterList.Find(x => x.Id == connect.Id);
                             if (connectParter == null)
                             {
-                                msg = $"鎹㈢儹鍣細{exchanger.Id} 杩炴帴缁勪欢 {connect.Id} 涓嶅瓨鍦�";
-                                return false;
+                                exchanger.ConnectList.Remove(connect);
+                            }
+                            else
+                            {
+                                if (connectParter is RevitBlunthead blunthead)
+                                {
+                                    var decorator = new Model.RevitDecorator();
+                                    decorator.Id = blunthead.Id;
+                                    decorator.Code = blunthead.Code;
+                                    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);
+                                }
                             }
                         }
 
@@ -176,7 +189,7 @@
                         startJunction.ModelType = null;
                         startJunction.Description = "鎹㈢儹鍣ㄤ慨姝f椂锛岃嚜鍔ㄦ坊鍔�";
                         startJunction.Quality = exchanger.StartQuality;
-                        startJunction.Position = exchanger.StartPosition;
+                        startJunction.Position = startConnectList.GetCenterPosition();
                         startJunction.Elev = exchanger.StartElev;
                         startJunction.Demand = null;
                         startJunction.DemandPattern = null;
@@ -185,9 +198,16 @@
                         foreach (var startConnect in startConnectList)
                         {
                             var startConnectParter = allParterList.Find(x => x.Id == startConnect.Id);
-                            if (startConnectParter is IRevitLink revitLink)
+                            if (startConnectParter is RevitLink revitLink)
                             {
-                                revitLink.EndCode = startJunction.Id;
+                                if (revitLink.StartCode == exchanger.Id)
+                                {
+                                    revitLink.StartCode = startJunction.Id;
+                                }
+                                else if (revitLink.EndCode == exchanger.Id)
+                                {
+                                    revitLink.EndCode = startJunction.Id;
+                                }
                             }
                         }
                         allParterList.Add(startJunction);
@@ -206,7 +226,7 @@
                         endJunction.ModelType = null;
                         endJunction.Description = "鎹㈢儹鍣ㄤ慨姝f椂锛岃嚜鍔ㄦ坊鍔�";
                         endJunction.Quality = exchanger.EndQuality;
-                        endJunction.Position = exchanger.EndPosition;
+                        endJunction.Position = endConnectList.GetCenterPosition();
                         endJunction.Elev = exchanger.EndElev;
                         endJunction.Demand = null;
                         endJunction.DemandPattern = null;
@@ -215,9 +235,16 @@
                         foreach (var endConnect in endConnectList)
                         {
                             var endConnectParter = allParterList.Find(x => x.Id == endConnect.Id);
-                            if (endConnectParter is IRevitLink revitLink)
+                            if (endConnectParter is RevitLink revitLink)
                             {
-                                revitLink.StartCode = endJunction.Id;
+                                if (revitLink.StartCode == exchanger.Id)
+                                {
+                                    revitLink.StartCode = endJunction.Id;
+                                }
+                                else if (revitLink.EndCode == exchanger.Id)
+                                {
+                                    revitLink.EndCode = endJunction.Id;
+                                }
                             }
                         }
                         allParterList.Add(endJunction);
@@ -262,7 +289,7 @@
             foreach (var link in allLinks)
             {
                 var startLinkParter = allParterList.Find(x => x.Code == link.StartCode);
-                if (startLinkParter is IRevitLink)
+                if (startLinkParter is RevitLink startLink)
                 {
                     var junction = new Model.RevitJunction();
                     junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList());
@@ -278,12 +305,20 @@
                     junction.DemandPattern = null;
                     rhs.Junctions.Add(junction);
                     link.StartCode = junction.Code;
-                    (startLinkParter as IRevitLink).EndCode = junction.Code;
+
+                    if (startLink.StartCode == link.Code)
+                    {
+                        startLink.StartCode = junction.Code;
+                    }
+                    else if (startLink.EndCode == link.Code)
+                    {
+                        startLink.EndCode = junction.Code;
+                    }
                     allParterList.Add(junction);
                 }
 
                 var endLinkParter = allParterList.Find(x => x.Code == link.EndCode);
-                if (endLinkParter is IRevitLink)
+                if (endLinkParter is RevitLink endLink)
                 {
                     var junction = new Model.RevitJunction();
                     junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList());
@@ -299,7 +334,14 @@
                     junction.DemandPattern = null;
                     rhs.Junctions.Add(junction);
                     link.EndCode = junction.Code;
-                    (endLinkParter as IRevitLink).StartCode = junction.Code;
+                    if (endLink.StartCode == link.Code)
+                    {
+                        endLink.StartCode = junction.Code;
+                    }
+                    else if (endLink.EndCode == link.Code)
+                    {
+                        endLink.EndCode = junction.Code;
+                    }
                     allParterList.Add(junction);
                 }
             }

--
Gitblit v1.9.3