Commit 73a9973d authored by 刘乐's avatar 刘乐

1, 水力模型接口微调

parent 93fd6516
...@@ -21,12 +21,12 @@ void CivConQuaTest::test(char* uri) ...@@ -21,12 +21,12 @@ void CivConQuaTest::test(char* uri)
// 追踪分析 // 追踪分析
void CivConTrackTest::test(char* uri) void CivConTrackTest::test(char* uri)
{ {
char result[1024 * 128]; char result[1024 * 512];
char sn[32]; char sn[64];
strcpy_s(sn, "JD0000006"); strcpy_s(sn, "ffd0f63d-b8c3-4354-aea5-aedc52cb8e16");
int succ = trackingSimulation(uri, sn, 12, result); int succ = trackingSimulation(uri, sn, 6, result);
std::cout << result << std::endl; std::cout << result << std::endl;
std::cout << "测试结果:" << succ << std::endl; std::cout << "测试结果:" << succ << std::endl;
...@@ -35,8 +35,8 @@ void CivConTrackTest::test(char* uri) ...@@ -35,8 +35,8 @@ void CivConTrackTest::test(char* uri)
void CivUpstreamTrackingTest::test(char* uri) void CivUpstreamTrackingTest::test(char* uri)
{ {
// 追踪节点编号 // 追踪节点编号
char sn[32]; char sn[64];
strcpy(sn, "JD0000006"); strcpy(sn, "ffd0f63d-b8c3-4354-aea5-aedc52cb8e16");
char result[1024 * 128]; char result[1024 * 128];
...@@ -53,10 +53,10 @@ void CivUpstreamTrackingTest::test(char* uri) ...@@ -53,10 +53,10 @@ void CivUpstreamTrackingTest::test(char* uri)
void CivDownStreamTrackingTest::test(char* uri) void CivDownStreamTrackingTest::test(char* uri)
{ {
// 追踪节点编号 // 追踪节点编号
char sn[32]; char sn[64];
strcpy(sn, "JD0000006"); strcpy(sn, "3997f59b-91ae-44e1-be89-c23b6b330909");
char result[1024 * 128]; char result[1024 * 512];
bool isSucc = downstreamTracking(uri, sn, result); bool isSucc = downstreamTracking(uri, sn, result);
...@@ -71,8 +71,8 @@ void CivDownStreamTrackingTest::test(char* uri) ...@@ -71,8 +71,8 @@ void CivDownStreamTrackingTest::test(char* uri)
void CivWaterSupplyScopeTest::test(char* uri) void CivWaterSupplyScopeTest::test(char* uri)
{ {
// 追踪节点编号 // 追踪节点编号
char sn[32]; char sn[512];
strcpy(sn, "JD0000006"); strcpy(sn, "ffd0f63d-b8c3-4354-aea5-aedc52cb8e16");
char result[1024 * 32]; char result[1024 * 32];
......
...@@ -27,13 +27,11 @@ int main(int argc, char* argv[]) ...@@ -27,13 +27,11 @@ int main(int argc, char* argv[])
// 测试追踪分析 // 测试追踪分析
/* CivTestContext context(new CivConTrackTest()); /*CivTestContext context(new CivConTrackTest());
context.contextTest(findUri);*/ context.contextTest(findUri);*/
// 上游追踪 // 上游追踪
/* CivTestContext context(new CivUpstreamTrackingTest()); /*CivTestContext context(new CivUpstreamTrackingTest());
context.contextTest(findUri);*/ context.contextTest(findUri);*/
// 下游追踪 // 下游追踪
...@@ -45,8 +43,7 @@ int main(int argc, char* argv[]) ...@@ -45,8 +43,7 @@ int main(int argc, char* argv[])
/* CivTestContext context(new CivWaterSupplyScopeTest()); /* CivTestContext context(new CivWaterSupplyScopeTest());
context.contextTest(findUri);*/ context.contextTest(findUri);*/
getchar(); getchar();
return 0; return 0;
} }
\ No newline at end of file
...@@ -500,6 +500,9 @@ int ALGraph<VertexType, EdgeType>::getVertexNumber() ...@@ -500,6 +500,9 @@ int ALGraph<VertexType, EdgeType>::getVertexNumber()
template <class VertexType, class EdgeType> template <class VertexType, class EdgeType>
VertexType ALGraph<VertexType, EdgeType>::getData(IN int index) VertexType ALGraph<VertexType, EdgeType>::getData(IN int index)
{ {
if (index < 0)
return VertexType();
Vertex<VertexType, EdgeType> tex = mVertexArray.at(index); Vertex<VertexType, EdgeType> tex = mVertexArray.at(index);
VertexType vertex = tex.mVertex; VertexType vertex = tex.mVertex;
return vertex; return vertex;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "CivSimuResStruct.h" #include "CivSimuResStruct.h"
#include "CivCommonUtils.h" #include "CivCommonUtils.h"
#include "CivDate.h" #include "CivDate.h"
#include "CivSysLog.h"
CivHydrCompute::CivHydrCompute() CivHydrCompute::CivHydrCompute()
{ {
...@@ -27,22 +28,25 @@ bool CivHydrCompute::qualityCompute() ...@@ -27,22 +28,25 @@ bool CivHydrCompute::qualityCompute()
char binFile[128]; char binFile[128];
strcpy_s(binFile, mBinFile.c_str()); strcpy_s(binFile, mBinFile.c_str());
CivSysLog::getInstance()->info("打开inp文件", "CivHydrCompute", __FUNCTION__);
errcode = ENopen(inpFile, rptFile, binFile); errcode = ENopen(inpFile, rptFile, binFile);
if (errcode > 0) if (errcode > 0)
{ {
CivSysLog::getInstance()->error("ENopen 失败", "CivHydrCompute", __FUNCTION__);
ENclose(); ENclose();
return false; return false;
} }
if (ENopenH() > 0) if (ENopenH() > 0)
{ {
CivSysLog::getInstance()->error("ENopenH 失败", "CivHydrCompute", __FUNCTION__);
ENclose(); ENclose();
return false; return false;
} }
if (ENinitH(EN_SAVE) > 0) if (ENinitH(EN_SAVE) > 0)
{ {
CivSysLog::getInstance()->error("ENinitH 失败", "CivHydrCompute", __FUNCTION__);
ENclose(); ENclose();
return false; return false;
} }
...@@ -95,20 +99,21 @@ bool CivHydrCompute::qualityCompute() ...@@ -95,20 +99,21 @@ bool CivHydrCompute::qualityCompute()
ENclose(); ENclose();
return false; return false;
} }
iTime++;
// 获取水质模拟结果 // 获取水质模拟结果
getNodeQuality(iTime); getNodeQuality(iTime);
getLinkQuality(iTime); getLinkQuality(iTime);
ENstepQ(&tstep); ENstepQ(&tstep);
iTime++;
} while (tstep > 0); } while (tstep > 0);
ENcloseQ(); ENcloseQ();
ENclose(); ENclose();
CivSysLog::getInstance()->info("ENclose", "CivHydrCompute", __FUNCTION__);
return true; return true;
} }
...@@ -128,7 +133,7 @@ bool CivHydrCompute::hdyrCompute() ...@@ -128,7 +133,7 @@ bool CivHydrCompute::hdyrCompute()
char binFile[128]; char binFile[128];
strcpy_s(binFile, mBinFile.c_str()); strcpy_s(binFile, mBinFile.c_str());
errcode = ENopen(inpFile, rptFile, binFile); errcode = ENopen(inpFile, rptFile, binFile);
if (errcode > 0) if (errcode > 0)
...@@ -173,6 +178,7 @@ bool CivHydrCompute::hdyrCompute() ...@@ -173,6 +178,7 @@ bool CivHydrCompute::hdyrCompute()
// 获取当前节点和管段数据 // 获取当前节点和管段数据
getNodeResult(iTime); getNodeResult(iTime);
getLinkResult(iTime); getLinkResult(iTime);
iTime++; iTime++;
} while (tstep > 0); } while (tstep > 0);
...@@ -201,9 +207,9 @@ void CivHydrCompute::dateAndTime(int time,std::string& nowDate,std::string& nowT ...@@ -201,9 +207,9 @@ void CivHydrCompute::dateAndTime(int time,std::string& nowDate,std::string& nowT
} }
if (modulus < 10) if (modulus < 10)
nowTime = ("0" + std::to_string(a) + ":00"); nowTime = ("0" + std::to_string(a) + ":00:00");
else else
nowTime = (std::to_string(a) + ":00"); nowTime = (std::to_string(a) + ":00:00");
nowTime = nowDate + " " + nowTime; nowTime = nowDate + " " + nowTime;
} }
...@@ -335,6 +341,7 @@ void CivHydrCompute::getLinkQuality(short time) ...@@ -335,6 +341,7 @@ void CivHydrCompute::getLinkQuality(short time)
void CivHydrCompute::saveResult(const std::string& uri) void CivHydrCompute::saveResult(const std::string& uri)
{ {
mResultCache.save(uri); mResultCache.save(uri);
} }
......
#include "CivHydrSimulation.h" #include "CivHydrSimulation.h"
#include "CivInpConvertor.h" #include "CivInpConvertor.h"
#include "CivSysLog.h"
CivHydrSimulation::CivHydrSimulation(const std::string& uri):mUri(uri) CivHydrSimulation::CivHydrSimulation(const std::string& uri):mUri(uri)
{ {
...@@ -31,16 +32,28 @@ bool CivHydrSimulation::hdyrSimulation() ...@@ -31,16 +32,28 @@ bool CivHydrSimulation::hdyrSimulation()
bool CivHydrSimulation::qualitySimulation() bool CivHydrSimulation::qualitySimulation()
{ {
CivSysLog::getInstance()->info("开始水质模拟", "CivSysLog", __FUNCTION__);
CivSysLog::getInstance()->info("开始转inp文件", "CivSysLog", __FUNCTION__);
CivInpConvertor convertor(mUri); CivInpConvertor convertor(mUri);
std::string inpFileS = convertor.convertBaseInp(); std::string inpFileS = convertor.convertBaseInp();
if (inpFileS.empty() || inpFileS == "") if (inpFileS.empty() || inpFileS == "")
{
CivSysLog::getInstance()->error("转inp文件失败", "CivSysLog", __FUNCTION__);
return false; return false;
}
CivSysLog::getInstance()->info("转inp文件成功", "CivSysLog", __FUNCTION__);
CivSysLog::getInstance()->info("开始计算", "CivSysLog", __FUNCTION__);
mHydrCompute.cacheCodeSn(mUri); mHydrCompute.cacheCodeSn(mUri);
if (!mHydrCompute.qualityCompute()) if (!mHydrCompute.qualityCompute())
{ {
CivSysLog::getInstance()->error("计算失败", "CivSysLog", __FUNCTION__);
return false; return false;
} }
CivSysLog::getInstance()->info("计算成功", "CivSysLog", __FUNCTION__);
mHydrCompute.saveResult(mUri); mHydrCompute.saveResult(mUri);
return true; return true;
......
...@@ -78,9 +78,11 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn, ...@@ -78,9 +78,11 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn,
{ {
return ""; return "";
} }
std::string codeTosn;
helper.getCodeToSn(sn, codeTosn);
CivInpBuilder* builder = new CivBaseInpBuilder(mUri); CivInpBuilder* builder = new CivBaseInpBuilder(mUri);
builder->setOption("Quality", "TRACE "+sn); builder->setOption("Quality", "TRACE "+ codeTosn);
builder->setTimes("Duration", hours); builder->setTimes("Duration", hours);
builder->resetAllToZero(); builder->resetAllToZero();
builder->setQuality(sn, "1"); builder->setQuality(sn, "1");
...@@ -96,6 +98,32 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn, ...@@ -96,6 +98,32 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn,
return ""; return "";
} }
delete builder;
return inpFile;
}
std::string CivInpConvertor::convertAnalysisInp()
{
CivHydrTableHelper helper(mUri);
if (!helper.mainTain())
{
return "";
}
CivInpBuilder* builder = new CivBaseInpBuilder(mUri);
builder->setTimes("Duration", "1");
CivInpDirector director;
director.setBuilder(builder);
director.create();
std::string inpFile = CivCommonUtils::getExePath() + "\\test.inp";
if (!builder->getNewInp(inpFile))
{
delete builder;
return "";
}
delete builder; delete builder;
return inpFile; return inpFile;
} }
\ No newline at end of file
...@@ -32,6 +32,8 @@ public: ...@@ -32,6 +32,8 @@ public:
*/ */
std::string convertTrackInp(const std::string& sn,const std::string& hours); std::string convertTrackInp(const std::string& sn,const std::string& hours);
std::string convertAnalysisInp();
private: private:
std::string mUri; std::string mUri;
}; };
\ No newline at end of file
...@@ -67,6 +67,7 @@ void CivSimulResultCache::clear() ...@@ -67,6 +67,7 @@ void CivSimulResultCache::clear()
bool CivSimulResultCache::save(const std::string& uri) bool CivSimulResultCache::save(const std::string& uri)
{ {
CivSysLog::getInstance()->info("开始存入数据", "CivSimulResultCache", __FUNCTION__);
CivSimulResDbHelper helper(uri); CivSimulResDbHelper helper(uri);
for (auto iter = mNodeItemsMap.begin(); iter != mNodeItemsMap.end(); iter++) for (auto iter = mNodeItemsMap.begin(); iter != mNodeItemsMap.end(); iter++)
{ {
...@@ -77,6 +78,8 @@ bool CivSimulResultCache::save(const std::string& uri) ...@@ -77,6 +78,8 @@ bool CivSimulResultCache::save(const std::string& uri)
{ {
helper.insertLinks(iter->second); helper.insertLinks(iter->second);
} }
CivSysLog::getInstance()->info("数据存入完成", "CivSimulResultCache", __FUNCTION__);
return true; return true;
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "CivHydrSimulation.h" #include "CivHydrSimulation.h"
#include "CivInpConvertor.h" #include "CivInpConvertor.h"
#include "CivInpDbHelper.h" #include "CivInpDbHelper.h"
#include "CivSysLog.h"
CivTrackingAnalysis::CivTrackingAnalysis(const std::string& uri) CivTrackingAnalysis::CivTrackingAnalysis(const std::string& uri)
:mGraph(new ALGraph<CivGraphJunction, CivGraphEdage>()),mUri(uri) :mGraph(new ALGraph<CivGraphJunction, CivGraphEdage>()),mUri(uri)
...@@ -18,7 +19,7 @@ CivTrackingAnalysis::~CivTrackingAnalysis() ...@@ -18,7 +19,7 @@ CivTrackingAnalysis::~CivTrackingAnalysis()
bool CivTrackingAnalysis::createGraphFrom() bool CivTrackingAnalysis::createGraphFrom()
{ {
CivInpConvertor convertor(mUri); CivInpConvertor convertor(mUri);
std::string inpFile = convertor.convertTrackInp("", "0"); std::string inpFile = convertor.convertAnalysisInp();
if (inpFile.empty()) if (inpFile.empty())
return false; return false;
...@@ -38,6 +39,7 @@ bool CivTrackingAnalysis::createGraphFrom() ...@@ -38,6 +39,7 @@ bool CivTrackingAnalysis::createGraphFrom()
CivCoordinates coords; CivCoordinates coords;
CivInpDbHelper helper(mUri); CivInpDbHelper helper(mUri);
helper.getCoordinates(coords); helper.getCoordinates(coords);
helper.getSnToCode(mSnToCodeMap);
std::list<CivCoordinates::CoordTable> coordTableLis = coords.mTables; std::list<CivCoordinates::CoordTable> coordTableLis = coords.mTables;
std::list<CivCoordinates::CoordTable>::iterator iter; std::list<CivCoordinates::CoordTable>::iterator iter;
...@@ -46,7 +48,7 @@ bool CivTrackingAnalysis::createGraphFrom() ...@@ -46,7 +48,7 @@ bool CivTrackingAnalysis::createGraphFrom()
CivCoordinates::CoordTable coordTable = *iter; CivCoordinates::CoordTable coordTable = *iter;
// 插入顶点数据 // 插入顶点数据
CivGraphJunction graphJunction(coordTable.ID, coordTable.XCoord, coordTable.YCoord); CivGraphJunction graphJunction(coordTable.code, coordTable.XCoord, coordTable.YCoord);
auto iter = nodeItems.find(coordTable.ID); auto iter = nodeItems.find(coordTable.ID);
if (iter != nodeItems.end()) if (iter != nodeItems.end())
{ {
...@@ -65,35 +67,48 @@ bool CivTrackingAnalysis::createGraphFrom() ...@@ -65,35 +67,48 @@ bool CivTrackingAnalysis::createGraphFrom()
for (pIter = pipesTableLis.begin(); pIter != pipesTableLis.end(); pIter++) for (pIter = pipesTableLis.begin(); pIter != pipesTableLis.end(); pIter++)
{ {
CivPipe::PipesTable pipeTable = *pIter; CivPipe::PipesTable pipeTable = *pIter;
auto iter = mSnToCodeMap.find(pipeTable.Node1);
if (iter == mSnToCodeMap.end())
{
continue;
}
std::string startcode = iter->second;
// 获取管段起点坐标 // 获取管段起点坐标
CivGraphJunction graphJunction1(pipeTable.Node1); CivGraphJunction graphJunction1(startcode);
int index1 = mGraph->getVertexIndex(graphJunction1); int index1 = mGraph->getVertexIndex(graphJunction1);
CivGraphJunction sStartjuction = mGraph->getData(index1); CivGraphJunction sStartjuction = mGraph->getData(index1);
auto endCodeiter = mSnToCodeMap.find(pipeTable.Node2);
if (endCodeiter == mSnToCodeMap.end())
{
continue;
}
std::string endcode = endCodeiter->second;
// 获取管段终点坐标值 // 获取管段终点坐标值
CivGraphJunction graphJunction2(pipeTable.Node2); CivGraphJunction graphJunction2(endcode);
int index2 = mGraph->getVertexIndex(graphJunction2); int index2 = mGraph->getVertexIndex(graphJunction2);
CivGraphJunction endJunction = mGraph->getData(index2); CivGraphJunction endJunction = mGraph->getData(index2);
if (sStartjuction.getHead() > endJunction.getHead()) if (sStartjuction.getHead() > endJunction.getHead())
{ {
CivGraphEdage edAge(pipeTable.ID, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() }); CivGraphEdage edAge(pipeTable.code, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() });
mGraph->insertAEdge(sStartjuction, endJunction, edAge); mGraph->insertAEdge(sStartjuction, endJunction, edAge);
} }
else if (sStartjuction.getHead() == endJunction.getHead()) else if (sStartjuction.getHead() == endJunction.getHead())
{ {
CivGraphEdage edAge1(pipeTable.ID, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() }); CivGraphEdage edAge1(pipeTable.code, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() });
mGraph->insertAEdge(sStartjuction, endJunction, edAge1); mGraph->insertAEdge(sStartjuction, endJunction, edAge1);
CivGraphEdage edAge2(pipeTable.ID, pipeTable.Length, { endJunction.getXCoord(),endJunction.getYCoord(), sStartjuction.getXCoord(),sStartjuction.getYCoord() }); CivGraphEdage edAge2(pipeTable.code, pipeTable.Length, { endJunction.getXCoord(),endJunction.getYCoord(), sStartjuction.getXCoord(),sStartjuction.getYCoord() });
mGraph->insertAEdge(endJunction, sStartjuction, edAge2); mGraph->insertAEdge(endJunction, sStartjuction, edAge2);
} }
else else
{ {
CivGraphEdage edAge(pipeTable.ID, pipeTable.Length, { endJunction.getXCoord(),endJunction.getYCoord(), sStartjuction.getXCoord(),sStartjuction.getYCoord() }); CivGraphEdage edAge(pipeTable.code, pipeTable.Length, { endJunction.getXCoord(),endJunction.getYCoord(), sStartjuction.getXCoord(),sStartjuction.getYCoord() });
mGraph->insertAEdge(endJunction, sStartjuction, edAge); mGraph->insertAEdge(endJunction, sStartjuction, edAge);
} }
...@@ -104,10 +119,13 @@ bool CivTrackingAnalysis::createGraphFrom() ...@@ -104,10 +119,13 @@ bool CivTrackingAnalysis::createGraphFrom()
bool CivTrackingAnalysis::transformJson(const std::vector<CivGraphJunction>& junctions, bool CivTrackingAnalysis::transformJson(const std::vector<CivGraphJunction>& junctions,
const std::vector<CivGraphEdage>& pipes, std::string& jsonResult) const std::vector<CivGraphEdage>& pipes, std::string& jsonResult)
{ {
jsonResult.append("[");
// 管段 // 管段
size_t pipesTotal = pipes.size(); size_t pipesTotal = pipes.size();
if (pipesTotal <= 0)
return false;
jsonResult.append("[");
for (int i = 0; i < pipesTotal; i++) for (int i = 0; i < pipesTotal; i++)
{ {
CivGraphEdage edge = pipes[i]; CivGraphEdage edge = pipes[i];
...@@ -133,20 +151,23 @@ bool CivTrackingAnalysis::transformJson(const std::vector<CivGraphJunction>& jun ...@@ -133,20 +151,23 @@ bool CivTrackingAnalysis::transformJson(const std::vector<CivGraphJunction>& jun
bool CivTrackingAnalysis::upstreamTracking(const std::string& sN, std::string& jsonResult) bool CivTrackingAnalysis::upstreamTracking(const std::string& sN, std::string& jsonResult)
{ {
CivSysLog::getInstance()->info("上游追踪:" + sN, "CivTrackingAnalysis", __FUNCTION__);
std::vector<CivGraphJunction> junctions; std::vector<CivGraphJunction> junctions;
std::vector<CivGraphEdage> edges; std::vector<CivGraphEdage> edges;
if (!upstreamTracking(sN, junctions, edges)) if (!upstreamTracking(sN, junctions, edges))
{ {
CivSysLog::getInstance()->error("追踪失败", "CivTrackingAnalysis", __FUNCTION__);
return false; return false;
} }
// 将查询到的信息拼接成字符串 // 将查询到的信息拼接成字符串
if (!transformJson(junctions, edges, jsonResult)) if (!transformJson(junctions, edges, jsonResult))
{ {
CivSysLog::getInstance()->error("转字符串失败", "CivTrackingAnalysis", __FUNCTION__);
return false; return false;
} }
CivSysLog::getInstance()->info("追踪成功", "CivTrackingAnalysis", __FUNCTION__);
return true; return true;
} }
...@@ -154,15 +175,17 @@ bool CivTrackingAnalysis::downstreamTracking(const std::string& sN, std::string& ...@@ -154,15 +175,17 @@ bool CivTrackingAnalysis::downstreamTracking(const std::string& sN, std::string&
{ {
std::vector<CivGraphJunction> junctions; std::vector<CivGraphJunction> junctions;
std::vector<CivGraphEdage> edges; std::vector<CivGraphEdage> edges;
CivSysLog::getInstance()->info("下游追踪:" + sN, "CivTrackingAnalysis", __FUNCTION__);
if (!downstreamTracking(sN, junctions, edges)) if (!downstreamTracking(sN, junctions, edges))
{ {
CivSysLog::getInstance()->error("追踪失败", "CivTrackingAnalysis", __FUNCTION__);
return false; return false;
} }
// 将查询到的信息拼接成字符串 // 将查询到的信息拼接成字符串
if (!transformJson(junctions, edges,jsonResult)) if (!transformJson(junctions, edges,jsonResult))
{ {
CivSysLog::getInstance()->error("转字符串失败", "CivTrackingAnalysis", __FUNCTION__);
return false; return false;
} }
return true; return true;
...@@ -178,6 +201,7 @@ bool CivTrackingAnalysis::upstreamTracking(const std::string& sN, ...@@ -178,6 +201,7 @@ bool CivTrackingAnalysis::upstreamTracking(const std::string& sN,
std::vector<CivGraphJunction>& junctions, std::vector<CivGraphJunction>& junctions,
std::vector<CivGraphEdage>& pipes) std::vector<CivGraphEdage>& pipes)
{ {
// 上溯,图反向 // 上溯,图反向
ALGraph<CivGraphJunction, CivGraphEdage>* graph = mGraph->reverseGraph(); ALGraph<CivGraphJunction, CivGraphEdage>* graph = mGraph->reverseGraph();
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "CivGraphList.h" #include "CivGraphList.h"
#include <vector> #include <vector>
#include <string> #include <string>
#include <map>
#define ALGORITHMEXPORT __declspec(dllexport) #define ALGORITHMEXPORT __declspec(dllexport)
...@@ -82,5 +83,6 @@ private: ...@@ -82,5 +83,6 @@ private:
private: private:
std::string mUri; std::string mUri;
std::map<std::string, std::string> mSnToCodeMap;
ALGraph<CivGraphJunction, CivGraphEdage>* mGraph; // 管网有向图 ALGraph<CivGraphJunction, CivGraphEdage>* mGraph; // 管网有向图
}; };
...@@ -63,6 +63,7 @@ public: ...@@ -63,6 +63,7 @@ public:
Str Roughness; Str Roughness;
Str MinorLoss; Str MinorLoss;
Str Status; Str Status;
Str code;
} PipesTable; } PipesTable;
void addItem(const PipesTable& table); void addItem(const PipesTable& table);
...@@ -188,8 +189,11 @@ public: ...@@ -188,8 +189,11 @@ public:
Str ID; Str ID;
Str XCoord; Str XCoord;
Str YCoord; Str YCoord;
Str code;
} CoordTable; } CoordTable;
void addItem(const CoordTable& table); void addItem(const CoordTable& table);
std::list<CoordTable> mTables; std::list<CoordTable> mTables;
}; };
......
...@@ -86,7 +86,6 @@ bool CivConnection::insertBulk(const std::string& table, ...@@ -86,7 +86,6 @@ bool CivConnection::insertBulk(const std::string& table,
} }
sql = sql.substr(0, sql.length() - 1); sql = sql.substr(0, sql.length() - 1);
std::cout << sql << std::endl;
std::string utf8Sql = CivCommonUtils::string_To_UTF8(sql); std::string utf8Sql = CivCommonUtils::string_To_UTF8(sql);
//2 执行插入操作 //2 执行插入操作
if (!execSql(utf8Sql)) if (!execSql(utf8Sql))
...@@ -156,7 +155,7 @@ bool CivConnection::query(const std::string& table, ...@@ -156,7 +155,7 @@ bool CivConnection::query(const std::string& table,
sql.append(" where "); sql.append(" where ");
sql.append(where); sql.append(where);
} }
std::cout << sql << std::endl;
std::string utf8Sql = CivCommonUtils::string_To_UTF8(sql); std::string utf8Sql = CivCommonUtils::string_To_UTF8(sql);
// 2 执行sql语句 // 2 执行sql语句
if (!execSql(utf8Sql)) if (!execSql(utf8Sql))
......
...@@ -177,3 +177,26 @@ bool CivHydrTableHelper::unTopoTable(const std::string& table, const std::vector ...@@ -177,3 +177,26 @@ bool CivHydrTableHelper::unTopoTable(const std::string& table, const std::vector
} }
return false; return false;
} }
void CivHydrTableHelper::getCodeToSn(const std::string& code, std::string& sn)
{
std::string sql = "select \"本点号\" from 节点 where code = '" + code+"'";
std::string utfsql = CivCommonUtils::string_To_UTF8(sql);
if (mConn && !mConn->execSql(utfsql))
{
mErrInfo = mConn->getLastError();
return;
}
std::vector<std::map<std::string, std::string>> res;
mConn->queryResult(res);
if (res.size() <= 0)
{
return;
}
sn = res[0].find("本点号")->second;
return;
}
...@@ -15,6 +15,8 @@ public: ...@@ -15,6 +15,8 @@ public:
~CivHydrTableHelper(); ~CivHydrTableHelper();
bool mainTain(); bool mainTain();
void getCodeToSn(const std::string& code, std::string& sn);
private: private:
void updateAssem(const std::string& table, const std::string& filed, const std::string& prefix); void updateAssem(const std::string& table, const std::string& filed, const std::string& prefix);
bool topoMaintain(); bool topoMaintain();
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
CivInpDbHelper::CivInpDbHelper(const std::string& uri) CivInpDbHelper::CivInpDbHelper(const std::string& uri)
:CivInpHelperAbs(uri) :CivInpHelperAbs(uri)
{ {
mCondtion = " " + PROJFILED + " is null or " + PROJFILED + "=''"; mCondtion = "1=1 ";
} }
CivInpDbHelper::~CivInpDbHelper() CivInpDbHelper::~CivInpDbHelper()
...@@ -58,7 +58,8 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes) ...@@ -58,7 +58,8 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
pipeTable.diameter, pipeTable.diameter,
pipeTable.friction, pipeTable.friction,
pipeTable.localLoss, pipeTable.localLoss,
pipeTable.status pipeTable.status,
pipeTable.code
}; };
std::vector<std::map<std::string, std::string>> resultVector; std::vector<std::map<std::string, std::string>> resultVector;
...@@ -79,7 +80,7 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes) ...@@ -79,7 +80,7 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
pipe.Roughness = map.find(pipeTable.friction)->second; pipe.Roughness = map.find(pipeTable.friction)->second;
pipe.MinorLoss = map.find(pipeTable.localLoss)->second; pipe.MinorLoss = map.find(pipeTable.localLoss)->second;
pipe.Status = map.find(pipeTable.status)->second; pipe.Status = map.find(pipeTable.status)->second;
pipe.code = map.find(pipeTable.code)->second;
pipes.addItem(pipe); pipes.addItem(pipe);
} }
return true; return true;
...@@ -232,7 +233,8 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord) ...@@ -232,7 +233,8 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
std::vector<std::string> fields = { std::vector<std::string> fields = {
nodeTable.sn, nodeTable.sn,
nodeTable.xCoord, nodeTable.xCoord,
nodeTable.yCoord nodeTable.yCoord,
nodeTable.code
}; };
std::vector<std::map<std::string, std::string>> resultVector; std::vector<std::map<std::string, std::string>> resultVector;
...@@ -249,6 +251,7 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord) ...@@ -249,6 +251,7 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
coordTable.ID = map.find(fields[0])->second; coordTable.ID = map.find(fields[0])->second;
coordTable.XCoord = map.find(fields[1])->second; coordTable.XCoord = map.find(fields[1])->second;
coordTable.YCoord = map.find(fields[2])->second; coordTable.YCoord = map.find(fields[2])->second;
coordTable.code = map.find(nodeTable.code)->second;
coord.addItem(coordTable); coord.addItem(coordTable);
} }
...@@ -256,6 +259,8 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord) ...@@ -256,6 +259,8 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
return true; return true;
} }
bool CivInpDbHelper::getQuality(CivQuality& quality) bool CivInpDbHelper::getQuality(CivQuality& quality)
{ {
JunctionTable nodeTable; JunctionTable nodeTable;
...@@ -268,7 +273,8 @@ bool CivInpDbHelper::getQuality(CivQuality& quality) ...@@ -268,7 +273,8 @@ bool CivInpDbHelper::getQuality(CivQuality& quality)
std::vector<std::map<std::string, std::string>> resultVector; std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PIPENODE, fields, resultVector, mCondtion); mDbConn->query(PIPENODE, fields, resultVector, mCondtion);
mDbConn->query(RESIVOIR, fields, resultVector,mCondtion);
mDbConn->query(TANK, fields, resultVector, mCondtion);
size_t totals = resultVector.size(); size_t totals = resultVector.size();
for (int i = 0; i < totals; i++) for (int i = 0; i < totals; i++)
......
...@@ -149,4 +149,34 @@ bool CivInpHelperAbs::getLabels(CivLabels& labels) ...@@ -149,4 +149,34 @@ bool CivInpHelperAbs::getLabels(CivLabels& labels)
bool CivInpHelperAbs::getTags(CivTags& tags) bool CivInpHelperAbs::getTags(CivTags& tags)
{ {
return true; return true;
} }
\ No newline at end of file
void CivInpHelperAbs::getSnToCode(std::map<std::string, std::string>& coord)
{
JunctionTable nodeTable;
std::vector<std::string> fields = {
nodeTable.sn,
nodeTable.code
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PIPENODE, fields, resultVector);
mDbConn->query(TANK, fields, resultVector);
mDbConn->query(RESIVOIR, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
CivCoordinates::CoordTable coordTable;
std::map<std::string, std::string> map = resultVector[i];
std::string sn = map.find(nodeTable.sn)->second;
std::string code = map.find(nodeTable.code)->second;
coord.insert(std::pair<std::string, std::string>(sn,code));
}
}
...@@ -23,6 +23,7 @@ public: ...@@ -23,6 +23,7 @@ public:
virtual bool getCoordinates(CivCoordinates& coord) =0; virtual bool getCoordinates(CivCoordinates& coord) =0;
virtual bool getQuality(CivQuality& quality)=0; virtual bool getQuality(CivQuality& quality)=0;
void getSnToCode(std::map<std::string, std::string>& coord);
// 不要重载函数 // 不要重载函数
bool getPatterns(CivPatterns& patterns) ; bool getPatterns(CivPatterns& patterns) ;
......
...@@ -67,7 +67,6 @@ bool CivPgDbConnection::execSql(const std::string& sql) ...@@ -67,7 +67,6 @@ bool CivPgDbConnection::execSql(const std::string& sql)
if (!errorStr.empty()) if (!errorStr.empty())
{ {
mLastError = errorStr; mLastError = errorStr;
std::cout << mLastError << std::endl;
PQclear(mResult); PQclear(mResult);
return false; return false;
} }
......
...@@ -54,17 +54,16 @@ bool CivSimulResDbHelper::insertNodes(const NodeResultItems& nodeitems) ...@@ -54,17 +54,16 @@ bool CivSimulResDbHelper::insertNodes(const NodeResultItems& nodeitems)
NodeResultItem nodeItem = iter->second; NodeResultItem nodeItem = iter->second;
std::string sn = nodeItem.code; std::string sn = nodeItem.code;
std::vector<std::string> vecRes = std::vector<std::string> vecRes;
{ vecRes.push_back("\'" + sn + "\'");
"\'"+sn+"\'", vecRes.push_back(std::to_string(nodeItem.dDemand));
std::to_string(nodeItem.dDemand), vecRes.push_back(std::to_string(nodeItem.dPressure));
std::to_string(nodeItem.dPressure), vecRes.push_back(std::to_string(nodeItem.dQuality));
std::to_string(nodeItem.dQuality), vecRes.push_back(std::to_string(nodeItem.dHead));
std::to_string(nodeItem.dHead), vecRes.push_back("\'" + nodeItem.dDate + "\'");
"\'" + nodeItem.dDate + "\'", vecRes.push_back("\'" + nodeItem.dTime + "\'");
"\'" + nodeItem.dTime + "\'", vecRes.push_back("\'" + CurrentTime + "\'");
"\'" + CurrentTime + "\'"
};
vecVec.push_back(vecRes); vecVec.push_back(vecRes);
condition = "\'" + nodeItem.dTime + "\'"; condition = "\'" + nodeItem.dTime + "\'";
} }
...@@ -102,6 +101,8 @@ bool CivSimulResDbHelper::insertLinks(const LinkResultItems& linkMap) ...@@ -102,6 +101,8 @@ bool CivSimulResDbHelper::insertLinks(const LinkResultItems& linkMap)
vecVec.push_back(vecRes); vecVec.push_back(vecRes);
condition = "\'" + linkItem.dTime + "\'"; condition = "\'" + linkItem.dTime + "\'";
} }
if (!mConn->del(PIPERESULTTABLE, " 时间点 = " + condition)) if (!mConn->del(PIPERESULTTABLE, " 时间点 = " + condition))
return false; return false;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
*/ */
typedef struct JunctionTableFileds typedef struct JunctionTableFileds
{ {
Str code = "code";
Str sn = "本点号"; Str sn = "本点号";
Str xCoord = "横坐标"; Str xCoord = "横坐标";
Str yCoord = "纵坐标"; Str yCoord = "纵坐标";
...@@ -50,7 +51,7 @@ typedef struct JunctionTableFileds ...@@ -50,7 +51,7 @@ typedef struct JunctionTableFileds
Str waterConsump = "用水量"; Str waterConsump = "用水量";
Str waterShortage = "用水缺额"; Str waterShortage = "用水缺额";
Str totalWater = "总水量"; Str totalWater = "总水量";
Str totalHead = "水头"; Str totalHead = "水头";
Str pressure = "压力"; Str pressure = "压力";
Str quality = "水质"; Str quality = "水质";
}JunctionTable; }JunctionTable;
...@@ -60,6 +61,7 @@ typedef struct JunctionTableFileds ...@@ -60,6 +61,7 @@ typedef struct JunctionTableFileds
*/ */
typedef struct PipeTableFields typedef struct PipeTableFields
{ {
Str code = "code";
Str snNo = "编号"; Str snNo = "编号";
Str startPoint = "起始节点"; Str startPoint = "起始节点";
Str endPoint = "终止节点"; Str endPoint = "终止节点";
...@@ -123,7 +125,7 @@ typedef struct TankTableFileds ...@@ -123,7 +125,7 @@ typedef struct TankTableFileds
Str minLevel = "最低水位"; Str minLevel = "最低水位";
Str maxLevel = "最高水位"; Str maxLevel = "最高水位";
Str diametor = "直径"; Str diametor = "直径";
Str minVolume = "容量"; Str minVolume = "最小容积";
Str volumeCurve = "容积曲线"; Str volumeCurve = "容积曲线";
Str mixedCore = "混合分数"; Str mixedCore = "混合分数";
Str mixedPattern = "混合模式"; Str mixedPattern = "混合模式";
...@@ -185,7 +187,7 @@ typedef struct ValveTableFileds ...@@ -185,7 +187,7 @@ typedef struct ValveTableFileds
typedef struct NodeResultTableField typedef struct NodeResultTableField
{ {
Str Number = "本点号"; Str Number = "本点号";
Str dHead = "水头"; Str dHead = "水头";
Str dPressure = "压力"; Str dPressure = "压力";
Str dDemand = "实际需水量"; Str dDemand = "实际需水量";
Str dQuality = "水质"; Str dQuality = "水质";
...@@ -268,7 +270,7 @@ typedef struct ProjNodeTableField ...@@ -268,7 +270,7 @@ typedef struct ProjNodeTableField
Str ProjConsumption = "用水量"; Str ProjConsumption = "用水量";
Str ProjLackWater = "用水缺额"; Str ProjLackWater = "用水缺额";
Str ProjTotalWater = "总水量"; Str ProjTotalWater = "总水量";
Str ProjTotalHead = "水头"; Str ProjTotalHead = "水头";
Str ProjPressure = "压力"; Str ProjPressure = "压力";
Str ProjQuality = "水质"; Str ProjQuality = "水质";
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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