From 7cbbe62fea4efded9cf73939a860f7bbb2169458 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 23 三月 2023 18:07:57 +0800 Subject: [PATCH] 1 --- ExportMap/cs/SGUtils.cs | 30 ++++++++------ ExportMap/cs/XYZUtils.cs | 20 ++++++---- ExportMap/Controllers/ConvertController.cs | 18 ++++---- ExportMap/cs/ConvertUtils.cs | 18 +++++---- 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/ExportMap/Controllers/ConvertController.cs b/ExportMap/Controllers/ConvertController.cs index 28c8d48..428ff47 100644 --- a/ExportMap/Controllers/ConvertController.cs +++ b/ExportMap/Controllers/ConvertController.cs @@ -32,13 +32,13 @@ return ResponseMsg<string>.fail("浠ょ墝鏃犳晥"); } - int count = ConvertUtils.Convert(args); - if (0 == count) + List<int> rs = ConvertUtils.Convert(args); + if (null == rs || rs.Count == 0) { return ResponseMsg<string>.fail("澶辫触"); } - return ResponseMsg<string>.success("鎴愬姛", "ok", count); + return ResponseMsg<string>.success("鎴愬姛", string.Join(",", rs), rs.Count); } catch (Exception ex) { @@ -73,13 +73,13 @@ } string err = null; - int count = XYZUtils.Generate(args, ref err); - if (0 == count) + List<int> rs = XYZUtils.Generate(args, ref err); + if (null == rs || rs.Count == 0) { return ResponseMsg<string>.fail(null == err ? "澶辫触" : err); } - return ResponseMsg<string>.success("鎴愬姛", "ok", count); + return ResponseMsg<string>.success("鎴愬姛", string.Join(",", rs), rs.Count); } catch (Exception ex) { @@ -112,13 +112,13 @@ SGUtils utils = new SGUtils(); string err = null; - int count = utils.Release(args, ref err); - if (0 == count) + List<int> rs = utils.Release(args, ref err); + if (null == rs || rs.Count == 0) { return ResponseMsg<string>.fail(null == err ? "澶辫触" : err); } - return ResponseMsg<string>.success("鎴愬姛", "ok", count); + return ResponseMsg<string>.success("鎴愬姛", string.Join(",", rs), rs.Count); } catch (Exception ex) { diff --git a/ExportMap/cs/ConvertUtils.cs b/ExportMap/cs/ConvertUtils.cs index 0a092d0..cca8fb3 100644 --- a/ExportMap/cs/ConvertUtils.cs +++ b/ExportMap/cs/ConvertUtils.cs @@ -35,15 +35,15 @@ /// <summary> /// 妯″瀷杞崲 /// </summary> - public static int Convert(XYZArgs args) + public static List<int> Convert(XYZArgs args) { - int count = 0; string uploadFolder = Tools.GetSetting("uploadFolder"); string tilesFolder = Path.Combine(Tools.GetSetting("lfData"), "3d\\3dtiles"); List<SysMeta> list = XYZUtils.SelectMetas(args.ids, "and type in ('ifc', 'fbx', 'rvt')"); - if (null == list || list.Count == 0) return 0; + if (null == list || list.Count == 0) return null; + List<int> ids = new List<int>(); foreach (SysMeta meta in list) { string modelFile = Path.Combine(uploadFolder, meta.path); @@ -63,13 +63,13 @@ if (File.Exists(jsonFile)) { string path = jsonFile.Replace(Tools.GetSetting("lfData") + "\\", ""); - InsertToDB(meta, args, path); + int pubid = InsertToDB(meta, args, path); - count++; + if (pubid > 0) ids.Add(pubid); } } - return count; + return ids; } /// <summary> @@ -121,9 +121,9 @@ /// <summary> /// 鎻掑叆鏁版嵁搴� /// </summary> - private static void InsertToDB(SysMeta meta, XYZArgs args, string path) + private static int InsertToDB(SysMeta meta, XYZArgs args, string path) { - if (PubDBHelper.IsPublish(meta.id)) return; + if (PubDBHelper.IsPublish(meta.id)) return 0; SysPublish sys = NewPublish(meta, args); sys.path = path; @@ -135,6 +135,8 @@ PubDBHelper.InsertLayer(sys, meta, 100); PubDBHelper.InsertMetaPub(meta.id, pubid, args.userId); } + + return pubid; } /// <summary> diff --git a/ExportMap/cs/SGUtils.cs b/ExportMap/cs/SGUtils.cs index 44125b4..070aef5 100644 --- a/ExportMap/cs/SGUtils.cs +++ b/ExportMap/cs/SGUtils.cs @@ -58,20 +58,19 @@ /// </summary> /// <param name="args">XYZ鍙傛暟</param> /// <returns>琛屾暟</returns> - public int Release(XYZArgs args, ref string err) + public List<int> Release(XYZArgs args, ref string err) { List<SysMeta> list = XYZUtils.SelectMetas(args.ids, "and type in ('mpt', '3dml')"); - if (null == list || list.Count == 0) return 0; + if (null == list || list.Count == 0) return null; int maxId = GetMaxId(); // maxId = 411576; RomoveNoneFiles(list); - if (list.Count == 0) return 0; + if (list.Count == 0) return null; //err = LinkFiles(list); //if (!string.IsNullOrEmpty(err)) return 0; MoveFiles(list); - int count = 0; string names = GetNames(list); for (int i = 0; i < 61; i++) { @@ -80,12 +79,10 @@ List<SpatialItem> items = SelectItems(names); if (null == items || items.Count == 0) continue; - InsertInto(list, items, args); - count = items.Count; - break; + return InsertInto(list, items, args); } - return count; + return null; } /// <summary> @@ -151,24 +148,29 @@ /// <summary> /// 鎻掑叆鏁版嵁鍙戝竷琛� /// </summary> - private void InsertInto(List<SysMeta> list, List<SpatialItem> items, XYZArgs args) + private List<int> InsertInto(List<SysMeta> list, List<SpatialItem> items, XYZArgs args) { + List<int> ids = new List<int>(); foreach (SysMeta meta in list) { IEnumerable<SpatialItem> iterator = from item in items where item.Name.Equals(meta.id + "_" + meta.name) select item; - if (null == iterator) return; + if (null == iterator) return ids; meta.verid = iterator.First().id; - InsertToDB(meta, args); + int pubid = InsertToDB(meta, args); + + if (pubid > 0) ids.Add(pubid); } + + return ids; } /// <summary> /// 鎻掑叆鏁版嵁搴� /// </summary> - private static void InsertToDB(SysMeta meta, XYZArgs args) + private static int InsertToDB(SysMeta meta, XYZArgs args) { - if (PubDBHelper.IsPublish(meta.id)) return; + if (PubDBHelper.IsPublish(meta.id)) return 0; SysPublish sys = NewPublish(meta, args); sys.path = meta.id + "\\" + meta.name; @@ -180,6 +182,8 @@ PubDBHelper.InsertLayer(sys, meta, sys.type == "3dml" ? 100 : 0); PubDBHelper.InsertMetaPub(meta.id, pubid, args.userId); } + + return pubid; } /// <summary> diff --git a/ExportMap/cs/XYZUtils.cs b/ExportMap/cs/XYZUtils.cs index 733fc45..5224d2b 100644 --- a/ExportMap/cs/XYZUtils.cs +++ b/ExportMap/cs/XYZUtils.cs @@ -78,11 +78,11 @@ /// </summary> /// <param name="args">XYZ鍙傛暟</param> /// <param name="err">閿欒淇℃伅</param> - /// <returns>鏁版嵁鍙戝竷ID</returns> - public static int Generate(XYZArgs args, ref string err) + /// <returns>鏁版嵁鍙戝竷ID闆嗗悎</returns> + public static List<int> Generate(XYZArgs args, ref string err) { List<SysMeta> list = SelectMetas(args.ids, "and type in ('tif', 'tiff', 'img')"); - if (null == list || list.Count == 0) return 0; + if (null == list || list.Count == 0) return null; string dateStr = ExportUtil.DateStr; //string batFile = Path.Combine(BatPath, dateStr + ".bat"); @@ -100,15 +100,17 @@ //if (File.Exists(batFile)) File.Delete(batFile); if (File.Exists(tifFile)) File.Delete(tifFile); + List<int> ids = new List<int>(); string viewFile = Path.Combine(xyzPath, "view.html"); if (File.Exists(viewFile)) { string path = "2d\\tiles" + "\\" + args.dircode; - InsertToDB(list, args, path); - return 1; + int pubid = InsertToDB(list, args, path); + + if (pubid > 0) ids.Add(pubid); } - return 0; + return ids; } /// <summary> @@ -157,9 +159,9 @@ /// <summary> /// 鎻掑叆鏁版嵁搴� /// </summary> - private static void InsertToDB(List<SysMeta> metas, XYZArgs args, string path) + private static int InsertToDB(List<SysMeta> metas, XYZArgs args, string path) { - if (PubDBHelper.IsPublish(args.dircode)) return; + if (PubDBHelper.IsPublish(args.dircode)) return 0; SysPublish sys = NewPublish(metas[0], args); sys.path = path; @@ -178,6 +180,8 @@ PubDBHelper.InsertMetaPub(meta.id, pubid, args.userId); } } + + return pubid; } /// <summary> -- Gitblit v1.9.3