| | |
| | | <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> |
| | | var data = null; |
| | | var path = "20221119094847"; |
| | | var app = {}; |
| | | var path = "20221128010101"; |
| | | var url = "http://127.0.0.1:12316/"; |
| | | var token = "5e8b731c-0d9b-45d5-8781-23fd3bb8f526"; |
| | | var token = "c0014676-76e2-477e-9cc7-75c08e985737"; |
| | | |
| | | $(function () { |
| | | $("#pathSpan").html(path); |
| | | $("#tokenSpan").html(token); |
| | | getPublicKey(); |
| | | }); |
| | | |
| | | // Ajax |
| | |
| | | function getUrl(method) { |
| | | return url + method + "?token=" + token; |
| | | } |
| | | </script> |
| | | <script> |
| | | // 下载地图 * |
| | | function downloadMap(guid) { |
| | | var a = document.createElement('a'); // 创建a标签 |
| | | a.style.display = 'none'; // 设置不可见 |
| | | a.href = getUrl("mark/downloadFile") + "&guid=" + guid; |
| | | |
| | | document.body.appendChild(a); // 加入 |
| | | a.click(); // 触发点击 |
| | | document.body.removeChild(a); // 释放 |
| | | } |
| | | |
| | | // 上传数据 * |
| | | 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(getUrl("uploader/uploadData") + "&path=" + path, { |
| | | 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); |
| | | if (rs.code == 200 && rs.result != null) { |
| | | rs = rs.result; |
| | | } |
| | | console.log(rs); |
| | | }, |
| | | error: function (e) { |
| | | console.error(e); |
| | | function getPublicKey() { |
| | | $.get(url + "sign/getPublicKey", function (rs) { |
| | | if (rs && rs.code == 200) { |
| | | window.encrypt = new JSEncrypt(); |
| | | encrypt.setPublicKey(rs.result); |
| | | } |
| | | }); |
| | | } |
| | |
| | | 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); |
| | | data = rs.result; |
| | | app.data = rs.result; |
| | | }); |
| | | } |
| | | |
| | | // 删除文件 |
| | | function deleteFiles() { |
| | | if (data == null) return; |
| | | if (app.data == null) return; |
| | | |
| | | ajax(getUrl("dataUpload/deleteFiles"), "POST", JSON.stringify([data[0]]), null, null, function (rs) { |
| | | ajax(getUrl("dataUpload/deleteFiles"), "POST", JSON.stringify([app.data[0]]), null, null, function (rs) { |
| | | console.log(rs); |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | selectFiles(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | // 文件入库 |
| | | function insertFiles() { |
| | | if (data == null) return; |
| | | if (app.data == null) return; |
| | | |
| | | var obj = { |
| | | metaEntity: { |
| | |
| | | gather: "2022-10-03 15:00:00", |
| | | descr: "测试文件上传", |
| | | }, |
| | | fileEntities: data |
| | | fileEntities: app.data |
| | | }; |
| | | |
| | | ajax(getUrl("dataUpload/insertFiles"), "POST", JSON.stringify(obj), null, null, function (rs) { |
| | | console.log(rs); |
| | | data = null; |
| | | app.data = null; |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | }); |
| | | } |
| | |
| | | ajax(getUrl("dataLoader/selectFiles") + "&path=" + path, "GET", null, null, null, function (rs) { |
| | | console.log(rs); |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | data = rs.result; |
| | | app.data = rs.result; |
| | | }); |
| | | } |
| | | |
| | | // 删除文件 |
| | | function deleteFiles2() { |
| | | if (data == null) return; |
| | | if (app.data == null) return; |
| | | |
| | | ajax(getUrl("dataLoader/deleteFiles"), "POST", JSON.stringify([data[0]]), null, null, function (rs) { |
| | | console.log(rs); |
| | |
| | | }); |
| | | } |
| | | |
| | | // 读取映射 |
| | | function readMappers() { |
| | | ajax(getUrl("dataLoader/selectMappers") + "&path=" + path, "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 (data == null) return; |
| | | if (app.data == null) return; |
| | | |
| | | var obj = { |
| | | metaEntity: { |
| | |
| | | gather: "2022-10-05 15:00:00", |
| | | descr: "测试Xls", |
| | | }, |
| | | fileEntities: data, |
| | | fileEntities: app.data, |
| | | tabEntities: [ |
| | | { fileName: "2-2 管线成果表.xlsx", tab: null, entity: "ddGdcg" }, |
| | | { fileName: "海原县中线成果表.xlsx", tab: null, entity: "mdZxcg" } |
| | | { 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); |
| | | data = null; |
| | | app.data = null; |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | }); |
| | | } |
| | | |
| | | // Shp入库 |
| | | function insertShps() { |
| | | 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: [ |
| | | { |
| | | "entity": "dlg25wboul", |
| | | "fileName": "test.shp.zip", |
| | | "subPath": "20221128010101_zip\\test.shp\\pgShp\\dlg_25w_boul.shp", |
| | | "tab": "dlg_25w_boul.shp", |
| | | "type": "shp" |
| | | }, |
| | | { |
| | | "entity": "dlg25wresa", |
| | | "fileName": "test.shp.zip", |
| | | "subPath": "20221128010101_zip\\test.shp\\pgShp\\dlg_25w_resa.shp", |
| | | "tab": "dlg_25w_resa.shp", |
| | | "type": "shp" |
| | | }, |
| | | { |
| | | "entity": "dlgagnp", |
| | | "fileName": "test.shp.zip", |
| | | "subPath": "20221128010101_zip\\test.shp\\pgShp\\dlg_agnp.shp", |
| | | "tab": "dlg_agnp.shp", |
| | | "type": "shp" |
| | | }] |
| | | }; |
| | | |
| | | 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); |
| | | }); |
| | | } |
| | | |
| | | // GDB入库 |
| | | function insertGdb() { |
| | | 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: [ |
| | | { |
| | | "entity": "dlg25wboul", |
| | | "fileName": "test.gdb.zip", |
| | | "subPath": "20221128010101_zip\\test.gdb\\pg.gdb", |
| | | "tab": "dlg_25w_boul", |
| | | "type": "gdb" |
| | | }, |
| | | { |
| | | "entity": "dlg25wresa", |
| | | "fileName": "test.gdb.zip", |
| | | "subPath": "20221128010101_zip\\test.gdb\\pg.gdb", |
| | | "tab": "dlg_25w_resa", |
| | | "type": "gdb" |
| | | }, |
| | | { |
| | | "entity": "dlgagnp", |
| | | "fileName": "test.gdb.zip", |
| | | "subPath": "20221128010101_zip\\test.gdb\\pg.gdb", |
| | | "tab": "dlg_agnp", |
| | | "type": "gdb" |
| | | }] |
| | | }; |
| | | |
| | | 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); |
| | | }); |
| | | } |
| | | |
| | | // MDB |
| | | function insertMdb() { |
| | | 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: [ |
| | | { |
| | | "entity": "dlg25wboul", |
| | | "fileName": "test.mdb", |
| | | "subPath": "20221128010101\\test.mdb", |
| | | "tab": "dlg_25w_boul", |
| | | "type": "mdb" |
| | | }, |
| | | { |
| | | "entity": "dlg25wresa", |
| | | "fileName": "test.mdb", |
| | | "subPath": "20221128010101\\test.mdb", |
| | | "tab": "dlg_25w_resa", |
| | | "type": "mdb" |
| | | }/*, |
| | | { |
| | | "entity": "dlgagnp", |
| | | "fileName": "test.mdb", |
| | | "subPath": "20221128010101\\test.mdb", |
| | | "tab": "dlg_agnp", |
| | | "type": "mdb" |
| | | }*/] |
| | | }; |
| | | |
| | | 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 = "e7d7161a4bf2b78b460f0ebcf5bcc83c"; // "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> |
| | | </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 /><br /> |
| | | <hr /> |
| | | <br /> |
| | | <br /> |
| | | |
| | | 数据上传: |
| | | <input id="file1" name="file1" type="file" multiple="multiple" /> |
| | | <input id="file1" type="file" multiple="multiple" /> |
| | | <input value="上传文件" type="button" onclick="uploadFiles();" /> |
| | | <input value="查询文件" type="button" onclick="selectFiles();" /> |
| | | <input value="删除文件" type="button" onclick="deleteFiles();" /> |
| | | <input value="文件入库" type="button" onclick="insertFiles();" /> |
| | | <hr /><br /><br /> |
| | | <hr /> |
| | | <br /> |
| | | <br /> |
| | | |
| | | 数据入库: |
| | | <input id="file2" name="file2" type="file" multiple="multiple" accept=".xls,.xlsx,.mdb,.shp.zip,.gdb.zip" /> |
| | | 数据入库: |
| | | <input id="file2" type="file" multiple="multiple" accept=".xls,.xlsx,.mdb,.shp.zip,.gdb.zip" /> |
| | | <input value="上传文件" type="button" onclick="uploadFiles2();" /> |
| | | <input value="查询文件" type="button" onclick="selectFiles2();" /> |
| | | <input value="删除文件" type="button" onclick="deleteFiles2();" /> |
| | | <input value="读取映射" type="button" onclick="readMappers();" /> |
| | | <input value="Xls入库" type="button" onclick="insertXls();" /> |
| | | <hr /><br /><br /> |
| | | <input value="Shp入库" type="button" onclick="insertShps();" /> |
| | | <input value="Gdb入库" type="button" onclick="insertGdb();" /> |
| | | <input value="Mdb入库" type="button" onclick="insertMdb();" /> |
| | | <hr /> |
| | | <br /> |
| | | <br /> |
| | | |
| | | 数据检索: |
| | | <input id="file3" type="file" multiple="multiple" /> |
| | | <input value="上传附件" type="button" onclick="uploadAttach();" /> |
| | | <hr /> |
| | | <br /> |
| | | <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 /> |
| | | <br /> |
| | | </form> |
| | | <br /> |
| | | <br /> |