From 329e55db60273ae7583a2cd3fda0ba8eb4e133ac Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 04 五月 2023 14:15:16 +0800
Subject: [PATCH] 1

---
 ExportMap/up.html             |   47 ++++++---------
 ExportMap/db/PostgreHelper.cs |   26 ++++++++
 ExportMap/js/insertFiles.js   |   41 +++++++++++++
 ExportMap/db/PubDBHelper.cs   |   18 ++++-
 4 files changed, 100 insertions(+), 32 deletions(-)

diff --git a/ExportMap/db/PostgreHelper.cs b/ExportMap/db/PostgreHelper.cs
index 6a19629..8659d6d 100644
--- a/ExportMap/db/PostgreHelper.cs
+++ b/ExportMap/db/PostgreHelper.cs
@@ -134,6 +134,32 @@
             }
         }
 
+        public int GetIntScalar(string sql, params DbParameter[] args)
+        {
+            using (NpgsqlConnection con = new NpgsqlConnection(ConStr))
+            {
+                if (con.State != ConnectionState.Open)
+                {
+                    con.Open();
+                }
+
+                using (NpgsqlCommand cmd = new NpgsqlCommand(sql, con))
+                {
+                    if (args != null)
+                    {
+                        foreach (DbParameter arg in args)
+                        {
+                            cmd.Parameters.Add(arg);
+                        }
+                    }
+
+                    object obj = cmd.ExecuteScalar();
+
+                    return null == obj ? 0 : Convert.ToInt32(obj);
+                }
+            }
+        }
+
         /// <summary>
         /// 鎵цSQL锛岃繑鍥炲奖鍝嶈鏁�
         /// </summary>
diff --git a/ExportMap/db/PubDBHelper.cs b/ExportMap/db/PubDBHelper.cs
index 432325e..275bb62 100644
--- a/ExportMap/db/PubDBHelper.cs
+++ b/ExportMap/db/PubDBHelper.cs
@@ -19,10 +19,11 @@
         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, elev) 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) + 1 from lf.sys_layer where pid = (select id from lf.sys_layer where cn_name = @name limit 1)), 0, @user, @name, @serve, @pubid, @elev);";
-        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, elev) values (@pid, @cnName, @enName, @url, 2, (select coalesce(level, 0) + 1 from lf.sys_layer where id = @pid), (select coalesce(max(order_num), 0) + 1 from lf.sys_layer where pid = @pid), 0, @user, @data, @serve, @pubid, @elev)";
+        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, elev) values (@pid, @cnName, @enName, @url, 2, (select coalesce(level, 0) + 1 from lf.sys_layer where id = @pid), (select coalesce(max(order_num), 0) + 1 from lf.sys_layer where pid = @pid), 0, @user, @data, @serve, @pubid, @elev) returning id";
 
         private static string updateMetaSql = "update lf.sys_meta set path = @path where id = @id";
+
+        private static string selectLayerSql = "select id from lf.sys_layer where pid = @pid and cn_name = @name";
 
         /// <summary>
         /// 鏄�/鍚﹀彂甯冭繃
@@ -121,10 +122,19 @@
         public static int SelectLayerPid(SysMeta meta)
         {
             string sql = GetSelectLayerPidSql(meta);
+            int pid = Tools.DBHelper.GetIntScalar(sql);
 
-            object obj = Tools.DBHelper.GetScalar(sql);
+            List<DbParameter> list = new List<DbParameter>();
+            list.Add(new NpgsqlParameter("@pid", pid));
+            list.Add(new NpgsqlParameter("@name", meta.dirname));
 
-            return null == obj ? 0 : Convert.ToInt32(obj);
+            int layerId = Tools.DBHelper.GetIntScalar(selectLayerSql, list.ToArray());
+            if (0 == layerId)
+            {
+                //
+            }
+
+            return layerId;
         }
 
         /// <summary>
diff --git a/ExportMap/js/insertFiles.js b/ExportMap/js/insertFiles.js
index 2cf4b6a..f46e3b0 100644
--- a/ExportMap/js/insertFiles.js
+++ b/ExportMap/js/insertFiles.js
@@ -706,3 +706,44 @@
         "verid": 0
     }
 ];
+
+
+var xlsFiles = [{
+    "createTime": null,
+    "createUser": 1,
+    "depcode": "00",
+    "dircode": "0A",
+    "entity": null,
+    "epsgCode": "EPSG:4490",
+    "eventid": "de7305ea-8e4c-4bb5-a135-f40ee8a15012",
+    "extName": ".xls",
+    "guid": "d33145704a27cda67577d7c51dc26c18",
+    "isMeta": false,
+    "msg": null,
+    "name": "涓夋々涓�鐗�.xls",
+    "path": "20230428\\涓夋々涓�鐗�.xls",
+    "rows": 0,
+    "sizes": 0.021,
+    "tab": null,
+    "type": "xls",
+    "verid": 0
+}, {
+    "createTime": null,
+    "createUser": 1,
+    "depcode": "00",
+    "dircode": "0A",
+    "entity": null,
+    "epsgCode": "EPSG:4490",
+    "eventid": "d1091b43-e3a4-4ef2-bc3a-b93396d9d827",
+    "extName": ".xls",
+    "guid": "34250a66dfc5508dd4e2de16790c5913",
+    "isMeta": false,
+    "msg": null,
+    "name": "鏁板瓧姝e皠褰卞儚鍥�.xlsx",
+    "path": "20230428\\鏁板瓧姝e皠褰卞儚鍥�.xlsx",
+    "rows": 0,
+    "sizes": 0.009,
+    "tab": null,
+    "type": "xls",
+    "verid": 0
+}];
diff --git a/ExportMap/up.html b/ExportMap/up.html
index ad5b7cb..b93d388 100644
--- a/ExportMap/up.html
+++ b/ExportMap/up.html
@@ -10,10 +10,10 @@
   <script src="js/insertFiles.js"></script>
   <script>
     var app = {};
-    var path = "20230228";
+    var path = "20230425";
     var url = "http://127.0.0.1:12316/server/";
     //var token = "c36e4f94-dfde-401e-9967-2c4a449f1300";
-    var token = "e507a96b-ca70-4531-b7ef-b3ecb3fb6094";
+    var token = "dce05aee-5b55-4835-bb45-e128d9c1f145";
 
     $(function () {
       $("#pathSpan").html(path);
@@ -121,32 +121,10 @@
       });
     }
 
-    // Xls鍏ュ簱 *
+    // Xls鍏ュ簱
     function insertXls() {
-      if (app.data == null) return;
-
-      var obj = {
-        metaEntity: {
-          depid: 1,
-          dirid: 10,
-          verid: 0,
-          //type: "file",
-          //cs: "CGCS 2000",
-          //scale: "1:1000",
-          //resolution: "0.5m",
-          gather: "2022-10-05 15:00:00",
-          descr: "娴嬭瘯Xls",
-        },
-        fileEntities: app.data,
-        tabEntities: [
-          { filename: "2-2 绠$嚎鎴愭灉琛�.xlsx", subPath: "20221128010101\2-2 绠$嚎鎴愭灉琛�.xlsx", tab: null, entity: "mdGdcg", type: "xls" },
-          { filename: "娴峰師鍘夸腑绾挎垚鏋滆〃.xlsx", subPath: "20221128010101\娴峰師鍘夸腑绾挎垚鏋滆〃.xlsx", tab: null, entity: "mdZxcg", type: "xls" }
-        ]
-      };
-
-      ajax(getUrl("dataLoader/insertFiles"), "POST", JSON.stringify(obj), null, null, function (rs) {
+      ajax(getUrl("dataUpload/insertFiles"), "POST", JSON.stringify(xlsFiles), null, null, function (rs) {
         console.log(rs);
-        app.data = null;
         alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
       });
     }
@@ -538,13 +516,25 @@
 
     // 娴嬭瘯鍙戝竷
     function testPublish() {
-      //debugger
       var type = $("#selectPubType").find("option:selected").text().split("锛�")[0];
       var vals = $("#selectPubType").find("option:selected").val();
       console.log("娴嬭瘯鍙戝竷", type, vals);
 
       var data = { "ids": vals.split(","), "type": type, "name": "DOM_0.2m", "min": 12, "max": 18, depcode: "000305", dircode: "0102" };
       ajax(getUrl("publish/insertForPub"), "POST", JSON.stringify(data), null, null, function (rs) {
+        console.log(rs);
+        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
+      });
+    }
+
+    // 涓嬭浇鐡︾墖
+    function downloadTiles() {
+      var data = {
+        pwd: encrypt.encrypt("Test!321&456"),
+        //pubid: 15, xmin: 112.9534213185, ymin: 32.1588839103, xmax: 112.9734893228, ymax: 32.1736306779
+        pubid: 15, xmin: 112.943013, ymin: 32.158525, xmax: 112.974408, ymax: 32.174741
+      };
+      ajax(getUrl("inquiry/downloadTiles"), "POST", JSON.stringify(data), null, null, function (rs) {
         console.log(rs);
         alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
       });
@@ -563,7 +553,7 @@
     <input value="涓婁紶鏂囦欢" type="button" onclick="uploadFiles();" />
     <input value="鏌ヨ鏂囦欢 *" type="button" onclick="selectFiles();" />
     <input value="鍒犻櫎鏂囦欢" type="button" onclick="deleteFiles();" />
-    <!--<input value="Xls鍏ュ簱" type="button" onclick="insertXls();" />-->
+    <input value="Xls鍏ュ簱" type="button" onclick="insertXls();" />
     <input value="璇诲彇鏄犲皠 *" type="button" onclick="readMappers();" />
     <input value="缁煎悎鏁版嵁鍏ュ簱 *" type="button" onclick="insertAllFiles();" />
     <input value="绌洪棿鏁版嵁鍏ュ簱 *" type="button" onclick="insertDbFiles();" />
@@ -627,6 +617,7 @@
       <option value="1525">MPT</option>
     </select>
     <input value="娴嬭瘯鍙戝竷" type="button" onclick="testPublish();" />
+    <input value="涓嬭浇鐡︾墖" type="button" onclick="downloadTiles();" />
     <hr />
     <br />
   </form>

--
Gitblit v1.9.3