From bbafc4e99b3cc42692bd9f7d8becf801aa70ddb3 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期日, 19 三月 2023 16:56:17 +0800 Subject: [PATCH] 1 --- ExportMap/cs/SGUtils.cs | 1 + ExportMap/cs/XYZUtils.cs | 5 +++++ ExportMap/cs/ConvertUtils.cs | 1 + ExportMap/db/PubDBHelper.cs | 30 +++++++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 1 deletions(-) diff --git a/ExportMap/cs/ConvertUtils.cs b/ExportMap/cs/ConvertUtils.cs index ac69899..36a5e36 100644 --- a/ExportMap/cs/ConvertUtils.cs +++ b/ExportMap/cs/ConvertUtils.cs @@ -131,6 +131,7 @@ int pubid = PubDBHelper.InsertPublish(sys); if (pubid > 0) { + PubDBHelper.InsertLayer(sys, meta); PubDBHelper.InsertMetaPub(meta.id, pubid, args.userId); } } diff --git a/ExportMap/cs/SGUtils.cs b/ExportMap/cs/SGUtils.cs index d5335fb..f9d4455 100644 --- a/ExportMap/cs/SGUtils.cs +++ b/ExportMap/cs/SGUtils.cs @@ -195,6 +195,7 @@ int pubid = PubDBHelper.InsertPublish(sys); if (pubid > 0) { + PubDBHelper.InsertLayer(sys, meta); PubDBHelper.InsertMetaPub(meta.id, pubid, args.userId); } } diff --git a/ExportMap/cs/XYZUtils.cs b/ExportMap/cs/XYZUtils.cs index 53d2871..2db0fcf 100644 --- a/ExportMap/cs/XYZUtils.cs +++ b/ExportMap/cs/XYZUtils.cs @@ -191,6 +191,11 @@ int pubid = PubDBHelper.InsertPublish(sys); if (pubid > 0) { + PubDBHelper.InsertLayer(sys, new SysMeta() + { + name = args.name, + type = metas[0].type + }); foreach (SysMeta meta in metas) { PubDBHelper.InsertMetaPub(meta.id, pubid, args.userId); diff --git a/ExportMap/db/PubDBHelper.cs b/ExportMap/db/PubDBHelper.cs index c15cd16..d2c82f1 100644 --- a/ExportMap/db/PubDBHelper.cs +++ b/ExportMap/db/PubDBHelper.cs @@ -12,9 +12,14 @@ { public class PubDBHelper { + private static List<string> imgList = new List<string>() { "tif", "tiff", "img", "mpt" }; + private static string insertPublishSql = "insert into lf.sys_publish(name, url, path, type, status, dirid, depid, min, max, json, create_user, geom, bak) values (@name, @url, @path, @type, @status, @dirid, @depid, @min, @max, @json, @create_user, {0}, @bak) returning id"; private static string insertMetaPubSql = "insert into lf.sys_meta_pub (metaid, pubid, create_user) select {0}, {1}, {2} from (select 1) temp where not exists (select 1 from lf.sys_meta_pub where metaid = {0} and pubid = {1})"; + + // 妯″瀷-@cnName锛宮odel-@enName锛岃嚜鍔ㄥ彂甯冩ā鍨�-@name锛宧ttp:// - @url锛孴ileset-@serve锛�1-@user锛�7-@pubid + private static string insertLayerSql = "insert into lf.sys_layer (pid, cn_name, en_name, url, type, level, order_num, is_show, create_user, data_type, serve_type, pubid) values ((select coalesce(id, 0) from lf.sys_layer where cn_name = @name limit 1), @cnName, @enName, @url, 2, (select coalesce(level, 0) + 1 from lf.sys_layer where cn_name = @name limit 1), (select coalesce(max(order_num), 0) from lf.sys_layer where pid = (select id from lf.sys_layer where cn_name = @name limit 1)), 0, @user, @name, @serve, @pubid);"; /// <summary> /// 鏄�/鍚﹀彂甯冭繃 @@ -56,7 +61,6 @@ /// <summary> /// 鎻掑叆鏁版嵁鍙戝竷琛ㄨ褰� /// </summary> - /// <returns></returns> public static int InsertPublish(SysPublish sys) { List<DbParameter> list = Tool.GetParams<SysPublish>(insertPublishSql, sys); @@ -68,6 +72,30 @@ } /// <summary> + /// 鎻掑叆鍥惧眰琛ㄨ褰� + /// </summary> + public static int InsertLayer(SysPublish sys, SysMeta meta) + { + bool isImg = imgList.Contains(meta.type); + string cnName = meta.name.Split(new char[] { '.' })[0]; + string name = isImg ? "鑷姩鍙戝竷褰卞儚" : "鑷姩鍙戝竷妯″瀷"; + string serve = isImg ? (meta.type.Equals("mpt") ? "Mpt" : "TMS") : "Tileset"; + + List<DbParameter> list = new List<DbParameter>(); + list.Add(new NpgsqlParameter("@cnName", cnName)); + list.Add(new NpgsqlParameter("@enName", meta.name)); + list.Add(new NpgsqlParameter("@name", name)); + list.Add(new NpgsqlParameter("@url", sys.url)); + list.Add(new NpgsqlParameter("@serve", serve)); + list.Add(new NpgsqlParameter("@pubid", sys.id)); + list.Add(new NpgsqlParameter("@user", sys.create_user)); + + int rows = Tool.DBHelper.ExecuteNonQuery(insertLayerSql, list.ToArray()); + + return rows; + } + + /// <summary> /// 鑾峰彇鍙傛暟鍒楄〃 /// </summary> public static List<DbParameter> GetParams<T>(string sql, T t) -- Gitblit v1.9.3