Commit 564481ba authored by 刘乐's avatar 刘乐

1,建模文档

parent bf0bd3c8
......@@ -215,6 +215,50 @@ Componets CivDbConnection::getComponets(StrQuote tableName) const
return nodes;
}
Componets CivDbConnection::getLikelyPipes(StrQuote tableName) const
{
if (!isValid())
return Nodes();
// 查询点数据
std::string sql = "select * from public.\"" + tableName + "\"";
PGresult* result = PQexec(mConn, sql.c_str());
if (result == NULL)
{
return Nodes();
}
// rows count
Componets nodes;
std::vector<std::string> codes;
int rows = PQntuples(result);
int columns = PQnfields(result);
for (int i = 0; i < rows; i++)
{
Componet node;
for (int j = 0; j < columns; j++)
{
char* item = PQgetvalue(result, i, j);
char* fieldName = PQfname(result, j); // 获取列表字段名
if ("code" == fieldName)
{
codes.push_back(fieldName);
}
std::string itemStr = CivCommonUtils::UTF8_To_string(item);
std::string fieldStr = CivCommonUtils::UTF8_To_string(fieldName);
node.insert(std::pair<std::string, std::string>(fieldStr, itemStr));
}
nodes.push_back(node);
}
PQclear(result);
std::string sql2 = "select * from public.\"管线\"";
return nodes;
}
bool CivDbConnection::createTable(StrQuote tableName, StrQuote schema)
{
return true;
......
......@@ -23,11 +23,17 @@ public:
Tables getTables(StrQuote netName, StrQuote schema = "public") const;
/**
*@brief 获取管网组件数据:管线,节点,水源等(必须组件) 水泵,阀门(可选组件)
*@brief 获取管网组件数据:管线,节点,水源等(必须组件)
*@tableName: 组件表
*/
Componets getComponets(StrQuote tableName) const;
/**
*@brief 水泵,阀门 (节点转换为管线)
*@tableName: 组件表
*/
Componets getLikelyPipes(StrQuote tableName) const;
/**
*@brief 创建表格
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment