소스 검색

Merge branch 'master' of http://dev.dp.sagacloud.cn:8886/r/Revit/SAGA.MBI

xulisong 6 년 전
부모
커밋
0504fc176c

+ 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

+ 4 - 1
MBI/SAGA.MBI/Extend/DocExtend.cs

@@ -114,7 +114,10 @@ namespace SAGA.MBI.Tools
             List<Family> listFamily = doc.GetFamilys();
             var fa = listFamily.FirstOrDefault(t => filterFamily(t.Name));
             List<FamilySymbol> symbolList = fa?.GetFamilySymbols();
-            return symbolList?.FirstOrDefault();
+            var fs= symbolList?.FirstOrDefault();
+            if (fs!=null&&!fs.IsActive)
+                fs.Activate();
+            return fs;
         }
     }
 }

+ 1 - 1
MBI/SAGA.MBI/Extend/ElementExtend.cs

@@ -130,7 +130,7 @@ namespace SAGA.MBI.Tools
         /// <returns></returns>
         public static XYZ ToXyz(this string xyzstr)
         {
-            XYZ xyz = null;
+            XYZ xyz = XYZ.Zero;
             var strs = xyzstr.Split(',');
             if (strs.Length == 3)
             {

+ 37 - 4
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,12 +47,17 @@ 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))
                             {
-                                XYZ xyz = XYZ.Zero;
+                                //使用BIMLocation中的坐标,mm转为英寸
+                                XYZ xyz = mode.MEquipBase.Location.ToXyz().ConvertToApi();
                                 var level = GetCurFloorLevel(doc);
-
+                                //传标高,z值设置为零
+                                xyz=xyz.NewZ(0);
                                 fi = doc.Create.NewFamilyInstance(xyz, fs, level, StructuralType.NonStructural);
                                 mode.MEquipBase.SaveDutyBIMRelation(doc.PathName.GetFileName(),fi.Id.ToString());
                                 trans.Commit();
@@ -94,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;
+                }
+            }
+            );
+        }
     }
 }

+ 3 - 3
MBI/SAGA.MBI/ToolsData/DataCheck/DataCheckBase.cs

@@ -65,8 +65,8 @@ namespace SAGA.MBI.ToolsData.DataCheck
         {
             bool result = RIsChecked;
             
-            if (result)
-                result = !(results.All(t => t.IsRight));
+            //if (result)
+            //    result = !(results.All(t => t.IsRight));
             //如果有没有通过的项
             if (!result)
             {
@@ -99,7 +99,7 @@ namespace SAGA.MBI.ToolsData.DataCheck
         {
             DCRExport.SetTemplatePath(Context.TemplatePath);
             Export();
-            //SetSheetVisible();
+            SetSheetVisible();
         }
         #endregion
 

+ 3 - 10
MBI/SAGA.MBI/ToolsData/ModeCheck/ElementRangeCheck.cs

@@ -16,6 +16,8 @@ using SAGA.DotNetUtils.Others;
 using SAGA.MBI.Tools;
 using SAGA.MBI.ToolsData.CheckBase;
 using SAGA.RevitUtils.Extends;
+using NPOI.SS.Util;
+using NPOI.XSSF.UserModel;
 
 namespace SAGA.MBI.ToolsData.ModeCheck
 {
@@ -289,17 +291,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                 //添加 共检查XXX条数据,未通过检查的如下 提示
                 IRow rowTip = sheet.CreateRow(index - 1);
                 rowTip.AddCell(0, $"总检查{Results.Count}条数据,未通过检查的如下", DataCheckNPOIStyle.Title);
-                //IRow row4 = sheet.CreateRow(index);
-                //row4.HeightInPoints = 15;
 
-                //row4.AddCell(0, "楼层本地名称", DataCheckNPOIStyle.Title);
-                //row4.AddCell(1, "文件名", DataCheckNPOIStyle.Title);
-                //row4.AddCell(2, "文件地址", DataCheckNPOIStyle.Title);
-                //row4.AddCell(3, "族名称", DataCheckNPOIStyle.Title);
-                //row4.AddCell(4, "类型", DataCheckNPOIStyle.Title);
-                //row4.AddCell(5, "ID", DataCheckNPOIStyle.Title);
-                //row4.AddCell(6, "通过", DataCheckNPOIStyle.Title);
-                //row4.AddCell(7, "备注(失败原因)", DataCheckNPOIStyle.Title);
                 foreach (ElementRangeCheckResult result in Results)
                 {
                     SagaSignCheckResult rbase = result.RBase as SagaSignCheckResult;
@@ -321,6 +313,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                     rowN.AddCell(6, rowN4, style);
                     rowN.AddCell(7, result.RMessage, style);
                 }
+         
                 #endregion
 
             }

+ 1 - 0
MBI/SAGA.MBI/ToolsData/ModeCheck/FloorMissCheck.cs

@@ -35,6 +35,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         public FloorMiss()
         {
             Name = "楼层缺失检查";
+            RIsNeedTwoMoreFloors = true;
         }
         [DataCheckProcessAspect]
         public override bool Check()

+ 1 - 0
MBI/SAGA.MBI/ToolsData/ModeCheck/FloorSequenceCheck.cs

@@ -33,6 +33,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         public FloorSequenceCheck()
         {
             Name = "楼层标高与楼层顺序号检查";
+            RIsNeedTwoMoreFloors = true;
         }
         [DataCheckProcessAspect]
         public override bool Check()

+ 1 - 0
MBI/SAGA.MBI/ToolsData/ModeCheck/GridCheck.cs

@@ -25,6 +25,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         public GridCheck()
         {
             Name = "轴网检查";
+            RIsNeedTwoMoreFloors = true;
         }
         [DataCheckProcessAspect]
         public override bool Check()

+ 7 - 3
MBI/SAGA.MBI/ToolsData/ModeCheck/ModeCheckBase.cs

@@ -70,8 +70,8 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         {
             bool result = RIsChecked;
             
-            if (result)
-                result = !(results.All(t => t.IsRight));
+            //if (result)
+            //    result = !(results.All(t => t.IsRight));
             //如果有没有通过的项
             if (!result)
             {
@@ -104,7 +104,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         {
             DCRExport.SetTemplatePath(Context.TemplatePath);
             Export();
-            //SetSheetVisible();
+            SetSheetVisible();
         }
         #endregion
 
@@ -127,6 +127,10 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             get { return m_SpecificationSheet; }
             set { m_SpecificationSheet = value; }
         }
+        /// <summary>
+        /// 两层以上楼层检查才有意义
+        /// </summary>
+        public bool RIsNeedTwoMoreFloors { get; set; }
 
         #endregion
     }

+ 9 - 12
MBI/SAGA.MBI/ToolsData/ModeCheck/SagaPositionCheck.cs

@@ -56,19 +56,16 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             bool sequenceResult = true;
             //标准通过率
             double rrate =m_RateValue;
-            if (RBase.Results.Count > 1)
+            foreach (SagaSignCheckResult result in RBase.Results)
             {
-                foreach (SagaSignCheckResult result in RBase.Results)
-                {
-                    double rate = result.RCPassRate;
-                    bool isright= rate.IsThanEq(rrate);
-                    string tip = isright ?"": $"构件范围检查通过率低于{rrate*100}%,请检查saga标记位置是否正确";
-                    var tempResult=new SagaPositionCheckCheckResult();
-                    tempResult.IsRight = isright;
-                    tempResult.RMessage = tip;
-                    tempResult.RBase = result;
-                    Results.Add(tempResult);
-                }
+                double rate = result.RCPassRate;
+                bool isright = rate.IsThanEq(rrate);
+                string tip = isright ? "" : $"构件范围检查通过率低于{rrate * 100}%,请检查saga标记位置是否正确";
+                var tempResult = new SagaPositionCheckCheckResult();
+                tempResult.IsRight = isright;
+                tempResult.RMessage = tip;
+                tempResult.RBase = result;
+                Results.Add(tempResult);
             }
 
             return sequenceResult;

+ 3 - 2
MBI/SAGA.MBI/ToolsData/ModeCheck/WinModeCheckSetting.xaml

@@ -43,7 +43,7 @@
                                 <WrapPanel>
                                     <CheckBox IsChecked="{Binding Path=IsSelected,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
                                               Width="Auto" VerticalContentAlignment="Center" 
-                                              Click="TreeItemChecked_OnChecked">
+                                              Click="TreeItem_Click">
                                     </CheckBox>
                                     <Label Content="{Binding Path=Item.TvItemName}"></Label>
                                 </WrapPanel>
@@ -66,7 +66,8 @@
                                 <WrapPanel  >
                                     <CheckBox IsChecked="{Binding Path=RIsChecked,UpdateSourceTrigger=PropertyChanged}" 
                                       IsEnabled="{Binding Path=RIsReadOnly,Converter={StaticResource BoolInverseConverter}}"
-                                      VerticalContentAlignment="Center"></CheckBox>
+                                      VerticalContentAlignment="Center"
+                                              Click="CheckItem_Click"></CheckBox>
                                     <Label Content="{Binding Path=Name}"></Label>
                                 </WrapPanel>
                             </DataTemplate>

+ 50 - 12
MBI/SAGA.MBI/ToolsData/ModeCheck/WinModeCheckSetting.xaml.cs

@@ -28,14 +28,14 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             myListbox.ItemsSource = checkItems;
             Init();
             this.DataContext = this;
-            
+
         }
 
         private void Init()
         {
             ProjectList = MBIControl.ProjectTree.Children;
             if (ProjectList.FirstOrDefault() != null)
-                SetTreeState(ProjectList.FirstOrDefault(), true);
+                SetTreeItemState(ProjectList.FirstOrDefault(), true);
             SavePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
                 $"{MBIControl.ProjectCur}{m_CheckType.GetDescription()}检查结果.xlsx");
             OFImage = CommonTool.GetBtnImagePath(SavePath);
@@ -105,7 +105,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             {
                 MessageBox.Show("请选择需要检查的建筑");
                 if (ProjectList.FirstOrDefault() != null)
-                    SetTreeState(ProjectList.FirstOrDefault(), true);
+                    SetTreeItemState(ProjectList.FirstOrDefault(), true);
             }
             else
             {
@@ -135,27 +135,46 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             return context;
         }
 
-        private void TreeItemChecked_OnChecked(object sender, RoutedEventArgs e)
+        private void TreeItem_Click(object sender, RoutedEventArgs e)
         {
             if (sender is CheckBox chk)
             {
                 bool state = chk.IsChecked == true;
                 if (chk.DataContext is TreeNodeItem node)
                 {
-                    //SetTreeState(node, state);
-                    SetChildrenState(node, state);
-                    SetParentState(node, state);
+                    SetTreeItemState(node, state);
                 }
             }
         }
-
-        private void SetTreeState(TreeNodeItem node, bool state)
+        /// <summary>
+        /// 设置节点状态
+        /// </summary>
+        /// <param name="node"></param>
+        /// <param name="state"></param>
+        private void SetTreeItemState(TreeNodeItem node, bool state)
         {
             node.IsSelected = state;
             SetChildrenState(node, state);
             SetParentState(node, state);
+            CheckCheckItem();
         }
-
+        /// <summary>
+        /// 获取检查项的默认选状态
+        /// </summary>
+        private void CheckCheckItem()
+        {
+            var floors = DalProjectTree.GetSelectedFloors();
+            if (floors.Count <= 1)
+            {
+                var checkItems = myListbox.ItemsSource as List<ICheckBase>;
+                checkItems?.ForEach(t => { if (t is ModeCheckBase mbase) if (mbase.RIsNeedTwoMoreFloors) t.RIsChecked = false; });
+            }
+        }
+        /// <summary>
+        /// 设置子节点状态
+        /// </summary>
+        /// <param name="node"></param>
+        /// <param name="state"></param>
         private void SetChildrenState(TreeNodeItem node, bool state)
         {
             foreach (TreeNodeItem child in node.Children)
@@ -163,7 +182,11 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                 child.IsSelected = state;
             }
         }
-
+        /// <summary>
+        /// 设置父节点状态
+        /// </summary>
+        /// <param name="node"></param>
+        /// <param name="state"></param>
         private void SetParentState(TreeNodeItem node, bool state)
         {
             if (node.Parent != null)
@@ -182,11 +205,26 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                         }
                     }
                 }
-                node.Parent.IsSelected = node.Parent.Children.Any(t=>t.IsSelected);
+                node.Parent.IsSelected = node.Parent.Children.Any(t => t.IsSelected);
                 SetParentState(node.Parent, state);
             }
 
         }
+
+        private void CheckItem_Click(object sender, RoutedEventArgs e)
+        {
+            if (sender is CheckBox chk)
+            {
+                if (chk.IsChecked == true)
+                {
+                    var checkItem = chk.DataContext as ModeCheckBase;
+                    if (checkItem.RIsNeedTwoMoreFloors)
+                    {
+                        MessageBox.Show("请选择两个及以上楼层再检查此项");
+                    }
+                }
+            }
+        }
     }
 }
 

+ 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();
+                }
+
             }
         }
     }