管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2024-09-03 3cfb6aa02516135fb174ab1b30620f2007924663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>LF接口测试</title>
  <meta http-equiv="Expires" content="0" />
  <meta http-equiv="Cache" content="no-cache" />
  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Cache-control" content="no-cache" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src="js/jquery.1.12.4.js"></script>
  <script src="js/rsa.min.js"></script>
  <script src="js/rollups.js"></script>
  <script src="js/config.js"></script>
  <script>
    var url = "http://127.0.0.1:12316/server/";
    var token = "?token=9c62ba00-5c82-40c2-a210-6aecc33e8c96";
    // 项目,站场,管道中心线,战略通道,矢量图,影像注记,影像图
 
    window.onload = function () {
      getPublicKey();
    }
 
    function getPublicKey() {
      $.get(url + "sign/getPublicKey", function (rs) {
        if (rs && rs.code == 200) {
          window.encrypt = new JSEncrypt();
          encrypt.setPublicKey(rs.result);
        }
      });
    }
 
    function ajax(url, type, data, dataType, contentType, fn) {
      $.ajax({
        url: url,
        type: type,
        data: data,
        dataType: dataType || "json", // html、json、jsonp、script、text
        contentType: contentType || "application/json", // "application/x-www-form-urlencoded"
        success: function (data) {
          fn(data);
        },
        error: function (e) {
          console.error(e);
          fn();
        }
      });
    }
 
    function TestCros() {
      $.get(url + "Style/selectCount", function (rs) {
        alert(rs.result);
      });
    }
 
    function check() {
      $.get(url + "sign/check" + token, function (rs) {
        alert("code: " + rs.code + ", msg: " + rs.msg + ", result: " + rs.result);
      });
    }
 
    function getCurrentUser() {
      $.get(url + "sign/getCurrentUser" + token, function (rs) {
        alert("code: " + rs.code + ", msg: " + rs.msg + ", result: " + rs.result.uname);
      });
    }
 
    function logout() {
      $.get(url + "sign/logout" + token, function (rs) {
        alert("code: " + rs.code + ", msg: " + rs.msg + ", result: " + rs.result);
      });
    }
 
    function updateUsersPwd() {
      var data = {
        "adminPwd": encrypt.encrypt("Admin@123"),
        "newPwd": encrypt.encrypt("Admin@123"),
        "ids": [4, 5]
      };
 
      // JSON.stringify(data),"application/x-www-form-urlencoded"
      ajax(url + "user/updateUsersPwd" + token, "POST", JSON.stringify(data), "json", null, function (rs) {
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        console.log(rs);
      });
    }
 
    function ajxUpload() {
      var formData = new FormData();
      var fs = document.getElementById("file1");
      for (var i = 0, c = fs.files.length; i < c; i++) {
        formData.append("file", fs.files[i]); // fs.files[i].name
      }
 
      $.ajax(url + "style/upload" + token, {
        type: "post",
        data: formData,
        async: false,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          alert(rs.code + ":" + rs.result);
          console.log(rs);
        },
        error: function (e) {
          console.error(e);
        }
      });
    }
 
    // 上传数据
    function uploadData() {
      var formData = new FormData();
      var fs = document.getElementById("file1");
      for (var i = 0, c = fs.files.length; i < c; i++) {
        formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file
      }
      formData.append("name", "测试");
      formData.append("dirid", "10");
      formData.append("depid", "1");
      formData.append("verid", "1");
      formData.append("type", "gdb");
      formData.append("cs", "CGCS 2000");
      formData.append("scale", "1:1000");
      formData.append("resolution", "0.5m");
      formData.append("gather", "2022-10-03 15:00:00");
      formData.append("descr", "质量不错");
 
      $.ajax(url + "uploader/uploadData" + token, {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
          console.log(rs);
        },
        error: function (e) {
          console.error(e);
        }
      });
    }
 
    function uploadShpForWKT() {
      var formData = new FormData();
      var fs = document.getElementById("shpFiles");
      var exts = [".shp", ".shx", ".dbf", ".prj"];
 
      var count = 0;
      for (var i = 0, c = fs.files.length; i < c; i++) {
        var name = fs.files[i].name.toLocaleLowerCase();
        var ext = name.substring(name.lastIndexOf("."));
        if (exts.indexOf(ext) > -1) {
          count++;
          formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file
        }
      }
      if (count != 4) {
        alert("ShapeFile文件选择不全!");
        return;
      }
 
      $.ajax(url + "inquiry/uploadShp" + token, {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result.csid + ", " + rs.result.wkt);
          console.log(rs);
        },
        error: function (e) {
          console.error(e);
        }
      });
    }
 
    function downloadMarkShp() {
      var data = [
          { id: 1, name: "Point-1", bak: "{}", wkt: "POINT(95.80461853400004 34.13862467200005)" },
          { id: 2, name: "Linestring-1", bak: "{}", wkt: "LINESTRING(04.98985101830993 37.43840773692756,104.99318913447104 37.43883729720358)" },
          { id: 3, name: "Polygon-1", bak: "{}", wkt: "POLYGON((104.9907822932683 37.43532941961706,104.99088987736599 37.43532941961706,104.9908670336867 37.4349030213574,104.99078327712658 37.4349030213574,104.9907822932683 37.43532941961706))" }
      ];
 
      ajax(url + "comprehensive/downloadShp" + token, "POST", JSON.stringify(data), "json", null, function (rs) {
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        // 下载文件
        if (rs && rs.code == 200) {
          var a = document.createElement('a'); // 创建一个a标签元素
          a.style.display = 'none'; // 设置元素不可见
          // http://127.0.0.1:12316/server/comprehensive/downloadFile?guid=5f0d5b61ca8cd79a07502f308c2f4dcc
          a.href = url + "comprehensive/downloadFile" + token + "&guid=" + rs.result;
 
          document.body.appendChild(a); // 加入
          a.click(); // 触发点击,下载
          document.body.removeChild(a); // 释放
        }
      });
 
      function htmlDownload(data) {
        var url = window.URL.createObjectURL(new Blob([data], { type: "application/zip" }));
 
        var link = document.createElement('a');
        link.style.display = 'none';
        link.href = url;
        link.setAttribute('download', "shp.zip");
        document.body.appendChild(link);
        link.click();
 
        window.URL.revokeObjectURL(url);
        document.body.removeChild(link);
      }
    }
 
    function testAES() {
      var str1 = encrypt("admin");
      var str2 = decrypt(str1);
      //console.log("%c%s", "color: red; background: yellow; font-size: 24px;", "admin");
      console.log("admin", str1, str2);
 
      var str3 = "gAPpDbZ53XfoQfvT8dj/uhBWX5os8kBJQ1LrNvH3VX7byFQdUJMPiEr8Fkj0q2i1pw+L8KFrvR0MLXq2xaO21nlQQXmEPofJxpDQZwEWUIFZsToXo1kLRD3t6WQezxWB8YTzXHM20Ba73x/ZuuezVhOFOq1U8HKf1dXQdv7gBzEB6fWMmFDc3FuH8GDDHv3LfT86Gio9VgMO6ohlrUdf3ZKtTHeLSuzGF4t0RZuX97YBNo25IIzpeTfRTXBxfdxA";
      console.log(decrypt(str3));
    }
 
    function encrypt(word){
      return CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(word), CryptoJS.enc.Utf8.parse(base64Decode("QSNzX2xGX3NFcnZlX2sueQ==")), { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }).toString();
    }
 
    function decrypt(word) {
      return CryptoJS.enc.Utf8.stringify(CryptoJS.AES.decrypt(word, CryptoJS.enc.Utf8.parse(base64Decode("QSNzX2xGX3NFcnZlX2sueQ==")), { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })).toString();
    }
 
    function downloadFile() {
      var a = document.createElement('a'); // 创建一个a标签元素
      a.style.display = 'none'; // 设置元素不可见
      a.href = url + "comprehensive/downloadFile" + token + "&guid=" + "5ce046cc05b186332775c03ac6792caf";
 
      document.body.appendChild(a); // 加入
      a.click(); // 触发点击,下载
      document.body.removeChild(a); // 释放
    }
 
    function uploadShpForMark() {
      var formData = new FormData();
      var fs = document.getElementById("shpFiles");
      var exts = [".shp", ".shx", ".dbf", ".prj"];
 
      var count = 0;
      for (var i = 0, c = fs.files.length; i < c; i++) {
        var name = fs.files[i].name.toLocaleLowerCase();
        var ext = name.substring(name.lastIndexOf("."));
        if (exts.indexOf(ext) > -1) {
          count++;
          formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file
        }
      }
      if (count != 4) {
        alert("ShapeFile文件选择不全!");
        return;
      }
 
      $.ajax(url + "comprehensive/uploadShp" + token, {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + ", " + JSON.stringify(rs.result));
          console.log(rs);
        },
        error: function (e) {
          console.error(e);
        }
      });
    }
 
    function pipeAnalysis() {
      var data = {
        gid: 24,
        tabs: ["bd.dlg_25w_hydl", "bd.dlg_25w_lrdl", "bd.dlg_25w_lrrl", "bd.dlg_25w_hyda"]
      };
 
      $.ajax(url + "pipeline/selectPipeAnalysis" + token, {
        type: "POST",
        data: JSON.stringify(data),
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + ", " + JSON.stringify(rs.result));
          console.log(rs);
        },
        error: function (e) {
          console.error(e);
        }
      });
    }
 
    function downloadPipeReq() {
      var data = {
        pwd: encrypt.encrypt("Test!321&456"),
        gid: 24,
        tabs: ["bd.dlg_25w_hydl", "bd.dlg_25w_lrdl", "bd.dlg_25w_lrrl", "bd.dlg_25w_hyda"]
      };
 
      $.ajax(url + "pipeline/downloadReq" + token, {
        type: "POST",
        data: JSON.stringify(data),
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + ", " + JSON.stringify(rs.result));
          console.log(rs);
        },
        error: function (e) {
          console.error(e);
        }
      });
    }
  </script>
  <script>
    function exportMap1() {
      var page = $("#selectPage").find("option:selected").text();
      var data = {
        token: token.replace("?token=", ""),
        title: "管道基础大数据平台(DW1-01)",
        pageSize: page,
        province: "河北省",
        scale: "1:5万",
        resolution: "5米",
        date: "2022.12.20",
        layers: "项目,站场,管道中心线,矢量图",
        rotation: 0,
        xmin: 103.394023,
        ymin: 30.690466,
        ymax: 37.871048,
        xmax: 112.534648
      };
 
      ajax(url + "export/insertMap" + token, "POST", JSON.stringify(data), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", result = " + rs.result);
        if (rs.code = 200) downloadMap(rs.result);
      });
    }
 
    function exportMap2() {
      var page = $("#selectPage").find("option:selected").text();
      var data = {
        token: token.replace("?token=", ""),
        title: "管道基础大数据平台(DW1-02)",
        pageSize: page,
        province: "山东省",
        scale: "1:20万",
        resolution: "20米",
        date: "2022.11.10",
        layers: "项目,站场,管道中心线,影像注记,影像图",
        rotation: 0,
        xmin: 103.394023,
        ymin: 30.690466,
        ymax: 37.871048,
        xmax: 112.534648
      };
 
      ajax(url + "export/insertMap" + token, "POST", JSON.stringify(data), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", result = " + rs.result);
        if (rs.code = 200) downloadMap(rs.result);
      });
    }
 
    function downloadMap(guid) {
      var a = document.createElement('a'); // 创建一个a标签元素
      a.style.display = 'none'; // 设置元素不可见
      a.href = url + "mark/downloadFile" + token + "&guid=" + guid;
 
      document.body.appendChild(a); // 加入
      a.click(); // 触发点击,下载
      document.body.removeChild(a); // 释放
    }
  </script>
</head>
<body>
  <input type="button" value="TestCros" onclick="TestCros();" />
  <input type="button" value="check" onclick="check();" />
  <input type="button" value="getCurrentUser" onclick="getCurrentUser();" />
  <input type="button" value="logout" onclick="logout();" />
  <input type="button" value="updateUsersPwd" onclick="updateUsersPwd();" />
  <input type="button" value="insertUser" onclick="insertUser();" />
  <input type="button" value="Ajax上传" onclick="ajxUpload()" />
  <input type="button" value="uploadData" onclick="uploadData();" />
  <input type="button" value="uploadShpForWKT" onclick="uploadShpForWKT();" />
  <input type="button" value="downloadFile" onclick="downloadFile();" />
  <input type="button" value="downloadMarkShp" onclick="downloadMarkShp();" />
  <input type="button" value="uploadShpForMark" onclick="uploadShpForMark();" />
  <input type="button" value="管线分析" onclick="pipeAnalysis()" />
  <input type="button" value="管线分析下载" onclick="downloadPipeReq()" />
  <br />
  <br />
 
  <form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="http://127.0.0.1:12316/file/upload">
    文件上传:
    <input id="file1" name="file1" type="file" multiple="multiple" />
    <input id="file2" name="file2" type="file" multiple="multiple" webkitdirectory />
    shpFiles:<input id="shpFiles" name="shpFiles" type="file" multiple="multiple" accept=".shp,.shx,.dbf,.prj" />
  </form>
  <br />
 
  出图:<select id="selectPage">
    <option>A0</option>
    <option>A1</option>
    <option>A2</option>
    <option>A3</option>
    <option selected="selected">A4</option>
    <option>A5</option>
    <option>A6</option>
  </select>
  <input type="button" value="出图-1" onclick="exportMap1()" />
  <input type="button" value="出图-2" onclick="exportMap2()" />
</body>
</html>
<!--
  decrypt("gAPpDbZ53XfoQfvT8dj/uhBWX5os8kBJQ1LrNvH3VX7byFQdUJMPiEr8Fkj0q2i1pw+L8KFrvR0MLXq2xaO21nlQQXmEPofJxpDQZwEWUIFZsToXo1kLRD3t6WQezxWB8YTzXHM20Ba73x/ZuuezVhOFOq1U8HKf1dXQdv7gBzEB6fWMmFDc3FuH8GDDHv3LfT86Gio9VgMO6ohlrUdf3ZKtTHeLSuzGF4t0RZuX97YBNo25IIzpeTfRTXBxfdxA")
  "POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))"
 
  decrypt("6vqSpEI5Uu76H5TiwFjM6KDhY6dOpnFwSnOYNa7y0Wa6iyzrntctmq4HxwyEQdis")
  "POINT(95.80461853400004 34.13862467200005)"
-->