var AnalysisConnection = function (url, tableName, s_expno, e_expno, f_sExp, f_eExp) {
var FMap = top.Freedom.Map;
var FSuperMap = top.SuperMap;
var foundList = [];
var foundPath = [];
var connPath = [];
var waitFind = [];
var count = 0;
var isFind = false;
var maxCount = 1000;
this.Excute = function () {
FMap.getTempLayer().removeAllFeatures();
foundPath = [];
foundPath = [];
waitFind = [];
connPath = [];
isFind = false;
maxCount = 1000;
count = 0;
foundList.push(s_expno);
waitFind.push(s_expno);
findWaitExp();
};
function findWaitExp() {
if (!isFind) {
if (waitFind.length > 0) {
if (count > maxCount) {
if (FMap.queryList.length == 0) {
top.$.messager.confirm({
title: '友情提示',
msg: '已经进行了 [' + count + '] 次查询,[' + foundList.length + '] 条记录,可能两个管点不连通!</br>是否继续搜索?',
fn: function (r) {
if (r) {
maxCount = maxCount + 1000;
count++;
findNextExp(waitFind[0]);
}
}
});
}
} else {
count++;
findNextExp(waitFind[0]);
}
}
}
};
function checkFinished() {
if (!isFind && waitFind.length == 0 && FMap.queryList.length == 0) {
top.$.messager.alert('友情提示', '系统已经检索完所有连通的管线,两个管点不连通!', 'info');
} else if (isFind && FMap.queryList.length == 0) {
FMap.getTempLayer().removeAllFeatures();
redrawPath(foundPath[foundPath.length - 1]);
}
}
function redrawPath(path) {
connPath.push(path);
var feature = path.line;
feature.style = FMap.selstyle;
FMap.getTempLayer().addFeatures(feature);
if (path.spoint != s_expno) {
var find = null;
$.each(foundPath, function (i, item) {
if (path.spoint == item.epoint) {
find = item;
return false;
}
});
if (find) {
redrawPath(find);
}
} else {
$("#resultDataGrid").datagrid({
data: [connPath],
columns: [[
{ field: 'line.attributes.埋设方式', title: 'Code', width: 100 },
{ field: 'line.attributes.起始点号', title: 'Name', width: 100 },
{ field: 'line.attributes.终止点号', title: 'Price', width: 100, align: 'right' }
]]
});
}
};
function findNextExp(expno) {
waitFind.splice(0, 1);
var params = [];
var param = new FSuperMap.REST.FilterParameter({
name: tableName,
attributeFilter: f_sExp + "='" + expno + "' or " + f_eExp + "='" + expno + "'"
});
params.push(param);
var SQLParams = new FSuperMap.REST.QueryBySQLParameters({
queryParams: params
});
FMap.queryBySQL(url, SQLParams, function (e) {
if (e.result.currentCount > 0 && e.result.recordsets.length == 1 && !isFind) {
var fs = e.result.recordsets[0].features;
$.each(fs, function (i, item) {
var sexpno = item.attributes[f_sExp], eexpno = item.attributes[f_eExp];
if (foundList.indexOf(sexpno) == -1 && !isFind) {//表示找到的点不在已经找到的列表里,则继续向下查找
foundList.push(sexpno)
waitFind.push(sexpno);
var path = {
spoint: expno,
epoint: sexpno,
line: item
};
foundPath.push(path);
var feature = item;
feature.style = FMap.selstyle;
FMap.getTempLayer().addFeatures(feature);
if (sexpno == e_expno) {
isFind = true;
//FMap.getTempLayer().removeAllFeatures();
//redrawPath(path);
} else {
findWaitExp();
}
} else if (foundList.indexOf(eexpno) == -1 && !isFind) {//表示找到的点不在已经找到的列表里,则继续向下查找
foundList.push(eexpno)
waitFind.push(eexpno);
var path = {
spoint: expno,
epoint: eexpno,
line: item
};
foundPath.push(path);
var feature = item;
feature.style = FMap.selstyle;
FMap.getTempLayer().addFeatures(feature);
if (eexpno == e_expno) {
isFind = true;
//FMap.getTempLayer().removeAllFeatures();
//redrawPath(path);
} else {
findWaitExp();
}
}
});
}
checkFinished();
}, function (e) {
var d = e;
});
}
};
评论区