From fc818ac66ff6b30f40252fcc28b92970d62a765a Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期四, 05 十二月 2024 16:23:37 +0800 Subject: [PATCH] 项目导入优化 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/01-import/00-core/ImportXhsProjectHelper.cs | 308 +++++++++++++++++++++++++++----------------------- 1 files changed, 165 insertions(+), 143 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/01-import/00-core/ImportXhsProjectHelper.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/01-import/00-core/ImportXhsProjectHelper.cs index 0f9ca13..9daa7d0 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/01-import/00-core/ImportXhsProjectHelper.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/01-import/00-core/ImportXhsProjectHelper.cs @@ -1,6 +1,8 @@ 锘縰sing Castle.Core.Internal; using DevExpress.XtraEditors; +using HStation.Model; using HStation.Vmo; +using Microsoft.Extensions.DependencyInjection; using static DevExpress.XtraEditors.XtraInputBox; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window; @@ -41,86 +43,104 @@ feedBackProgress?.Invoke(100, 5); - #endregion 绗竴姝� 涓存椂鏂囦欢澶勭悊锛堣繘搴�5%锛� + #endregion #region 绗簩姝� 鍒涘缓椤圭洰锛堣繘搴� 10%锛� - feedBackMsg?.Invoke("姝e湪鍒涘缓椤圭洰...", Color.Black); - - var project = new Vmo.XhsProjectExtensionsVmo(); - project.NO = vm.NO; - project.Name = vm.Name; - project.Address = vm.Address; - project.Customer = vm.Customer; - project.Flags = vm.Flags; - project.TagName = vm.TagName; - project.Description = vm.Description; - project.SiteList = new List<XhsProjectSiteVmo>() - { - new XhsProjectSiteVmo() - { - Name=vm.Name, - Description=vm.Description - } - }; - - var projectId = await BLLFactory<HStation.BLL.XhsProjectExtensions>.Instance.Insert(project); - if (projectId < 1) + //灏氭湭鍒涘缓椤圭洰 + if (vm.Project == null) { - feedBackMsg?.Invoke("椤圭洰鍒涘缓澶辫触锛侊紒锛�", Color.Red); - return false; + feedBackMsg?.Invoke("姝e湪鍒涘缓椤圭洰...", Color.Black); + + var project = new Vmo.XhsProjectExtensionsVmo(); + project.NO = vm.NO; + project.Name = vm.Name; + project.Address = vm.Address; + project.Customer = vm.Customer; + project.Flags = vm.Flags; + project.TagName = vm.TagName; + project.Description = vm.Description; + project.SiteList = new List<XhsProjectSiteVmo>() + { + new XhsProjectSiteVmo() + { + Name=vm.Name, + Description=vm.Description + } + }; + + var projectId = await BLLFactory<HStation.BLL.XhsProjectExtensions>.Instance.Insert(project); + if (projectId < 1) + { + feedBackMsg?.Invoke("椤圭洰鍒涘缓澶辫触锛侊紒锛�", Color.Red); + return false; + } + vm.ProjectID = projectId; + vm.Project = await BLLFactory<HStation.BLL.XhsProjectExtensions>.Instance.GetByID(projectId); + vm.ProjectSiteID = vm.Project.SiteList.FirstOrDefault().ID; + + feedBackMsg?.Invoke("椤圭洰鍒涘缓鎴愬姛銆傘�傘��", Color.Green); } - - feedBackMsg?.Invoke("椤圭洰鍒涘缓鎴愬姛銆傘�傘��", Color.Green); - - vm.ProjectID = projectId; feedBackProgress?.Invoke(100, 10); - #endregion 绗簩姝� 鍒涘缓椤圭洰锛堣繘搴� 10%锛� + #endregion #region 绗笁姝� 璁剧疆鍦板浘浣嶇疆锛堣繘搴� 20%锛� - feedBackMsg?.Invoke("姝e湪璁剧疆鍦板浘浣嶇疆...", Color.Black); - - if (vm.Location != null) + if (vm.MapInfo != null) { - var mapInfo = new Yw.Vmo.MapInfoVmo(); - mapInfo.ObjectType = HStation.Xhs.DataType.XhsProject; - mapInfo.ObjectID = projectId; - mapInfo.ObjectName = project.Name; - mapInfo.Purpose = Yw.Map.Purpose.Location; - mapInfo.Kind = Yw.Map.Kind.Gaodei; - mapInfo.Shape = Yw.Map.Shape.Marker; - mapInfo.Position = vm.Location.ToJson(); + feedBackMsg?.Invoke("姝e湪璁剧疆鍦板浘浣嶇疆...", Color.Black); - var mapInfoId = await BLLFactory<Yw.BLL.MapInfo>.Instance.Insert(mapInfo); - if (mapInfoId < 1) + if (vm.Location != null) { - feedBackMsg?.Invoke("璁剧疆鍦板浘浣嶇疆澶辫触锛侊紒锛�", Color.Red); + var mapInfo = new Yw.Vmo.MapInfoVmo(); + mapInfo.ObjectType = HStation.Xhs.DataType.XhsProject; + mapInfo.ObjectID = vm.ProjectID.Value; + mapInfo.ObjectName = vm.Project.Name; + mapInfo.Purpose = Yw.Map.Purpose.Location; + mapInfo.Kind = Yw.Map.Kind.Gaodei; + mapInfo.Shape = Yw.Map.Shape.Marker; + mapInfo.Position = vm.Location.ToJson(); + + var mapInfoId = await BLLFactory<Yw.BLL.MapInfo>.Instance.Insert(mapInfo); + if (mapInfoId < 1) + { + feedBackMsg?.Invoke("璁剧疆鍦板浘浣嶇疆澶辫触锛侊紒锛�", Color.Red); + } + else + { + vm.MapInfoID = mapInfoId; + vm.MapInfo = await BLLFactory<Yw.BLL.MapInfo>.Instance.GetByID(mapInfoId); + feedBackMsg?.Invoke("璁剧疆鍦板浘浣嶇疆鎴愬姛銆傘�傘��", Color.Green); + } } else { - vm.MapInfoID = mapInfoId; - feedBackMsg?.Invoke("璁剧疆鍦板浘浣嶇疆鎴愬姛銆傘�傘��", Color.Green); + feedBackMsg?.Invoke("鏈缃湴鍥句綅缃俊鎭紒锛侊紒", Color.Red); } - } - else - { - feedBackMsg?.Invoke("鏈缃湴鍥句綅缃俊鎭紒锛侊紒", Color.Red); } feedBackProgress?.Invoke(100, 20); - #endregion 绗笁姝� 璁剧疆鍦板浘浣嶇疆锛堣繘搴� 20%锛� + #endregion - #region 绗洓姝� 鍘嬬缉鏂囦欢瑙f瀽 锛堣繘搴�25%锛� - - msg = "姝e湪瑙f瀽妯″瀷鏂囦欢..."; - feedBackMsg?.Invoke(msg, Color.Black); + #region 绗洓姝� 鍘嬬缉鏂囦欢瑙f瀽 锛堣繘搴�30%锛� var zipFilePwd = HStation.Settings.XhsParasHelper.Xhs.File.Password; - var bol = Yw.FileFolderZipHelper.UnZip(vm.ZipFile, tempFolder, zipFilePwd); + var localZipFile = vm.LocalZipFile; + if (!vm.IsLocal) + { + if (vm.TransferRevitFile != null) + { + feedBackMsg?.Invoke("姝e湪涓嬭浇妯″瀷鏂囦欢...", Color.Black); + localZipFile = await BLLFactory<HStation.BLL.TransferRevitFile>.Instance.Download(vm.TransferRevitFile.StorageHouse, vm.TransferRevitFile.StorageCode); + feedBackMsg?.Invoke("妯″瀷鏂囦欢涓嬭浇瀹屾垚锛侊紒锛�", Color.Green); + } + } + msg = "姝e湪瑙f瀽妯″瀷鏂囦欢..."; + feedBackMsg?.Invoke(msg, Color.Black); + var bol = Yw.FileFolderZipHelper.UnZip(localZipFile, tempFolder, zipFilePwd); if (!bol) { feedBackMsg?.Invoke("妯″瀷鏂囦欢瑙f瀽澶辫触锛侊紒锛�", Color.Red); @@ -141,11 +161,11 @@ feedBackMsg?.Invoke("妯″瀷鏂囦欢瑙f瀽鎴愬姛銆傘�傘��", Color.Green); - feedBackProgress?.Invoke(100, 25); + feedBackProgress?.Invoke(100, 30); - #endregion 绗洓姝� 鍘嬬缉鏂囦欢瑙f瀽 锛堣繘搴�25%锛� + #endregion - #region 绗簲姝� 瑙f瀽姘村姏缁撴瀯鏂囦欢 锛堣繘搴�30%锛� + #region 绗簲姝� 瑙f瀽姘村姏缁撴瀯鏂囦欢 锛堣繘搴�40%锛� feedBackMsg?.Invoke("姝e湪瑙f瀽姘村姏缁撴瀯鏂囦欢...", Color.Black); var structFileInfo = allFileInfoList.Find(x => x.Name == HStation.Revit.ConstParas.StructFileName); @@ -157,59 +177,50 @@ return true; } var structOthersFileInfo = allFileInfoList.Find(x => x.Name == HStation.Revit.ConstParas.StructOthersFileName); - - var structRevitModel = HStation.Service.RevitParseHelper.FromJsonFile(structFileInfo.FullName, structOthersFileInfo?.FullName, out msg); - if (structRevitModel == null) + var structRevitModel = HStation.Service.RevitParseHelper.FromJsonFile + (structFileInfo.FullName, structOthersFileInfo?.FullName, out bool structFileResult, out List<string> structFileMsgList); + //瑙f瀽缁撴灉鍒ゆ柇 + if (!structFileResult) { - feedBackMsg?.Invoke($"{msg}锛侊紒锛�", Color.Red); - feedBackMsg?.Invoke("椤圭洰瀵煎叆缁撴潫銆傘�傘��", Color.Blue); - feedBackProgress?.Invoke(100, 100); - return true; + structFileMsgList?.ForEach(x => feedBackMsg?.Invoke(x, Color.Red)); } - - //Revit 灞炴�ч敊璇鐞� - var hasRevitError = false; - var allRevitParterList = structRevitModel.GetAllParters(); - foreach (var revitParter in allRevitParterList) + //Revit灞炴�ч敊璇鐞� + var hasRevitPropError = false; + if (structRevitModel != null) { - if (revitParter.PropStatusList != null && revitParter.PropStatusList.Count > 0) + var allRevitParterList = structRevitModel.GetAllParters(); + foreach (var revitParter in allRevitParterList) { - foreach (var revitParterPropStatus in revitParter.PropStatusList) + if (revitParter.PropStatusList != null && revitParter.PropStatusList.Count > 0) { - if (revitParterPropStatus.PropStatus == HStation.Revit.ePropStatus.Error) + foreach (var revitParterPropStatus in revitParter.PropStatusList) { - hasRevitError = true; - } - switch (revitParterPropStatus.PropStatus) - { - case Revit.ePropStatus.Error: - { - feedBackMsg?.Invoke($"鏋勪欢缂栫爜锛歿revitParter.Code}锛屾瀯浠跺睘鎬э細{revitParterPropStatus.PropName}锛岄敊璇細{revitParterPropStatus.StatusInfo} ", Color.Red); - } - break; - - case Revit.ePropStatus.Lack: - { - feedBackMsg?.Invoke($"鏋勪欢缂栫爜锛歿revitParter.Code}锛屾瀯浠跺睘鎬э細{revitParterPropStatus.PropName}锛岀己鐪侊細{revitParterPropStatus.StatusInfo} ", Color.Gray); - } - break; - - case Revit.ePropStatus.Abnormal: - { - feedBackMsg?.Invoke($"鏋勪欢缂栫爜锛歿revitParter.Code}锛屾瀯浠跺睘鎬э細{revitParterPropStatus.PropName}锛屽紓甯革細{revitParterPropStatus.StatusInfo} ", Color.Orange); - } - break; + if (revitParterPropStatus.PropStatus == HStation.Revit.ePropStatus.Error) + { + hasRevitPropError = true; + } + switch (revitParterPropStatus.PropStatus) + { + case Revit.ePropStatus.Error: + { + feedBackMsg?.Invoke($"鏋勪欢绫诲瀷锛歿revitParter.Catalog}锛屾瀯浠剁紪鐮侊細{revitParter.Id}锛屾瀯浠跺睘鎬э細{revitParterPropStatus.PropName}锛岄敊璇細{revitParterPropStatus.StatusInfo} ", Color.Red); + } + break; + default: break; + } } } } } - if (hasRevitError) + if (hasRevitPropError || !structFileResult) { - feedBackMsg?.Invoke($"姘村姏缁撴瀯鏂囦欢灞炴�ч敊璇紒锛侊紒", Color.Red); + feedBackMsg?.Invoke($"姘村姏缁撴瀯鏂囦欢瑙f瀽閿欒锛侊紒锛�", Color.Red); feedBackMsg?.Invoke("椤圭洰瀵煎叆缁撴潫銆傘�傘��", Color.Blue); feedBackProgress?.Invoke(100, 100); return true; } + + vm.RevitModel = structRevitModel; var hydroInfo = HStation.Hydro.TransferHelper.FromRevit(structRevitModel, out msg); if (hydroInfo == null) @@ -220,23 +231,13 @@ return true; } - var hydroId = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo); - if (hydroId < 1) - { - feedBackMsg?.Invoke("姘村姏缁撴瀯淇℃伅淇濆瓨澶辫触锛侊紒锛�", Color.Red); - feedBackMsg?.Invoke("椤圭洰瀵煎叆缁撴潫銆傘�傘��", Color.Blue); - feedBackProgress?.Invoke(100, 100); - return true; - } - feedBackMsg?.Invoke("姝e湪杩涜浜у搧鍖归厤...", Color.Black); - hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroId); - var matchingParas = AssetsMatchingParasHelper.Create(hydroInfo); + var matchingParas = Yw.WinFrmUI.HydroMatchingHelper.Create(hydroInfo); if (AssetsMatchingHelper.Matching(matchingParas, out string error)) { - if (AssetsMatchingParasHelper.Apply(hydroInfo, matchingParas)) + if (Yw.WinFrmUI.HydroMatchingHelper.Apply(hydroInfo, matchingParas)) { - feedBackMsg?.Invoke("浜у搧鍖归厤鎴愬姛銆傘�傘��", Color.Green); + feedBackMsg?.Invoke("浜у搧鍖归厤瀹屾垚銆傘�傘��", Color.Green); } else { @@ -247,34 +248,53 @@ { feedBackMsg?.Invoke("浜у搧鍖归厤澶辫触锛侊紒锛�", Color.Red); } - hydroId = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo); - feedBackMsg?.Invoke("姘村姏缁撴瀯鏂囦欢瑙f瀽鎴愬姛銆傘�傘��", Color.Green); - feedBackProgress?.Invoke(100, 30); - vm.HydroID = hydroId; - - #endregion 绗簲姝� 瑙f瀽姘村姏缁撴瀯鏂囦欢 锛堣繘搴�30%锛� - - #region 绗叚姝� 鍏宠仈姘村姏缁撴瀯妯″瀷锛堣繘搴� 40%锛� - - var projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(projectId); - if (projectSite == null) + feedBackMsg?.Invoke("姝e湪杩涜绠$綉淇...", Color.Black); + if (hydroInfo.RepairLinksDirection(out msg)) { - feedBackMsg?.Invoke("椤圭洰绔欎俊鎭敊璇�...", Color.Red); + feedBackMsg?.Invoke(msg, Color.Green); + } + else + { + feedBackMsg?.Invoke(msg, Color.Red); + } + + feedBackMsg?.Invoke("姝e湪杩涜绠$綉鍙傛暟淇...", Color.Black); + hydroInfo.RepairParas(out msg); + if (string.IsNullOrEmpty(msg)) + { + feedBackMsg?.Invoke("绠$綉鍙傛暟淇瀹屾垚銆傘�傘��", Color.Green); + } + else + { + feedBackMsg?.Invoke(msg, Color.Red); + } + + feedBackMsg?.Invoke("姝e湪淇濆瓨姘村姏缁撴瀯淇℃伅...", Color.Black); + var hydroId = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(hydroInfo); + if (hydroId < 1) + { + feedBackMsg?.Invoke("姘村姏缁撴瀯淇℃伅淇濆瓨澶辫触锛侊紒锛�", Color.Red); feedBackMsg?.Invoke("椤圭洰瀵煎叆缁撴潫銆傘�傘��", Color.Blue); feedBackProgress?.Invoke(100, 100); return true; } + feedBackMsg?.Invoke("姘村姏缁撴瀯淇℃伅淇濆瓨鎴愬姛銆傘�傘��", Color.Green); - var projectSiteId = projectSite.ID; - vm.ProjectSiteID = projectSite.ID; + feedBackMsg?.Invoke("姘村姏缁撴瀯鏂囦欢瑙f瀽鎴愬姛銆傘�傘��", Color.Green); + feedBackProgress?.Invoke(100, 40); + vm.HydroID = hydroId; + + #endregion + + #region 绗叚姝� 鍏宠仈姘村姏缁撴瀯妯″瀷锛堣繘搴� 50%锛� feedBackMsg?.Invoke("姝e湪鍏宠仈姘村姏缁撴瀯妯″瀷...", Color.Black); var hydroRelation = new Yw.Vmo.HydroModelRelationVmo(); hydroRelation.ObjectType = HStation.Xhs.DataType.XhsProjectSite; - hydroRelation.ObjectID = projectSiteId; - hydroRelation.ModelID = hydroId; + hydroRelation.ObjectID = vm.ProjectSiteID.Value; + hydroRelation.ModelID = vm.HydroID.Value; hydroRelation.Purpose = HStation.Xhs.Purpose.Simulation; hydroRelation.Content = null; hydroRelation.Description = null; @@ -290,11 +310,11 @@ vm.HydroRelationID = hydroRelationId; feedBackMsg?.Invoke("鍏宠仈姘村姏缁撴瀯妯″瀷鎴愬姛銆傘�傘��", Color.Green); - feedBackProgress?.Invoke(100, 40); + feedBackProgress?.Invoke(100, 50); - #endregion 绗叚姝� 鍏宠仈姘村姏缁撴瀯妯″瀷锛堣繘搴� 40%锛� + #endregion - #region 绗竷姝� 涓婁紶Revit妯″瀷鏂囦欢锛堣繘搴� 45%锛� + #region 绗竷姝� 涓婁紶Revit妯″瀷鏂囦欢锛堣繘搴� 60%锛� feedBackMsg?.Invoke("姝e湪瑙f瀽Revit妯″瀷鏂囦欢...", Color.Black); var rvtFileInfo = allFileInfoList.Find(x => x.Name == HStation.Revit.ConstParas.RvtFileName); @@ -306,8 +326,8 @@ return true; } - // var bimfaceId = await Yw.WinFrmUI.BimfaceHelper.UploadFile(rvtFileInfo.FullName);//涓婁紶 - var bimfaceId = 10000878572231; //娴嬭瘯鐢ㄤ緥 + //var bimfaceId = await Yw.WinFrmUI.BimfaceHelper.UploadFile(rvtFileInfo.FullName);//涓婁紶 + var bimfaceId = 10000884893369; //娴嬭瘯鐢ㄤ緥 10000878572231 10000882826621 10000884283372 10000884362886 10000884702464 10000884893369 if (bimfaceId < 1) { feedBackMsg?.Invoke("Revit妯″瀷鏂囦欢涓婁紶澶辫触锛侊紒锛�", Color.Red); @@ -318,11 +338,11 @@ vm.BimfaceId = bimfaceId; feedBackMsg?.Invoke("瑙f瀽Revit妯″瀷鏂囦欢鎴愬姛銆傘�傘��", Color.Green); - feedBackProgress?.Invoke(100, 45); + feedBackProgress?.Invoke(100, 60); - #endregion 绗竷姝� 涓婁紶Revit妯″瀷鏂囦欢锛堣繘搴� 45%锛� + #endregion - #region 绗叓姝� 淇濆瓨Bimface鏂囦欢 锛堣繘搴� 50%锛� + #region 绗叓姝� 淇濆瓨Bimface鏂囦欢 锛堣繘搴� 65%锛� feedBackMsg?.Invoke("姝e湪淇濆瓨Bimface鏂囦欢...", Color.Black); @@ -346,17 +366,17 @@ vm.BimfaceFileID = bimfaceFileId; feedBackMsg?.Invoke("Bimface鏂囦欢淇濆瓨鎴愬姛銆傘�傘��", Color.Green); - feedBackProgress?.Invoke(100, 50); + feedBackProgress?.Invoke(100, 65); - #endregion 绗叓姝� 淇濆瓨Bimface鏂囦欢 锛堣繘搴� 50%锛� + #endregion - #region 绗節姝� 鍏宠仈Bimface鏂囦欢锛堣繘搴� 55%锛� + #region 绗節姝� 鍏宠仈Bimface鏂囦欢锛堣繘搴� 70%锛� feedBackMsg?.Invoke("姝e湪鍏宠仈Bimface鏂囦欢...", Color.Black); var bimfaceRelation = new Yw.Vmo.BimfaceFileRelationVmo(); bimfaceRelation.ObjectType = HStation.Xhs.DataType.XhsProjectSite; - bimfaceRelation.ObjectID = projectSiteId; + bimfaceRelation.ObjectID = vm.ProjectSiteID.Value; bimfaceRelation.BimfaceFileID = bimfaceFileId; bimfaceRelation.Purpose = HStation.Xhs.Purpose.Simulation; bimfaceRelation.Description = vm.Description; @@ -371,11 +391,11 @@ } vm.BimfaceFileRelationID = bimfaceRelationId; feedBackMsg?.Invoke("Bimface鏂囦欢鍏宠仈鎴愬姛銆傘�傘��", Color.Green); - feedBackProgress?.Invoke(100, 55); + feedBackProgress?.Invoke(100, 70); - #endregion 绗節姝� 鍏宠仈Bimface鏂囦欢锛堣繘搴� 55%锛� + #endregion - #region 绗崄姝� 鍙戣捣bimface杞崲锛堣繘搴� 80%锛� + #region 绗崄姝� 鍙戣捣bimface杞崲锛堣繘搴� 90%锛� feedBackMsg?.Invoke("姝e湪杩涜Bimface妯″瀷杞婚噺鍖�...", Color.Black); //var bimfaceTranslateStatus = await Yw.WinFrmUI.BimfaceHelper.TranslateRvtFile(bimfaceId);//鍙戣捣杞崲 @@ -404,9 +424,9 @@ feedBackMsg?.Invoke("Bimface妯″瀷杞婚噺鍖栧畬鎴愩�傘�傘��", Color.Green); } - feedBackProgress?.Invoke(100, 80); + feedBackProgress?.Invoke(100, 90); - #endregion 绗崄姝� 鍙戣捣bimface杞崲锛堣繘搴� 80%锛� + #endregion #region 绗崄涓�姝� 鏇存柊Bimface鏂囦欢鐘舵�侊紙杩涘害 100%锛� @@ -427,7 +447,9 @@ feedBackMsg?.Invoke("椤圭洰瀵煎叆瀹屾垚銆傘�傘��", Color.Green); return true; - #endregion 绗崄涓�姝� 鏇存柊Bimface鏂囦欢鐘舵�侊紙杩涘害 100%锛� + #endregion } + + } } \ No newline at end of file -- Gitblit v1.9.3