管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2023-02-08 6eafc81a275b14cc6a2fc653f883e94c0313bc43
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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>上传接口测试</title>
  <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/insertFiles.js"></script>
  <script>
    var app = {};
    var path = "20230127";
    var url = "http://127.0.0.1:12316/server/";
    var token = "dca04924-122a-4b1a-88b7-aca0c4a7ba47";
 
    $(function () {
      $("#pathSpan").html(path);
      $("#tokenSpan").html(token);
      getPublicKey();
    });
 
    // Ajax
    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();
        }
      });
    }
 
    // 获取URL
    function getUrl(method) {
      return url + method + "?token=" + token;
    }
 
    function getPublicKey() {
      $.get(url + "sign/getPublicKey", function (rs) {
        if (rs && rs.code == 200) {
          window.encrypt = new JSEncrypt();
          encrypt.setPublicKey(rs.result);
        }
      });
    }
  </script>
  <script>
    // 查询目录
    function selectPath() {
      ajax(getUrl("dataUpload/selectPath"), "GET", null, null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        path = rs.result;
      });
    }
 
    // 上传文件
    function uploadFiles() {
      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
      }
 
      $.ajax(getUrl("dataUpload/uploadFiles") + "&path=" + path, {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          document.getElementById("file1").value = "";
          console.log(rs);
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        },
        error: function (e) {
          document.getElementById("file1").value = "";
          console.error(e);
          alert("上传文件失败!");
        }
      });
    }
 
    // 查询文件
    function selectFiles() {
      ajax(getUrl("dataUpload/selectFiles") + "&path=" + path, "GET", null, null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        app.data = rs.result;
      });
    }
 
    // 删除文件
    function deleteFiles() {
      if (app.data == null) return;
 
      ajax(getUrl("dataUpload/deleteFiles"), "POST", JSON.stringify([data[0]]), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        selectFiles();
      });
    }
 
    // 读取映射
    function readMappers() {
      ajax(getUrl("dataUpload/selectMappers") + "&path=" + path + "&dirid=163&verid=0&epsgCode=EPSG:4490", "GET", null, null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        if (rs.code == 200) {
          app.mappers = rs.result;
        }
      });
    }
 
    // 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) {
        console.log(rs);
        app.data = null;
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
  </script>
  <script>
    // 上传附件
    function uploadAttach() {
      var formData = new FormData();
      var fs = document.getElementById("file3");
      if (fs.files.length == 0) {
        alert("请选择要上传的文件!");
        return;
      }
      for (var i = 0, c = fs.files.length; i < c; i++) {
        formData.append("file", fs.files[i]); // fs.files[i].name,file
      }
 
      $.ajax(getUrl("dataQuery/uploadFiles") + "&tabName=lf.sys_style&eventid=fa25979a5ef8b43ba82a0be35b3fb0d4", {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          console.log(rs);
          document.getElementById("file3").value = "";
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        },
        error: function (e) {
          console.error(e);
          document.getElementById("file3").value = "";
          alert("上传文件失败!");
        }
      });
    }
  </script>
  <script>
    function downloadReq() {
      var obj = {
        pwd: encrypt.encrypt("Test!321&456"),
        ids: [113, 120, 121, 122]
      };
 
      ajax(getUrl("meta/downloadReq"), "POST", JSON.stringify(obj), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
 
    function selectDownloadFile() {
      var guid = "af68c8d6d847070e3a3055ba58e05929"; // "5ce046cc05b186332775c03ac6792caf";
      var pwd = encodeURIComponent(encrypt.encrypt("Test!321&456")); // Admin@123
 
      ajax(getUrl("meta/selectDownloadFile") + "&guid=" + guid + "&pwd=" + pwd, "GET", null, null, null, function (rs) {
        console.log(rs);
        //alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        if (rs.code != 200 || !rs.result) {
          alert(rs.msg);
          return;
        }
 
        downloadFile(guid, pwd);
      });
    }
 
    function downloadFile(guid, pwd) {
      //var a = document.createElement('a');
      //a.style.display = 'none';
      //a.href = getUrl("meta/downloadFile") + "&guid=" + guid + "&pwd=" + encodeURIComponent(encrypt.encrypt("Admin@123"));
 
      //document.body.appendChild(a);
      //a.click();
      //document.body.removeChild(a);
 
      var url = getUrl("meta/downloadFile") + "&guid=" + guid + "&pwd=" + pwd;
      $("#downFrame").attr("src", url).click();
    }
  </script>
  <script>
    function downloadDbReq() {
      var obj = {
        pwd: encrypt.encrypt("Test!321&456"),
        entities: ["dlgagnp", "dlg25wboul", "dlg25wresa"],
        // entities: ["dlgagnp"],
        wkt: aesEncrypt("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))")
      };
 
      ajax(getUrl("dataLib/downloadDbReq"), "POST", JSON.stringify(obj), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
 
    function aesEncrypt(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 aesDecrypt(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();
    }
  </script>  
  <script>
    function selectDbOverflowDep() {
      var obj = {
        // entities: ["dlgagnp"],
        entities: ["dlgagnp", "dlg25wboul", "dlg25wresa"],
        wkt: aesEncrypt("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))")
      };
 
      ajax(getUrl("dataLib/selectDbOverflowDep"), "POST", JSON.stringify(obj), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
 
    function insertApply() {
      var obj = {
        ids: [20, 21, 22],
        pwd: aesEncrypt("Test!321&456"),
        tabs: ["城市点", "行政区划线", "居民地面"],
        entities: ["dlgagnp", "dlg25wboul", "dlg25wresa"],
        wkt: aesEncrypt("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))"),
        descr: "用于生产项目,请批准"
      };
 
      ajax(getUrl("apply/insertApply"), "POST", JSON.stringify(obj), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
 
    // 综合数据入库
    function insertAllFiles() {
      ajax(getUrl("dataUpload/insertFiles"), "POST", JSON.stringify(metaFiles), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
 
    // 多文件入库
    function insertMultiFiles() {
      if (!app.mappers) return;
      ajax(getUrl("dataUpload/insertFiles"), "POST", JSON.stringify(app.mappers), null, null, function (rs) {
        console.log(rs);
        app.mappers = null;
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
 
    // 挂载附件
    function uploadAnnex() {
      var formData = new FormData();
      var fs = document.getElementById("file1");
      if (fs.files.length == 0) {
        alert("请选择要上传的文件!");
        return;
      }
      for (var i = 0, c = fs.files.length; i < c; i++) {
        formData.append("file", fs.files[i]); // fs.files[i].name,file
      }
      formData.append("ids", 1209);
      formData.append("ids", 1180);
      formData.append("ids", 1387);
 
      //$.ajax(getUrl("dataUpload/uploadXlsAnnex") + "&path=" + path + "&ids=1209&ids=1180&ids=1387", {
      $.ajax(getUrl("dataUpload/uploadXlsAnnex") + "&path=" + path, {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          console.log(rs);
          document.getElementById("file1").value = "";
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        },
        error: function (e) {
          console.error(e);
          document.getElementById("file3").value = "";
          alert("上传文件失败!");
        }
      });
    }
 
    // 空间数据入库
    function insertDbFiles() {
      ajax(getUrl("dataUpload/insertFiles"), "POST", JSON.stringify(dbFiles), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
 
    // 请求管线分析
    function selectPipeAnalysis() {
      var data = {
        gid: 24,
        tabs: ["bd.dlg_25w_hydl", "bd.dlg_25w_lrdl", "bd.dlg_25w_lrrl", "bd.dlg_25w_hyda"]
      };
      ajax(getUrl("pipeline/selectPipeAnalysis"), "POST", JSON.stringify(data), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
 
    // 管线分析结果下载
    function downloadPipeAnalysis() {
      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(getUrl("pipeline/downloadReq"), "POST", JSON.stringify(data), null, null, function (rs) {
        console.log(rs);
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
      });
    }
  </script>
</head>
<body>
  <form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="http://127.0.0.1:12316/file/upload">
    上传路径:<span id="pathSpan"></span>,当前令牌:<span id="tokenSpan"></span>
    <hr />
    <br />
 
    数据入库:
    <input id="file1" type="file" multiple="multiple" accept=".xls,.xlsx,.mdb,.zip" />
    <input value="查询目录 *" type="button" onclick="selectPath();" />
    <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="读取映射 *" type="button" onclick="readMappers();" />
    <input value="综合数据入库 *" type="button" onclick="insertAllFiles();" />
    <input value="空间数据入库 *" type="button" onclick="insertDbFiles();" />
    <input value="多文件入库 *" type="button" onclick="insertMultiFiles();" />
    <input value="挂载附件 *" type="button" onclick="uploadAnnex();" />
    <hr />
    <br />
 
    数据检索:
    <input id="file3" type="file" multiple="multiple" />
    <input value="上传附件" type="button" onclick="uploadAttach();" />
    <hr />
    <br />
 
    元数据:
    <input value="请求下载" type="button" onclick="downloadReq();" />
    <input value="下载文件" type="button" onclick="selectDownloadFile();" />
    <iframe id="downFrame" src="" style="display: none; border: 0; padding: 0; height: 0; width: 0"></iframe>
    <hr />
    <br />
 
    空间数据:
    <input value="请求下载" type="button" onclick="downloadDbReq();" />
    <input value="下载文件" type="button" onclick="selectDownloadFile();" />
    <hr />
    <br />
 
    数据申请:
    <input value="查询DB中溢出的单位ID" type="button" onclick="selectDbOverflowDep();" />
    <input value="插入数据申请" type="button" onclick="insertApply();" />
    <input value="请求管线分析" type="button" onclick="selectPipeAnalysis();" />
    <input value="管线分析结果下载" type="button" onclick="downloadPipeAnalysis();" />
    <hr />
    <br />
  </form>
  <br />
  <br />
</body>
</html>