Pārlūkot izejas kodu

mxg:修正待建模型清单,创建后未从列表中移除问题

mengxiangge 6 gadi atpakaļ
vecāks
revīzija
b06f000396

+ 25 - 10
MBI/SAGA.MBI/DataArrange/DalUploadFloor.cs

@@ -342,19 +342,34 @@ namespace SAGA.MBI.DataArrange
                 else
                 {
                     //请求Duty,Bim数据库中的id
-                    var dutyId = mode.GetDutyBIMRelationByDuty()?.DutyId;
+                    var dutyId = mode.GetDutyBIMRelationByBIM()?.DutyId;
                     if (dutyId.IsNullOrEmpty())
                     {//本地数据库不存在此岗位
                         mode.Operator = DocumentChangedOperator.Add;
                     }
                     else
                     {
-                        mode.Id = dutyId;
-                        mode.Operator = DocumentChangedOperator.Modified;
-                        //处理设备所在楼层,Add方法已经处理设备所在楼层关系
-                        RltEquipinFloor rlt =
-                            new RltEquipinFloor(dutyId, context.FloorId) {Operator = DocumentChangedOperator.Add};
-                        context.UnGroupDatas.Add(rlt);
+                        //物理世界存在该岗位
+                        var tempmode = CommonConvert.QueryObjectById(dutyId);
+                        if (tempmode != null)
+                        {
+                            //更改族名称处理,如果设备族四位或六位改了,需要将岗位删除,重建岗位
+                            if (mode.EquipClassCode != tempmode.EquipClassCode)
+                            {
+                                mode.Operator = DocumentChangedOperator.Add;
+                                tempmode.Operator = DocumentChangedOperator.Delete;
+                                context.Add(tempmode);
+                            }
+                            else
+                            {
+                                mode.Id = dutyId;
+                                mode.Operator = DocumentChangedOperator.Modified;
+                                //处理设备所在楼层,Add方法已经处理设备所在楼层关系
+                                RltEquipinFloor rlt =
+                                    new RltEquipinFloor(dutyId, context.FloorId) { Operator = DocumentChangedOperator.Add };
+                                context.UnGroupDatas.Add(rlt);
+                            }
+                        }
                     }
                     context.Add(mode);
                 }
@@ -368,7 +383,7 @@ namespace SAGA.MBI.DataArrange
         {
             //如果为空间并且周长为零,删除云平台的空间数据
             if (OperateZeroSpace(mode, elem)) return;
-            
+
             if (mode != null)
             {
                 //物理世界存在该岗位
@@ -402,14 +417,14 @@ namespace SAGA.MBI.DataArrange
                 else
                 {
                     //请求Duty,本地数据库中的id,待建模设备
-                    var dutyId = newmode.GetDutyBIMRelationByDuty()?.DutyId;
+                    var dutyId = newmode.GetDutyBIMRelationByBIM()?.DutyId;
                     if (dutyId.IsNotNullEmpty())
                     {//本地数据库存在
                         newmode.Id = dutyId;
                         newmode.Operator = DocumentChangedOperator.Modified;
                         //处理设备所在楼层,Add方法已经处理设备所在楼层关系
                         RltEquipinFloor rlt =
-                            new RltEquipinFloor(dutyId, context.FloorId) {Operator = DocumentChangedOperator.Add};
+                            new RltEquipinFloor(dutyId, context.FloorId) { Operator = DocumentChangedOperator.Add };
                         context.UnGroupDatas.Add(rlt);
                     }
                     else

+ 33 - 2
MBI/SAGA.MBI/RevitReference/RVTNoModeDutyOperate.cs

@@ -22,6 +22,7 @@ using SAGA.MBI.WinView.BeModingDutyList;
 using SAGA.RevitUtils.Extends;
 using SAGA.RevitUtils.Windows;
 using SAGA.MBI.Extend;
+using SAGA.DotNetUtils.Others;
 
 namespace SAGA.MBI.RevitReference
 {
@@ -46,7 +47,10 @@ namespace SAGA.MBI.RevitReference
                         try
                         {
                             FamilySymbol fs = doc.GetFamilySymbol(mode.MEquipBase.EquipClassCode);
-                            if (fs == null) return Result.Cancelled;
+                            if (fs == null)
+                            {
+                                MessageShowBase.Infomation($"没有找到编码{mode.MEquipBase.EquipClassCode}类型的族,请手动载入后再操作。");
+                                return Result.Cancelled; }
                             if (IsBasePointFamily(fs))
                             {
                                 //使用BIMLocation中的坐标,mm转为英寸
@@ -96,6 +100,33 @@ namespace SAGA.MBI.RevitReference
             Level level = view?.GenLevel ?? doc.GetLevels().FirstOrDefault();
             return level;
         }
-
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        public static void RegenerateMode(Element elem)
+        {
+            var doc = ExternalDataWrapper.Current.Doc;
+            FamilyInstance fi = null;
+            ExecuteCmd.ExecuteCommand(() =>
+            {
+                using (Transaction trans = new Transaction(doc, "更新设备信息"))
+                {
+                    trans.Start();
+                    try
+                    {
+                        var p1 = elem.GetParameterString(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS);
+                        elem.SetParameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS, p1);
+                        trans.Commit();
+                    }
+                    catch (Exception e)
+                    {
+                        trans.RollBack();
+                    }
+                    return Result.Succeeded;
+                }
+            }
+            );
+        }
     }
 }

+ 10 - 5
MBI/SAGA.MBI/WinView/BeModingDutyList/MEquipNoMode.cs

@@ -174,6 +174,7 @@ namespace SAGA.MBI.WinView.BeModingDutyList
                 {
                     MEquipBase.SaveDutyBIMRelation(equipM.FloorId, elem.Id.ToString());
                     this.BimId = elem.Id.ToString();
+                    RVTNoModeDutyOperate.RegenerateMode(elem);
                     return;
                 }
 
@@ -194,7 +195,7 @@ namespace SAGA.MBI.WinView.BeModingDutyList
             }
             else
             {
-                WinCommonTip win=new WinCommonTip();
+                WinCommonTip win = new WinCommonTip();
                 win.Show("请先选中模型再关联!!!", "", buttonStyle: MessageBoxButton.OK);
             }
         }
@@ -249,10 +250,14 @@ namespace SAGA.MBI.WinView.BeModingDutyList
             if (space != null)
             {
                 var spaceM = DalSpace.GetSpaceQueryId(space);
-                var rltspaceDel = new RltEquipInSpace(MEquipBase.Id, null) { Operator = DocumentChangedOperator.Delete };
-                rltspaceDel.AddorUpdateObject();
-                var rltspaceAdd = new RltEquipInSpace(MEquipBase.Id, spaceM.Id) { Operator = DocumentChangedOperator.Add };
-                rltspaceAdd.AddorUpdateObject();
+                if (spaceM != null)
+                {
+                    var rltspaceDel = new RltEquipInSpace(MEquipBase.Id, null) { Operator = DocumentChangedOperator.Delete };
+                    rltspaceDel.AddorUpdateObject();
+                    var rltspaceAdd = new RltEquipInSpace(MEquipBase.Id, spaceM.Id) { Operator = DocumentChangedOperator.Add };
+                    rltspaceAdd.AddorUpdateObject();
+                }
+
             }
         }
     }