duheng
2024-10-16 083c4e47c7a59025f3348bd093693c6b3febb014
Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs
@@ -1,6 +1,4 @@
using 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)
@@ -47,7 +44,7 @@
        private static bool Zero(Model.RevitModel rhs, out string msg)
        {
            msg = string.Empty;
            var allWaterSourceList = rhs.GetAllWaterSources();
            var allWaterSourceList = rhs.GetAllSources();
            if (allWaterSourceList == null || allWaterSourceList.Count < 1)
            {
                msg = "无水源";
@@ -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);
                                }
                            }
                        }
@@ -185,7 +198,7 @@
                        foreach (var startConnect in startConnectList)
                        {
                            var startConnectParter = allParterList.Find(x => x.Id == startConnect.Id);
                            if (startConnectParter is IRevitLink revitLink)
                            if (startConnectParter is RevitLink revitLink)
                            {
                                if (revitLink.StartCode == exchanger.Id)
                                {
@@ -222,7 +235,7 @@
                        foreach (var endConnect in endConnectList)
                        {
                            var endConnectParter = allParterList.Find(x => x.Id == endConnect.Id);
                            if (endConnectParter is IRevitLink revitLink)
                            if (endConnectParter is RevitLink revitLink)
                            {
                                if (revitLink.StartCode == exchanger.Id)
                                {
@@ -276,7 +289,7 @@
            foreach (var link in allLinks)
            {
                var startLinkParter = allParterList.Find(x => x.Code == link.StartCode);
                if (startLinkParter is IRevitLink startLink)
                if (startLinkParter is RevitLink startLink)
                {
                    var junction = new Model.RevitJunction();
                    junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList());
@@ -293,11 +306,11 @@
                    rhs.Junctions.Add(junction);
                    link.StartCode = junction.Code;
                    if (startLink.StartCode == link.StartCode)
                    if (startLink.StartCode == link.Code)
                    {
                        startLink.StartCode = junction.Code;
                    }
                    else if (startLink.EndCode == link.StartCode)
                    else if (startLink.EndCode == link.Code)
                    {
                        startLink.EndCode = junction.Code;
                    }
@@ -305,7 +318,7 @@
                }
                var endLinkParter = allParterList.Find(x => x.Code == link.EndCode);
                if (endLinkParter is IRevitLink endLink)
                if (endLinkParter is RevitLink endLink)
                {
                    var junction = new Model.RevitJunction();
                    junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList());
@@ -321,11 +334,11 @@
                    junction.DemandPattern = null;
                    rhs.Junctions.Add(junction);
                    link.EndCode = junction.Code;
                    if (endLink.StartCode == link.EndCode)
                    if (endLink.StartCode == link.Code)
                    {
                        endLink.StartCode = junction.Code;
                    }
                    else if (endLink.EndCode == link.EndCode)
                    else if (endLink.EndCode == link.Code)
                    {
                        endLink.EndCode = junction.Code;
                    }