Преглед изворни кода

Merge branch 'master' of https://git.dev.tencent.com/xuhuo1234/saga

xls пре 6 година
родитељ
комит
10d18664ad
25 измењених фајлова са 379 додато и 136 уклоњено
  1. BIN
      MBI/MBIResource/DataCheck/垃圾数据检查结果输出-模版.xlsx
  2. 23 0
      MBI/SAGA.DotNetUtils/DB/SQLiteUpdateUtil.cs
  3. 1 0
      MBI/SAGA.DotNetUtils/SAGA.DotNetUtils.csproj
  4. 26 53
      MBI/SAGA.GplotManage/GplotCommand.cs
  5. 3 6
      MBI/SAGA.GplotManage/SAGA.GplotManage.csproj
  6. 1 1
      MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/DistributionRelationshipHandler.cs
  7. 1 1
      MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/EquipPowerRelationshipHandler.cs
  8. 1 1
      MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/ObjectControlRelationshipHandler.cs
  9. 0 1
      MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj
  10. 12 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs
  11. 2 1
      MBI/SAGA.MBI/Calc/CalcContext.cs
  12. 28 25
      MBI/SAGA.MBI/Calc/ObjectCalc.cs
  13. 9 5
      MBI/SAGA.MBI/DataArrange/DalModeFileManange.cs
  14. 5 4
      MBI/SAGA.MBI/DataArrange/DalUploadFloor.cs
  15. 1 1
      MBI/SAGA.MBI/Extend/StringExtend.cs
  16. 1 1
      MBI/SAGA.MBI/RequestData/LoginRequest.cs
  17. 32 15
      MBI/SAGA.MBI/RequestData/UpLoadFileRequest.cs
  18. 2 0
      MBI/SAGA.MBI/SAGA.MBI.csproj
  19. 2 1
      MBI/SAGA.MBI/ToolsData/CheckBase/CheckOperation.cs
  20. 1 1
      MBI/SAGA.MBI/ToolsData/CheckEquipCategory.cs
  21. 5 0
      MBI/SAGA.MBI/ToolsData/CorrectLossDuty.cs
  22. 162 0
      MBI/SAGA.MBI/ToolsData/DataCheck/DutyModeCodeDiffCheck.cs
  23. 27 0
      MBI/SAGA.MBI/ToolsData/DataCheck/DutyModeCodeDiffCheckResult.cs
  24. 24 17
      MBI/SAGA.MBI/WinView/Space/SpaceManager.cs
  25. 10 2
      MBI/SAGA.RevitUtils/Extends/DocumentExtend.cs

BIN
MBI/MBIResource/DataCheck/垃圾数据检查结果输出-模版.xlsx


+ 23 - 0
MBI/SAGA.DotNetUtils/DB/SQLiteUpdateUtil.cs

@@ -0,0 +1,23 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:SQLiteUpdateUtil
+ * 作者:xulisong
+ * 创建时间: 2019/3/19 16:54:35
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.DotNetUtils.DB
+{
+    public static class SQLiteUpdateUtil
+    {
+        public static void UpdateDb(int oldVersion, int newVersion)
+        {
+           // SQLiteHelper.exno
+        }
+    }
+}

+ 1 - 0
MBI/SAGA.DotNetUtils/SAGA.DotNetUtils.csproj

@@ -297,6 +297,7 @@
     <Compile Include="Data\SingleFactory.cs" />
     <Compile Include="Data\SingleInstance.cs" />
     <Compile Include="DB\SQLiteHelper.cs" />
+    <Compile Include="DB\SQLiteUpdateUtil.cs" />
     <Compile Include="DB\TableNameAttribute.cs" />
     <Compile Include="Encrypt\MD5Tools.cs" />
     <Compile Include="Extend\BitmapExtend.cs" />

+ 26 - 53
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -1,22 +1,14 @@
 
 using System.Collections.Generic;
 using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading;
 using Autodesk.Revit.Attributes;
 using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Plumbing;
 using Autodesk.Revit.UI;
 using Newtonsoft.Json;
-using SAGA.GplotDrawData;
 using SAGA.GplotDrawData.View;
 using SAGA.GplotManage.UploadRelated;
 using SAGA.GplotRelationComputerManage;
-using SAGA.MBI.Common;
 using SAGA.Models;
-using SAGA.RevitUtils;
-using SAGA.RevitUtils.Extends;
 using SAGA.RevitUtils.Extends;
 
 namespace SAGA.GplotManage
@@ -69,14 +61,9 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            //RelationTypeManager.GetSystemRelationTypeNames() 
-            List<string> useRelations = RelationTypeManager.GetSystemRelationTypeNames();//new List<string>() { "ChillWaterLoop" };
-            SystemComputerHandler handler1 = new SystemComputerHandler();
-            handler1.ComputerWidthCache(useRelations);
+            SystemComputerHandler.ComputerAllRelations();
             WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
             floorWin.Show();
-            //var space = GplotFactory.Create(GraphTypeEnum.ChillWaterLoop);
-            //space.Show(GplotShowType.Default);
             return Result.Succeeded;
         }
 
@@ -87,7 +74,7 @@ namespace SAGA.GplotManage
     }
 
     /// <summary>
-    /// 冷冻水计算--平面回水
+    /// 系统平面信息
     /// </summary>
     [Transaction(TransactionMode.Manual)]
     [Regeneration(RegenerationOption.Manual)]
@@ -95,13 +82,9 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            List<string> useRelations = RelationTypeManager.GetSystemRelationTypeNames(); 
-            SystemComputerHandler handler1 = new SystemComputerHandler();
-            handler1.ComputerWidthCache(useRelations);
+            SystemComputerHandler.ComputerAllRelations();
             WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
             floorWin.Show();
-            //var space = GplotFactory.Create(GraphTypeEnum.ChillWaterLoop);
-            //space.Show(GplotShowType.ViewPlan);
             return Result.Succeeded;
         }
 
@@ -112,7 +95,7 @@ namespace SAGA.GplotManage
     }
 
     /// <summary>
-    /// 冷冻水计算--立面
+    /// 系统立面信息
     /// </summary>
     [Transaction(TransactionMode.Manual)]
     [Regeneration(RegenerationOption.Manual)]
@@ -120,13 +103,9 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            List<string> useRelations = RelationTypeManager.GetSystemRelationTypeNames(); 
-            SystemComputerHandler handler1 = new SystemComputerHandler();
-            handler1.ComputerWidthCache(useRelations);
+            SystemComputerHandler.ComputerAllRelations();
             WinSystem verticalWin = new WinSystem(GplotShowType.VerticalPlan);
             verticalWin.Show();
-            //var space = GplotFactory.Create(GraphTypeEnum.ChillWaterLoop);
-            //space.Show(GplotShowType.VerticalPlan);
             return Result.Succeeded;
 
         }
@@ -138,6 +117,26 @@ namespace SAGA.GplotManage
     }
 
     /// <summary>
+    /// 机房信息
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class ChillWaterLoopRoom : ExternalCommand
+    {
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+            SystemComputerHandler.ComputerAllRelations();
+            WinMachineRoom room = new WinMachineRoom();
+            room.Show();
+            return Result.Succeeded;
+        }
+
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        {
+            return true;
+        }
+    }
+    /// <summary>
     /// 拓扑图上传测试
     /// </summary>
     [Transaction(TransactionMode.Manual)]
@@ -227,31 +226,5 @@ namespace SAGA.GplotManage
             return true;
         }
     }
-    /// <summary>
-    /// 冷战测试
-    /// </summary>
-    [Transaction(TransactionMode.Manual)]
-    [Regeneration(RegenerationOption.Manual)]
-    public class ChillWaterLoopRoom : ExternalCommand
-    {
-        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
-        {
-            //var relationType = RelationTypeManager.GetRelationTypeItem("ChillWaterLoop");
-            List<string> useRelations = new List<string>() { "ChillWaterLoop" };
-            SystemComputerHandler handler1 = new SystemComputerHandler();
-            handler1.ComputerWidthCache(useRelations);
-            WinMachineRoom room = new WinMachineRoom();
-            room.Show();
-            return Result.Succeeded;
-            RoomShowHandler handler = new RoomShowHandler("ChillWaterLoop");
-            handler.Show();
-            ;
-            return Result.Succeeded;
-        }
-
-        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
-        {
-            return true;
-        }
-    }
+  
 }

+ 3 - 6
MBI/SAGA.GplotManage/SAGA.GplotManage.csproj

@@ -129,12 +129,6 @@
     <Compile Include="GplotManage\GplotView\GplotView.cs" />
     <Compile Include="Command\GplotUtil.cs" />
     <Compile Include="GraphTypeEnum.cs" />
-    <Compile Include="RelationManager\ElectricalRelationUploader.cs" />
-    <Compile Include="RelationManager\IRelationUploader.cs" />
-    <Compile Include="RelationManager\RelationDataManager.cs" />
-    <Compile Include="RelationManager\RelationUploader.cs" />
-    <Compile Include="RelationManager\SpaceRelationUploader.cs" />
-    <Compile Include="RelationManager\SystemRelationUploader.cs" />
     <Compile Include="SystemChecks\CheckSystemResultView.xaml.cs">
       <DependentUpon>CheckSystemResultView.xaml</DependentUpon>
     </Compile>
@@ -260,6 +254,9 @@
       <Generator>MSBuild:Compile</Generator>
     </Page>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="RelationManager\" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="..\packages\MrAdvice.2.5.24\build\MrAdvice.targets" Condition="Exists('..\packages\MrAdvice.2.5.24\build\MrAdvice.targets')" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/DistributionRelationshipHandler.cs

@@ -17,7 +17,7 @@ using MBIEquipItem = SAGA.Models.EquipmentItem;
 
 namespace SAGA.GplotRelationComputerManage
 {
-    public sealed class DistributionRelationshipHandler : IElectricalRelationHandler
+    public sealed class DistributionRelationshipHandler //: IElectricalRelationHandler
     {
         public string ElectricalRelationType
         {

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/EquipPowerRelationshipHandler.cs

@@ -16,7 +16,7 @@ using SAGA.Models;
 using MBIEquipItem = SAGA.Models.EquipmentItem;
 namespace SAGA.GplotRelationComputerManage
 {
-    public class EquipPowerRelationshipHandler : IElectricalRelationHandler
+    public class EquipPowerRelationshipHandler //: IElectricalRelationHandler
     {
         public string ElectricalRelationType
         {

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/ObjectControlRelationshipHandler.cs

@@ -17,7 +17,7 @@ using MBIEquipItem = SAGA.Models.EquipmentItem;
 
 namespace SAGA.GplotRelationComputerManage
 {
-    public class ObjectControlRelationshipHandler : IElectricalRelationHandler
+    public class ObjectControlRelationshipHandler //: IElectricalRelationHandler
     {
         public string ElectricalRelationType
         {

+ 0 - 1
MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj

@@ -132,7 +132,6 @@
     <Compile Include="PowerDistribution\Common\PowerComputerContext.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\DistributionRelationshipHandler.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\EquipPowerRelationshipHandler.cs" />
-    <Compile Include="PowerDistribution\ComputerHandler\IElectricalRelationHandler.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\ObjectControlRelationshipHandler.cs" />
     <Compile Include="PumpEnd\DrawEnd.cs" />
     <Compile Include="PumpEnd\DuctTerminalBll.cs" />

+ 12 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs

@@ -69,5 +69,17 @@ namespace SAGA.GplotRelationComputerManage
             }
             Computer(useRelationTypes);
         }
+
+
+        /// <summary>
+        /// 计算所有关系信息
+        /// </summary>
+        public static void ComputerAllRelations()
+        {
+            // List<string> useRelations = new List<string>() { "ChillWaterLoop" };
+            List<string> useRelations = RelationTypeManager.GetSystemRelationTypeNames();
+            SystemComputerHandler handler1 = new SystemComputerHandler();
+            handler1.ComputerWidthCache(useRelations);
+        }
     }
 }

+ 2 - 1
MBI/SAGA.MBI/Calc/CalcContext.cs

@@ -70,11 +70,12 @@ namespace SAGA.MBI.Calc
         /// <summary>
         /// 打开项目
         /// </summary>
-        public void OpenDocument()
+        public Document OpenDocument()
         {
             string path = MFloor.FullPath;
             var uiApp = ExternalDataWrapper.Current.UiApp;
             RevitDoc = uiApp.Application.OpenDocumentFile(path);
+            return RevitDoc;
         }
         /// <summary>
         /// 关闭项目

+ 28 - 25
MBI/SAGA.MBI/Calc/ObjectCalc.cs

@@ -59,9 +59,9 @@ namespace SAGA.MBI.Calc
             var spaces = context.RevitDoc.GetSpaces();
             foreach (Space space in spaces)
             {
-                if(!space.IsSpace())continue;
+                if (!space.IsSpace()) continue;
                 MISpace mspace = DalSpace.GetSpace(space);
-                if(mspace==null)continue;
+                if (mspace == null) continue;
                 mspace.Operator = DocumentChangedOperator.Add;
                 context.MSpaces.Add(mspace);
             }
@@ -73,9 +73,10 @@ namespace SAGA.MBI.Calc
         private static void CalcEquipPartRlt(CalcContext context)
         {
             var familyInstances = context.RevitDoc.GetFamilyInstances();
+            List<FamilyInstance> parts = new List<FamilyInstance>();
             foreach (FamilyInstance fi in familyInstances)
             {
-                if(!fi.IsValidObject)continue;
+                if (!fi.IsValidObject) continue;
                 if (fi.IsEquipment())
                 {
                     MEquipment equipment = DalEquip.GetEquipment(fi);
@@ -91,15 +92,15 @@ namespace SAGA.MBI.Calc
                     if (mSpace != null)
                     {
                         //设备所在空间添加添加一组关系
-                        context.RltEquipInSpaces.Add(new RltEquipInSpace(mSpace, equipment){Operator = DocumentChangedOperator.Add});
+                        context.RltEquipInSpaces.Add(new RltEquipInSpace(mSpace, equipment) { Operator = DocumentChangedOperator.Add });
                     }
                 }
-               
+
                 //在这里处理信标
-                if (fi.IsBeacon())
+                else if (fi.IsBeacon())
                 {
                     MBeacon mode = DalBeacon.GetBeacon(fi);
-                    if(mode==null)continue;
+                    if (mode == null) continue;
                     mode.Operator = DocumentChangedOperator.Add;
                     context.MBeacons.Add(mode);
 
@@ -113,30 +114,32 @@ namespace SAGA.MBI.Calc
                         context.RltBeaconinElementSps.Add(new RltBeaconinElementSp(mSpace, mode) { Operator = DocumentChangedOperator.Add });
                     }
                 }
+                else if (fi.IsEquipmentPart())
+                {
+                    parts.Add(fi);
+                }
             }
             //单独处理部件,因为部件要依赖设备
-            foreach (FamilyInstance fi in familyInstances)
+            foreach (FamilyInstance fi in parts)
             {
                 // 在这里处理部件 
-                if (fi.IsEquipmentPart())
-                {
-                    MEquipmentPart equipment = DalEquipPart.GetEquipPart(fi);
-                    if(equipment?.MEquipment == null)continue;
-                    
-                    equipment.Operator = DocumentChangedOperator.Add;
-                    context.MEquipmentParts.Add(equipment);
+                MEquipmentPart equipment = DalEquipPart.GetEquipPart(fi);
+                if (equipment?.MEquipment == null) continue;
 
-                    //识别设备所在空间
-                    var space = fi.GetReferenceSpace();
-                    if (space == null) continue;
-                    string spaceId = space.GetCloudBIMId();
-                    MISpace mSpace = context.MSpaces.FirstOrDefault(t => t.BimID == spaceId);
-                    if (mSpace != null)
-                    {
-                        //设备所在空间添加添加一组关系
-                        context.RltEquipInSpaces.Add(new RltEquipInSpace(mSpace, equipment) { Operator = DocumentChangedOperator.Add });
-                    }
+                equipment.Operator = DocumentChangedOperator.Add;
+                context.MEquipmentParts.Add(equipment);
+
+                //识别设备所在空间
+                var space = fi.GetReferenceSpace();
+                if (space == null) continue;
+                string spaceId = space.GetCloudBIMId();
+                MISpace mSpace = context.MSpaces.FirstOrDefault(t => t.BimID == spaceId);
+                if (mSpace != null)
+                {
+                    //设备所在空间添加添加一组关系
+                    context.RltEquipInSpaces.Add(new RltEquipInSpace(mSpace, equipment) { Operator = DocumentChangedOperator.Add });
                 }
+
             }
 
         }

+ 9 - 5
MBI/SAGA.MBI/DataArrange/DalModeFileManange.cs

@@ -330,10 +330,14 @@ namespace SAGA.MBI.DataArrange
                     new CommonEqualComparer<MISpace>((a, b) => { return a.BimID == b.BimID; }));
                 context.MSpaces.AddRange(spaces);
                 //处理设备所在空间
-                context.RltEquipInSpaces.AddRange(newContext.RltEquipInSpaces.Where(t => context.MEquipments.Select(tt => tt.BimID).Contains((t)?.MEquipment.BimID)));
-                context.RltEquipInSpaces.AddRange(newContext.RltEquipInSpaces.Where(t => context.MEquipmentParts.Select(tt => tt.BimID).Contains((t)?.MEquipment.BimID)));
-                context.RltEquipInSpaces.AddRange(newContext.RltEquipInSpaces.Where(t => context.MSpaces.Select(tt => tt.BimID).Contains((t)?.MSpace.BimID)));
-                context.RltBeaconinElementSps.AddRange(newContext.RltBeaconinElementSps.Where(t => context.MBeacons.Select(tt => tt.BimID).Contains((t)?.MBeacon.BimID)));
+                var bimids = context.MEquipments.Select(tt => tt.BimID).ToList();
+                context.RltEquipInSpaces.AddRange(newContext.RltEquipInSpaces.Where(t => bimids.Contains((t).MEquipment.BimID)));
+                bimids = context.MEquipmentParts.Select(tt => tt.BimID).ToList();
+                context.RltEquipInSpaces.AddRange(newContext.RltEquipInSpaces.Where(t => bimids.Contains((t).MEquipment.BimID)));
+                bimids = context.MSpaces.Select(tt => tt.BimID).ToList();
+                context.RltEquipInSpaces.AddRange(newContext.RltEquipInSpaces.Where(t => bimids.Contains((t).MSpace.BimID)));
+                bimids = context.MBeacons.Select(tt => tt.BimID).ToList();
+                context.RltBeaconinElementSps.AddRange(newContext.RltBeaconinElementSps.Where(t => bimids.Contains((t).MBeacon.BimID)));
             }
             else
             {
@@ -433,7 +437,7 @@ namespace SAGA.MBI.DataArrange
                     win.ShowDialog();
                 }
                 GenerateLog(bedelContext, beaddContext, bemodifyContext);
-                //Traceloger.Log("执行删除数据操作");
+                Traceloger.Log("执行删除数据操作");
                 ////删除
                 //bedelContext.Del();
                 //Traceloger.Log("执行上传新数据操作");

+ 5 - 4
MBI/SAGA.MBI/DataArrange/DalUploadFloor.cs

@@ -78,7 +78,7 @@ namespace SAGA.MBI.DataArrange
             }
             if (count >= 1)
                 //下载完成提示窗体;文件服务器缺少文件,会出现进度条无法关闭的情况;
-                UpLoadFileRequest.CloseDownloadWin(count == i, hasTip: true);
+                UpLoadFileRequest.CloseDownloadWin(count == j, hasTip: true);
             return i == j;
         }
         /// <summary>
@@ -241,7 +241,7 @@ namespace SAGA.MBI.DataArrange
                     //检测到自己加锁 才读取日志
                     if (uploadFloor.MFloor.FloorLock.LockState != MFloorLockState.LockBySelf)
                         continue;
-                    currentFloor = uploadFloor.MFloor.FullPath;
+                    currentFloor = uploadFloor.MFloor.ToString();
                     Document document = null;
                     try
                     {
@@ -320,7 +320,7 @@ namespace SAGA.MBI.DataArrange
             }
             catch (Exception e)
             {
-                MessageShow.Show(e, strMessage: $"楼层 { currentFloor ?? string.Empty} 打开异常或网络异常,请检查后再进行操作!");
+                MessageShow.Show(e, strMessage: $"楼层 { currentFloor ?? string.Empty} 打开异常或网络异常,请检查后再进行操作!\r\n");
                 vm = null;
             }
 
@@ -539,8 +539,9 @@ namespace SAGA.MBI.DataArrange
         {
             //if (mode.Operator == DocumentChangedOperator.None) return;
             var revitId = mode.BimID.GetBIMID();
+            if (revitId==0) return;
             var fi = context.RevitDoc.GetElement(revitId) as FamilyInstance;
-            Autodesk.Revit.DB.Mechanical.Space space = fi?.Space;
+            Autodesk.Revit.DB.Mechanical.Space space = fi?.GetReferenceSpace();
             if (space == null) return;
             //查询有没有Space对象
             string spaceId = space.GetCloudBIMId();

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

@@ -26,7 +26,7 @@ namespace SAGA.MBI.Tools
 
         /// <summary>
         /// 云平台BIMId转化为Revit Id
-        /// 去掉文件名前缀
+        /// 去掉文件名前缀,找不到返回值为0
         /// </summary>
         /// <returns></returns>
         public static int GetBIMID(this string cbimId)

+ 1 - 1
MBI/SAGA.MBI/RequestData/LoginRequest.cs

@@ -49,7 +49,7 @@ namespace SAGA.MBI.RequestData
         /// <returns></returns>
         public static string Login(string phoneNumber, string identifyingCode)
         {
-            string url = MBIConst.GoodHandLocalHost + "business-os/project/person/verifyCode/test"; //";//";//"
+            string url = MBIConst.GoodHandLocalHost + "business-os/project/person/verifyCode";//test"; /test
             JObject idJObject = new JObject();
             idJObject.Add("phone", phoneNumber);
             idJObject.Add("code", identifyingCode);

+ 32 - 15
MBI/SAGA.MBI/RequestData/UpLoadFileRequest.cs

@@ -16,6 +16,7 @@ using Aliyun.OSS;
 using Aliyun.OSS.Common;
 using Newtonsoft.Json.Linq;
 using SAGA.DotNetUtils;
+using SAGA.DotNetUtils.Encrypt;
 using SAGA.DotNetUtils.Extend;
 using SAGA.DotNetUtils.FileOperate;
 using SAGA.DotNetUtils.Http;
@@ -94,7 +95,7 @@ namespace SAGA.MBI.RequestData
             windown.LabelFloorName = $"正在下载{floorName}层模型文件,请稍后。。。";
             windown.LabelPath = fullPath;
             windown.Count = count;
-            windown.Cur = cur;
+            windown.Cur = cur; 
         }
         /// <summary>
         /// 下载指定文件到指定
@@ -106,6 +107,7 @@ namespace SAGA.MBI.RequestData
         {
             bool result = true;
             string fullPath = tuple.Item1;
+            string floorName = tuple.Item3;
             string cloudName = CommonTool.GetCloudRevitName(fullPath);
             int state = tuple.Item2;
             if (state == 2)
@@ -138,6 +140,18 @@ namespace SAGA.MBI.RequestData
                         }
                         //写入文件
                         FileStreamOperate.WriteFile(fs.ToArray(), fullPath);
+
+                        #region 下载后Md5较验
+
+                        string md5 = MD5Tools.GetMD5HashFromFile(fullPath);
+                        //下载后的文件md5校验
+                        if (client.GetObjectMetadata(bucketName, key).ETag.ToUpper() != md5.ToUpper())
+                        {
+                            throw new Exception($"楼层 {floorName} MD5校验失败,本地与服务器不一致!");
+                        }
+
+                        #endregion
+
                     }
                 }
 
@@ -146,8 +160,7 @@ namespace SAGA.MBI.RequestData
             }
             catch (Exception ex)
             {
-                MessageShow.Show(ex,
-                    strMessage: "Revit文件下载失败!");
+                MessageShowBase.Infomation("Revit文件下载失败!\r\n"+ex.Message+"\r\n"+ex.StackTrace);
                 result = false;
                 CloseDownloadWin(result,false);
             }
@@ -182,7 +195,7 @@ namespace SAGA.MBI.RequestData
                 windown = null;
             }
             if (hasTip)
-                MessageShowBase.Infomation(issucess ? "Revit文件下载完毕!" : "Revit文件下载失败!");
+                MessageShowBase.Infomation(issucess ? "Revit模型文件下载成功!" : "Revit模型文件下载失败!");
         }
 
         #endregion
@@ -338,7 +351,7 @@ namespace SAGA.MBI.RequestData
                 win = null;
             }
             if (hasTip)
-                MessageBox.Show(issucess ? "数据上传完毕!" : "数据上传失败!");
+                MessageBox.Show(issucess ? "Revit模型文件上传成功!" : "Revit文件上传失败!");
 
         }
         /// <summary>
@@ -365,22 +378,26 @@ namespace SAGA.MBI.RequestData
                     putObjectRequest.StreamTransferProgress += StreamProgressCallback;
 
                     client.PutObject(putObjectRequest);
+
+                    #region 上传后MD5较验
+
+                    string md5 = MD5Tools.GetMD5HashFromFile(filePath);
+                    //上传后的文件md5校验
+                    if (client.GetObjectMetadata(bucketName, key).ETag.ToUpper() != md5.ToUpper())
+                    {
+                        throw new Exception($"楼层 {floorName} MD5校验失败,本地与服务器不一致!");
+                    }
+
+                    #endregion
+
                 }
                 Console.WriteLine("Put object:{0} succeeded", key);
             }
-            catch (OssException ex)
-            {
-                Console.WriteLine(@"Failed with error code: {0}; Error info: {1}. \nRequestID:{2}\tHostID:{3}",
-                    ex.ErrorCode, ex.Message, ex.RequestId, ex.HostId);
-                result = false;
-                CloseUploadWindow(result);
-                return false;
-            }
             catch (Exception ex)
             {
-                Console.WriteLine($@"Failed with error info: { ex.Message}");
+                MessageShowBase.Infomation("Revit文件上传载失败!\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                 result = false;
-                CloseUploadWindow(result);
+                CloseUploadWindow(result,false);
             }
             return result;
         }

+ 2 - 0
MBI/SAGA.MBI/SAGA.MBI.csproj

@@ -334,6 +334,8 @@
     <Compile Include="RevitModelHandle\RevitParameterUpdate.cs" />
     <Compile Include="RevitReference\RVTNoModeDutyOperate.cs" />
     <Compile Include="Service\InputService.cs" />
+    <Compile Include="ToolsData\DataCheck\DutyModeCodeDiffCheck.cs" />
+    <Compile Include="ToolsData\DataCheck\DutyModeCodeDiffCheckResult.cs" />
     <Compile Include="ToolsData\DataCheck\SpaceEquipFloorCheck.cs" />
     <Compile Include="ToolsData\DataCheck\SpaceEquipFloorCheckResult.cs" />
     <Compile Include="ToolsData\DelZeroSpace.cs" />

+ 2 - 1
MBI/SAGA.MBI/ToolsData/CheckBase/CheckOperation.cs

@@ -80,9 +80,10 @@ namespace SAGA.MBI.ToolsData.CheckBase
             List<DataCheckBase> list = new List<DataCheckBase>();
             list.Add(new DutyFMInfoCheck());
             list.Add(new QRCodeContextCheck());
+            list.Add(new SpaceEquipFloorCheck());
             list.Add(new MissDutyOrMode());
             list.Add(new BIMDuplicationCheck());
-            list.Add(new SpaceEquipFloorCheck());
+            list.Add(new DutyModeCodeDiff());
             list.ForEach(t =>
             {
                 t.RIsChecked = true;

+ 1 - 1
MBI/SAGA.MBI/ToolsData/CheckEquipCategory.cs

@@ -81,7 +81,7 @@ namespace SAGA.MBI.ToolsData
         /// <param name="baseContext"></param>
         /// <param name="delcontext"></param>
         /// <param name="addContext"></param>
-        private static void Check(CalcContext baseContext, CalcContext delcontext, CalcContext addContext)
+        public static void Check(CalcContext baseContext, CalcContext delcontext, CalcContext addContext)
         {
             var doc = baseContext.RevitDoc;
             //检查空间,逻辑不通,暂时注释掉

+ 5 - 0
MBI/SAGA.MBI/ToolsData/CorrectLossDuty.cs

@@ -88,11 +88,16 @@ namespace SAGA.MBI.ToolsData
         /// <returns></returns>
         public static Tuple<CalcContext, CalcContext> GetCheckResult(MFloor floor)
         {
+            Log4Net.Debug("start");
             var oldContext = DalCommon.DownLoadCouldData(floor);
+            Log4Net.Debug("download");
             var newContext = ObjectCalc.Calc(floor);
+            Log4Net.Debug("calc");
             //分组
             var beaddContext = DalModeFileManange.GetAddContext(oldContext, newContext, true);
+            Log4Net.Debug("addcontext");
             var bedelContext = (DalModeFileManange.GetDelContext(oldContext, newContext, true));
+            Log4Net.Debug("delcontext");
             RemoveNoBimIdDuty(bedelContext);
             return new Tuple<CalcContext, CalcContext>(beaddContext, bedelContext);
         }

+ 162 - 0
MBI/SAGA.MBI/ToolsData/DataCheck/DutyModeCodeDiffCheck.cs

@@ -0,0 +1,162 @@
+/* ==============================================================================
+ * 功能描述:岗位和资产信息点一致性检查
+ * 创 建 者:Garrett
+ * 创建日期:2018/10/23 15:08:55
+ * ==============================================================================*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Windows.Documents;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Mechanical;
+using Newtonsoft.Json.Linq;
+using NPOI.SS.UserModel;
+using SAGA.DotNetUtils.Extend;
+using SAGA.DotNetUtils.Logger;
+using SAGA.DotNetUtils.Others;
+using SAGA.MBI.Calc;
+using SAGA.MBI.DataArrange;
+using SAGA.MBI.JsonConvert;
+using SAGA.MBI.Model;
+using SAGA.MBI.RequestData;
+using SAGA.MBI.Tools;
+using SAGA.MBI.ToolsData.CheckBase;
+using SAGA.MBI.ToolsData.ModeCheck;
+using SAGA.RevitUtils.Extends;
+
+namespace SAGA.MBI.ToolsData.DataCheck
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    class DutyModeCodeDiff : DataCheckBase
+    {
+        public DutyModeCodeDiff()
+        {
+            Name = "模型中的族编码和岗位的设备类编码一致性检查";
+        }
+        [DataCheckProcessAspect]
+        public override bool Check()
+        {
+            IsRight = GetCheckResult();
+            return IsRight;
+        }
+
+        public override void Correct()
+        {
+            throw new NotImplementedException();
+        }
+
+        #region CheckMethod
+        /// <summary>
+        /// 对比信息点是否一致
+        /// </summary>
+        /// <returns></returns>
+        private bool GetCheckResult()
+        {
+            bool result = true;
+            var floors = DalProjectTree.GetSelectedFloors(true);
+            foreach (var mfloor in floors)
+            {
+                Results.AddRange(GetCheckResult(mfloor));
+            }
+            return Results.All(t => t.IsRight);
+        }
+
+        private List<DutyModeCodeDiffCheckResult> GetCheckResult(MFloor floor)
+        {
+            List<DutyModeCodeDiffCheckResult> list = new List<DutyModeCodeDiffCheckResult>();
+
+            var context = DalCommon.DownLoadCouldData(floor);
+            try
+            {
+                var doc=context.OpenDocument();
+                string floorName = context.MFloor.ToString();
+                //检查空间,逻辑不通,暂时注释掉
+                List<MRevitEquipBase> modes = new List<MRevitEquipBase>();
+                //检查设备
+                modes.AddRange(context.MEquipments);
+                //检查部件 
+                modes.AddRange(context.MEquipmentParts);
+                //信标不用检查
+                foreach (var mode in modes)
+                {
+                    string cBimId = mode.BimID;
+                    if (cBimId.IsNullOrEmpty()) continue;
+                    int bimid = cBimId.GetBIMID();
+                    FamilyInstance fi = doc.GetElement(bimid) as FamilyInstance;
+                    if (fi == null) continue;
+                    var code = fi.GetFamilyCode();
+                    var cCode = mode.EquipClassCode;
+                    if (code != cCode)
+                    {
+                        DutyModeCodeDiffCheckResult result = new DutyModeCodeDiffCheckResult();
+                        result.FloorName = floorName;
+                        result.DutyId = mode.Id;
+                        result.BIMID = bimid.ToString();
+                        result.DCode = cCode;
+                        result.MCode = code;
+                        result.FamilyName = fi.GetFamily()?.Name;
+                        result.IsRight = false;
+                        result.RMessage = "模型族编码与岗位设备类编码不一致,请检查模型是否需要更新或使用“族编码同步”命令同步";
+                        list.Add(result);
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                MessageShowBase.Show(e);
+            }
+            finally
+            {
+                context.RevitDoc.CloseDoc();
+            }
+            return list;
+        }
+
+        #endregion
+
+        //[DataCheckProcessAspect]
+        public override void Export()
+        {
+            //   Check();
+            try
+            {
+                IWorkbook book = DCRExport.GetWorkbook();
+                //ISheet sheet = book.CreateSheet(Name);
+                ISheet sheet = book.GetSheet(Name);
+
+                #region 添加数据
+                int index = 3;
+
+                foreach (DutyModeCodeDiffCheckResult result in Results)
+                {
+                    //数量过多,只显示有问题的
+                    //if (result.IsRight) continue;
+                    index++;
+                    IRow rowN = sheet.CreateRow(index);
+                    DataCheckNPOIStyle style = result.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
+                    int i = 0;
+                    rowN.AddCell(i++, result.FloorName, style);
+                    rowN.AddCell(i++, result.MCode, style);
+                    rowN.AddCell(i++, result.FamilyName, style);
+                    rowN.AddCell(i++, result.BIMID, style);
+                    rowN.AddCell(i++, result.DCode, style);
+                    rowN.AddCell(i++, result.DutyId, style);
+                    string rowN4 = result.IsRight ? "通过" : "不通过";
+                    rowN.AddCell(i++, rowN4, style);
+                    rowN.AddCell(i++, result.RMessage, style);
+                }
+                #endregion
+
+            }
+            catch (Exception e)
+            {
+                MessageShowBase.Show(e);
+            }
+        }
+    }
+}

+ 27 - 0
MBI/SAGA.MBI/ToolsData/DataCheck/DutyModeCodeDiffCheckResult.cs

@@ -0,0 +1,27 @@
+/* ==============================================================================
+ * 功能描述:岗位和资产信息点一致性检查结果
+ * 创 建 者:Garrett
+ * 创建日期:2018/10/23 15:13:17
+ * ==============================================================================*/
+
+using SAGA.MBI.ToolsData.CheckBase;
+using SAGA.MBI.ToolsData.ModeCheck;
+
+namespace SAGA.MBI.ToolsData.DataCheck
+{
+    /// <summary>
+    /// UnitCheckResult
+    /// </summary>
+    class DutyModeCodeDiffCheckResult : DataCheckResultBase
+    {
+        public string FloorName { get; set; }
+        public string DutyId { get; set; }
+        public string DutyName { get; set; }
+        public string BIMID { get; set; }
+        public string FamilyName { get; set; }
+        //岗位设备类编码
+        public string DCode { get; set; }
+        //模型族编码
+        public string MCode { get; set; }
+    }
+}

+ 24 - 17
MBI/SAGA.MBI/WinView/Space/SpaceManager.cs

@@ -92,7 +92,7 @@ namespace SAGA.MBI.WinView
                 return;
             double z = view.GenLevel.Elevation;
             Document doc = view.Document;
-            Plane p =Plane.CreateByNormalAndOrigin(view.ViewDirection,XYZ.Zero);
+            Plane p =Plane.CreateByNormalAndOrigin(view.ViewDirection, view.Origin);
             var sp = SketchPlane.Create(doc, p);
             foreach (var pair in separations)
             {             
@@ -133,24 +133,31 @@ namespace SAGA.MBI.WinView
                 var phase = doc.GetElement(phaseId) as Phase;
                 #region 创建新的节点
                 List<XYZ> points = new List<XYZ>();
-                var topology = doc.get_PlanTopology(level, phase);
-                foreach (PlanCircuit topologyCircuit in topology.Circuits)
-                {
-                    var point = topologyCircuit.GetPointInside();
-                    var xyz = new XYZ(point.U, point.V, level.ProjectElevation); //适当升高一些
-                    points.Add(xyz);
-                }
+                //using (SubTransaction sub=new SubTransaction(doc)) 
+                //{
+                //    var spaceSipliter=doc.GetElements<>()
+                //}
+               // PlanTopologySetting
+               // doc.Create.newsp
+                //doc.get_PlanTopology(,)
+                //var topology = doc.get_PlanTopology(level, phase);
+                //foreach (PlanCircuit topologyCircuit in topology.Circuits)
+                //{
+                //    var point = topologyCircuit.GetPointInside();
+                //    var xyz = new XYZ(point.U, point.V, level.ProjectElevation); //适当升高一些
+                //    points.Add(xyz);
+                //}
 
-                foreach (var point in points)
-                {
-                    var oldSpace = doc.GetSpaceAtPoint(point, phase);
-                    if (oldSpace == null)
-                    {
-                        doc.Create.NewSpace(level, phase, new UV(point.X, point.Y));
-                    }
-                }
+                //foreach (var point in points)
+                //{
+                //    var oldSpace = doc.GetSpaceAtPoint(point, phase);
+                //    if (oldSpace == null)
+                //    {
+                //        doc.Create.NewSpace(level, phase, new UV(point.X, point.Y));
+                //    }
+                //}
                 #endregion
-                // doc.Create.NewSpaces2()
+                // doc.Create
                 var newSpaces = doc.Create.NewSpaces2(level, phase, view);
             }
 

+ 10 - 2
MBI/SAGA.RevitUtils/Extends/DocumentExtend.cs

@@ -634,8 +634,16 @@ namespace SAGA.RevitUtils.Extends
         /// <returns></returns>
         public static Element GetElement(this Document doc, int intId)
         {
-            var id = new ElementId(intId);
-            return doc.GetElement(id);
+            try
+            {
+                var id = new ElementId(intId);
+                return doc.GetElement(id);
+            }
+            catch (Exception e)
+            {
+                
+                return null;
+            }
         }
 
         /// <summary>