<!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)"
|
-->
|