From 7e063d4b2812aeaabc247c2c3f0fc5b12b5478e8 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 12 十月 2023 16:26:13 +0800 Subject: [PATCH] 出图底图允许添加多个 --- MoonExp/cs/ExportUtil.cs | 68 +++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 1 deletions(-) diff --git a/MoonExp/cs/ExportUtil.cs b/MoonExp/cs/ExportUtil.cs index 4bb0552..41173e7 100644 --- a/MoonExp/cs/ExportUtil.cs +++ b/MoonExp/cs/ExportUtil.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Configuration; +using System.Data; using System.Diagnostics; using System.IO; using System.Linq; @@ -122,6 +123,10 @@ return i.ToString(); } + private static readonly string selectResSql = "select a.id, a.url, b.url || case when length(b.args) > 0 then '?' || b.args else '' end \"surl\" from lf.sys_layer a left join lf.sys_res b on a.resid = b.id where a.category = 3 and a.is_layer = 1 and a.id in ({0})"; + + public ExportUtil() { } + /// <summary> /// 鐢熸垚 /// </summary> @@ -195,7 +200,7 @@ .Replace("{date}", DateTime.Now.ToString("yyyy.MM.dd")) .Replace("{layers}", args.layers) .Replace("{imgPath}", imgPath) - .Replace("{wmsUrl}", null == args.wmtsUrl ? string.Empty : args.wmtsUrl); + .Replace("{wmsUrl}", getWmtsUrl(args)); File.WriteAllText(qptFile, xml); } @@ -245,5 +250,66 @@ return str; } + + /// <summary> + /// 鑾峰彇WMTS鍦板潃锛屽涓互鑻辨枃閫楀彿闅斿紑 + /// </summary> + public static string getWmtsUrl(ExportArgs args) + { + List<string> list = new List<string>(); + foreach (int id in args.layerIds) + { + List<string> resList = SelectMapUrls(id); + if (null != resList && resList.Count > 0) + { + list.AddRange(resList); + } + } + + if (0 == list.Count) + { + string defaultUrl = Tools.GetSetting("wmtsUrl"); + if (!string.IsNullOrEmpty(defaultUrl)) list.Add(defaultUrl); + } + + string wmtsUrl = string.Join(",", list); + + return wmtsUrl; + } + + /// <summary> + /// 鏌ヨ鍦板浘Url + /// </summary> + public static List<string> SelectMapUrls(int id) + { + string sql = string.Format(selectResSql, id); + DataTable dt = Tools.DBHelper.GetDataTable(sql); + if (null == dt || 0 == dt.Rows.Count) + { + return null; + } + + List<SysRes> resList = ModelHandler.FillModel<SysRes>(dt); + if (null == resList || 0 == resList.Count) + { + return null; + } + + List<string> list = new List<string>(); + foreach (SysRes res in resList) + { + if (!string.IsNullOrEmpty(res.surl)) + { + list.Add(res.surl); + continue; + } + if (!string.IsNullOrEmpty(res.url)) + { + list.Add(res.url); + } + } + + return list; + } } } -- Gitblit v1.9.3